aboutsummaryrefslogtreecommitdiff
path: root/gdb/macrotab.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2018-07-24 12:48:58 -0700
committerKeith Seitz <keiths@redhat.com>2018-07-24 12:48:58 -0700
commit380618d68a2b4ee60cebf3941d11a5af4e0aeee0 (patch)
tree2494bab101a189e588427019771ed07dd6e7b6af /gdb/macrotab.c
parent4b17aefe753a8d62ccd491b6a39dabdc69e91445 (diff)
downloadgdb-380618d68a2b4ee60cebf3941d11a5af4e0aeee0.zip
gdb-380618d68a2b4ee60cebf3941d11a5af4e0aeee0.tar.gz
gdb-380618d68a2b4ee60cebf3941d11a5af4e0aeee0.tar.bz2
Set CU language before processing any DIEs (symtab/23010 et al)
This patch is another attempt at really fixing the multitude of assertions being seen where symbols of one language are being added to symbol lists of another language. In this specific case, the backtrace command (thread apply all bt full) that is looking for the compunit containing the PC of the thread. That calls get_prev_frame several times. This function calls (eventually) dwarf2_frame_prev_register. That eventually ends up calling find_pc_compunit_symtab. In this function (find_pc_sect_compunit_symtab actually), we loop over all compunits, calling the "quick" function dw2_find_pc_sect_compunit_symtab. That function calls dw2_instantiate_symtab to read in all the CU's symbols. Now the fun begins. dw2_do_instantiate_symtab queues the per_cu for reading, using a default "pretend" language of language_minimal with the expectation that this will be set later. The DIEs of this (only queued) CU are then processed. The first DIE is DW_TAG_compile_unit. That's handled by read_file_scope. (Nearly) The first thing read_file_scope does is: get_scope_pc_bounds (die, &lowpc, &highpc, cu); This function loops over the children of the current DIE (a compile_unit), looking for bounds. The first such child is a subprogram, and we attempt to get its bounds. We use dwarf2_attr to get at DW_AT_high_pc. This subprogram has DW_AT_specification set, so dwarf_attr (via follow_die_ref/follow_die_offset) will follow that, but follow_die_offset *also* attempts to load the containing CU for the spec DIE. That spec DIE lives inside a CU that is a partial_unit and has no language attribute. So it simply inherits the language from the CU that elicited the read. [That all happens in follow_die_offset.] The original CU's language is still language_minimal -- we haven't gotten to the line in read_file_scope that actually sets the language yet! And that is the cause of these problems. The call to prepare_one_comp_unit needs to be the *first* thing that is done when reading a CU so that the CU's language can be recorded (and inherited by any referenced partial_units). Since a test reproducer for this has been so elusive, this patch also adds a wrapper function around add_symbol_to_list which asserts when adding a symbol of one language to a list containing symbols of a different language. gdb/ChangeLog: 2017-07-24 Keith Seitz <keiths@redhat.com> PR symtab/23010 * dwarf2read.c (dw2_add_symbol_to_list): New function. (fixup_go_packaging, new_symbol): Use dw2_add_symbol_to_list instead of add_symbol_to_list. (read_file_scope): Call prepare_one_comp_unit before reading any other DIEs.
Diffstat (limited to 'gdb/macrotab.c')
0 files changed, 0 insertions, 0 deletions