]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/dwarf: store dwo_file_up in dwo_file_set
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 5 Mar 2025 05:06:43 +0000 (00:06 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 5 Mar 2025 16:58:31 +0000 (11:58 -0500)
commit93258b5fa6eb08b2d06cc3b1ffd93e5ce30eed7c
treebb614c5ad29c081805552fdb68f6eeba79458549
parent76ee822b86e86a548d00849202c10fdc0b397ac1
gdb/dwarf: store dwo_file_up in dwo_file_set

Heap-allocated dwo_file objects, stored in dwarf2_per_bfd::dwo_files,
are never freed.  They are created in one of the
create_dwo_unit_in_dwp_* or lookup_dwo_cutu functions.  I confirmed this
by running:

  $ make check TESTS="gdb.cp/anon-ns.exp" RUNTESTFLAGS="--target_board=fission-dwp"
  $ ./gdb -q -nx --data-directory=data-directory testsuite/outputs/gdb.cp/anon-ns/anon-ns -ex "p main" -ex "file" -batch

... and checking the ASan leak report.  I also debugged this invocation
of GDB, placed a breakpoint on ~dwo_file, and didn't see any hit.

Change the dwo_file set to hold dwo_file_up objects.  When the
dwarf2_per_bfd object gets destroyed, dwo_file objects will
automatically get destroyed.  With this change, I see the related leaks
disappear in the ASan leak report, and my ~dwo_file breakpoint gets hit
when debugging GDB.

Change-Id: Icb38539c3f9e553f3625c625a00fc63dd6e9f3c5
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read.c
gdb/dwarf2/read.h