Added a convenience function to dump backtraces for gdb-less debugging

This commit is contained in:
Martin Willi
2012-05-21 12:18:49 +02:00
parent b5341bb07c
commit 32400cd91a
2 changed files with 26 additions and 0 deletions
+17
View File
@@ -248,3 +248,20 @@ backtrace_t *backtrace_create(int skip)
return &this->public;
}
/**
* See header
*/
void backtrace_dump(char *label, FILE *file, bool detailed)
{
backtrace_t *backtrace;
backtrace = backtrace_create(2);
if (label)
{
fprintf(file, "Debug backtrace: %s\n", label);
}
backtrace->log(backtrace, file, detailed);
backtrace->destroy(backtrace);
}
+9
View File
@@ -77,4 +77,13 @@ struct backtrace_t {
*/
backtrace_t *backtrace_create(int skip);
/**
* Create a backtrace, dump it and clean it up.
*
* @param label description to print for this backtrace, or NULL
* @param file FILE to log backtrace to
* @param detailed TRUE to resolve line/file using addr2line (slow)
*/
void backtrace_dump(char *label, FILE *file, bool detailed);
#endif /** BACKTRACE_H_ @}*/