熟悉 Fuchsia 调试程序 zxdb 的基本功能后,您可能需要执行以下操作:
调试崩溃转储
Zxdb 支持加载由崩溃报告生成的小型转储。
您可以使用 ffx debug core
命令加载崩溃报告,例如:
ffx debug core <var>crash_dump_file</var>
下载符号
Zxdb 会自动搜索在 symbol-index 中注册的服务器,查找在任何本地配置的符号目录中找不到的符号。您可以使用以下命令查看在您的 Signals-index 中注册的符号服务器的完整列表:
ffx debug symbol-index list -a
这将递归遍历和解析全局符号索引中包含的所有符号索引文件。如需了解详情,请参阅关于符号设置。
显示的服务器用于下载符号文件并将它们异步加载到调试程序。对于特别大的调试信息文件,您可能会看到 zxdb 中的 sym-stat
的输出如下:
[zxdb] sym-stat
...
Base: 0xc37e9000
Build ID: ba17ef8c43bccf5fb6bf84f9a8d83d9cf3be8976 (Downloading...)
Symbols loaded: No
...
这表示下载正在进行中。文件下载完毕后,zxdb 会将新下载文件中的符号编入索引,并继续进行调试。
附加到现有进程
在大多数情况下,除非您自动执行 zxdb 工作流,否则不应附加到特定进程。如果您使用的是未自动执行的 zxdb,则应将 zxdb 附加到组件标识符(请参阅运行 zxdb)。
如果有进程的 koid(内核对象 ID),您可以附加到大多数正在运行的进程。zxdb 提供了一个 ps
命令,用于查看在 Fuchsia 设备或模拟器上运行的进程。
在尝试运行 ps
之前,请确保已将 zxdb 挂接到组件,或者至少已连接到 Fuchsia 设备:
例如,如需连接到 core/starnix_runner
组件,请使用以下代码:
ffx component debug core/starnix_runner
连接调试程序后,您可以运行 ps
来查看 Fuchsia 设备或模拟器上所有活动进程的列表:
[zxdb] ps
j: 1033 root
p: 1102 bin/component_manager
j: 1662
j: 1811 bootstrap/console fuchsia-boot:///console#meta/console.cm
p: 1845 console.cm
...
j: 66524 core/starnix_runner fuchsia-pkg://fuchsia.com/starnix#meta/starnix_runner.cm
▶ p: 66562 starnix_runner.cm
j: 66763
j: 66764 core/starnix_runner/kernels:RW3JlbU starnix_kernel#meta/starnix_kernel.cm
p: 66797 starnix_kernel.cm
p: 67333 init
j: 88021
p: 88084 debug_agent.cm
j: 4227 zircon-shell
p: 4608 sh:console
根据上面的输出内容:
作业或进程后面的数字是对象的 KOID。然后,您可以:
附加到特定进程
在 zxdb 控制台中,您可以附加到特定进程。例如,如需附加到 KOID 为 66797
的 starnix_kernel.cm
进程,请使用以下命令:
[zxdb] attach 66797
Attached Process 2 state=Running koid=66797 name=starnix_kernel.cm component=starnix_kernel.cm
Loading 15 modules for starnix_kernel.cm ....
[zxdb]
附加到特定作业中的所有进程
在 zxdb 控制台中,您可以附加到作业中的所有进程。例如,要附加到 KOID 为 66764
的 core/starnix_kernels:RW3JlbU
作业,请使用以下命令:
[zxdb] attach -j 66764
Waiting for process matching "job 66764".
Type "filter" to see the current filters.
Attached Process 2 state=Running koid=66797 name=starnix_kernel.cm component=starnix_kernel.cm
Attached Process 3 state=Running koid=67333 name=init component=starnix_kernel.cm
Loading 15 modules for starnix_kernel.cm .....Done.
Loading 17 modules for init Done.
附加到作业中的特定进程
在 zxdb 控制台中,您可以附加到作业中的特定进程。例如,如需附加到 KOID 为 66764
的作业中的 starnix_kernel.cm
进程,请使用以下命令:
[zxdb] attach -j 66764 starnix_kernel.cm
Waiting for process matching "starnix_kernel.cm".
Type "filter" to see the current filters.
Attached Process 2 state=Running koid=66797 name=starnix_kernel.cm component=starnix_kernel.cm
Attached Process 3 state=Running koid=67333 name=init component=starnix_kernel.cm
Loading 15 modules for starnix_kernel.cm .....Done.
Loading 17 modules for init Done.
[zxdb]