+2004-11-10 Randolph Chung <tausq@debian.org>
+
+ * blockframe.c (inside_entry_func): Move to .....
+ * frame.c (inside_entry_func): ... here, and make static.
+ (backtrace_past_entry): New flag.
+ (get_prev_frame): Stop backtrace at the entry function if enabled
+ by flag. Update comments.
+ (_initialize_frame): Add command to set backtrace_past_entry flag.
+ * defs.h (inside_entry_func): Remove prototype.
+
2004-11-10 Mark Kettenis <kettenis@gnu.org>
* dwarf2read.c: Fix formatting.
@kindex show backtrace
Display the current user entry point backtrace policy.
+@item set backtrace past-entry
+@itemx set backtrace past-entry on
+Backtraces will continue past the internal entry point of an application.
+This entry point is encoded by the linker when the application is built,
+and is likely before the user entry point @code{main} (or equivalent) is called.
+
+@item set backtrace past-entry off
+Backtraces will stop when they encouter the internal entry point of an
+application. This is the default.
+
+@item show backtrace past-entry
+Display the current internal entry point backtrace policy.
+
@item set backtrace limit @var{n}
@itemx set backtrace limit 0
@cindex backtrace limit
/* Flag to indicate whether backtraces should stop at main et.al. */
static int backtrace_past_main;
+static int backtrace_past_entry;
static unsigned int backtrace_limit = UINT_MAX;
static void
return maddr == get_frame_func (this_frame);
}
+/* Test whether THIS_FRAME is inside the process entry point function. */
+
+static int
+inside_entry_func (struct frame_info *this_frame)
+{
+ return (get_frame_func (this_frame) == entry_point_address ());
+}
+
/* Return a structure containing various interesting information about
the frame that called THIS_FRAME. Returns NULL if there is entier
no such frame or the frame fails any of a set of target-independent
dummy frame PCs 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
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
+ /* NOTE: tausq/2004-10-09: this is needed if, for example, the compiler
+ applied tail-call optimizations to main so that a function called
+ from main returns directly to the caller of main. Since we don't
+ stop at main, we should at least stop at the entry point of the
+ application. */
+ if (!backtrace_past_entry
&& this_frame->unwind->type != DUMMY_FRAME && this_frame->level >= 0
&& inside_entry_func (this_frame))
{
NULL, NULL, &set_backtrace_cmdlist,
&show_backtrace_cmdlist);
+ add_setshow_boolean_cmd ("past-entry", class_obscure,
+ &backtrace_past_entry, "\
+Set whether backtraces should continue past the entry point of a program.", "\
+Show whether backtraces should continue past the entry point of a program.", "\
+Normally there are no callers beyond the entry point of a program, so GDB\n\
+will terminate the backtrace there. Set this variable if you need to see \n\
+the rest of the stack trace.", "\
+Whether backtraces should continue past the entry point is %s.",
+ NULL, NULL, &set_backtrace_cmdlist,
+ &show_backtrace_cmdlist);
+
add_setshow_uinteger_cmd ("limit", class_obscure,
&backtrace_limit, "\
Set an upper bound on the number of backtrace levels.", "\