Re: Stack Pointer..?
- From: yf110@xxxxxxxxxxxxxxxxxxx (Malcolm Dew-Jones)
- Date: 10 Oct 2005 13:28:52 -0700
7trackers@xxxxxxxxx wrote:
: Hi people...
: Here's my question...
: a function other than main is getting executed
: you have to find out which function called this function
: how can we do in C...?
You could rewrite your functions to include that information
(No pretense of being real code)
main()
{
do_something("from main",1,2,3);
}
do_something( char *from, int i, int j, int k)
{
do_something_else("do_something",'a','b','c');
}
do_something_else( char *from, etc...)
{
printf("I was called from %s",from);
}
To get a full stack trace you would have to add some kind of link as well,
but I haven't thought to add that here.
Various compilers and debuggers have options to help do this sort of thing
much easier.
--
This programmer available for rent.
.
- Follow-Ups:
- Re: Stack Pointer..?
- From: Dave Thompson
- Re: Stack Pointer..?
- References:
- Stack Pointer..?
- From: 7trackers
- Stack Pointer..?
- Prev by Date: [OT] Re: Size of data types in C?
- Next by Date: Re: volatile and "needed side effects"
- Previous by thread: Re: Stack Pointer..?
- Next by thread: Re: Stack Pointer..?
- Index(es):
Relevant Pages
|