llvm-project
55e3b6d9 - [lldb] Add count for errors of DWO files in statistics and combine DWO file count functions (#155023)

Commit
4 days ago
[lldb] Add count for errors of DWO files in statistics and combine DWO file 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) ```
Author
Parents
Loading