Using DTrace to Get Stack Trace / Profiling Rust Data

I am trying to get a good plugin with my Rust code. Unfortunately, Xcode 8.3 no longer supports exporting profiling data, so I'm trying to use DTrace to get profiling data.

I have included debugging information in my Cargo.tomlfor binaries release:

[profile.release]
debug = true

Then I run the release ( mybinaryname) binary and the stack trace example using DTrace:

sudo dtrace -n 'profile-997 /execname == "mybinaryname"/ { @[ustack(100)] = count(); }' -o out.user_stacks

The end result looks something like this:

          0x10e960500
          0x10e964632
          0x10e9659e0
          0x10e937edd
          0x10e92aae2
          0x10e92d0d7
          0x10e982c8b
          0x10e981fc1
          0x7fff93c70235
          0x1
            1

By comparison, getting the tracks iTerm2gives me nice tracks like this:

          CoreFoundation`-[__NSArrayM removeAllObjects]
          AppKit`_NSGestureRecognizerUpdate+0x769
          CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__+0x17
          CoreFoundation`__CFRunLoopDoObservers+0x187
          CoreFoundation`__CFRunLoopRun+0x4be
          CoreFoundation`CFRunLoopRunSpecific+0x1a4
          HIToolbox`RunCurrentEventLoopInMode+0xf0
          HIToolbox`ReceiveNextEventCommon+0x1b0
          HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter+0x47
          AppKit`_DPSNextEvent+0x460
          AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0xaec
          AppKit`-[NSApplication run]+0x39e
          AppKit`NSApplicationMain+0x4d5
          iTerm2`main+0x6e
          libdyld.dylib`start+0x1
          iTerm2`0x1
            1

Rust? (Xcode Instruments , !) , , - ?

+4
1

, , , , , 100% .

, rustc , target/release/deps/mybinaryname-hashcode.dSYM. target/release/deps/mybinaryname-hashcode, .

MacOS - LLDB, , Spotlight. , Frameworks , Xcode Instruments DTrace. ( DebugSymbols.framework CoreSymbolication.framework.) - , .

, dtrace -p PID :

sudo dtrace -p $PID -n 'profile-997 /pid == '$PID'/ { @[ustack(100)] = count(); }' -o $TMPFILE &>/dev/null

man of -p:

-, . -p, dtrace , , . D, , -s $target.

, Rust -p, .

+3

Source: https://habr.com/ru/post/1675034/


All Articles