Re: Question about C Programming.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 5, 2009 at 12:49 PM, Ravi Sankar <ravisankar.g@xxxxxxxxx> wrote:
> Hi,
>
> I would like to know how can I get the function name of the caller in c?.

I don't know how to get the function name, but you can get the return
address in the caller function using "__builtin_return_address()".
Google for it and you would get some idea. Inorder to get function
name from address, probably you will have to do some translation, just
like debuggers do.

Thanks -
Manish


>
> Like
> // c code
>
> void foo(void)
> {
>
> bar();
> }
>
> void bar(void)
> {
>   // who is my caller?
> }
>
> I don't want to change the caller function code to add arguments etc.
> Even  I don't have access to the caller function source code.
>
> Thanks for your help.
>
> --
> --,
> BR,
> Ravi Sankar Guntur.
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux