aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-09-30 16:57:37 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-09-30 16:57:37 +0000
commitb084d499897043f621ec43c38594957e859ee884 (patch)
tree1fc9fc4a5970de9e2d01d7aaabdc3549277a3a6c
parent506800a969be975219e8f7c82efa68589d56b259 (diff)
downloadfsf-binutils-gdb-b084d499897043f621ec43c38594957e859ee884.zip
fsf-binutils-gdb-b084d499897043f621ec43c38594957e859ee884.tar.gz
fsf-binutils-gdb-b084d499897043f621ec43c38594957e859ee884.tar.bz2
* dwarf2read.c (dwarf2_get_subprogram_pc_bounds): New function.
(get_scope_pc_bounds): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2read.c43
2 files changed, 43 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b8e1027..dfa6df1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-30 Joel Brobecker <brobecker@adacore.com>
+
+ * dwarf2read.c (dwarf2_get_subprogram_pc_bounds): New function.
+ (get_scope_pc_bounds): Use it.
+
2008-09-27 Tom Tromey <tromey@redhat.com>
* NEWS: Update.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 5778fef..5e4d15f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3324,6 +3324,43 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
return ret;
}
+/* Assuming that DIE represents a subprogram DIE or a lexical block, get
+ its low and high PC addresses. Do nothing if these addresses could not
+ be determined. Otherwise, set LOWPC to the low address if it is smaller,
+ and HIGHPC to the high address if greater than HIGHPC. */
+
+static void
+dwarf2_get_subprogram_pc_bounds (struct die_info *die,
+ CORE_ADDR *lowpc, CORE_ADDR *highpc,
+ struct dwarf2_cu *cu)
+{
+ CORE_ADDR low, high;
+ struct die_info *child = die->child;
+
+ if (dwarf2_get_pc_bounds (die, &low, &high, cu))
+ {
+ *lowpc = min (*lowpc, low);
+ *highpc = max (*highpc, high);
+ }
+
+ /* If the language does not allow nested subprograms (either inside
+ subprograms or lexical blocks), we're done. */
+ if (cu->language != language_ada)
+ return;
+
+ /* Check all the children of the given DIE. If it contains nested
+ subprograms, then check their pc bounds. Likewise, we need to
+ check lexical blocks as well, as they may also contain subprogram
+ definitions. */
+ while (child && child->tag)
+ {
+ if (child->tag == DW_TAG_subprogram
+ || child->tag == DW_TAG_lexical_block)
+ dwarf2_get_subprogram_pc_bounds (child, lowpc, highpc, cu);
+ child = sibling_die (child);
+ }
+}
+
/* Get the low and high pc's represented by the scope DIE, and store
them in *LOWPC and *HIGHPC. If the correct values can't be
determined, set *LOWPC to -1 and *HIGHPC to 0. */
@@ -3350,11 +3387,7 @@ get_scope_pc_bounds (struct die_info *die,
{
switch (child->tag) {
case DW_TAG_subprogram:
- if (dwarf2_get_pc_bounds (child, &current_low, &current_high, cu))
- {
- best_low = min (best_low, current_low);
- best_high = max (best_high, current_high);
- }
+ dwarf2_get_subprogram_pc_bounds (child, &best_low, &best_high, cu);
break;
case DW_TAG_namespace:
/* FIXME: carlton/2004-01-16: Should we do this for