From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28112 invoked by alias); 16 Jun 2005 22:46:38 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 28063 invoked by uid 22791); 16 Jun 2005 22:46:29 -0000 Received: from [202.80.36.21] (HELO steven) (202.80.36.21) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 16 Jun 2005 22:46:29 +0000 Received: from sakuraindustries.com (localhost [127.0.0.1]) by steven (Postfix) with ESMTP id D8C61129C7F; Fri, 17 Jun 2005 09:46:28 -1100 (GMT+11) Message-ID: <42B336A4.40704@sakuraindustries.com> Date: Thu, 16 Jun 2005 22:46:00 -0000 From: Steven Johnson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.6) Gecko/20040115 MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb@sources.redhat.com Subject: Re: Unwinding stack past main() when it has another name References: <200506152247.07232.rodda@kde.org> <200506160112.58152.rodda@kde.org> <20050615163658.GA18795@nevyn.them.org> <200506161743.00708.rodda@kde.org> <20050616132242.GA5480@nevyn.them.org> <42B322E5.4080403@sakuraindustries.com> <20050616220527.GA9960@nevyn.them.org> In-Reply-To: <20050616220527.GA9960@nevyn.them.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-06/txt/msg00179.txt.bz2 Daniel Jacobowitz wrote: >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. > > I stand corrected. It is in fact in the standard as you say. I have just been so exposed to code (written by many people) where the first C function that runs isnt called "main" it seemed to be a convention rather than a rule. But as you say, many tool chains, gcc included allow for a program to not have a "main" function if you get in and modify the startup code and link map, which you often do for embedded targets, and doing so is not "standard" C. >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. > > > I wasnt suggesting GDB was broken in this regard, I was simply pointing out that not all (what Ive always considered to be) "C" programs have a main() function. Steven