啟動 fidlcat
並附加至執行中的程序後,此工具就會開始記錄使用 FIDL 收發及接收的系統呼叫。
請參閱下列 fidlcat
的基本範例輸出內容:
Monitoring echo_client.cm koid=193974 echo_client.cm 193974:193976 zx_channel_create(options: uint32 = 0) -> ZX_OK (out0: handle = d7e9f83b(channel:0), out1: handle = d6c9fd5f(channel:1))
範例輸出內容包含以下資訊:
echo_client.cm:產生此顯示的程序名稱。
193974:程序 koid。
193976:執行緒 koid。
zx_channel_create:已攔截/顯示的系統呼叫名稱。
依名稱、類型和值列出系統呼叫輸入參數 (例如 handle 和 options)。
系統呼叫回傳值 (
ZX_OK
) 及輸出參數。
如果是代表 FIDL 交易的系統呼叫,fidlcat
會顯示其他輸入和輸出參數。請看以下同步 fuchsia.examples/Echo.EchoString
要求範例:
echo_client.cm 193974:193976 zx_channel_call_etc(handle: handle = Channel:d089f8fb(dir:/svc/fuchsia.examples.Echo), options: uint32 = ZX_CHANNEL_WRITE_USE_IOVEC, deadline: zx.time = ZX_TIME_INFINITE, rd_num_bytes: uint32 = 64, rd_num_handles: uint32 = 64) sent request fuchsia.examples/Echo.EchoString = { value: string = "hello" } -> ZX_OK received response fuchsia.examples/Echo.EchoString = { response: string = "hello" }
請注意顯示輸出中的 FIDL 要求和回應訊息,包括方法名稱和參數。
修改顯示畫面
根據預設,fidlcat
只會在每則訊息的第一行顯示程序資訊。使用 --with-process-info
旗標,在每一行加入下列詳細資料:
echo_client.cm 60014:60016 zx_channel_call_etc(handle: handle = Channel:35272afb(dir:/svc/fuchsia.examples.Echo), options: uint32 = ZX_CHANNEL_WRITE_USE_IOVEC, deadline: zx.time = ZX_TIME_INFINITE, rd_num_bytes: uint32 = 64, rd_num_handles: uint32 = 64) echo_client.cm 60014:60016 sent request fuchsia.examples/Echo.EchoString = { value: string = "hello" } echo_client.cm 60014:60016 -> ZX_OK echo_client.cm 60014:60016 received response fuchsia.examples/Echo.EchoString = { response: string = "hello" }
堆疊框架
您可以使用 --stack
旗標顯示每個系統呼叫的堆疊框架。根據預設 (--stack=0
),系統不會顯示堆疊框架。
只有 --stack=1
會顯示呼叫網站 (1 到 4 個影格):
echo_client.cm 675407:675409 at zircon/system/ulib/fidl/llcpp_message.cc:243:12 fidl::OutgoingMessage::CallImpl echo_client.cm 675407:675409 zx_channel_call_etc(handle: handle = Channel:8b745347(dir:/svc/fuchsia.examples.Echo), options: uint32 = ZX_CHANNEL_WRITE_USE_IOVEC, deadline: zx.time = ZX_TIME_INFINITE, rd_num_bytes: uint32 = 64, rd_num_handles: uint32 = 64) sent request fuchsia.examples/Echo.EchoString = { value: string = "hello" } -> ZX_OK received response fuchsia.examples/Echo.EchoString = { response: string = "hello" }
這個選項不會增加任何負荷 (螢幕除外)。
使用 --stack=2
後,所有影格都會顯示:
echo_client.cm 717533:717535 at 3ac285b4811 _start echo_client.cm 717533:717535 at zircon/third_party/ulib/musl/src/env/__libc_start_main.c:215:5 __libc_start_main echo_client.cm 717533:717535 at zircon/third_party/ulib/musl/src/env/__libc_start_main.c:140:3 start_main echo_client.cm 717533:717535 at examples/fidl/llcpp/client_sync/main.cc:30:27 main echo_client.cm 717533:717535 at fidling/gen/examples/fidl/fuchsia.examples/fuchsia.examples/llcpp/fidl/fuchsia.examples/cpp/wire_messaging.h:2711:12 fidl::internal::WireSyncClientImpl<fuchsia_examples::Echo>::EchoString echo_client.cm 717533:717535 at fidling/gen/examples/fidl/fuchsia.examples/fuchsia.examples/llcpp/fidl/fuchsia.examples/cpp/wire_messaging.cc:1051:12 fidl::WireResult<fuchsia_examples::Echo::EchoString>::WireResult echo_client.cm 717533:717535 at zircon/system/ulib/fidl/include/lib/fidl/llcpp/message.h:205:3 fidl::OutgoingMessage::Call<fidl::WireResponse<fuchsia_examples::Echo::EchoString>, zx::unowned<zx::channel> > echo_client.cm 717533:717535 at zircon/system/ulib/fidl/include/lib/fidl/llcpp/message.h:196:5 fidl::OutgoingMessage::Call<fidl::WireResponse<fuchsia_examples::Echo::EchoString> > echo_client.cm 717533:717535 at zircon/system/ulib/fidl/llcpp_message.cc:243:12 fidl::OutgoingMessage::CallImpl echo_client.cm 717533:717535 zx_channel_call_etc(handle: handle = Channel:f751d2fb(dir:/svc/fuchsia.examples.Echo), options: uint32 = ZX_CHANNEL_WRITE_USE_IOVEC, deadline: zx.time = ZX_TIME_INFINITE, rd_num_bytes: uint32 = 64, rd_num_handles: uint32 = 64) sent request fuchsia.examples/Echo.EchoString = { value: string = "hello" } -> ZX_OK received response fuchsia.examples/Echo.EchoString = { response: string = "hello" }
這個選項會增加一些負擔,因為每次呼叫系統時,都必須要求 zxdb 的完整堆疊 (而且 fidlcat 將較為繁雜)。只有在需要瞭解程式碼的哪個部分呼叫系統呼叫時,才應使用此方法。
篩選輸出內容
音調
根據預設,fidlcat
只會顯示 zx_channel
系統呼叫。--syscalls
選項可讓您定義規則運算式,以選取要解碼並顯示顯示的系統呼叫。
如要顯示所有系統呼叫,請使用:--syscalls=".\*"
--exclude-syscalls
旗標會定義一般到期時間,從 --syscalls
選取的集合中排除系統呼叫。
如要顯示,Syscall 必須符合 --syscalls
模式,且不符合 --exclude-syscalls
模式。
以下範例會顯示 zx_handle
以外的所有 syscall,除外:
--syscalls ".\*" --exclude-syscalls "zx_handle_.\*"
訊息
根據預設,fidlcat
會顯示所有訊息。你可以使用以下方式指定要顯示的訊息:
--messages
可讓您指定一或多個規則運算式,訊息必須滿足才能顯示。--exclude-messages
可讓您指定一或多個規則運算式,以便顯示訊息。
如果同時使用這兩個選項,訊息必須滿足其中一個以 --messages
指定的規則運算式,且不符合 --exclude-messages
指定的任何規則運算式。
訊息篩選功能適用於方法的完整名稱。例如以下標記:
--messages=".*Open"
比對方式如下:
fuchsia.io/Directory.Open
fuchsia.io/Node.OnOpen
Threads
使用 --thread=<thread koid>
選項時,系統只會顯示指定執行緒的事件。這個選項可以多次使用,以顯示多個執行緒。
分組輸出內容
通訊協定
使用 --with=top
和 --with=top=<path>
選項產生檢視畫面,依程序、通訊協定和方法將輸出內容分組。群組會根據事件數量排序,因此具有更多相關事件的群組會較早列出。
Threads
使用 --with=group-by-thread
和 --with=group-by-thread=<path>
選項可產生檢視畫面,針對每個執行緒顯示所有事件的簡短版本。
延後顯示訊息
根據預設,fidlcat
會在訊息附加到程序後立即顯示訊息。
您可以使用 --trigger
選項延後顯示畫面,直到提供的規則運算式與傳入訊息相符為止。
如果您需要瞭解收到或發出特定訊息後的狀況,這項功能就非常實用。
摘要檢視
如要設定 fidlcat
顯示工作階段的高階摘要,而非列出個別訊息,請使用 --with=summary
和 --with=summary=<path>
選項。
echo_client.cm 1505832: 16 handles Process:ac4ce043(proc-self) startup Vmar:a43cfe53(vmar-root) startup Thread:d5dce00f(thread-self) startup Channel:91cce2f3(dir:/svc) write request fuchsia.io/Directory.Open(".") -> Channel:c65ce1c3(dir:/svc) startup Channel:daece3fb(dir:/pkg) startup Socket:cb8ce31f(fd:1) closed by zx_handle_close startup Socket:df8ce687(fd:2) closed by zx_handle_close startup Channel:93ccfcf7(directory-request:/) startup Clock:b7ecfe9b() startup Job:674ce17f(job-default) startup Vmo:adbcfc9f(vdso-vmo) startup Vmo:ef2ce06f(stack-vmo) Channel:c65ce1c3(dir:/svc) linked to Channel:da9cebcb(channel:1) created by zx_channel_create write request fuchsia.io/Directory.Open("fuchsia.examples.Echo") -> Channel:767ce3f3(dir:/svc/fuchsia.examples.Echo) closed by zx_handle_close Channel:da9cebcb(channel:1) linked to Channel:c65ce1c3(dir:/svc) created by zx_channel_create closed by Channel:91cce2f3(dir:/svc) sending fuchsia.io/Directory.Open Channel:767ce3f3(dir:/svc/fuchsia.examples.Echo) linked to Channel:f4bce307(channel:3) created by zx_channel_create call request fuchsia.examples/Echo.EchoString write request fuchsia.examples/Echo.SendString read event fuchsia.examples/Echo.OnString closed by zx_handle_close Channel:f4bce307(channel:3) linked to Channel:767ce3f3(dir:/svc/fuchsia.examples.Echo) created by zx_channel_create closed by Channel:c65ce1c3(dir:/svc) sending fuchsia.io/Directory.Open
這會顯示工作階段中所有受監控程序、帳號代碼和管道的清單,並附上額外的摘要詳細資料:
控制代碼:控點是在程序建立期間繼承的啟動控制代碼,或在程序生命週期中建立。對於非啟動控點,
fidlcat
也會顯示用於建立及關閉每個控制代碼的系統呼叫相關資訊。管道:顯示對頻道另一端負責的控制代碼,以及收發的 FIDL 訊息清單。
持續監控
根據預設,fidlcat
工作階段會在所有附加程序結束時終止。
使用 --stay-alive
選項可讓工作階段保持執行,直到您手動結束 fidlcat
(例如使用 Ctrl-C) 為止。
這可讓您在同一個監控工作階段中多次重新啟動程式。每次重新啟動時,fidlcat
工作階段都會自動附加至新程序。