The new target metrics command will report internal timings and information that can be used to track performance in LLDB. The information can also be used to help reproduce the debug session and exact breakpoint state if the appropriate options are used. This allows users to report performance issues or bugs where breakpoints were not resolved and LLDB engineers can use this information to track the issue.
The command emits JSON so that the structured data can be used to report timings to databases for performance tracking.
(lldb) target metrics
{
"firstStopTime": 0.33988644499999998, "launchOrAttachTime": 0.31808012899999999, "targetCreateTime": 31.168737819, "totalBreakpointResolveTime": 6.6650758780000006, "totalDebugInfoIndexTime": 0, "totalDebugInfoParseTime": 4.2728297900000118, "totalDebugInfoSize": 6581323413, "totalSymbolTableIndexTime": 17.815137097000008, "totalSymbolTableParseTime": 12.261250563000004
}
With no options we report some timings at the top level:
"launchOrAttachTime" is the time it takes from the time launch or attach is started, to when we hit our first private eStateStopped state
"firstStopTime" is the time it takes to stop at our first public stop. This time only has meaning if you run your program to a known breakpoint and want to compare timings with new versions of LLDB. This is because your program might not stop at a breakpoint right away unless a targetted breakpoint has been set for measuring.
"targetCreateTime" is the time it takes to set the main executable in the target and all dependent shared libraries. This time will include the symbol preloading if symbol preloading is enabled. This time can help is measure how long it takes to parse the symbol tables, index the symbol tables, and index the debug info along with any debug info parsing that might be required.
"totalBreakpointResolveTime" is the time it took to resolve any breakpoints that were set. If you specify the "--breakpoints" or "-b" option, you can get a breakdown of resolve time on a per breakpoint level.
"totalDebugInfoIndexTime" is the time it took to index the debug information for all current modules in the target.
"totalDebugInfoParseTime" is the time it took to parse the debug information for all current modules in the target.
"totalDebugInfoSize" is the sum of all debug information sections from all object files in the module.
"totalSymbolTableIndexTime" is the time it took to parse the symbol tables for each object file in all modules.
"totalSymbolTableParseTime" is the time it took to index the symbol tables for each object file in all modules.
Adding the "--modules" options will include a top level "modules" array that contains full details on each module, breaking down the debug info parse/index times and size, symbol table parse/index times along with enough info to identify the module (path, triple, uuid).
(lldb) target metrics --modules
...
"modules": [ { "debugInfoIndexTime": 0, "debugInfoParseTime": 0.054413763000000004, "debugInfoSize": 18118626, "path": "/Users/gclayton/Documents/src/lldb/main/Debug/bin/lldb", "symbolTableIndexTime": 0.22065103899999999, "symbolTableParseTime": 0.138976874, "triple": "x86_64-apple-macosx11.0.0", "uuid": "F59B8D3F-67B1-35EC-A1AA-E0ABB5CB3601" }, { "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "debugInfoSize": 0, "path": "/usr/lib/dyld", "symbolTableIndexTime": 0.01367178, "symbolTableParseTime": 0.0093677970000000006, "triple": "x86_64-apple-macosx11.6.0", "uuid": "0CC19410-FD43-39AE-A32A-50273F8303A4" }, { "debugInfoIndexTime": 0, "debugInfoParseTime": 4.2184160270000115, "debugInfoSize": 6563204787, "path": "/Users/gclayton/Documents/src/lldb/main/Debug/bin/LLDB.framework/Versions/A/LLDB", "symbolTableIndexTime": 17.112896844000002, "symbolTableParseTime": 11.240680348, "triple": "x86_64-apple-macosx11.0.0", "uuid": "CB1763B7-BB3D-38A1-AB32-237E59244745" },
Adding the "--breakpoints option will include details on all breakpoints including the breakpoint ID, individual resolve time, and "details" which contains the serialized breakpoint settings that were already built into each breakpoint, so we can know the exact details of how a breakpoint was set.
(lldb) target metrics --breakpoints
{
"breakpoints": [ { "details": {...}, "id": 1, "resolveTime": 2.2936575110000001 }
Adding the "--locations" options will dump the details of all resolved breakpoint locations withing each breakpoint:
(lldb) target metrics --locations
{
"breakpoints": [ { ..., "locations": [ { "enabled": true, "fileAddress": 15783486, "hardward": false, "hitCount": 0, "id": 1, "indirect": false, "loadAddress": 4319532606, "reexported": false, "resolved": true, "symbolContext": { "compUnit": "/Users/gclayton/Documents/src/lldb/main/llvm-project/lldb/source/Target/Target.cpp", "function": "lldb_private::Target::Target(lldb_private::Debugger&, lldb_private::ArchSpec const&, std::__1::shared_ptr<lldb_private::Platform> const&, bool)", "module": "CB1763B7-BB3D-38A1-AB32-237E59244745", "sourceColumn": 1, "sourceFile": "/Users/gclayton/Documents/src/lldb/main/llvm-project/lldb/source/Target/Target.cpp", "sourceLine": 123, "symbol": "lldb_private::Target::Target(lldb_private::Debugger&, lldb_private::ArchSpec const&, std::__1::shared_ptr<lldb_private::Platform> const&, bool)" } }, { "enabled": true, "fileAddress": 15787038, "hardward": false, "hitCount": 0, "id": 2, "indirect": false, "loadAddress": 4319536158, "reexported": false, "resolved": true, "symbolContext": { "compUnit": "/Users/gclayton/Documents/src/lldb/main/llvm-project/lldb/source/Target/Target.cpp", "function": "lldb_private::Target::Target(lldb_private::Debugger&, lldb_private::ArchSpec const&, std::__1::shared_ptr<lldb_private::Platform> const&, bool)", "module": "CB1763B7-BB3D-38A1-AB32-237E59244745", "sourceColumn": 1, "sourceFile": "/Users/gclayton/Documents/src/lldb/main/llvm-project/lldb/source/Target/Target.cpp", "sourceLine": 123, "symbol": "lldb_private::Target::Target(lldb_private::Debugger&, lldb_private::ArchSpec const&, std::__1::shared_ptr<lldb_private::Platform> const&, bool)" } } ], "resolveTime": 4.3714183670000004
Could the double and uint64_t here/below be a typedef to some unit? typedef double Seconds/typedef uint64_t ByteCount or something along those lines. Would make the unit we're expecting more obvious and I can easily find all the related code.