mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
Fix POSIX backtrace compile
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <px4_log.h>
|
#include <px4_log.h>
|
||||||
|
#ifdef __PX4_POSIX
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
__EXPORT int __px4_log_level_current = PX4_LOG_LEVEL_AT_RUN_TIME;
|
__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" };
|
__EXPORT const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1] = { "INFO", "DEBUG", "WARN", "ERROR", "PANIC" };
|
||||||
|
|
||||||
void px4_backtrace()
|
void px4_backtrace()
|
||||||
{
|
{
|
||||||
|
#ifdef __PX4_POSIX
|
||||||
void *buffer[10];
|
void *buffer[10];
|
||||||
char **callstack;
|
char **callstack;
|
||||||
int bt_size;
|
int bt_size;
|
||||||
@@ -16,11 +19,12 @@ void px4_backtrace()
|
|||||||
bt_size = backtrace(buffer, 10);
|
bt_size = backtrace(buffer, 10);
|
||||||
callstack = backtrace_symbols(buffer, bt_size);
|
callstack = backtrace_symbols(buffer, bt_size);
|
||||||
|
|
||||||
PX4_INFO("Backtrace:", bt_size);
|
PX4_INFO("Backtrace: %d", bt_size);
|
||||||
|
|
||||||
for(idx=0; idx < bt_size; idx++)
|
for (idx = 0; idx < bt_size; idx++) {
|
||||||
PX4_INFO("%s", callstack[idx]);
|
PX4_INFO("%s", callstack[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
free(callstack);
|
free(callstack);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user