From fc4007c969ec4208fb7c7cee2f50211a9aa0f40f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 20 Nov 2016 13:20:32 -0700 Subject: Remove make_cleanup_htab_delete This removes make_cleanup_htab_delete in favor of destructors, building on an earlier patch that added the htab_up typedef. Testing revealed that more cleanup-removal work was needed in dwarf2loc.c, so this version of the patch changes code there to use unordered_set and vector, removing some more cleanups. 2017-01-10 Tom Tromey * utils.h (make_cleanup_htab_delete): Don't declare. * utils.c (do_htab_delete_cleanup, make_cleanup_htab_delete): Remove. * linespec.c (decode_compound_collector): Add constructor, destructor. (lookup_prefix_sym): Remove cleanup. (symtab_collector): Add constructor, destructor. (collect_symtabs_from_filename): Remove cleanup. * disasm.c (do_mixed_source_and_assembly): Use htab_up. * compile/compile-c-symbols.c (generate_c_for_variable_locations): Use htab_up. * gnu-v3-abi.c (gnuv3_print_vtable): Use htab_up. * dwarf2read.c (dw2_expand_symtabs_matching) (dw2_map_symbol_filenames, dwarf_decode_macros) (write_psymtabs_to_index): Use htab_up. * dwarf2loc.c (func_verify_no_selftailcall) (call_site_find_chain_1, func_verify_no_selftailcall) (chain_candidate, call_site_find_chain_1): Use std::unordered_set, std::vector, gdb::unique_xmalloc_ptr. (call_sitep): Remove typedef. (dwarf2_locexpr_baton_eval): Remove unused variable. --- gdb/disasm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'gdb/disasm.c') diff --git a/gdb/disasm.c b/gdb/disasm.c index 84a03e9288..f419501b08 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -498,14 +498,12 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, int i, nlines; int num_displayed = 0; print_source_lines_flags psl_flags = 0; - struct cleanup *cleanups; struct cleanup *ui_out_chain; struct cleanup *ui_out_tuple_chain; struct cleanup *ui_out_list_chain; CORE_ADDR pc; struct symtab *last_symtab; int last_line; - htab_t dis_line_table; gdb_assert (main_symtab != NULL && SYMTAB_LINETABLE (main_symtab) != NULL); @@ -515,8 +513,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, but if that text is for code that will be disassembled later, then we'll want to defer printing it until later with its associated code. */ - dis_line_table = allocate_dis_line_table (); - cleanups = make_cleanup_htab_delete (dis_line_table); + htab_up dis_line_table (allocate_dis_line_table ()); pc = low; @@ -548,7 +545,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, pc += length; if (sal.symtab != NULL) - add_dis_line_entry (dis_line_table, sal.symtab, sal.line); + add_dis_line_entry (dis_line_table.get (), sal.symtab, sal.line); } /* Second pass: print the disassembly. @@ -565,9 +562,6 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, which is where we put file name and source line contents output. Cleanup usage: - cleanups: - For things created at the beginning of this function and need to be - kept until the end of this function. ui_out_chain Handles the outer "asm_insns" list. ui_out_tuple_chain @@ -625,7 +619,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, not associated with code that we'll print later. */ for (l = sal.line - 1; l > last_line; --l) { - if (line_has_code_p (dis_line_table, sal.symtab, l)) + if (line_has_code_p (dis_line_table.get (), + sal.symtab, l)) break; } if (l < sal.line - 1) @@ -728,7 +723,6 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout, } do_cleanups (ui_out_chain); - do_cleanups (cleanups); } static void -- cgit v1.2.3