aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-09-13 22:19:51 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-09-13 22:19:51 +0000
commitbc30ff585c49cf1d4a4c4df15f6c15fda4dae86b (patch)
tree03a03ff7b319b1b73ccae9cd688fda13532a204e /gdb/dwarf2read.c
parentd0b76dc6dfba19f3f3f98386cef2be82f5ef701b (diff)
downloadgdb-bc30ff585c49cf1d4a4c4df15f6c15fda4dae86b.zip
gdb-bc30ff585c49cf1d4a4c4df15f6c15fda4dae86b.tar.gz
gdb-bc30ff585c49cf1d4a4c4df15f6c15fda4dae86b.tar.bz2
* dwarf2read.c (add_partial_subprogram): New procedure.
(scan_partial_symbols): Use it. (load_partial_dies): Read in children of subprogram and lexical blocks for Ada compilation units.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c80
1 files changed, 62 insertions, 18 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a62bd28..2a4acb9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -757,6 +757,10 @@ static void add_partial_namespace (struct partial_die_info *pdi,
static void add_partial_enumeration (struct partial_die_info *enum_pdi,
struct dwarf2_cu *cu);
+static void add_partial_subprogram (struct partial_die_info *pdi,
+ CORE_ADDR *lowpc, CORE_ADDR *highpc,
+ struct dwarf2_cu *cu);
+
static gdb_byte *locate_pdi_sibling (struct partial_die_info *orig_pdi,
gdb_byte *info_ptr,
bfd *abfd,
@@ -1771,21 +1775,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
switch (pdi->tag)
{
case DW_TAG_subprogram:
- if (pdi->has_pc_info)
- {
- if (pdi->lowpc < *lowpc)
- {
- *lowpc = pdi->lowpc;
- }
- if (pdi->highpc > *highpc)
- {
- *highpc = pdi->highpc;
- }
- if (!pdi->is_declaration)
- {
- add_partial_symbol (pdi, cu);
- }
- }
+ add_partial_subprogram (pdi, lowpc, highpc, cu);
break;
case DW_TAG_variable:
case DW_TAG_typedef:
@@ -2135,6 +2125,51 @@ add_partial_namespace (struct partial_die_info *pdi,
scan_partial_symbols (pdi->die_child, lowpc, highpc, cu);
}
+/* Read a partial die corresponding to a subprogram and create a partial
+ symbol for that subprogram. When the CU language allows it, this
+ routine also defines a partial symbol for each nested subprogram
+ that this subprogram contains.
+
+ DIE my also be a lexical block, in which case we simply search
+ recursively for suprograms defined inside that lexical block.
+ Again, this is only performed when the CU language allows this
+ type of definitions. */
+
+static void
+add_partial_subprogram (struct partial_die_info *pdi,
+ CORE_ADDR *lowpc, CORE_ADDR *highpc,
+ struct dwarf2_cu *cu)
+{
+ if (pdi->tag == DW_TAG_subprogram)
+ {
+ if (pdi->has_pc_info)
+ {
+ if (pdi->lowpc < *lowpc)
+ *lowpc = pdi->lowpc;
+ if (pdi->highpc > *highpc)
+ *highpc = pdi->highpc;
+ if (!pdi->is_declaration)
+ add_partial_symbol (pdi, cu);
+ }
+ }
+
+ if (! pdi->has_children)
+ return;
+
+ if (cu->language == language_ada)
+ {
+ pdi = pdi->die_child;
+ while (pdi != NULL)
+ {
+ fixup_partial_die (pdi, cu);
+ if (pdi->tag == DW_TAG_subprogram
+ || pdi->tag == DW_TAG_lexical_block)
+ add_partial_subprogram (pdi, lowpc, highpc, cu);
+ pdi = pdi->die_sibling;
+ }
+ }
+}
+
/* See if we can figure out if the class lives in a namespace. We do
this by looking for a member function; its demangled name will
contain namespace info, if there is any. */
@@ -5555,6 +5590,7 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
&& !is_type_tag_for_partial (abbrev->tag)
&& abbrev->tag != DW_TAG_enumerator
&& abbrev->tag != DW_TAG_subprogram
+ && abbrev->tag != DW_TAG_lexical_block
&& abbrev->tag != DW_TAG_variable
&& abbrev->tag != DW_TAG_namespace
&& abbrev->tag != DW_TAG_member)
@@ -5677,9 +5713,14 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
sizeof (struct partial_die_info));
/* For some DIEs we want to follow their children (if any). For C
- we have no reason to follow the children of structures; for other
+ we have no reason to follow the children of structures; for other
languages we have to, both so that we can get at method physnames
- to infer fully qualified class names, and for DW_AT_specification. */
+ to infer fully qualified class names, and for DW_AT_specification.
+
+ For Ada, we need to scan the children of subprograms and lexical
+ blocks as well because Ada allows the definition of nested
+ entities that could be interesting for the debugger, such as
+ nested subprograms for instance. */
if (last_die->has_children
&& (load_all
|| last_die->tag == DW_TAG_namespace
@@ -5688,7 +5729,10 @@ load_partial_dies (bfd *abfd, gdb_byte *info_ptr, int building_psymtab,
&& (last_die->tag == DW_TAG_class_type
|| last_die->tag == DW_TAG_interface_type
|| last_die->tag == DW_TAG_structure_type
- || last_die->tag == DW_TAG_union_type))))
+ || last_die->tag == DW_TAG_union_type))
+ || (cu->language == language_ada
+ && (last_die->tag == DW_TAG_subprogram
+ || last_die->tag == DW_TAG_lexical_block))))
{
nesting_level++;
parent_die = last_die;