> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 strace 调试

要使用 strace 调试,请通过 SSH 运行以下命令:

1. 运行进程状态命令:
   > ```text theme={null}
   > ps -ef
   > ```
   >
   > **示例输出:**
   >
   > ```text theme={null}
   > root         440       1  0 00:00 ?        00:00:00 /usr/lib/system/systemd-udevd
   > ```
2. 识别要调试的进程的 PID。
3. 运行 strace 命令:
   > ```text theme={null}
   > strace -p 440
   > ```
   在此示例中,`440` 是 PID
   > **示例输出:**
   >
   > ```text theme={null}
   > root@iq-9075-evk:/# strace -p 440
   > strace: Process 440 attached
   > gettid()                                = 440
   > epoll_pwait(7, [{events=EPOLLIN, data=0xb}], 212, -1, NULL, 8) = 1
   > read(11, "\1\0\0\0\0\0\0\0", 8)         = 8
   > socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 15
   > getsockopt(15, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
   > setsockopt(15, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
   > getsockopt(15, SOL_SOCKET, SO_SNDBUF, [8388608], [4]) = 0
   > setsockopt(15, SOL_SOCKET, SO_SNDBUFFORCE, [8388608], 4) = 0
   > getuid()                                = 0
   > geteuid()                               = 0
   > getgid()                                = 0
   > getegid()                               = 0
   > sendmsg(15, {msg_name={sa_family=AF_UNIX, sun_path="/run/systemd/notify"}, msg_namelen=22, msg_iov=[{iov_base="WATCHDOG=1", iov_len=10}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 10
   > close(15)                               = 0
   > timerfd_settime(11, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=1490, tv_nsec=794546000}}, NULL) = 0
   > gettid()                                = 440
   > epoll_pwait(7
   > ```
   有关 strace 的更多信息,请参阅 [Linux 手册页](https://man7.org/linux/man-pages/man1/strace.1.html)。
