)]}'
{
  "commit": "967434aa3275842637937e9ac17614a10f81bae7",
  "tree": "e71324212f2125dc221ebd14a17cd2c3d5eec45f",
  "parents": [
    "31b38d67f246066cbca9328a5b2dd66a31e71245"
  ],
  "author": {
    "name": "royitaqi",
    "email": "royitaqi@users.noreply.github.com",
    "time": "Thu Apr 24 17:23:41 2025 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Apr 24 17:23:41 2025 -0700"
  },
  "message": "[lldb] Remerge #136236 (Avoid force loading symbols in statistics collection (#136795)\n\nFix a [test\nfailure](https://github.com/llvm/llvm-project/pull/136236#issuecomment-2819772879)\nin #136236, apply a minor renaming of statistics, and remerge. See\ndetails below.\n\n# Changes in #136236\n\nCurrently, `DebuggerStats::ReportStatistics()` calls\n`Module::GetSymtab(/*can_create\u003d*/false)`, but then the latter calls\n`SymbolFile::GetSymtab()`. This will load symbols if haven\u0027t yet. See\nstacktrace below.\n\nThe problem is that `DebuggerStats::ReportStatistics` should be\nread-only. This is especially important because it reports stats for\nsymtab parsing/indexing time, which could be affected by the reporting\nitself if it\u0027s not read-only.\n\nThis patch fixes this problem by adding an optional parameter\n`SymbolFile::GetSymtab(bool can_create \u003d true)` and receiving the\n`false` value passed down from `Module::GetSymtab(/*can_create\u003d*/false)`\nwhen the call is initiated from `DebuggerStats::ReportStatistics()`.\n\n---\n\nNotes about the following stacktrace:\n1. This can be reproduced. Create a helloworld program on **macOS** with\ndSYM, add `settings set target.preload-symbols false` to `~/.lldbinit`,\ndo `lldb a.out`, then `statistics dump`.\n2. `ObjectFile::GetSymtab` has `llvm::call_once`. So the fact that it\ncalled into `ObjectFileMachO::ParseSymtab` means that the symbol table\nis actually being parsed.\n\n```\n(lldb) bt\n* thread #1, queue \u003d \u0027com.apple.main-thread\u0027, stop reason \u003d step over\n    frame #0: 0x0000000124c4d5a0 LLDB`ObjectFileMachO::ParseSymtab(this\u003d0x0000000111504e40, symtab\u003d0x0000600000a05e00) at ObjectFileMachO.cpp:2259:44\n  * frame #1: 0x0000000124fc50a0 LLDB`lldb_private::ObjectFile::GetSymtab()::$_0::operator()(this\u003d0x000000016d35c858) const at ObjectFile.cpp:761:9\n    frame #5: 0x0000000124fc4e68 LLDB`void std::__1::__call_once_proxy[abi:v160006]\u003cstd::__1::tuple\u003clldb_private::ObjectFile::GetSymtab()::$_0\u0026\u0026\u003e\u003e(__vp\u003d0x000000016d35c7f0) at mutex:652:5\n    frame #6: 0x0000000198afb99c libc++.1.dylib`std::__1::__call_once(unsigned long volatile\u0026, void*, void (*)(void*)) + 196\n    frame #7: 0x0000000124fc4dd0 LLDB`void std::__1::call_once[abi:v160006]\u003clldb_private::ObjectFile::GetSymtab()::$_0\u003e(__flag\u003d0x0000600003920080, __func\u003d0x000000016d35c858) at mutex:670:9\n    frame #8: 0x0000000124fc3cb0 LLDB`void llvm::call_once\u003clldb_private::ObjectFile::GetSymtab()::$_0\u003e(flag\u003d0x0000600003920080, F\u003d0x000000016d35c858) at Threading.h:88:5\n    frame #9: 0x0000000124fc2bc4 LLDB`lldb_private::ObjectFile::GetSymtab(this\u003d0x0000000111504e40) at ObjectFile.cpp:755:5\n    frame #10: 0x0000000124fe0a28 LLDB`lldb_private::SymbolFileCommon::GetSymtab(this\u003d0x0000000104865200) at SymbolFile.cpp:158:39\n    frame #11: 0x0000000124d8fedc LLDB`lldb_private::Module::GetSymtab(this\u003d0x00000001113041a8, can_create\u003dfalse) at Module.cpp:1027:21\n    frame #12: 0x0000000125125bdc LLDB`lldb_private::DebuggerStats::ReportStatistics(debugger\u003d0x000000014284d400, target\u003d0x0000000115808200, options\u003d0x000000014195d6d1) at Statistics.cpp:329:30\n    frame #13: 0x0000000125672978 LLDB`CommandObjectStatsDump::DoExecute(this\u003d0x000000014195d540, command\u003d0x000000016d35d820, result\u003d0x000000016d35e150) at CommandObjectStats.cpp:144:18\n    frame #14: 0x0000000124f29b40 LLDB`lldb_private::CommandObjectParsed::Execute(this\u003d0x000000014195d540, args_string\u003d\"\", result\u003d0x000000016d35e150) at CommandObject.cpp:832:9\n    frame #15: 0x0000000124efbd70 LLDB`lldb_private::CommandInterpreter::HandleCommand(this\u003d0x0000000141b22f30, command_line\u003d\"statistics dump\", lazy_add_to_history\u003deLazyBoolCalculate, result\u003d0x000000016d35e150, force_repeat_command\u003dfalse) at CommandInterpreter.cpp:2134:14\n    frame #16: 0x0000000124f007f4 LLDB`lldb_private::CommandInterpreter::IOHandlerInputComplete(this\u003d0x0000000141b22f30, io_handler\u003d0x00000001419b2aa8, line\u003d\"statistics dump\") at CommandInterpreter.cpp:3251:3\n    frame #17: 0x0000000124d7b5ec LLDB`lldb_private::IOHandlerEditline::Run(this\u003d0x00000001419b2aa8) at IOHandler.cpp:588:22\n    frame #18: 0x0000000124d1e8fc LLDB`lldb_private::Debugger::RunIOHandlers(this\u003d0x000000014284d400) at Debugger.cpp:1225:16\n    frame #19: 0x0000000124f01f74 LLDB`lldb_private::CommandInterpreter::RunCommandInterpreter(this\u003d0x0000000141b22f30, options\u003d0x000000016d35e63c) at CommandInterpreter.cpp:3543:16\n    frame #20: 0x0000000122840294 LLDB`lldb::SBDebugger::RunCommandInterpreter(this\u003d0x000000016d35ebd8, auto_handle_events\u003dtrue, spawn_thread\u003dfalse) at SBDebugger.cpp:1212:42\n    frame #21: 0x0000000102aa6d28 lldb`Driver::MainLoop(this\u003d0x000000016d35ebb8) at Driver.cpp:621:18\n    frame #22: 0x0000000102aa75b0 lldb`main(argc\u003d1, argv\u003d0x000000016d35f548) at Driver.cpp:829:26\n    frame #23: 0x0000000198858274 dyld`start + 2840\n```\n\n# Changes in this PR top of the above\n\nFix a [test\nfailure](https://github.com/llvm/llvm-project/pull/136236#issuecomment-2819772879)\nin `TestStats.py`. The original version of the added test checks that\nall modules have symbol count zero when `target.preload-symbols \u003d\u003d\nfalse`. The test failed on macOS. Due to various reasons, on macOS,\nsymbols can be loaded for dylibs even with that setting, but not for the\nmain module. For now, the fix of the test is to limit the assertion to\nonly the main module. The test now passes on macOS. In the future, when\nwe have a way to control a specific list of plug-ins to be loaded, there\nmay be a configuration that this test can use to assert that all modules\nhave symbol count zero.\n\nApply a minor renaming of statistics, per the\n[suggestion](https://github.com/llvm/llvm-project/pull/136226#issuecomment-2825080275)\nin #136226 after merge.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cfcca04a76de819b8ff4a4cf08f8e252ab3bccb7",
      "old_mode": 33188,
      "old_path": "lldb/include/lldb/Symbol/ObjectFile.h",
      "new_id": "7fca6383fa9f38ef2e7ce98bd725b11151f028cb",
      "new_mode": 33188,
      "new_path": "lldb/include/lldb/Symbol/ObjectFile.h"
    },
    {
      "type": "modify",
      "old_id": "f35d3ee9f22ae5dbe32640bee2d993f92bdd8457",
      "old_mode": 33188,
      "old_path": "lldb/include/lldb/Symbol/SymbolFile.h",
      "new_id": "df2f263b18e1759bd7e3d3d5a7494444c009dbe3",
      "new_mode": 33188,
      "new_path": "lldb/include/lldb/Symbol/SymbolFile.h"
    },
    {
      "type": "modify",
      "old_id": "7a366bfabec865368ab1f0cc4a786af9e91685e9",
      "old_mode": 33188,
      "old_path": "lldb/include/lldb/Symbol/SymbolFileOnDemand.h",
      "new_id": "6ed389a48880cf0e168dfc6eadf53981a87c0fa6",
      "new_mode": 33188,
      "new_path": "lldb/include/lldb/Symbol/SymbolFileOnDemand.h"
    },
    {
      "type": "modify",
      "old_id": "b87a12a8ab9cd614d736211d708af6b0ae8e6d6a",
      "old_mode": 33188,
      "old_path": "lldb/include/lldb/Target/Statistics.h",
      "new_id": "565f1b4351bddc3a27c3302e5b5090b52dd136ec",
      "new_mode": 33188,
      "new_path": "lldb/include/lldb/Target/Statistics.h"
    },
    {
      "type": "modify",
      "old_id": "ad7046e596278d445ab20b845476c6e21e4f702b",
      "old_mode": 33188,
      "old_path": "lldb/source/Core/Module.cpp",
      "new_id": "625c14e4a2153ead47ffc37716f81953500ca2f6",
      "new_mode": 33188,
      "new_path": "lldb/source/Core/Module.cpp"
    },
    {
      "type": "modify",
      "old_id": "2f2c59d6af62056461a0bb03c5ce9dea15976a5e",
      "old_mode": 33188,
      "old_path": "lldb/source/Symbol/ObjectFile.cpp",
      "new_id": "afd0d298e675ecf9efa41a3b9677c34108bd0552",
      "new_mode": 33188,
      "new_path": "lldb/source/Symbol/ObjectFile.cpp"
    },
    {
      "type": "modify",
      "old_id": "94e32b55572ddfdb6c5eb5bf16ed84b093c8ff80",
      "old_mode": 33188,
      "old_path": "lldb/source/Symbol/SymbolFile.cpp",
      "new_id": "870d778dca74048b651a2a652617e24f9ed152c4",
      "new_mode": 33188,
      "new_path": "lldb/source/Symbol/SymbolFile.cpp"
    },
    {
      "type": "modify",
      "old_id": "2bb93dfffa5aa9f71f79087c707c1da6d7290daa",
      "old_mode": 33188,
      "old_path": "lldb/source/Target/Statistics.cpp",
      "new_id": "12e7190ae1f747223871bfec0f49f613a8c1df27",
      "new_mode": 33188,
      "new_path": "lldb/source/Target/Statistics.cpp"
    },
    {
      "type": "modify",
      "old_id": "a358f5178c7fa7b1be81b8dd88ef2f633617f761",
      "old_mode": 33188,
      "old_path": "lldb/test/API/commands/statistics/basic/TestStats.py",
      "new_id": "a9a7e933a3211b233642448d3ec72b12c85b7572",
      "new_mode": 33188,
      "new_path": "lldb/test/API/commands/statistics/basic/TestStats.py"
    },
    {
      "type": "modify",
      "old_id": "f67ac46c738e787776014a9f78c5e5fd3578f94d",
      "old_mode": 33188,
      "old_path": "lldb/unittests/Symbol/LineTableTest.cpp",
      "new_id": "eadab40a37facf74859b65a535d94c874be832ad",
      "new_mode": 33188,
      "new_path": "lldb/unittests/Symbol/LineTableTest.cpp"
    },
    {
      "type": "modify",
      "old_id": "e431c31e1eac15c0f266575101dde3de92509a08",
      "old_mode": 33188,
      "old_path": "lldb/unittests/Symbol/SymtabTest.cpp",
      "new_id": "d3f462fab86a13ed1f1c3e76b6e21f0794e03da8",
      "new_mode": 33188,
      "new_path": "lldb/unittests/Symbol/SymtabTest.cpp"
    }
  ]
}
