diff options
author | Aaron Merey <[email protected]> | 2024-03-25 15:57:25 -0400 |
---|---|---|
committer | Aaron Merey <[email protected]> | 2024-04-11 12:34:43 -0400 |
commit | d4b0848be5f575ff9464fee12ce7be416e4fb392 (patch) | |
tree | 069c99466a5e380ed949dedac2c695f9a576339e /libdw/dwarf_macro_getsrcfiles.c | |
parent | db33cb0cac3253c34881c0377ada51d9803eaae0 (diff) |
libdw: dwarf_getsrcfiles should not imply dwarf_getsrclines
dwarf_getsrcfiles causes line data to be read in addition to file data.
This is wasteful for programs which only need file or directory names.
Debuginfod server is one such example.
Fix this by moving the srcfile reading in read_srclines into a separate
function read_srcfiles. This change improves debuginfod server's max
resident set size by up to 75% during rpm indexing.
* libdw/dwarf_getsrcfiles.c (dwarf_getsrcfiles): Replace
dwarf_getsrclines and __libdw_getsrclines with
__libdw_getsrcfiles.
* libdw/dwarf_getsrclines.c (read_line_header): New function.
(read_srcfiles): New function.
(read_srclines): Move srcfile reading into read_srcfiles.
Add parameter to use cached srcfiles if available.
Also merge srcfiles with any files from DW_LNE_define_file.
(__libdw_getsrclines): Changed to call get_lines_or_files.
(__libdw_getsrcfiles): New function. Calls get_lines_or_files.
(get_lines_or_files): New function based on the old
__libdw_getsrclines. Call read_srcfiles if linesp is NULL,
otherwise call read_srclines. Pass previously read srcfiles
to read_srclines if available.
* libdw/dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles):
Replace __libdw_getsrclines with __libdw_getsrcfiles.
* libdw/libdwP.h (__libdw_getsrcfiles): New declaration.
* tests/.gitignore: Add new test binary.
* tests/get-files.c: Verify that dwarf_getsrcfiles does
not cause srclines to be read.
* tests/get-lines.c: Verify that srclines can be read
after srcfiles have been read.
* tests/Makefile.am: Add new testfiles.
* tests/get-files-define-file.c: Print file names before
and after reading DW_LNE_define_file.
* tests/run-get-files.sh: Add get-files-define-file test.
* tests/testfile-define-file.bz2: New testfile. Copy of
testfile36.debug but with a line program consisting of two
DW_LNE_define_file opcodes.
https://sourceware.org/bugzilla/show_bug.cgi?id=27405
Signed-off-by: Aaron Merey <[email protected]>
Diffstat (limited to 'libdw/dwarf_macro_getsrcfiles.c')
-rw-r--r-- | libdw/dwarf_macro_getsrcfiles.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c index 11c587af..5e02935d 100644 --- a/libdw/dwarf_macro_getsrcfiles.c +++ b/libdw/dwarf_macro_getsrcfiles.c @@ -74,8 +74,8 @@ dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro, the same unit through dwarf_getsrcfiles, and the file names will be broken. */ - if (__libdw_getsrclines (table->dbg, line_offset, table->comp_dir, - table->address_size, NULL, &table->files) < 0) + if (__libdw_getsrcfiles (table->dbg, line_offset, table->comp_dir, + table->address_size, &table->files) < 0) table->files = (void *) -1; } |