[Lldb-commits] [PATCH] D110804: Add a new command "target metrics".

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 30 00:56:49 PDT 2021


clayborg created this revision.
clayborg added reviewers: jingham, labath, aprantl, JDevlieghere, aadsm, wallace.
Herald added subscribers: dang, pengfei, arphaman, mgorny, emaste.
clayborg requested review of this revision.
Herald added subscribers: lldb-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110804

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Core/FileSpecList.h
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Core/Section.h
  lldb/include/lldb/Symbol/SymbolContext.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Metrics.h
  lldb/include/lldb/Target/PathMappingList.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/Utility/Timer.h
  lldb/include/lldb/lldb-forward.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/FileSpecList.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/Section.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
  lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Metrics.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/target/metrics/Makefile
  lldb/test/API/commands/target/metrics/TestTargetMetrics.py
  lldb/test/API/commands/target/metrics/a.cpp
  lldb/test/API/commands/target/metrics/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110804.376126.patch
Type: text/x-patch
Size: 74430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210930/6e7261c9/attachment-0001.bin>


More information about the lldb-commits mailing list