启动 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 获取全栈信息 {0}应该使用 只有当您需要了解代码的哪个部分称为系统调用时。
过滤输出
系统调用
默认情况下,fidlcat 仅显示 zx_channel 系统调用。
--syscalls选项可用于定义一个正则表达式
要解码和显示的系统调用。
如需显示所有系统调用,请使用:--syscalls=".\*"
--exclude-syscalls 标志定义了一个常规到期日,不包括
来自 --syscalls 选择的集合中的系统调用。
系统调用必须满足 --syscalls 模式(而非
符合 --exclude-syscalls 模式。
以下示例显示了除 zx_handle 之外的所有系统调用:
--syscalls ".\*" --exclude-syscalls "zx_handle_.\*"
消息
默认情况下,fidlcat 会显示所有消息。
您可以使用以下方式指定要显示的消息:
--messages可用于指定一个或多个正则表达式,即 消息必须满足的要求才能显示。--exclude-messages可用于指定一个或多个正则表达式 消息必须满足要求才能显示
如果同时使用这两个选项,则消息必须
满足使用 --messages 指定的某个正则表达式,而非
满足使用 --exclude-messages 指定的任何正则表达式。
消息过滤适用于方法的完全限定名称。例如: 以下标志:
--messages=".*Open"
匹配如下方法:
fuchsia.io/Directory.Open
fuchsia.io/Node.OnOpen
线程
在使用 --thread=<thread koid> 选项时,只有来自指定
会话。多次使用该选项可显示
线程。
对输出进行分组
协议
使用 --with=top 和 --with=top=<path> 选项生成一个视图,
按进程、协议和方法对输出进行分组。分组的排序方式:
因此可优先列出具有更多关联事件的组。
线程
您可以使用 --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 会话都会附加到新进程
。