mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 03:03:34 +08:00
31 lines
605 B
C
31 lines
605 B
C
#include <stdlib.h>
|
|
#include <px4_log.h>
|
|
#ifdef __PX4_POSIX
|
|
#include <execinfo.h>
|
|
#endif
|
|
|
|
__EXPORT int __px4_log_level_current = PX4_LOG_LEVEL_AT_RUN_TIME;
|
|
|
|
__EXPORT const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1] = { "INFO", "DEBUG", "WARN", "ERROR", "PANIC" };
|
|
|
|
void px4_backtrace()
|
|
{
|
|
#ifdef __PX4_POSIX
|
|
void *buffer[10];
|
|
char **callstack;
|
|
int bt_size;
|
|
int idx;
|
|
|
|
bt_size = backtrace(buffer, 10);
|
|
callstack = backtrace_symbols(buffer, bt_size);
|
|
|
|
PX4_INFO("Backtrace: %d", bt_size);
|
|
|
|
for (idx = 0; idx < bt_size; idx++) {
|
|
PX4_INFO("%s", callstack[idx]);
|
|
}
|
|
|
|
free(callstack);
|
|
#endif
|
|
}
|