This is the mail archive of the gdb-prs@sourceware.org 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: backtrace/1767: Backtrace in naked functions


The following reply was made to PR backtrace/1767; it has been noted by GNATS.

From: Marius Groeger <mgroeger@sysgo.com>
To: gdb-gnats@sources.redhat.com
Cc: Daniel Jacobowitz <drow@false.org>,
	Ruppert <dieter_ruppert@siemens.com>
Subject: Re: backtrace/1767: Backtrace in naked functions
Date: Mon, 26 Sep 2005 11:05:16 +0200 (CEST)

 Ok, I investigated a bit. The issue is "portable" and will in one 
 or another form show up on most architectures when there is no 
 main() in the backtrace. Examples for this are exception handlers, 
 signal wrappers, or thread launch wrappers. So we need to trigger 
 the termination in frame.c:get_prev_frame() somehow. The best way to 
 do this seems to make GDB think one dedicated function is main(). 
 Typically
 
 Based on a tip I received by Dieter I added an stab entry 
 N_MAIN to my prologue function. Then, dbxread.c:process_one_symbol() 
 should issue a set_main_name("thread_launcher").
 
    __asm__(".stabs \"thread_launcher\",42,0,0,0");
 
 However, it doesn't. (Maybe the .stabs directive isn't enough, and I 
 need special compile/link options?). Still, 
 dbxread.c:read_dbx_symtab() definitely does see the N_MAIN, and with 
 the following patch it will make this be "main":
 
 --- ../../gdb-6.3.50/gdb/dbxread.c	2005-02-11 19:13:49.000000000 +0100
 +++ ./dbxread.c	2005-09-26 10:52:12.000000000 +0200
 @@ -2061,6 +2062,11 @@
   #endif
   	  continue;
 
 +	  case N_MAIN:
 +	    namestring = set_namestring (objfile, nlist);
 +	    set_main_name(namestring);
 +	    continue;
 +
   	  case N_RBRAC:
   #ifdef HANDLE_RBRAC
   	  HANDLE_RBRAC (nlist.n_value);
 @@ -2072,7 +2078,6 @@
   	  case N_SSYM:			/* Claim: Structure or union element.
   					   Hopefully, I can ignore this.  */
   	  case N_ENTRY:		/* Alternate entry point; can ignore. */
 -	  case N_MAIN:			/* Can definitely ignore this.   */
   	  case N_CATCH:		/* These are GNU C++ extensions */
   	  case N_EHDECL:		/* that can safely be ignored here. */
   	  case N_LENG:
 
 What do you think?
 
 Marius
 
 -- 
 Marius Groeger <mgroeger@sysgo.com>
 SYSGO AG                      Embedded and Real-Time Software
 Voice: +49 6136 9948 0                  FAX: +49 6136 9948 10
 www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com
 


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