1

From inside C++ application, I want to call gdb to print stack trace of the current thread only.

This can be used to get stack trace for assert like macro from inside application. Gdb gives detailed stack trace which is highly complicated to achive "by hand":

How it can be done?

dimba
  • 26,717
  • 34
  • 141
  • 196
  • Usually it's done the other way around: tell gdb where and on what conditions to break, then get the call stack from gdb. Can you expand your question to say what you actually want to achieve? – Nathan Kidd Jan 28 '11 at 15:51
  • What do you need that glibc's backtrace(3) doesn't provide? – ninjalj Jan 29 '11 at 11:31
  • @ninjalj file name, line number, symbol demangling at least. gdb will also list arguments to functions. backtrace(8) also forces you to compile with -rdynamic, when gdb IMHO extracts data from debug information – dimba Jan 29 '11 at 12:41

0 Answers0