summaryrefslogtreecommitdiff
path: root/lldb/source/Target/Statistics.cpp
AgeCommit message (Collapse)Author
2025-10-01[LLDB] Add load core time to target metrics (#161581)Jacob Lalonde
This patch adds a load core time, right now we don't have much insight into the performance of load core, especially for large coredumps. To start collecting information on this I've added some minor instrumentation code to measure the two call sites of `LoadCore`. I've also added a test to validate the new metric is output in statistics dump
2025-09-09Reland"[lldb] Add count for errors of DWO files in statistics and combine ↵Ziyi Wang
DWO file count functions" (#156980) This relands changes in https://github.com/llvm/llvm-project/pull/155023 for adding a count of dwo errors and combine all the dwo related stats into one struct. The previous PR was reverted in https://github.com/llvm/llvm-project/pull/156777 as the newly added unit test `test_dwo_id_mismatch_error_stats` sometimes fails due to inappropriate use of `glob.glob`. This change modified the tests created in the former PR to collect and modify the dwo files by there names instead of using index after `glob.glob`. This will avoid the possible failure in these tests if the order of dwo files changes. [Original PR: https://github.com/llvm/llvm-project/pull/155023](https://github.com/llvm/llvm-project/pull/155023) ## Testing Ran unit tests ``` $ ./bin/llvm-lit /data/users/ziyiww/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py ./bin/llvm-lit /data/users/ziyiww/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py -v -- Testing: 1 tests, 1 workers -- PASS: lldb-api :: commands/statistics/basic/TestStats.py (1 of 1) Testing Time: 388.52s Total Discovered Tests: 1 Passed: 1 (100.00%) $ bin/lldb-dotest -p TestStats.py /data/users/ziyiww/llvm-project/lldb/test/API/commands/statistics/basic/ ---------------------------------------------------------------------- Ran 27 tests in 386.302s OK (skipped=3) ```
2025-09-03Revert "[lldb] Add count for errors of DWO files in statistics and combine ↵David Peixotto
DWO file count functions" (#156777) Reverts llvm/llvm-project#155023 The PR tests passed, but it failed in the CI. Reverting to give time to investigate.
2025-09-03[lldb] Add count for errors of DWO files in statistics and combine DWO file ↵Ziyi Wang
count functions (#155023) ## Summary A new `totalDwoErrorCount` counter is available in statistics when calling `statistics dump` to track the number of DWO errors. Additionally, this PR refactors the DWO file statistics by consolidating the existing functionality for counting loaded and total DWO files together with the number of DWO errors into a single function that returns a new DWOStats struct. 1. A new struct, `DWOStats` is created to hold the number of loaded DWO files, the total number of DWO files and the number of DWO errors. 2. Replaced the previous `GetDwoFileCounts` function for loaded and total DWO file counts with a single `GetDwoStats()` function returning the struct `DWOStats`. An override is implemented for `SymbolFileDWARF` that computes the new DWO error count alongside existing counts in one pass. If the status of a DWO CU is `Fail`, which means there is error happened during the loading process, we increment the DWO error counter. _Note: The newly created function `GetDwoStats` will only be called when we try to get statistics. Other codepaths will not be affected._ 3. In Statistics, we sum up the total number of DWO file loading errors. This is done by getting `DWOStats` for each symbol file and adding up the results for each module, then adding to the total count among all modules. 4. In Statistics, we also updated call sites to use the new combined function and struct for loaded and total DWO file counts. As it is possible for one module to have several symbol files, the DWO file counts in a module's stats are updated to be calculated by adding up the counts from all symbol files. ## Expected Behavior - When binaries are compiled with split-dwarf and separate DWO files, `totalDwoLoadErrorCount` would be the number of dwo files with error occurs during the loading process, 0 if no error occurs during a loading process. - When not using split-dwarf, we expect `totalDwoLoadErrorCount` to be 0 since there no DWO file loading errors would be caused. - `totalLoadedDwoFileCount` and `totalDwoFileCount` should be correctly calculated after refactoring and updating. ## Testing ### Manual Testing We created some files to simulate the possible DWO errors manually and observed the results generated by statistics dump. For example, if we delete one of the DWO files generated after compiling, we would get: ``` (lldb) statistics dump { ... "totalDwoLoadErrorCount": 1, ... } ``` We also checked the time cost of `statistics dump` w/o the modification to make sure no significant time cost increase imported. ### Unit test Added two unit tests that build with new "dwo_error_foo.cpp" and "dwo_error_main.cpp" files. For tests with flags -gsplit-dwarf, this generates 2 DWO files. In one of the tests, we delete both DWO files and check the result to see if it reflects the number of DWO files with errors correctly. In another test we update one of the files but loading the outdated .dwo file of it, expecting it increments the error count by 1. To run the test: ``` $ bin/lldb-dotest -p TestStats.py ~/local/llvm-project/lldb/test/API/commands/statistics/basic/ -G "dwo" ---------------------------------------------------------------------- Ran 27 tests in 2.680s OK (skipped=21) $ bin/lldb-dotest -p TestStats.py ~/local/llvm-project/lldb/test/API/commands/statistics/basic/ ---------------------------------------------------------------------- Ran 27 tests in 370.131s OK (skipped=3) ```
2025-06-24Reland "[lldb] Add count for number of DWO files loaded in statistics ↵qxy11
#144424" (#145572) This relands changes in #144424 for adding a count of DWO files parsed/loaded and the total number of DWO files. The previous PR was reverted in #145494 due to the newly added unit tests failing on Windows and MacOS CIs since these platforms don't support DWO. This change add an additional `@add_test_categories(["dwo"])` to the new tests to [skip](https://github.com/llvm/llvm-project/blob/cd46354dbd10820158edabe14dbd49d9f9010722/lldb/packages/Python/lldbsuite/test/test_categories.py#L56) these tests on Windows/MacOS. Original PR: #144424 ### Testing Ran unit tests ``` $ bin/lldb-dotest -p TestStats.py llvm-project/lldb/test/API/commands/statistics/basic/ ---------------------------------------------------------------------- Ran 24 tests in 211.391s OK (skipped=3) ```
2025-06-24Revert "[lldb] Add count for number of DWO files loaded in statistics" (#145494)Michael Buch
Reverts llvm/llvm-project#144424 Caused CI failures. macOS CI failure was: ``` 10:20:36 FAIL: test_dwp_dwo_file_count (TestStats.TestCase) 10:20:36 Test "statistics dump" and the loaded dwo file count. 10:20:36 ---------------------------------------------------------------------- 10:20:36 Traceback (most recent call last): 10:20:36 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py", line 639, in test_dwp_dwo_file_count 10:20:36 self.assertEqual(debug_stats["totalDwoFileCount"], 2) 10:20:36 AssertionError: 0 != 2 10:20:36 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 10:20:36 ====================================================================== 10:20:36 FAIL: test_no_debug_names_eager_loads_dwo_files (TestStats.TestCase) 10:20:36 Test the eager loading behavior of DWO files when debug_names is absent by 10:20:36 ---------------------------------------------------------------------- 10:20:36 Traceback (most recent call last): 10:20:36 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py", line 566, in test_no_debug_names_eager_loads_dwo_files 10:20:36 self.assertEqual(debug_stats["totalDwoFileCount"], 2) 10:20:36 AssertionError: 0 != 2 10:20:36 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 10:20:36 ====================================================================== 10:20:36 FAIL: test_split_dwarf_dwo_file_count (TestStats.TestCase) 10:20:36 Test "statistics dump" and the dwo file count. 10:20:36 ---------------------------------------------------------------------- 10:20:36 Traceback (most recent call last): 10:20:36 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py", line 588, in test_split_dwarf_dwo_file_count 10:20:36 self.assertEqual(len(debug_stats["modules"]), 1) 10:20:36 AssertionError: 42 != 1 10:20:36 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang ```
2025-06-23[lldb] Add count for number of DWO files loaded in statistics (#144424)qxy11
## Summary A new `totalLoadedDwoFileCount` and `totalDwoFileCount` counters to available statisctics when calling "statistics dump". 1. `GetDwoFileCounts ` is created, and returns a pair of ints representing the number of loaded DWO files and the total number of DWO files, respectively. An override is implemented for `SymbolFileDWARF` that loops through each compile unit, and adds to a counter if it's a DWO unit, and then uses `GetDwoSymbolFile(false)` to check whether the DWO file was already loaded/parsed. 3. In `Statistics`, use `GetSeparateDebugInfo` to sum up the total number of loaded/parsed DWO files along with the total number of DWO files. This is done by checking whether the DWO file was already successfully `loaded` in the collected DWO data, anding adding to the `totalLoadedDwoFileCount`, and adding to `totalDwoFileCount` for all CU units. ## Expected Behavior - When binaries are compiled with split-dwarf and separate DWO files, `totalLoadedDwoFileCount` would be the number of loaded DWO files and `totalDwoFileCount` would be the total count of DWO files. - When using a DWP file instead of separate DWO files, `totalLoadedDwoFileCount` would be the number of parsed compile units, while `totalDwoFileCount` would be the total number of CUs in the DWP file. This should be similar to the counts we get from loading separate DWO files rather than only counting whether a single DWP file was loaded. - When not using split-dwarf, we expect both `totalDwoFileCount` and `totalLoadedDwoFileCount` to be 0 since no separate debug info is loaded. ## Testing **Manual Testing** On an internal script that has many DWO files, `statistics dump` was called before and after a `type lookup` command. The `totalLoadedDwoFileCount` increased as expected after the `type lookup`. ``` (lldb) statistics dump { ... "totalLoadedDwoFileCount": 29, } (lldb) type lookup folly::Optional<unsigned int>::Storage typedef std::conditional<true, folly::Optional<unsigned int>::StorageTriviallyDestructible, folly::Optional<unsigned int>::StorageNonTriviallyDestructible>::type typedef std::conditional<true, folly::Optional<unsigned int>::StorageTriviallyDestructible, folly::Optional<unsigned int>::StorageNonTriviallyDestructible>::type ... (lldb) statistics dump { ... "totalLoadedDwoFileCount": 2160, } ``` **Unit test** Added three unit tests that build with new "third.cpp" and "baz.cpp" files. For tests with w/ flags `-gsplit-dwarf -gpubnames`, this generates 2 DWO files. Then, the test incrementally adds breakpoints, and does a type lookup, and the count should increase for each of these as new DWO files get loaded to support these. ``` $ bin/lldb-dotest -p TestStats.py ~/llvm-sand/external/llvm-project/lldb/test/API/commands/statistics/basic/ ---------------------------------------------------------------------- Ran 20 tests in 211.738s OK (skipped=3) ```
2025-06-09Add commands to list/enable/disable plugins (#134418)David Peixotto
This commit adds three new commands for managing plugins. The `list` command will show which plugins are currently registered and their enabled state. The `enable` and `disable` commands can be used to enable or disable plugins. A disabled plugin will not show up to the PluginManager when it iterates over available plugins of a particular type. The purpose of these commands is to provide more visibility into registered plugins and allow users to disable plugins for experimental perf reasons. There are a few limitations to the current implementation 1. Only SystemRuntime and InstrumentationRuntime plugins are currently supported. We can easily extend the existing implementation to support more types. The scope was limited to these plugins to keep the PR size manageable. 2. Only "statically" know plugin types are supported (i.e. those managed by the PluginManager and not from `plugin load`). It is possibly we could support dynamic plugins as well, but I have not looked into it yet.
2025-05-21[lldb] Remove unused local variables (NFC) (#140989)Kazu Hirata
2025-04-25Add symbol locator time for each module in statistics (#137379)GeorgeHuyubo
Identical PR to: https://github.com/llvm/llvm-project/pull/134563 Previous PR was approved and landed but broke the build due to bad merge. Manually resolve the merge conflict and try to land again. Co-authored-by: George Hu <georgehuyubo@gmail.com>
2025-04-25Revert "Add symbol locator time for each module in statistics (#134563)"Kazu Hirata
This reverts commit 070a4ae2f9bcf6967a7147ed2972f409eaa7d3a6. Multiple buildbot failures have been reported: https://github.com/llvm/llvm-project/pull/134563 The build fails with: lldb/source/Target/Statistics.cpp:75:39: error: use of undeclared identifier 'num_symbols_loaded'
2025-04-25Add symbol locator time for each module in statistics (#134563)GeorgeHuyubo
In statistics, add locate time for each module in statistics, we time the PluginManager::LocateExecutableSymbolFile and PluginManager::LocateExecutableObjectFile call, save the duration for the succeeded symbol locator plugin in the Module class as a map. New key being added: Module level: "_symbolLocatorTime_" Summary level: "_totalSymbolLocatorTime_" which would be a map of symbol_locator_plugin_name to time. Sample statistic dump output after this change: ``` Command: statistics dump ===============Output=============== { "commands": { "command container add": 1, "command script add": 51, "command script import": 59, "statistics dump": 1, "target create": 1, "type summary add": 36, "type synthetic add": 21 }, "memory": { "strings": { "bytesTotal": 2801664, "bytesUnused": 1704256, "bytesUsed": 1097408 } }, "modules": [ { "debugInfoByteSize": 244927, "debugInfoEnabled": true, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0.61934599999999995, "debugInfoParseTime": 0.00033100000000000002, "identifier": 94868115726768, "path": "/home/hyubo/.cache/llvm-debuginfod/client/llvmcache-720c9a0f5ba8b460a1524a25597226f0fa551f71-c4crasher", "symbolLocatorTime": { "debuginfod": 1.4547020000000002 }, "symbolTableIndexTime": 0.0035370000000000002, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.0055040000000000002, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "720C9A0F-5BA8-B460-A152-4A25597226F0-FA551F71" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868111142256, "path": "[vdso](0x00007ffd41c59000)", "symbolLocatorTime": { "debuginfod": 0.80597700000000005 }, "symbolTableIndexTime": 2.8e-05, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.00037300000000000001, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "4D1F38BD-BD34-DFB3-C9A5-B49A2A912219-AC713763" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868116162096, "path": "/usr/local/fbcode/platform010/lib/libc.so.6", "symbolLocatorTime": { "debuginfod": 0.286356 }, "symbolTableIndexTime": 0.0091780000000000004, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.081841999999999998, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "ACE9DF01-8872-3A35-6D14-3C92527EF739-4BE32C75" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868111990032, "path": "/usr/local/fbcode/platform010/lib/libm.so.6", "symbolLocatorTime": { "debuginfod": 0.63356699999999999 }, "symbolTableIndexTime": 0.0023960000000000001, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.021706, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "85932B54-0DE7-4FC1-23B0-FB09AD1A5A61-8E1098B7" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868116399488, "path": "/usr/local/fbcode/platform010/lib/libmvec.so.1", "symbolLocatorTime": { "debuginfod": 0.66705099999999995 }, "symbolTableIndexTime": 0.00053700000000000004, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.0034429999999999999, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "4537CA22-8E6E-495B-7A03-FC2CEDCAD71C-8A7B2067" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868111778368, "path": "/usr/local/fbcode/platform010/lib/libatomic.so.1", "symbolLocatorTime": { "debuginfod": 0.83268299999999995 }, "symbolTableIndexTime": 0.000243, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.0026640000000000001, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--", "uuid": "F90F9111-BBD1-C2A9-972A-34EB75ABE62E-3BDED9CF" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868116403264, "path": "/usr/local/fbcode/platform010/lib/libgcc_s.so.1", "symbolLocatorTime": { "debuginfod": 0.58871499999999999 }, "symbolTableIndexTime": 0.000292, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.0033, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--", "uuid": "1C715A92-40BE-BE95-E148-1B401749BAB8-15D09F9D" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868113225328, "path": "/usr/local/fbcode/platform010/lib/libstdc++.so.6", "symbolLocatorTime": { "debuginfod": 0.76993400000000001 }, "symbolTableIndexTime": 0.042455, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.081374000000000002, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--", "uuid": "C9DAEE53-F607-981B-6BED-F2042833BFC7-71A1E66C" }, { "debugInfoByteSize": 0, "debugInfoEnabled": false, "debugInfoHadIncompleteTypes": false, "debugInfoHadVariableErrors": false, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 94868113600960, "path": "/usr/local/fbcode/platform010/lib/ld.so", "symbolLocatorTime": { "debuginfod": 0.48382199999999997 }, "symbolTableIndexTime": 0.00054799999999999998, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.0057219999999999997, "symbolTableSavedToCache": false, "symbolTableStripped": false, "triple": "x86_64--linux", "uuid": "CCA86CF4-E4FF-42C8-7056-2F7D8B83AEE0-530B4095" } ], "targets": [ { "breakpoints": [], "dyldPluginName": "dump-modulelist-dyld", "expressionEvaluation": { "failures": 0, "successes": 0 }, "frameVariable": { "failures": 0, "successes": 0 }, "mismatchCoredumpModuleCount": 0, "moduleIdentifiers": [ 94868115726768, 94868111142256, 94868116162096, 94868111990032, 94868116399488, 94868111778368, 94868116403264, 94868113225328, 94868113600960 ], "signals": [ { "SIGABRT": 1 } ], "sourceMapDeduceCount": 0, "sourceRealpathAttemptCount": 0, "sourceRealpathCompatibleCount": 0, "stopCount": 1, "summaryProviderStatistics": [], "targetCreateTime": 4.1999999999999998e-05, "totalBreakpointResolveTime": 0, "totalSharedLibraryEventHitCount": 0 } ], "totalDebugInfoByteSize": 244927, "totalDebugInfoEnabled": 1, "totalDebugInfoIndexLoadedFromCache": 0, "totalDebugInfoIndexSavedToCache": 0, "totalDebugInfoIndexTime": 0.61934599999999995, "totalDebugInfoParseTime": 0.00033100000000000002, "totalModuleCount": 9, "totalModuleCountHasDebugInfo": 1, "totalModuleCountWithIncompleteTypes": 0, "totalModuleCountWithVariableErrors": 0, "totalSymbolLocatorTime": { "debuginfod": 6.5228070000000002 }, "totalSymbolTableIndexTime": 0.059214000000000003, "totalSymbolTableParseTime": 0.205928, "totalSymbolTableStripped": 0, "totalSymbolTablesLoadedFromCache": 0, "totalSymbolTablesSavedToCache": 0, "transcript": [ { "command": "symsrv", "commandArguments": "", "commandName": "symsrv", "durationInSeconds": 0.00069099999999999999, "error": "", "output": "", "timestampInEpochSeconds": 1744934015 }, { "command": "settings set symbols.enable-external-lookup true", "commandArguments": "symbols.enable-external-lookup true", "commandName": "settings set", "durationInSeconds": 4.1999999999999998e-05, "error": "", "output": "", "timestampInEpochSeconds": 1744934015 }, { "command": "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 https://our.intern.facebook.com/intern/debuginfod", "commandArguments": "plugin.symbol-locator.debuginfod.server-urls 0 https://our.intern.facebook.com/intern/debuginfod", "commandName": "settings insert-before", "durationInSeconds": 5.5999999999999999e-05, "error": "", "output": "", "timestampInEpochSeconds": 1744934015 }, { "command": "target create --core \"/var/tmp/cores/c4crasher.crasher.1576894\"", "commandArguments": "--core \"/var/tmp/cores/c4crasher.crasher.1576894\"", "commandName": "target create", "durationInSeconds": 6.7297630000000002, "error": "", "output": "Core file '/var/tmp/cores/c4crasher.crasher.1576894' (x86_64) was loaded.\n", "timestampInEpochSeconds": 1744934017 }, { "command": "fbpaste statistics dump", "commandArguments": "statistics dump", "commandName": "fbpaste", "timestampInEpochSeconds": 1744934055 }, { "command": "statistics dump", "commandArguments": "", "commandName": "statistics dump", "timestampInEpochSeconds": 1744934055 } ] } ``` Co-authored-by: George Hu <georgehuyubo@gmail.com>
2025-04-24[lldb] Remerge #136236 (Avoid force loading symbols in statistics collection ↵royitaqi
(#136795) Fix a [test failure](https://github.com/llvm/llvm-project/pull/136236#issuecomment-2819772879) in #136236, apply a minor renaming of statistics, and remerge. See details below. # Changes in #136236 Currently, `DebuggerStats::ReportStatistics()` calls `Module::GetSymtab(/*can_create=*/false)`, but then the latter calls `SymbolFile::GetSymtab()`. This will load symbols if haven't yet. See stacktrace below. The problem is that `DebuggerStats::ReportStatistics` should be read-only. This is especially important because it reports stats for symtab parsing/indexing time, which could be affected by the reporting itself if it's not read-only. This patch fixes this problem by adding an optional parameter `SymbolFile::GetSymtab(bool can_create = true)` and receiving the `false` value passed down from `Module::GetSymtab(/*can_create=*/false)` when the call is initiated from `DebuggerStats::ReportStatistics()`. --- Notes about the following stacktrace: 1. This can be reproduced. Create a helloworld program on **macOS** with dSYM, add `settings set target.preload-symbols false` to `~/.lldbinit`, do `lldb a.out`, then `statistics dump`. 2. `ObjectFile::GetSymtab` has `llvm::call_once`. So the fact that it called into `ObjectFileMachO::ParseSymtab` means that the symbol table is actually being parsed. ``` (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000124c4d5a0 LLDB`ObjectFileMachO::ParseSymtab(this=0x0000000111504e40, symtab=0x0000600000a05e00) at ObjectFileMachO.cpp:2259:44 * frame #1: 0x0000000124fc50a0 LLDB`lldb_private::ObjectFile::GetSymtab()::$_0::operator()(this=0x000000016d35c858) const at ObjectFile.cpp:761:9 frame #5: 0x0000000124fc4e68 LLDB`void std::__1::__call_once_proxy[abi:v160006]<std::__1::tuple<lldb_private::ObjectFile::GetSymtab()::$_0&&>>(__vp=0x000000016d35c7f0) at mutex:652:5 frame #6: 0x0000000198afb99c libc++.1.dylib`std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) + 196 frame #7: 0x0000000124fc4dd0 LLDB`void std::__1::call_once[abi:v160006]<lldb_private::ObjectFile::GetSymtab()::$_0>(__flag=0x0000600003920080, __func=0x000000016d35c858) at mutex:670:9 frame #8: 0x0000000124fc3cb0 LLDB`void llvm::call_once<lldb_private::ObjectFile::GetSymtab()::$_0>(flag=0x0000600003920080, F=0x000000016d35c858) at Threading.h:88:5 frame #9: 0x0000000124fc2bc4 LLDB`lldb_private::ObjectFile::GetSymtab(this=0x0000000111504e40) at ObjectFile.cpp:755:5 frame #10: 0x0000000124fe0a28 LLDB`lldb_private::SymbolFileCommon::GetSymtab(this=0x0000000104865200) at SymbolFile.cpp:158:39 frame #11: 0x0000000124d8fedc LLDB`lldb_private::Module::GetSymtab(this=0x00000001113041a8, can_create=false) at Module.cpp:1027:21 frame #12: 0x0000000125125bdc LLDB`lldb_private::DebuggerStats::ReportStatistics(debugger=0x000000014284d400, target=0x0000000115808200, options=0x000000014195d6d1) at Statistics.cpp:329:30 frame #13: 0x0000000125672978 LLDB`CommandObjectStatsDump::DoExecute(this=0x000000014195d540, command=0x000000016d35d820, result=0x000000016d35e150) at CommandObjectStats.cpp:144:18 frame #14: 0x0000000124f29b40 LLDB`lldb_private::CommandObjectParsed::Execute(this=0x000000014195d540, args_string="", result=0x000000016d35e150) at CommandObject.cpp:832:9 frame #15: 0x0000000124efbd70 LLDB`lldb_private::CommandInterpreter::HandleCommand(this=0x0000000141b22f30, command_line="statistics dump", lazy_add_to_history=eLazyBoolCalculate, result=0x000000016d35e150, force_repeat_command=false) at CommandInterpreter.cpp:2134:14 frame #16: 0x0000000124f007f4 LLDB`lldb_private::CommandInterpreter::IOHandlerInputComplete(this=0x0000000141b22f30, io_handler=0x00000001419b2aa8, line="statistics dump") at CommandInterpreter.cpp:3251:3 frame #17: 0x0000000124d7b5ec LLDB`lldb_private::IOHandlerEditline::Run(this=0x00000001419b2aa8) at IOHandler.cpp:588:22 frame #18: 0x0000000124d1e8fc LLDB`lldb_private::Debugger::RunIOHandlers(this=0x000000014284d400) at Debugger.cpp:1225:16 frame #19: 0x0000000124f01f74 LLDB`lldb_private::CommandInterpreter::RunCommandInterpreter(this=0x0000000141b22f30, options=0x000000016d35e63c) at CommandInterpreter.cpp:3543:16 frame #20: 0x0000000122840294 LLDB`lldb::SBDebugger::RunCommandInterpreter(this=0x000000016d35ebd8, auto_handle_events=true, spawn_thread=false) at SBDebugger.cpp:1212:42 frame #21: 0x0000000102aa6d28 lldb`Driver::MainLoop(this=0x000000016d35ebb8) at Driver.cpp:621:18 frame #22: 0x0000000102aa75b0 lldb`main(argc=1, argv=0x000000016d35f548) at Driver.cpp:829:26 frame #23: 0x0000000198858274 dyld`start + 2840 ``` # Changes in this PR top of the above Fix a [test failure](https://github.com/llvm/llvm-project/pull/136236#issuecomment-2819772879) in `TestStats.py`. The original version of the added test checks that all modules have symbol count zero when `target.preload-symbols == false`. The test failed on macOS. Due to various reasons, on macOS, symbols can be loaded for dylibs even with that setting, but not for the main module. For now, the fix of the test is to limit the assertion to only the main module. The test now passes on macOS. In the future, when we have a way to control a specific list of plug-ins to be loaded, there may be a configuration that this test can use to assert that all modules have symbol count zero. Apply a minor renaming of statistics, per the [suggestion](https://github.com/llvm/llvm-project/pull/136226#issuecomment-2825080275) in #136226 after merge.
2025-04-21[lldb] Add symbol/table count into statistics (#136226)royitaqi
# New stats The following stats are added and are available in both "statistics dump" command and in python API. 1. In summary: 1. Add `totalSymbolsLoaded`. The total number of symbols loaded in all modules. 2. Add `totalSymbolTablesLoaded `. The total number symbol tables loaded in all modules. 2. In each module's stats: 1. Add `symbolsLoaded`. The number of symbols loaded in the current module. # Example Example `statistics dump` output: ``` (lldb) statistics dump { ..., "modules": [ { "path": "/Users/<username>/demo/simple/a.out", "symbolsLoaded": 6, ... }, ... ], ... "totalSymbolTablesLoaded": 42, "totalSymbolsLoaded": 32198 } ``` # Tests **Manual test**: Built and ran lldb on a helloworld program. Ran `statistics dump`. Verified the above stats. **Unit test**: Ran the following tests: ``` $ bin/lldb-dotest -p TestStats.py ~/llvm-sand/external/llvm-project/lldb/test/API/commands/statistics/basic/ ... Ran 18 tests in 192.676s OK (skipped=3) ```
2025-03-10[lldb] Avoid force loading symbol files in statistics collection (#129593)David Peixotto
This commit modifies the `DebuggerStats::ReportStatistics` implementation to avoid loading symbol files for unloaded symbols. We collect stats on debugger shutdown and without this change it can cause the debugger to hang for a long while on shutdown if they symbols were not previously loaded (e.g. `settings set target.preload-symbols false`). The implementation is done by adding an optional parameter to `Module::GetSymtab` to control if the corresponding symbol file will be loaded in the same way that can control it for `Module::GetSymbolFile`.
2024-11-17Fix statistics dump to report per-target (#113723)jeffreytan81
"statistics dump" currently report the statistics of all targets in debugger instead of current target. This is wrong because there is a "statistics dump --all-targets" option that supposed to include everything. This PR fixes the issue by only report statistics for current target instead of all. It also includes the change to reset statistics debug info/symbol table parsing/indexing time during debugger destroy. This is required so that we report current statistics if we plan to reuse lldb/lldb-dap across debug sessions --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-09-16[lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745)Youngsuk Kim
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2024-09-10[LLDB][Data Formatters] Calculate average and total time for summary ↵Jacob Lalonde
providers within lldb (#102708) This PR adds a statistics provider cache, which allows an individual target to keep a rolling tally of it's total time and number of invocations for a given summary provider. This information is then available in statistics dump to help slow summary providers, and gleam more into insight into LLDB's time use.
2024-08-15[lldb] Realpath symlinks for breakpoints (#102223)royitaqi
Improve the chance of resolving file/line breakpoints by realpath'ing the support files before doing a second match attempt, with some conditions applied. A working [hello-world example](https://github.com/royitaqi/lldb_demos/blob/main/realpath/README.md). See [patch](https://github.com/llvm/llvm-project/pull/102223) for more info about problem/motivation, details of the feature, new settings, telemetries and tests.
2024-06-18[lldb] Add/change options in `statistics dump` to control what sections are ↵royitaqi
dumped (#95075) # Added/changed options The following options are **added** to the `statistics dump` command: * `--targets=bool`: Boolean. Dumps the `targets` section. * `--modules=bool`: Boolean. Dumps the `modules` section. When both options are given, the field `moduleIdentifiers` will be dumped for each target in the `targets` section. The following options are **changed**: * `--transcript=bool`: Changed to a boolean. Dumps the `transcript` section. # Behavior of `statistics dump` with various options The behavior is **backward compatible**: - When no options are provided, `statistics dump` dumps all sections. - When `--summary` is provided, only dumps the summary info. **New** behavior: - `--targets=bool`, `--modules=bool`, `--transcript=bool` overrides the above "default". For **example**: - `statistics dump --modules=false` dumps summary + targets + transcript. No modules. - `statistics dump --summary --targets=true --transcript=true` dumps summary + targets (in summary mode) + transcript. # Added options into public API In `SBStatisticsOptions`, add: * `Set/GetIncludeTargets` * `Set/GetIncludeModules` * `Set/GetIncludeTranscript` **Alternative considered**: Thought about adding `Set/GetIncludeSections(string sections_spec)`, which receives a comma-separated list of section names to be included ("targets", "modules", "transcript"). The **benefit** of this approach is that the API is more future-proof when it comes to possible adding/changing of section names. **However**, I feel the section names are likely to remain unchanged for a while - it's not like we plan to make big changes to the output of `statistics dump` any time soon. The **downsides** of this approach are: 1\ the readability of the API is worse (requires reading doc to understand what string can be accepted), 2\ string input are more prone to human error (e.g. typo "target" instead of expected "targets"). # Tests ``` bin/llvm-lit -sv ../external/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py ``` ``` ./tools/lldb/unittests/Interpreter/InterpreterTests ``` New test cases have been added to verify: * Different sections are dumped/not dumped when different `StatisticsOptions` are given through command line (CLI or `HandleCommand`; see `test_sections_existence_through_command`) or API (see `test_sections_existence_through_api`). * The order in which the options are given in command line does not matter (see `test_order_of_options_do_not_matter`). --------- Co-authored-by: Roy Shi <royshi@meta.com>
2024-06-06[lldb] Include memory stats in statistics summary (#94671)Alex Langford
The summary already includes other size information, e.g. total debug info size in bytes. The only other way I can get this information is by dumping all statistics which can be quite large. Adding it to the summary seems fair.
2024-06-03Re-merge `A few updates around "transcript"` (#92843) (#94067)royitaqi
Problematic PR: https://github.com/llvm/llvm-project/pull/92843 Reverted by: https://github.com/llvm/llvm-project/pull/94088 The first PR added a test which fails in Linux builds (see the last few comments there). This PR contains all the changes in the first PR, plus the fix to the said test. --------- Co-authored-by: Roy Shi <royshi@meta.com>
2024-05-31Revert "A few updates around "transcript"" (#94088)gulfemsavrun
Reverts llvm/llvm-project#92843 because it broke some lldb tests: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8746385730949743489/overview
2024-05-31A few updates around "transcript" (#92843)royitaqi
# Changes 1. Changes to the structured transcript. 1. Add fields `commandName` and `commandArguments`. They will hold the name and the arguments string of the expanded/executed command (e.g. `breakpoint set` and `-f main.cpp -l 4`). This is not to be confused with the `command` field, which holds the user input (e.g. `br s -f main.cpp -l 4`). 2. Add field `timestampInEpochSeconds`. It will hold the timestamp when the command is executed. 3. Rename field `seconds` to `durationInSeconds`, to improve readability, especially since `timestampInEpochSeconds` is added. 2. When transcript is available and the newly added option `--transcript` is present, add the transcript to the output of `statistics dump`, as a JSON array under a new field `transcript`. 3. A few test name and comment changes.
2024-02-19[Reland] Report only loaded debug info in statistics dump (#81706) (#82207)Wanyi
Updates: - The previous patch changed the default behavior to not load dwos in `DWARFUnit` ~~`SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = false);`~~ `SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = true);` - This broke some lldb-shell tests (see https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273/) - TestDebugInfoSize.py - with symbol on-demand, by default statistics dump only reports skeleton debug info size - `statistics dump -f` will load all dwos. debug info = skeleton debug info + all dwo debug info Currently running `statistics dump` will trigger lldb to load debug info that's not yet loaded (eg. dwo files). Resulted in a delay in the command return, which, can be interrupting. This patch also added a new option `--load-all-debug-info` asking statistics to dump all possible debug info, which will force loading all debug info available if not yet loaded.
2024-02-17Revert "Report only loaded debug info in statistics dump (#81706)" (#82150)Jonas Devlieghere
This reverts commit 21ddd7ff2b166c5e133b460b1a09ee8adb786ccd because it breaks a bunch of tests: https://lab.llvm.org/buildbot/#/builders/68/builds/69018 https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/16273
2024-02-17Report only loaded debug info in statistics dump (#81706)Wanyi
Currently running `statistics dump` will trigger lldb to load debug info that's not yet loaded (eg. dwo files). Resulted in a delay in the command return, which, can be interrupting. This patch also added a new option `--load-all-debug-info` asking statistics to dump all possible debug info, which will force loading all debug info available if not yet loaded.
2024-02-06Support statistics dump summary only mode (#80745)Wanyi
Add a new --summary option to statistics dump command so that it is much more light weight than the full version. Introduce a new SBStatisticsOptions API setting the verbosity of statistics dump. [PR #80218](https://github.com/llvm/llvm-project/pull/80218#discussion_r1473639878)
2024-02-05Add commands frequency to statistics dump (#80375)jeffreytan81
Adding command interpreter statistics into "statistics dump" command so that we can track the command usage frequency for telemetry purpose. This is useful to answer questions like what is the most frequently used lldb commands across all our users. --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2022-12-04[lldb] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-30Report which modules have forcefully completed types in statistics.Greg Clayton
A previous patch added the ability for us to tell if types were forcefully completed. This patch adds the ability to see which modules have forcefully completed types and aggregates the number of modules with forcefully completed types at the root level. We add a module specific setting named "debugInfoHadIncompleteTypes" that is a boolean value. We also aggregate the number of modules at the root level that had incomplete debug info with a key named "totalModuleCountWithIncompleteTypes" that is a count of number of modules that had incomplete types. Differential Revision: https://reviews.llvm.org/D138638
2022-11-20Add a new top level statistic that tracks how many modules have variable errors.Greg Clayton
We have a statistic on each module named "debugInfoHadVariableErrors" which tracks when we have debug info, but an error prevented the variables from being displayed. This patch adds a new top level statistic named "totalModuleCountWithVariableErrors" which is a count of the modules that have "debugInfoHadVariableErrors" set to true. Differential Revision: https://reviews.llvm.org/D138383
2022-11-16Make CompilerType safeAdrian Prantl
When a process gets restarted TypeSystem objects associated with it may get deleted, and any CompilerType objects holding on to a reference to that type system are a use-after-free in waiting. Because of the SBAPI, we don't have tight control over where CompilerTypes go and when they are used. This is particularly a problem in the Swift plugin, where the scratch TypeSystem can be restarted while the process is still running. The Swift plugin has a lock to prevent abuse, but where there's a lock there can be bugs. This patch changes CompilerType to store a std::weak_ptr<TypeSystem>. Most of the std::weak_ptr<TypeSystem>* uglyness is hidden by introducing a wrapper class CompilerType::WrappedTypeSystem that has a dyn_cast_or_null() method. The only sites that need to know about the weak pointer implementation detail are the ones that deal with creating TypeSystems. rdar://101505232 Differential Revision: https://reviews.llvm.org/D136650
2022-11-02[lldb] Add information on type systems to statistics dump commandAlex Langford
Context: I plan on using this change primarily downstream in the apple fork of llvm to track swift module loading time. Reviewed By: clayborg, tschuett Differential Revision: https://reviews.llvm.org/D137191
2022-09-28Track which modules have debug info variable errors.Greg Clayton
Now that we display an error when users try to get variables, but something in the debug info is preventing variables from showing up, track this with a new bool in each module's statistic information named "debugInfoHadVariableErrors". This patch modifies the code to track when we have variable errors in a module and adds accessors to get/set this value. This value is used in the module statistics and we added a test to verify this value gets set correctly. Differential Revision: https://reviews.llvm.org/D134508
2022-09-22Add auto source map deduce count statisticsJeffrey Tan
This patch adds auto source map deduce count as a target level statistics. This will help telemetry to track how many debug sessions benefit from this feature. Differential Revision: https://reviews.llvm.org/D134483
2022-04-26Introduce new symbol on-demand for debug infoJeffrey Tan
This diff introduces a new symbol on-demand which skips loading a module's debug info unless explicitly asked on demand. This provides significant performance improvement for application with dynamic linking mode which has large number of modules. The feature can be turned on with: "settings set symbols.load-on-demand true" The feature works by creating a new SymbolFileOnDemand class for each module which wraps the actual SymbolFIle subclass as member variable. By default, most virtual methods on SymbolFileOnDemand are skipped so that it looks like there is no debug info for that module. But once the module's debug info is explicitly requested to be enabled (in the conditions mentioned below) SymbolFileOnDemand will allow all methods to pass through and forward to the actual SymbolFile which would hydrate module's debug info on-demand. In an internal benchmark, we are seeing more than 95% improvement for a 3000 modules application. Currently we are providing several ways to on demand hydrate a module's debug info: * Source line breakpoint: matching in supported files * Stack trace: resolving symbol context for an address * Symbolic breakpoint: symbol table match guided promotion * Global variable: symbol table match guided promotion In all above situations the module's debug info will be on-demand parsed and indexed. Some follow-ups for this feature: * Add a command that allows users to load debug info explicitly while using a new or existing command when this feature is enabled * Add settings for "never load any of these executables in Symbols On Demand" that takes a list of globs * Add settings for "always load the the debug info for executables in Symbols On Demand" that takes a list of globs * Add a new column in "image list" that shows up by default when Symbols On Demand is enable to show the status for each shlib like "not enabled for this", "debug info off" and "debug info on" (with a single character to short string, not the ones I just typed) Differential Revision: https://reviews.llvm.org/D121631
2022-02-10Fix a double debug info size counting in top level stats for "statistics dump".Greg Clayton
This mainly affects Darwin targets (macOS, iOS, tvOS and watchOS) when these targets don't use dSYM files and the debug info was in the .o files. All modules, including the .o files that are loaded by the debug maps, were in the global module list. This was great because it allows us to see each .o file and how much it contributes. There were virtual functions on the SymbolFile class to fetch the symtab/debug info parse and index times, and also the total debug info size. So the main executable would add all of the .o file's stats together and report them as its own data. Then the "totalDebugInfoSize" and many other "totalXXX" top level totals were all being added together. This stems from the fact that my original patch only emitted the modules for a target at the start of the patch, but as comments from the reviews came in, we switched to emitting all of the modules from the global module list. So this patch fixes it so when we have a SymbolFileDWARFDebugMap that loads .o files, the main executable will have no debug info size or symtab/debug info parse/index times, but each .o file will have its own data as a separate module. Also, to be able to tell when/if we have a dSYM file I have added a "symbolFilePath" if the SymbolFile for the main modules path doesn't match that of the main executable. We also include a "symbolFileModuleIdentifiers" key in each module if the module does have multiple lldb_private::Module objects that contain debug info so that you can track down the information for a module and add up the contributions of all of the .o files. Tests were added that are labeled with @skipUnlessDarwin and @no_debug_info_test that test all of this functionality so it doesn't regress. For a module with a dSYM file, we can see the "symbolFilePath" is included: ``` "modules": [ { "debugInfoByteSize": 1070, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 4873280600, "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out", "symbolFilePath": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out.dSYM/Contents/Resources/DWARF/a.out", "symbolTableIndexTime": 7.9999999999999996e-06, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 7.8999999999999996e-05, "symbolTableSavedToCache": false, "triple": "arm64-apple-macosx12.0.0", "uuid": "E1F7D85B-3A42-321E-BF0D-29B103F5F2E3" }, ``` And for the DWARF in .o file case we can see the "symbolFileModuleIdentifiers" in the executable's module stats: ``` "modules": [ { "debugInfoByteSize": 0, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 0, "identifier": 4603526968, "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/a.out", "symbolFileModuleIdentifiers": [ 4604429832 ], "symbolTableIndexTime": 7.9999999999999996e-06, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0.000112, "symbolTableSavedToCache": false, "triple": "arm64-apple-macosx12.0.0", "uuid": "57008BF5-A726-3DE9-B1BF-3A9AD3EE8569" }, ``` And the .o file for 4604429832 looks like: ``` { "debugInfoByteSize": 1028, "debugInfoIndexLoadedFromCache": false, "debugInfoIndexSavedToCache": false, "debugInfoIndexTime": 0, "debugInfoParseTime": 6.0999999999999999e-05, "identifier": 4604429832, "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/main.o", "symbolTableIndexTime": 0, "symbolTableLoadedFromCache": false, "symbolTableParseTime": 0, "symbolTableSavedToCache": false, "triple": "arm64-apple-macosx" } ``` Differential Revision: https://reviews.llvm.org/D119400
2022-01-24[lldb] Add ConstString memory usage statisticsJonas Devlieghere
Add statistics about the memory usage of the string pool. I'm particularly interested in the memory used by the allocator, i.e. the number of bytes actually used by the allocator it self as well as the number of bytes allocated through the allocator. Differential revision: https://reviews.llvm.org/D117914
2022-01-19[lldb] Make StatsDuration thread-safePavel Labath
std::chrono::duration types are not thread-safe, and they cannot be concurrently updated from multiple threads. Currently, we were doing such a thing (only) in the DWARF indexing code (DWARFUnit::ExtractDIEsRWLocked), but I think it can easily happen that someone else tries to update another statistic like this without bothering to check for thread safety. This patch changes the StatsDuration type from a simple typedef into a class in its own right. The class stores the duration internally as std::atomic<uint64_t> (so it can be updated atomically), but presents it to its users as the usual chrono type (duration<float>). Differential Revision: https://reviews.llvm.org/D117474
2021-12-28Cache the manual DWARF index out to the LLDB cache directory when the LLDB ↵Greg Clayton
index cache is enabled. This patch add the ability to cache the manual DWARF indexing results to disk for faster subsequent debug sessions. Manual DWARF indexing is time consuming and causes all DWARF to be fully parsed and indexed each time you debug a binary that doesn't have an acceptable accelerator table. Acceptable accelerator tables include .debug_names in DWARF5 or Apple accelerator tables. This patch breaks up testing by testing all of the encoding and decoding of required C++ objects in a gtest unit test, and then has a test to verify the debug info cache is generated correctly. This patch also adds the ability to track when a symbol table or DWARF index is loaded or saved to the cache in the "statistics dump" command. This is essential to know in statistics as it can help explain why a debug session was slower or faster than expected. Reviewed By: labath, wallace Differential Revision: https://reviews.llvm.org/D115951
2021-11-15Add the stop count to "statistics dump" in each target's dictionary.Greg Clayton
It is great to know how many times the target has stopped over its lifetime as each time the target stops, and possibly resumes without the user seeing it for things like shared library loading and signals that are not notified and auto continued, to help explain why a debug session might be slow. This is now included as "stopCount" inside each target JSON. Differential Revision: https://reviews.llvm.org/D113810
2021-10-27Add unix signal hit counts to the target statistics.Greg Clayton
Android and other platforms make wide use of signals when running applications and this can slow down debug sessions. Tracking this statistic can help us to determine why a debug session is slow. The new data appears inside each target object and reports the signal hit counts: "signals": [ { "SIGSTOP": 1 }, { "SIGUSR1": 1 } ], Differential Revision: https://reviews.llvm.org/D112683
2021-10-27Add breakpoint resolving stats to each target.Greg Clayton
This patch adds breakpoints to each target's statistics so we can track how long it takes to resolve each breakpoint. It also includes the structured data for each breakpoint so the exact breakpoint details are logged to allow for reproduction of slow resolving breakpoints. Each target gets a new "breakpoints" array that contains breakpoint details. Each breakpoint has "details" which is the JSON representation of a serialized breakpoint resolver and filter, "id" which is the breakpoint ID, and "resolveTime" which is the time in seconds it took to resolve the breakpoint. A snippet of the new data is shown here: "targets": [ { "breakpoints": [ { "details": {...}, "id": 1, "resolveTime": 0.00039291599999999999 }, { "details": {...}, "id": 2, "resolveTime": 0.00022679199999999999 } ], "totalBreakpointResolveTime": 0.00061970799999999996 } ] This provides full details on exactly how breakpoints were set and how long it took to resolve them. Differential Revision: https://reviews.llvm.org/D112587
2021-10-26Add new key/value pairs to the module statistics for "statistics dump".Greg Clayton
The new key/value pairs that are added to each module's stats are: "debugInfoByteSize": The size in bytes of debug info for each module. "debugInfoIndexTime": The time in seconds that it took to index the debug info. "debugInfoParseTime": The time in seconds that debug info had to be parsed. At the top level we add up all of the debug info size, parse time and index time with the following keys: "totalDebugInfoByteSize": The size in bytes of all debug info in all modules. "totalDebugInfoIndexTime": The time in seconds that it took to index all debug info if it was indexed for all modules. "totalDebugInfoParseTime": The time in seconds that debug info was parsed for all modules. Differential Revision: https://reviews.llvm.org/D112501
2021-10-25Add modules stats into the "statistics dump" command.Greg Clayton
The new module stats adds the ability to measure the time it takes to parse and index the symbol tables for each module, and reports modules statistics in the output of "statistics dump" along with the path, UUID and triple of the module. The time it takes to parse and index the symbol tables are also aggregated into new top level key/value pairs at the target level. Differential Revision: https://reviews.llvm.org/D112279
2021-10-21Modify "statistics dump" to dump JSON.Greg Clayton
This patch is a smaller version of a previous patch https://reviews.llvm.org/D110804. This patch modifies the output of "statistics dump" to be able to get stats from the current target. It adds 3 new stats as well. The output of "statistics dump" is now emitted as JSON so that it can be used to track performance and statistics and the output could be used to populate a database that tracks performance. Sample output looks like: (lldb) statistics dump { "expressionEvaluation": { "failures": 0, "successes": 0 }, "firstStopTime": 0.34164492800000001, "frameVariable": { "failures": 0, "successes": 0 }, "launchOrAttachTime": 0.31969605400000001, "targetCreateTime": 0.0040863039999999998 } The top level keys are: "expressionEvaluation" which replaces the previous stats that were emitted as plain text. This dictionary contains the success and fail counts. "frameVariable" which replaces the previous stats for "frame variable" that were emitted as plain text. This dictionary contains the success and fail counts. "targetCreateTime" contains the number of seconds it took to create the target and load dependent libraries (if they were enabled) and also will contain symbol preloading times if that setting is enabled. "launchOrAttachTime" is the time it takes from when the launch/attach is initiated to when the first private stop occurs. "firstStopTime" is the time in seconds that it takes to stop at the first stop that is presented to the user via the LLDB interface. This value will only have meaning if you set a known breakpoint or stop location in your code that you want to measure as a performance test. This diff is also meant as a place to discuess what we want out of the "statistics dump" command before adding more funcionality. It is also meant to clean up the previous code that was storting statistics in a vector of numbers within the lldb_private::Target class. Differential Revision: https://reviews.llvm.org/D111686