backtrace

Getting the backtrace from the catch block

流过昼夜 提交于 2019-11-28 08:24:32
I am using backtrace to get the information from where the exception is thrown. In the constructor of my exception, I am storing the backtrace in a std::string, and in the catch block for exceptions of this type, I am printing this backtrace. But I was wondering, is it possible to somehow get the same backtrace in the catch block for other exception types? I don't think so. When executons stops in catch block the stack is unwound, and all that has happened before is not in stack anymore. You might be interested in a Boost library under development: Portable Backtrace . Example: #include <boost

How to unwind the stack to get backtrace for the specified stack pointer (SP)?

可紊 提交于 2019-11-28 07:18:45
I'm writing this for Android (ARM only), but I believe the principle is the same for generic Linux as well. I'm trying to capture the stack trace from within the signal handler, so that I can log it when my app crashes. This is what I've come up with using <unwind.h> . Initialization: struct sigaction signalhandlerDescriptor; memset(&signalhandlerDescriptor, 0, sizeof(signalhandlerDescriptor)); signalhandlerDescriptor.sa_flags = SA_SIGINFO; signalhandlerDescriptor._u._sa_sigaction = signalHandler; sigaction(SIGSEGV, &signalhandlerDescriptor, 0); The code itself: struct BacktraceState { void**

StackWalk64 on Windows - Get symbol name

故事扮演 提交于 2019-11-27 23:03:38
Alright, second question on SO in one day. Looks like Windows programming makes me happy... : S I'm currently trying to get the function call stack on a Win32 executable. This morning, I've also asked a question about this: Win32 - Backtrace from C code Now, I'm pretty sure that the StackWalk64 function is the key for this. I've read some articles on how to use it, as well as the MS documentation. It actually displays frames on my test program, so it kinda work... The problem is that I'm not able to retrieve the symbol name from the stack informations. I'm using the SymGetSymFromAddr64

Any porting available of backtrace for uclibc?

浪尽此生 提交于 2019-11-27 21:51:05
问题 We are running the uclibc linux on ARM 9. The problem is uclibc doesn't support backtrace. When a core dump happens, I cannot grab the call stack. Does anyone have a good solution for that? For example, an existing porting of backtrace for uclibc, or any good method to grab the call stack when a core dump happens (uclibc+ARM+Linux)? 回答1: Update: It seems that a patch was created to support backtrace() on uclibc for x86 and ARM (XScale) and it makes use of the __libc_stack_end symbol. Original

How do I get the backtrace for all the threads in GDB?

﹥>﹥吖頭↗ 提交于 2019-11-27 09:20:11
问题 Is there an equivalent command in GDB to that of WinDbg's "!process 0 7"? I want to extract all the threads in a dump file along with their backtraces in GDB. "info threads" doesn't output the stack traces. So, is there a command that does? 回答1: Generally, the backtrace is used to get the stack of the current thread, but if there is a necessity to get the stack trace of all the threads, use the following command. thread apply all bt 回答2: Is there a command that does? thread apply all where 来源

Getting a backtrace of other thread

泪湿孤枕 提交于 2019-11-27 04:38:43
In Linux, to get a backtrace you can use backtrace() library call, but it only returns backtrace of current thread. Is there any way to get a backtrace of some other thread, assuming I know it's TID (or pthread_t) and I can guarantee it sleeps? It seems that libunwind (http://www.nongnu.org/libunwind/) project can help. The problem is that it is not supported by CentOS, so I prefer not to use it. Any other ideas? Thanks. Signal Handling with the help of backtrace can solve your purpose. I mean if you have a PID of the Thread, you can raise a signal for that thread. and in the handler you can

How to make backtrace()/backtrace_symbols() print the function names?

霸气de小男生 提交于 2019-11-27 02:39:31
The Linux specific backtrace() and backtrace_symbols() allows you to produce a call trace of the program. However, it only prints function addresses, not their names for my program. How can I make them print the function names as well ? I've tried compiling the program with -g as well as -ggdb . The test case below just prints this: BACKTRACE ------------ ./a.out() [0x8048616] ./a.out() [0x8048623] /lib/libc.so.6(__libc_start_main+0xf3) [0x4a937413] ./a.out() [0x8048421] ---------------------- I'd want the first 2 items to also show the function names, foo and main Code: #include <execinfo.h>

Getting the backtrace from the catch block

浪尽此生 提交于 2019-11-27 02:18:01
问题 I am using backtrace to get the information from where the exception is thrown. In the constructor of my exception, I am storing the backtrace in a std::string, and in the catch block for exceptions of this type, I am printing this backtrace. But I was wondering, is it possible to somehow get the same backtrace in the catch block for other exception types? 回答1: I don't think so. When executons stops in catch block the stack is unwound, and all that has happened before is not in stack anymore.

How can I get PHP to produce a backtrace upon errors?

早过忘川 提交于 2019-11-27 00:21:41
Trying to debug PHP using its default current-line-only error messages is horrible. How can I get PHP to produce a backtrace (stack trace) when errors are produced? Xdebug prints a backtrace table on errors, and you don't have to write any PHP code to implement it. Downside is you have to install it as a PHP extension. My script for installing an error handler that produces a backtrace: <?php function process_error_backtrace($errno, $errstr, $errfile, $errline, $errcontext) { if(!(error_reporting() & $errno)) return; switch($errno) { case E_WARNING : case E_USER_WARNING : case E_STRICT : case

Win32 - Backtrace from C code

空扰寡人 提交于 2019-11-26 23:52:51
I'm currently looking for a way to get backtrace information under Windows, from C code (no C++). I'm building a cross-platform C library, with reference-counting memory management. It also have an integrated memory debugger that provides informations about memory mistakes ( XEOS C Foundation Library ). When a fault occurs, the debugger is launched, providing information about the fault, and the memory record involved. On Linux or Mac OS X, I can look for execinfo.h in order to use the backtrace function, so I can display additional infos about the memory fault. I'm looking for the same thing