* [patch, rfc, 6] Check for "main" in minimal symbols in BT
@ 2003-07-07 20:42 Andrew Cagney
2003-07-07 21:07 ` Daniel Jacobowitz
2003-07-15 17:31 ` Andrew Cagney
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-07-07 20:42 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
Hello,
This patch extends the inside_main_func() check so that, when "main"
isn't found in the symbol table, the mimimal symbol table is searched.
In case you're wondering, the logic for finding the end address of
"main" was cobbled together from random bits of code from blockframe and
the alpha. It certainly appears to work for d10v and i386.
Anyway, with this, the d10v's assembler backtrace stops at main goving
the short 'n' sharp backtrace
foo2
main
instead of the current:
foo2
main
_start
_start
The patch (since things now stop in "main") also removes the d10v
specific frame ID eq test; and updates the testsuite so that it doesn't
allow "_start" in the backtrace.
I intend checking this into both 6.0 branch and mainline in a few days.
comments,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4830 bytes --]
2003-07-07 Andrew Cagney <cagney@redhat.com>
* frame.c (get_prev_frame): Add comment about forgetting to check
the minimal symbol table for "main".
* blockframe.c (inside_main_func): Look for "main" in the minimal
symbol table.
* d10v-tdep.c (d10v_frame_this_id): Delete check that frames are
identical.
Index: testsuite/ChangeLog
2003-07-07 Andrew Cagney <cagney@redhat.com>
* gdb.asm/asm-source.exp: Do not allow "start" in the backtrace.
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.72
diff -u -r1.72 blockframe.c
--- blockframe.c 23 May 2003 17:05:19 -0000 1.72
+++ blockframe.c 7 Jul 2003 20:25:21 -0000
@@ -106,6 +106,47 @@
BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym));
}
}
+
+ /* Not in the normal symbol tables, see if "main" is in the partial
+ symbol table. If it's not, then give up. */
+ {
+ struct minimal_symbol *msymbol
+ = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);
+ if (msymbol != NULL && MSYMBOL_TYPE (msymbol) == mst_text)
+ {
+ struct obj_section *osect
+ = find_pc_sect_section (SYMBOL_VALUE_ADDRESS (msymbol),
+ msymbol->ginfo.bfd_section);
+ if (osect != NULL)
+ {
+ int i;
+ /* Step over other symbols at this same address, and
+ symbols in other sections, to find the next symbol in
+ this section with a different address. */
+ for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
+ {
+ if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol)
+ && SYMBOL_BFD_SECTION (msymbol + i) == SYMBOL_BFD_SECTION (msymbol))
+ break;
+ }
+
+ symfile_objfile->ei.main_func_lowpc = SYMBOL_VALUE_ADDRESS (msymbol);
+
+ /* Use the lesser of the next minimal symbol in the same
+ section, or the end of the section, as the end of the
+ function. */
+ if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL
+ && SYMBOL_VALUE_ADDRESS (msymbol + i) < osect->endaddr)
+ symfile_objfile->ei.main_func_highpc = SYMBOL_VALUE_ADDRESS (msymbol + i);
+ else
+ /* We got the start address from the last msymbol in the
+ objfile. So the end address is the end of the
+ section. */
+ symfile_objfile->ei.main_func_highpc = osect->endaddr;
+ }
+ }
+ }
+
return (symfile_objfile->ei.main_func_lowpc <= pc &&
symfile_objfile->ei.main_func_highpc > pc);
}
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.127
diff -u -r1.127 d10v-tdep.c
--- d10v-tdep.c 7 Jul 2003 14:36:57 -0000 1.127
+++ d10v-tdep.c 7 Jul 2003 20:25:21 -0000
@@ -1417,15 +1417,6 @@
id = frame_id_build (base, func);
- /* Check that we're not going round in circles with the same frame
- ID (but avoid applying the test to sentinel frames which do go
- round in circles). Can't use frame_id_eq() as that doesn't yet
- compare the frame's PC value. */
- if (frame_relative_level (next_frame) >= 0
- && get_frame_type (next_frame) != DUMMY_FRAME
- && frame_id_eq (get_frame_id (next_frame), id))
- return;
-
(*this_id) = id;
}
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.130
diff -u -r1.130 frame.c
--- frame.c 7 Jul 2003 20:07:12 -0000 1.130
+++ frame.c 7 Jul 2003 20:25:22 -0000
@@ -1870,6 +1870,12 @@
be allowed to unwind. */
/* NOTE: cagney/2003-02-25: Don't enable until someone has found
hard evidence that this is needed. */
+ /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func - wasn't
+ checking for "main" in the minimal symbols. With that fixed
+ asm-source tests now stop in "main" instead of halting the
+ backtrace in wierd and wonderful ways. Suspect that
+ inside_entry_file and inside_entry_func tests were added to work
+ around that (now fixed) case. */
if (0
&& this_frame->type != DUMMY_FRAME && this_frame->level >= 0
&& inside_entry_func (get_frame_pc (this_frame)))
Index: testsuite/gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.39
diff -u -r1.39 asm-source.exp
--- testsuite/gdb.asm/asm-source.exp 7 Jul 2003 14:48:50 -0000 1.39
+++ testsuite/gdb.asm/asm-source.exp 7 Jul 2003 20:25:26 -0000
@@ -244,7 +244,7 @@
# doesn't fall off the stack.
gdb_test "bt 10" \
- "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33(.*\#2.*start\[^\r\n\]*)?" \
+ "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33" \
"bt ALL in foo2"
# See if a capped `bt' prints the right source files.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, rfc, 6] Check for "main" in minimal symbols in BT
2003-07-07 20:42 [patch, rfc, 6] Check for "main" in minimal symbols in BT Andrew Cagney
@ 2003-07-07 21:07 ` Daniel Jacobowitz
2003-07-08 20:44 ` Andrew Cagney
2003-07-15 17:31 ` Andrew Cagney
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-07-07 21:07 UTC (permalink / raw)
To: gdb-patches
On Mon, Jul 07, 2003 at 04:42:05PM -0400, Andrew Cagney wrote:
> Hello,
>
> This patch extends the inside_main_func() check so that, when "main"
> isn't found in the symbol table, the mimimal symbol table is searched.
> In case you're wondering, the logic for finding the end address of
> "main" was cobbled together from random bits of code from blockframe and
> the alpha. It certainly appears to work for d10v and i386.
>
> Anyway, with this, the d10v's assembler backtrace stops at main goving
> the short 'n' sharp backtrace
>
> foo2
> main
>
> instead of the current:
>
> foo2
> main
> _start
> _start
>
> The patch (since things now stop in "main") also removes the d10v
> specific frame ID eq test; and updates the testsuite so that it doesn't
> allow "_start" in the backtrace.
>
> I intend checking this into both 6.0 branch and mainline in a few days.
Definitely like the patch! Should we make inside_entry_func also check
the minimal symbol table? Since we have the entry point PC reliably
(via ELF headers).
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, rfc, 6] Check for "main" in minimal symbols in BT
2003-07-07 21:07 ` Daniel Jacobowitz
@ 2003-07-08 20:44 ` Andrew Cagney
2003-07-08 21:55 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-07-08 20:44 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
>
> Definitely like the patch! Should we make inside_entry_func also check
> the minimal symbol table? Since we have the entry point PC reliably
> (via ELF headers).
Hmm, did I mention that inside_entry_func isn't called :-)
(also check the e-mail between my self and JimB, entry_point_address
isn't reliable - there are cases where it isn't but needs to be
re-located or indirected).
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, rfc, 6] Check for "main" in minimal symbols in BT
2003-07-08 20:44 ` Andrew Cagney
@ 2003-07-08 21:55 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-07-08 21:55 UTC (permalink / raw)
To: gdb-patches
On Tue, Jul 08, 2003 at 04:44:18PM -0400, Andrew Cagney wrote:
> >
> >Definitely like the patch! Should we make inside_entry_func also check
> >the minimal symbol table? Since we have the entry point PC reliably
> >(via ELF headers).
>
> Hmm, did I mention that inside_entry_func isn't called :-)
I still think it should be... otherwise, who knows what'll happen when
you step out of main?
> (also check the e-mail between my self and JimB, entry_point_address
> isn't reliable - there are cases where it isn't but needs to be
> re-located or indirected).
True. PIE (like PIC, for executables) throws a bit of a wrench in
that.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, rfc, 6] Check for "main" in minimal symbols in BT
2003-07-07 20:42 [patch, rfc, 6] Check for "main" in minimal symbols in BT Andrew Cagney
2003-07-07 21:07 ` Daniel Jacobowitz
@ 2003-07-15 17:31 ` Andrew Cagney
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-07-15 17:31 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 982 bytes --]
> Hello,
>
> This patch extends the inside_main_func() check so that, when "main" isn't found in the symbol table, the mimimal symbol table is searched. In case you're wondering, the logic for finding the end address of "main" was cobbled together from random bits of code from blockframe and the alpha. It certainly appears to work for d10v and i386.
>
> Anyway, with this, the d10v's assembler backtrace stops at main goving the short 'n' sharp backtrace
>
> foo2
> main
>
> instead of the current:
>
> foo2
> main
> _start
> _start
>
> The patch (since things now stop in "main") also removes the d10v specific frame ID eq test; and updates the testsuite so that it doesn't allow "_start" in the backtrace.
>
> I intend checking this into both 6.0 branch and mainline in a few days.
I've updated the (disabled) code in frame.c related to inside_entry_func
(see attached) to included more comments.
Committed to trunk and 6.0 branch.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 7011 bytes --]
2003-07-15 Andrew Cagney <cagney@redhat.com>
* frame.c (get_prev_frame): Move disabled inside_entry_func to
before code inhibiting repeated unwind attempts. Add to
commentary on that test's problems.
* blockframe.c (inside_main_func): Look for "main" in the minimal
symbol table.
* d10v-tdep.c (d10v_frame_this_id): Delete check that frames are
identical.
Index: testsuite/ChangeLog
2003-07-15 Andrew Cagney <cagney@redhat.com>
* gdb.asm/asm-source.exp: Do not allow "start" in the backtrace.
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.75
diff -u -r1.75 blockframe.c
--- blockframe.c 11 Jul 2003 15:31:43 -0000 1.75
+++ blockframe.c 15 Jul 2003 17:21:23 -0000
@@ -106,6 +106,47 @@
BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym));
}
}
+
+ /* Not in the normal symbol tables, see if "main" is in the partial
+ symbol table. If it's not, then give up. */
+ {
+ struct minimal_symbol *msymbol
+ = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);
+ if (msymbol != NULL && MSYMBOL_TYPE (msymbol) == mst_text)
+ {
+ struct obj_section *osect
+ = find_pc_sect_section (SYMBOL_VALUE_ADDRESS (msymbol),
+ msymbol->ginfo.bfd_section);
+ if (osect != NULL)
+ {
+ int i;
+ /* Step over other symbols at this same address, and
+ symbols in other sections, to find the next symbol in
+ this section with a different address. */
+ for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
+ {
+ if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol)
+ && SYMBOL_BFD_SECTION (msymbol + i) == SYMBOL_BFD_SECTION (msymbol))
+ break;
+ }
+
+ symfile_objfile->ei.main_func_lowpc = SYMBOL_VALUE_ADDRESS (msymbol);
+
+ /* Use the lesser of the next minimal symbol in the same
+ section, or the end of the section, as the end of the
+ function. */
+ if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL
+ && SYMBOL_VALUE_ADDRESS (msymbol + i) < osect->endaddr)
+ symfile_objfile->ei.main_func_highpc = SYMBOL_VALUE_ADDRESS (msymbol + i);
+ else
+ /* We got the start address from the last msymbol in the
+ objfile. So the end address is the end of the
+ section. */
+ symfile_objfile->ei.main_func_highpc = osect->endaddr;
+ }
+ }
+ }
+
return (symfile_objfile->ei.main_func_lowpc <= pc &&
symfile_objfile->ei.main_func_highpc > pc);
}
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.127
diff -u -r1.127 d10v-tdep.c
--- d10v-tdep.c 7 Jul 2003 14:36:57 -0000 1.127
+++ d10v-tdep.c 15 Jul 2003 17:21:24 -0000
@@ -1417,15 +1417,6 @@
id = frame_id_build (base, func);
- /* Check that we're not going round in circles with the same frame
- ID (but avoid applying the test to sentinel frames which do go
- round in circles). Can't use frame_id_eq() as that doesn't yet
- compare the frame's PC value. */
- if (frame_relative_level (next_frame) >= 0
- && get_frame_type (next_frame) != DUMMY_FRAME
- && frame_id_eq (get_frame_id (next_frame), id))
- return;
-
(*this_id) = id;
}
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.131
diff -u -r1.131 frame.c
--- frame.c 11 Jul 2003 14:52:17 -0000 1.131
+++ frame.c 15 Jul 2003 17:21:24 -0000
@@ -1816,6 +1816,44 @@
return NULL;
}
+ /* If we're already inside the entry function for the main objfile,
+ then it isn't valid. Don't apply this test to a dummy frame -
+ dummy frame PC's typically land in the entry func. Don't apply
+ this test to the sentinel frame. Sentinel frames should always
+ be allowed to unwind. */
+ /* NOTE: cagney/2003-02-25: Don't enable until someone has found
+ hard evidence that this is needed. */
+ /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func - wasn't
+ checking for "main" in the minimal symbols. With that fixed
+ asm-source tests now stop in "main" instead of halting the
+ backtrace in wierd and wonderful ways somewhere inside the entry
+ file. Suspect that inside_entry_file and inside_entry_func tests
+ were added to work around that (now fixed) case. */
+ /* NOTE: cagney/2003-07-15: danielj (if I'm reading it right)
+ suggested having the inside_entry_func test use the
+ inside_main_func msymbol trick (along with entry_point_address I
+ guess) to determine the address range of the start function.
+ That should provide a far better stopper than the current
+ heuristics. */
+ /* NOTE: cagney/2003-07-15: Need to add a "set backtrace
+ beyond-entry-func" command so that this can be selectively
+ disabled. */
+ if (0
+#if 0
+ && backtrace_beyond_entry_func
+#endif
+ && this_frame->type != DUMMY_FRAME && this_frame->level >= 0
+ && inside_entry_func (get_frame_pc (this_frame)))
+ {
+ if (frame_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog, "-> ");
+ fprint_frame (gdb_stdlog, NULL);
+ fprintf_unfiltered (gdb_stdlog, "// inside entry func }\n");
+ }
+ return NULL;
+ }
+
/* Only try to do the unwind once. */
if (this_frame->prev_p)
{
@@ -1862,26 +1900,6 @@
return NULL;
}
#endif
-
- /* If we're already inside the entry function for the main objfile,
- then it isn't valid. Don't apply this test to a dummy frame -
- dummy frame PC's typically land in the entry func. Don't apply
- this test to the sentinel frame. Sentinel frames should always
- be allowed to unwind. */
- /* NOTE: cagney/2003-02-25: Don't enable until someone has found
- hard evidence that this is needed. */
- if (0
- && this_frame->type != DUMMY_FRAME && this_frame->level >= 0
- && inside_entry_func (get_frame_pc (this_frame)))
- {
- if (frame_debug)
- {
- fprintf_unfiltered (gdb_stdlog, "-> ");
- fprint_frame (gdb_stdlog, NULL);
- fprintf_unfiltered (gdb_stdlog, "// inside entry func }\n");
- }
- return NULL;
- }
/* If any of the old frame initialization methods are around, use
the legacy get_prev_frame method. */
Index: testsuite/gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.39
diff -u -r1.39 asm-source.exp
--- testsuite/gdb.asm/asm-source.exp 7 Jul 2003 14:48:50 -0000 1.39
+++ testsuite/gdb.asm/asm-source.exp 15 Jul 2003 17:21:28 -0000
@@ -244,7 +244,7 @@
# doesn't fall off the stack.
gdb_test "bt 10" \
- "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33(.*\#2.*start\[^\r\n\]*)?" \
+ "\#0.*foo2.*asmsrc2\[.\]s:12.*\#1.*main.*asmsrc1\[.\]s:33" \
"bt ALL in foo2"
# See if a capped `bt' prints the right source files.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-07-15 17:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-07 20:42 [patch, rfc, 6] Check for "main" in minimal symbols in BT Andrew Cagney
2003-07-07 21:07 ` Daniel Jacobowitz
2003-07-08 20:44 ` Andrew Cagney
2003-07-08 21:55 ` Daniel Jacobowitz
2003-07-15 17:31 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox