所以我们试图在我们的 c++ 应用程序中使用向后 cpp打印堆栈跟踪。特别是我们正在使用信号处理程序来捕获错误并打印它们。 注意:使用llibdw获取详细堆栈
在 x86_64 上运行良好,但无法在 arm64 nvidia-jetson-nano 上打印完整的堆栈跟踪。
在 x86_64 上运行示例 bracktrace_test:
$ g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ uname --operating-system --kernel-name --kernel-release --hardware-platform --processor
Linux 4.15.0-65-generic x86_64 x86_64 GNU/Linux
$ g++ -g -rdynamic backward.hpp backtrace_test.cpp -o backtrace_test -ldw
$ ./backtrace_test
在 nano arm64 上运行相同的示例 bracktrace_test:
$ g++ --version
g++ (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ uname --operating-system --kernel-name --kernel-release --hardware-platform --processor
Linux 4.9.140-tegra aarch64 aarch64 GNU/Linux
$ g++ -g -rdynamic -funwind-tables -fasynchronous-unwind-tables backward.hpp backtrace_test.cpp -o backtrace_test -ldw
$ ./backtrace_test
回溯测试代码:
#define BACKWARD_HAS_DW 1
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdexcept>
#include "backward.hpp"
backward::SignalHandling sh;
void myfunc(int ncalls)
{
throw std::invalid_argument( "sample invalid exception");
}
int main(int argc, char *argv[])
{
myfunc();
exit(EXIT_SUCCESS);
}
问题跟踪:问题