LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-11-2008, 01:01 AM   #1
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Rep: Reputation: 24
how to kno parent function's name ?


hello friends,

Suppose I have 2 functions, fun_A() and fun_B().

Now fun_B is calling fun_A. So In fun_B how can i know tht "fun_A" has called me ?

I wanna make a C prog for the same....
 
Old 12-11-2008, 08:15 AM   #2
elprawn
Member
 
Registered: Feb 2005
Distribution: Gentoo 2008
Posts: 138

Rep: Reputation: 15
Pass the name of the caller as an argument.
 
Old 12-11-2008, 08:44 AM   #3
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
Not so sure how much relevant this is, but looks interesting.
 
Old 12-11-2008, 08:45 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
One method is to walk the call stack yet as how to do this is dependant on the system you are using. glibc gives you a backtrace, windows has StackWalk64, then there is __builtin_return_address and __builtin_frame_address.

edit:
What are you trying to achieve here is this for debugging information of say the allocation point or is this something completely different?

Last edited by dmail; 12-11-2008 at 09:01 AM.
 
Old 12-14-2008, 01:51 AM   #5
arunmathew1984
Member
 
Registered: Nov 2008
Posts: 31

Rep: Reputation: 15
Pass the fun_b() as an argument the name of the calling function.
[ So it will now become - fun_b(String caller) ]

Linux Archive

Last edited by arunmathew1984; 12-20-2008 at 11:25 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine a function's stack size. koodoo Programming 9 06-11-2007 11:40 AM
concerned parent concernwillym Linux - General 3 05-24-2007 07:02 AM
How to know which is the parent shell? anupamsr Linux - Newbie 6 01-20-2007 07:45 AM
How do i kno if i have the linux kernel source installed? ginda Linux - Newbie 1 02-05-2005 09:25 AM
just a command id like to kno thriller Linux - Newbie 2 07-06-2004 01:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration