This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Recognize bottom of stack on Linux


Daniel Jacobowitz <drow@mvista.com> writes:
> On Sun, Feb 03, 2002 at 09:06:36PM -0500, Jim Blandy wrote:
> > 
> > Now, some folks feel that GDB should show the whole stack, including
> > _start, __libc_start_main, and anything else that's there.  However,
> > this isn't the way GDB has ever traditionally behaved on native
> > targets.  So this patch makes GDB's backtraces end after main.
> > 
> > 2002-02-03  Jim Blandy  <jimb@redhat.com>
> > 
> > 	* i386-linux-tdep.c (i386_linux_frame_chain): Stop the frame chain
> > 	after `main', not just after the compilation unit containing the
> > 	entry point.
> 
> Shouldn't we use func_frame_chain_valid instead of
> file_frame_chain_valid instead of duplicating this?
> 
> I don't understand why that function doesn't have more callers.  It
> seems that at least all non-embedded targets, or at the very least all
> Linux targets, should use it.

The following works fine for me, too:

2002-02-05  Jim Blandy  <jimb@redhat.com>

	* i386-linux-tdep.c (i386_linux_frame_chain): Use
	func_frame_chain_valid, instead of plain inside_entry_file.

Index: gdb/i386-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v
retrieving revision 1.10
diff -c -r1.10 i386-linux-tdep.c
*** gdb/i386-linux-tdep.c	2001/12/10 22:04:10	1.10
--- gdb/i386-linux-tdep.c	2002/02/05 19:55:03
***************
*** 342,348 ****
    if (frame->signal_handler_caller || FRAMELESS_SIGNAL (frame))
      return frame->frame;
  
!   if (! inside_entry_file (frame->pc))
      return read_memory_unsigned_integer (frame->frame, 4);
  
    return 0;
--- 342,356 ----
    if (frame->signal_handler_caller || FRAMELESS_SIGNAL (frame))
      return frame->frame;
  
!   /* On Linux, the entry point is called _start, but that invokes
!      something called __libc_start_main, which calls main.  So if we
!      want the stack to end at main (as it does for GDB's other
!      targets), the `PC in entry point function' rule triggers too late
!      to get us the right result; we've already included
!      __libc_start_main in the backtrace, which we don't want.
!      func_frame_chain_valid checks both for `main', and for the entry
!      point function.  */
!   if (func_frame_chain_valid (1, frame))
      return read_memory_unsigned_integer (frame->frame, 4);
  
    return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]