-3

I need to print a call stack in log file in a running program (in C) as I need to check the flow, I have to send traces to other environment and I can't debug, Is there any way to do it in C.

2
  • 2
    You've provided no information here that can be used to help, and asked nothing specific. Without knowing what OS and compiler you're using, there's no information. As you've phrased it, an answer of "Yes, there's a way to do it in C" or "No, there's no way to do it in C" would be acceptable answers, which obviously would not be useful. If you want help here, you need to be much more specific about what you're asking, and provide more information about what environment you're using. The FAQ has some tips on how to ask better questions. Commented Mar 1, 2013 at 3:36
  • Possible duplicate. Commented Mar 1, 2013 at 3:39

1 Answer 1

1

If the platform is linux (and I believe in OSX too), you could use backtrace and backtrace_symbols to achieve what you want.

As per the notes section of backtrace

The symbol names may be unavailable without the use of special linker options. For systems using the GNU linker, it is necessary to use the -rdynamic linker option. Note that names of "static" functions are not exposed, and won't be available in the backtrace.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.