This is the mail archive of the gdb@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: Unwinding stack past main() when it has another name


On Fri, Jun 17, 2005 at 08:22:13AM -1100, Steven Johnson wrote:
> Daniel Jacobowitz wrote:
> 
> >The fact that we stop at _start is a feature, so hopefully you can rely
> >on that in the future.
> >
> >For some non-C languages we get the name of the main function from
> >debug information, but for C it's always main()
> > 
> >
> This isnt always the case for embedded targets.  There is no RULE that C 
> programs must have a main() function.  It may be that most do by 
> convention, but they dont have to.  In fact, main() can be a pain for 
> small embedded targets because it wants a return value and arguments, 
> which mean nothing for a program that isnt "launched" by a user on 
> demand, but the C compiler detects the special function name main() and 
> objects if it doesnt have the standard format.  Programs dont even need 
> to have an entry point called _start.  It all depends on how you set up 
> your link map.

In fact you're wrong: there is a rule that C programs must have a
main() function.  It's in the language standard.

The fact that many embedded toolchains allow you to do things
differently is outside the boundaries of the language standard, and if
you don't have a main() your backtraces will stop at your entry point,
determined from the ELF file.  GDB'll do the best it can.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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