How to trace a program from its very beginning without running it as root

前端 未结 7 1692
我在风中等你
我在风中等你 2021-02-04 09:44

I\'m writing a tool that calls through to DTrace to trace the program that the user specifies.

If my tool uses dtrace -c to run the program as a subprocess of DTrace, no

7条回答
  •  天命终不由人
    2021-02-04 09:57

    dtruss has the -n option where you can specify name of process you want to trace, without starting it (Credit to latter part of @kenorb's answer at https://stackoverflow.com/a/11706251/970301). So something like the following should do it:

    sudo dtruss -n "$program"
    $program
    

提交回复
热议问题