comp.lang.c
[Top] [All Lists]

Re: Backtrace function

Subject: Re: Backtrace function
From: Richard Heathfield
Date: Fri, 28 Mar 2008 23:30:30 +0000
Newsgroups: comp.lang.c

jacob navia said:

> Flash Gordon wrote:
>> jacob navia wrote, On 28/03/08 21:39:
<snip>
> 
>>> 5) Find out into which function the return address points to.
>>>
>>> 6) Is that the function "main"?
>>>
>>> 7) If not, get the next frame pointer and go to (2)
>> 
>> A problem if main was called recursively.
>> 
> 
> No. As I explained to Mr Heathfield, that raised the same objection,
> my algorithm just stops at the first possible recursive call of main
> It doesn't fail at all. It will not follow recursive calls to "main".
> 
> That is all.
> 
> Obviously, calling "main" recurisvely is very popular here.

Well, not really, but recursive main *is* legal. It seems to me that a 
non-portable solution would be free to learn main's caller (e.g. _startup, 
or whatever), and probe for that instead. This would allow recursive main 
calls to be backtraced properly.

<snip>

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -                                www">http://www. +rjh@
Google users: <                                www.cpax.org.uk/prg/writings/googly.php">http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy