473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

instrument functions in gcc - not proper address getting printed

5
Hi,


The problem is:

I am trying to get the function call tree by using the profiling functions __cyg_profile_func_enter and __cyg_profile_func_exit. But it is printing the address of these fns (__cyg_profile_func_enter and __cyg_profile_func_exit) instead of the other functions.

Please see the code and suggest a solution.

This is running on zdcc, a gcc derivative on Windows.

The code is

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. void __cyg_profile_func_enter( void *, void * )    __attribute__ ((no_instrument_function));
  4. void __cyg_profile_func_exit( void *, void * )    __attribute__ ((no_instrument_function));
  5.  
  6. FILE *fp = NULL;
  7.  
  8. int call_level = 0;
  9.  
  10. void *last_fn;
  11.  
  12.  
  13. void __cyg_profile_func_enter(void *this_fn, void *call_site)
  14. {
  15.  
  16.  if (fp == NULL) fp = fopen( "trace.txt", "w" ); 
  17.         if (fp == NULL) exit(-1); 
  18.  
  19.         if ( this_fn!=last_fn) ++call_level; 
  20.         for (int i=0;i<=call_level;i++) fprintf(fp,"\t"); 
  21.         fprintf(fp,  "entering %p\n", (int *)this_fn); 
  22.         (void)call_site; 
  23.         last_fn = this_fn; 
  24.  
  25.  }
  26.  
  27.  
  28. void __cyg_profile_func_exit(void *this_fn, void *call_site) 
  29.         --call_level; 
  30.         for (int i=0;i<=call_level;i++) fprintf(fp,"\t"); 
  31.         fprintf(fp, "exiting %p\n", (int *)this_fn); 
  32.         (void)call_site; 
  33.  
The code gets compiled and when running I got the following output.
Expand|Select|Wrap|Line Numbers
  1.         entering 29ff
  2.         entering 29ff
  3.         entering 29ff
  4.     exiting 2a79
  5.     entering 29ff
  6. exiting 2a79
  7. entering 29ff
  8. exiting 2a79
  9. entering 29ff
  10. exiting 2a79
  11. entering 29ff
  12. exiting 2a79
  13. entering 29ff
  14. exiting 2a79
I checked the addresses and found out that 29ff corresponds to __cyg_profile_func_enter and 2a79 corresponds to __cyg_profile_func_exit.

Why is this happening? Why is the proper address not printed?
Nov 6 '08 #1
5 6044
myra
5
Somebody please answer!
Nov 6 '08 #2
Banfa
9,065 Expert Mod 8TB
This is an international forum, waiting just under 2 hours and then demanding a reply is not going to work. The person who knows the answer to your question may be in a different time zone to you and may have just gone to sleep.

On this forum it is only consider OK to post this kind of message if
  1. It is worded in a polite fashion
  2. At least 24 hours have passed

I have no experience with you compiler but a quick search of the web suggests that you should try declaring your functions in this manor, instead of

Expand|Select|Wrap|Line Numbers
  1. void __cyg_profile_func_enter( void *, void * )    __attribute__ ((no_instrument_function));
  2.  
  3. void __cyg_profile_func_enter(void *this_fn, void *call_site)
  4. {
  5.    ...
  6. }
  7.  
try

Expand|Select|Wrap|Line Numbers
  1. void __attribute__ ((no_instrument_function)) __cyg_profile_func_enter(void *this_fn, void *call_site)
  2. {
  3.    ...
  4. }
  5.  
If this does not work you are going to have to wait for someone who knows more to answer.
Nov 6 '08 #3
myra
5
Hi,

Sorry. That was not demanding of an answer, but the tone of exasperation because I was under some pressure to finish it under a particular time.

Will not repeat it.

Thanks for the suggestion, but it also gives the same answer.

Any other idea of what might be wrong?
Nov 7 '08 #4
Banfa
9,065 Expert Mod 8TB
OK so no-one else has replied, this is a general forum so it is possible no has experience with your compiler (or that bit of it) you may what to try finding a forum specific to your compiler or if there isn't one a GCC specific forum (which I am sure must exist somewhere).

BTW did you mean zdcc or did you mean sdcc?
Nov 7 '08 #5
myra
5
It is zdcc. It is specific for a zsp chips that were developed by LSI. Something called sdcc is also there for some other dsps of them.

Well, I will see if i can find the info in some Gcc forum out there.
Nov 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

59
by: Haines Brown | last post by:
I've not had a clear definition in my mind of "citation," and so have avoided it. For example, if I suggest that the reputation of the New York Times has suffered, is that a citation? I suppose...
12
by: johny smith | last post by:
I am trying to figure out a way to print the address of what called a certain function once inside the function. I am assuming that this information is on the stack somewhere. But can someone...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
15
by: Marc Thrun | last post by:
Hello, I've got a few questions: 1) Given the two structs struct A { int x; }; and
7
by: victorsk | last post by:
Hello, I have a dll which I compiled in VB. Now I would like to use this dll in MapBasic program. However, I keep getting an error saying that the function which I am calling cannong be found....
47
by: Albert | last post by:
So structures are useful to group variables, so you can to refer to a collection as a single entity. Wouldn't it be useful to also have the ability to collect variable and functions? Ask K&R...
3
by: lotus | last post by:
Hi all. I want to control two different instrtument but have simliar functionality. Acually the fisrt one is controlled by using serial communication, and the other is controlled by LAN...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.