How to export Stack Trace using xctrace

I am trying to export .trace file data to xml using the following command

xctrace export --input report.trace --xpath '/trace-toc/run[@number="1"]/tracks/track[@name="Leaks"]/details/detail[@name="Leaks"]' --output output.xml
<?xml version="1.0"?>
<trace-query-result>
<node xpath='//trace-toc[1]/run[1]/tracks[1]/track[2]/details[1]/detail[1]'><row leaked-object="Swift.StringStorage" size="131072" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x130018000"/>
<row leaked-object="Swift.StringStorage" size="131072" responsible-frame="&lt;Allocated Prior To Attach&gt;" count="1" responsible-library="" address="0x140118000"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="&lt;Allocated Prior To Attach&gt;" count="1" responsible-library="" address="0x60000152d6e0"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x6000015f56e0"/>
<row leaked-object="Swift.StringStorage" size="131072" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x120028000"/>
<row leaked-object="Swift.StringStorage" size="131072" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x120048000"/>
<row leaked-object="Swift.StringStorage" size="131072" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x130038000"/>
<row leaked-object="Swift.StringStorage" size="131072" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x130058000"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x6000015038d0"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x600001508ea0"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x60000150a4c0"/>
<row leaked-object="MemoryLeaker" size="48" responsible-frame="_swift_allocObject_" count="1" responsible-library="libswiftCore.dylib" address="0x60000150cfc0"/>
</node></trace-query-result>

Data is being converted to xml but without any details of the Stack Trace

Is there any documentation that shows how I can include the Stack Trace as well?

Does xctrace support any other export format besides XML?

Thanks

Hi! Unfortunately, the Leaks instrument does not support exporting stack traces. Please file a request using Feedback Assistant (and reply with the ID here) so we can better prioritize fixing this.

As a workaround, you can use the leaks command line tool. If you can run your app and reproduce the issue on your Mac or in the Simulator, use the command leaks <pid> (e.g. leaks 123) or leaks MyApp. This will capture a memory graph of your running process, then analyze it for memory leaks and print out information about any leaks found. Make sure you run your application with Malloc Stack Logging enabled (under Product → Scheme → Edit Scheme… → Run → Diagnostics → Memory Management) to see stack traces in the output of the command.

If your app is unable to be run on macOS or in the Simulator, you can also capture a memory graph in Xcode while in a debug session by clicking the button between the “Debug View Hierarchy” and “Simulate Location” buttons in the debugger toolbar. Then, go to File → Export Memory Graph… to save a .memgraph file. That file can be passed into leaks (like leaks ~/Desktop/MyApp.memgraph) to produce the same information you’d get when running against a process on your Mac.

You might find the Detect and diagnose memory issues talk from WWDC21 helpful.

How to export Stack Trace using xctrace
 
 
Q