漫遊器:noindex
ffx debug fidl
會啟動 fidlcat
(Fuchsia 程式),監控 Fuchsia 裝置上的 FIDL 流量。
概念
fidlcat
這項工具可讓您監控 Fuchsia 裝置上的 FIDL 訊息並偵錯。fidlcat
會連線至裝置,並列印 Fuchsia 元件即時傳送及接收的所有 FIDL 訊息。
與其他 Fuchsia 偵錯工具類似,如果要讓 fidlcat
瞭解並解開 Fuchsia 元件的 FIDL 訊息,開發環境中必須提供該元件的偵錯符號。如要進一步瞭解偵錯符號,請參閱「註冊偵錯符號」。
不過,除了偵錯符號之外,fidlcat
還需要取得元件的 FIDL 中繼表示法 (IR) 檔案清單。這個清單通常會儲存為 Fuchsia 專案中標示為 all_fidl_json.txt
的全域檔案。如果您使用 Fuchsia 的 Bazel 規則,系統會在建構過程中自動產生這個清單檔案。
啟動 fidlcat
如要監控裝置上 Fuchsia 元件的 FIDL 流量,請執行下列指令:
ffx debug fidl -f <COMPONENT> --fidl-ir-path <LIST_OF_IR_FILES>
更改下列內容:
COMPONENT
- 您要監控的 Fuchsia 元件名稱。LIST_OF_IR_FILES
:包含 IR 檔案清單的檔案路徑,前置字串為@
(例如@/usr/home/alice/my-fuchsia-project/all_fidl_json.txt
)。
以下範例指令會啟動 fidlcat
,監控 memory_monitor
元件:
$ ffx debug fidl -f memory_monitor.cm --fidl-ir-path @/usr/home/alice/my-fuchsia-project/all_fidl_json.txt
成功連線至裝置後,這個指令會輸出類似以下的輸出內容:
$ ffx debug fidl -f memory_monitor.cm --fidl-ir-path @/usr/home/alice/my-fuchsia-project/all_fidl_json.txt
INFO: [main.cc(242)] Connected to symbol server gs://our-fuchsia-artifacts/debug
INFO: [main.cc(125)] Connecting to /tmp/debug_agent_lpaMdL.socket...
INFO: [main.cc(92)] Connected!
從這裡開始,指令會即時列印目標元件的 FIDL 訊息,例如:
2701.44 Monitoring memory_monitor.cm koid=47467
2703.286866 memory_monitor.cm 47467:47469 zx_channel_call_etc(handle: handle = 7dd2c40b, options: uint32 = ZX_CHANNEL_WRITE_USE_IOVEC, deadline: zx.time = ZX_TIME_INFINITE, rd_num_bytes: uint32 = 65536, rd_num_handles: uint32 = 64)
sent request fuchsia.kernel/Stats.GetMemoryStats = {}
2703.286866 -> ZX_OK
received response fuchsia.kernel/Stats.GetMemoryStats = {
stats: fuchsia.kernel/MemoryStats = {
total_bytes: uint64 = 8455393280
free_bytes: uint64 = 6727020544
wired_bytes: uint64 = 102539264
total_heap_bytes: uint64 = 32464896
free_heap_bytes: uint64 = 1672120
vmo_bytes: uint64 = 1540259840
mmu_overhead_bytes: uint64 = 50339840
ipc_bytes: uint64 = 278528
other_bytes: uint64 = 0
}
}
2703.815113 memory_monitor.cm 47467:47469 zx_channel_write_etc(handle: handle = 7df30f83, options: uint32 = 0)
sent request fuchsia.memory/Watcher.OnChange = {
stats: fuchsia.memory/Stats = {
total_bytes: uint64 = 8455393280
free_bytes: uint64 = 6727020544
wired_bytes: uint64 = 102539264
total_heap_bytes: uint64 = 32464896
free_heap_bytes: uint64 = 1672120
vmo_bytes: uint64 = 1540259840
mmu_overhead_bytes: uint64 = 50339840
ipc_bytes: uint64 = 278528
other_bytes: uint64 = 0
}
}
2703.815113 -> ZX_OK
...
如要結束 fidlcat
,請按下 Ctrl-C
。