summaryrefslogtreecommitdiff
path: root/lldb/test/API/commands/statistics/basic/dwo_error_foo.cpp
AgeCommit message (Collapse)Author
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) ```