0

Can anyone guide me how to build a call tree of a code of c If any one can suggest me any opensource tool I have used func_tree but it is not displaying the macro function call and function under macros...?????

Adrian
  • 5,603
  • 8
  • 53
  • 85

1 Answers1

0

Just before you compile the code, a C pre-processor expands all of your macros. This means that even the compiler doesn't get to see the macro definitions. Unfortunately for you, that means there is no possibility of including macros in your function call tracing.

Depending on how well you know your runtime environment, sometimes you can back-calculate where the stack trace frames are from your current position in the stack. Unfortunately, it is often a trick where the exact details only works for one environment. You need to re-perform the discovery of stack semantics for each environment. Here is project that performs such a technique, but it is not possible to know if it will be very useful to you.

Note that such a technique will likely also not display any compiler in-lining, as the function call gets rewritten to not exist when the compiler places the equivalent functional code into the calling block.

If you can't find a similar project with Google for your particular environment, odds are you'll have to write one yourself. If that is beyond you, you'll need to investigate whether it is worth learning the low level details of your environment, or if it is just better to perform more robust logging.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138