Macos Ktrace“ -t c&quot”系统呼叫跟踪在较新的MacOS上可用吗?

发布于 2025-02-06 06:44:54 字数 285 浏览 3 评论 0原文

有人知道是否有一种方法可以通过MacOS 12+中的KTRACE追踪系统调用? (显然,这是通过禁用的SIP。)

过去可以通过以下方式跟踪系统调用:

sudo ktrace trace -s -S -t c -c ./some_binary

现在-t是简单的

将时间打印为Mach绝对时间戳,而不是默认的本地壁时钟时间。

Anyone know if there's a way to trace only system calls via ktrace in macOS 12+? (Obviously this is with SIP disabled.)

In the past one could trace system calls via:

sudo ktrace trace -s -S -t c -c ./some_binary

Now the -t is simply

Print times as Mach absolute timestamps, instead of the default local wall clock time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘心安 2025-02-13 06:44:54

-t trstr的替换似乎是-f filter-desc。新的过滤器更灵活,但可以说使用一些提示。这是 manpage 必须说:

-f Filter-desc

将过滤器描述应用于跟踪会话,控制哪个
事件被追踪。

滤波器描述

过滤器描述是类和子类的逗号分隔列表
指示应追踪哪些事件的指定器。一堂课
指定符以c开始,并包含一个单个字节,在
十进制或十六进制。子类规范符以s开始
两个字节。高字节是班级,低字节是
该类的子类。

例如,此过滤器描述将启用类1和37和
第5类的子类33和35:c1,c0x25,s0x0521,s0x0523

您可以过滤的可能值在 bsd/sys/kdebug.h 类和子类定义下。

因此,如果您对BSD Syscalls感兴趣,那就是-f C4(类4 = dbg_bsd)。 Mach Syscalls(又称陷阱)将为-f S0X010C(类1 = dbg_mach,subclass 0c = dbg_mach_excp_excp_sc) 。

因此,要显示BSD Syscalls和Mach陷阱:

sudo ktrace trace -Ss -f C4,S0x010c -c ./some_binary

根据您的追求,您可能还需要C2,C3dbg_networkdbg_fsystem) 。

The replacement for -t trstr seems to be -f filter-desc. The new filters are more flexible but arguably a bit fiddlier to use. Here's what the manpage has to say:

-f filter-desc

Apply a filter description to the trace session, controlling which
events are traced.

FILTER DESCRIPTIONS

A filter description is a comma-separated list of class and subclass
specifiers that indicate which events should be traced. A class
specifier starts with C and contains a single byte, specified in
either decimal or hex. A subclass specifier starts with S and takes
two bytes. The high byte is the class and the low byte is the
subclass of that class.

For example, this filter description would enable classes 1 and 37 and
the subclasses 33 and 35 of class 5: C1,C0x25,S0x0521,S0x0523.

The possible values you can filter on are defined in bsd/sys/kdebug.h under Class and subclass definitions.

So if you're interested in BSD syscalls, that's -f C4 (class 4 = DBG_BSD). Mach syscalls (aka traps) would be -f S0x010c (class 1 = DBG_MACH, subclass 0c = DBG_MACH_EXCP_SC).

So to show BSD syscalls and Mach traps:

sudo ktrace trace -Ss -f C4,S0x010c -c ./some_binary

Depending on what you're after, you might also want C2,C3 (DBG_NETWORK and DBG_FSYSTEM).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文