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 - #include <stdio.h>
-
-
void __cyg_profile_func_enter( void *, void * ) __attribute__ ((no_instrument_function));
-
void __cyg_profile_func_exit( void *, void * ) __attribute__ ((no_instrument_function));
-
-
FILE *fp = NULL;
-
-
int call_level = 0;
-
-
void *last_fn;
-
-
-
void __cyg_profile_func_enter(void *this_fn, void *call_site)
-
{
-
-
if (fp == NULL) fp = fopen( "trace.txt", "w" );
-
if (fp == NULL) exit(-1);
-
-
if ( this_fn!=last_fn) ++call_level;
-
for (int i=0;i<=call_level;i++) fprintf(fp,"\t");
-
fprintf(fp, "entering %p\n", (int *)this_fn);
-
(void)call_site;
-
last_fn = this_fn;
-
-
}
-
-
-
void __cyg_profile_func_exit(void *this_fn, void *call_site)
-
{
-
--call_level;
-
for (int i=0;i<=call_level;i++) fprintf(fp,"\t");
-
fprintf(fp, "exiting %p\n", (int *)this_fn);
-
(void)call_site;
-
-
}
The code gets compiled and when running I got the following output. - entering 29ff
-
entering 29ff
-
entering 29ff
-
exiting 2a79
-
entering 29ff
-
exiting 2a79
-
entering 29ff
-
exiting 2a79
-
entering 29ff
-
exiting 2a79
-
entering 29ff
-
exiting 2a79
-
entering 29ff
-
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?
5 6044 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 - It is worded in a polite fashion
- 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 - void __cyg_profile_func_enter( void *, void * ) __attribute__ ((no_instrument_function));
-
-
void __cyg_profile_func_enter(void *this_fn, void *call_site)
-
{
-
...
-
}
-
try - void __attribute__ ((no_instrument_function)) __cyg_profile_func_enter(void *this_fn, void *call_site)
-
{
-
...
-
}
-
If this does not work you are going to have to wait for someone who knows more to answer.
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?
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
by: Mikhail Teterin |
last post by:
Hello!
Consider the following simple accessor function:
typedef struct {
int i;
char name;
} MY_TYPE;
const char *
|
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...
|
by: Marc Thrun |
last post by:
Hello,
I've got a few questions:
1) Given the two structs
struct A {
int x;
};
and
|
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....
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |