diff options
author | Pedro Alves <palves@redhat.com> | 2017-08-17 22:53:53 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-08-17 22:53:53 +0100 |
commit | 4c8aa72d0eb714a91ca2e47b816d0b4a0cb27843 (patch) | |
tree | e26cd9371fdd5f65aaa4446728ab7f5f0be295e8 /gdb/cli | |
parent | 714da62f64ef5527a22a3e897f7e21f69e442ade (diff) | |
download | fsf-binutils-gdb-4c8aa72d0eb714a91ca2e47b816d0b4a0cb27843.zip fsf-binutils-gdb-4c8aa72d0eb714a91ca2e47b816d0b4a0cb27843.tar.gz fsf-binutils-gdb-4c8aa72d0eb714a91ca2e47b816d0b4a0cb27843.tar.bz2 |
Plug line_header leaks
This plugs a couple leaks introduced by commit fff8551cf549
("dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr").
The first problem is that nothing owns the temporary line_header that
handle_DW_AT_stmt_list creates in some cases. Before the commit
mentioned above, the temporary line_header case used to have:
make_cleanup (free_cu_line_header, cu);
and that cleanup was assumed to be run by process_die, after
handle_DW_AT_stmt_list returns and before child DIEs were processed.
The second problem is found in setup_type_unit_groups: that also used
to have a similar make_cleanup call, and ended up with a similar leak
after the commit mentioned above.
Fix both cases by recording in dwarf2_cu whether a line header is
owned by the cu/die, and have process_die explicitly free the
line_header if so, making use of a new RAII object that also replaces
the reset_die_in_process cleanup, while at it.
Thanks to Philippe Waroquiers for noticing the leak and pointing in
the right direction.
gdb/ChangeLog:
2017-08-17 Pedro Alves <palves@redhat.com>
* dwarf2read.c (struct dwarf2_cu) <line_header_die_owner>: New
field.
(reset_die_in_process): Delete, replaced by ...
(process_die_scope): ... this new class. Make it responsible for
freeing cu->line_header too.
(process_die): Use process_die_scope.
(handle_DW_AT_stmt_list): Record the line header's owner CU/DIE in
cu->line_header_die_owner. Don't release the line header if it's
owned by the CU.
(setup_type_unit_groups): Make the CU/DIE own the line header.
Don't release the line header here.
Diffstat (limited to 'gdb/cli')
0 files changed, 0 insertions, 0 deletions