backtrace

Getting the current stack trace on Mac OS X

I'm trying to work out how to store and then print the current stack in my C++ apps on Mac OS X. The main problem seems to be getting dladdr to return the right symbol when given an address inside the main executable. I suspect that the issue is actually a compile option, but I'm not sure. I have tried the backtrace code from Darwin/Leo...

Is there a cheaper way to find the depth of the call stack than using backtrace()?

My logging code uses the return value of backtrace() to determine the current stack depth (for pretty printing purposes), but I can see from profiling that this is a pretty expensive call. I don't suppose there's a cheaper way of doing this? Note that I don't care about the frame addresses, just how many of them there are. edit: These...

How to extract debugging information from a crash

hello, If my C++ app crashes on Windows I want to send useful debugging information to our server. On Linux I would use the GNU backtrace() function - is there an equivalent for Windows? Also, is there a way to extract useful debugging information after a program has crashed? Or only from within the process? Richard (Advice along the...

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

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? ...

Strange backtrace - where is the error?

Hi! I'm developing an image processing application in C++. I've seen a lot of compiler errors and backtraces, but this one is new to me. #0 0xb80c5430 in __kernel_vsyscall () #1 0xb7d1b6d0 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0xb7d1d098 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0xb7d5924d in ?? () from /lib/tls/...

Generating C++ BackTraces in OS/X (10.5.7)

I've been utilizing backtrace and backtrace_symbols to generate programmatic stack traces for the purposes of logging/diagnosis. It seems to roughly work, however, I'm getting a little bit of mangling and there are no accompanying file/line numbers associated with each function invocation (as I'd expect within a gdb bt call or something...

Is there a gcc macro for determining that frame pointers are not eliminated?

When -fomit-frame-pointer is used (automatic for various -O settings), performing a backtrace is problematic. I am wondering if there is a way of determining at compile time that the code is compiled with this switch? In that case, I could put in an #ifndef to guard against backtracing when ill-advised. Is any macro set when this -fom...

Switching between multiple stacks in gdb 6.3

Hello! There are two stacks in the program: one is created by OS and the second is created by program itself to run some code with it. When the program crashes in the second stack, I want to switch to the main stack in gdb and see the backtrace. Is it possible? I tried to save the rsp to a variable and change it after the crash, but th...

Where do I use BackTrace calls on the Mac

I want to get a BackTrace from my crashing C++ Mac application however I am new to the Mac and am not sure how best to go about it. I found a question on stackoverflow that details its usage: getting the current stack trace on mac os x However my problem is that I do not see where the code is meant to live? Does it go in the main.cpp...

Is there a C equivalent for Perl's Carp module?

In some projects I've done in C, I've liked using the following macros which work similar to Perl's warn and die subroutines: #include <stdio.h> #include <stdlib.h> #define warn(...) \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, " at %s line %d\n", __FILE__, __LINE__) #define die(...) \ warn(__VA_ARGS__); \ exit(0x...

Visual C# backtrace: how to know where [external code] resides?

I am using visual c# to debug a large c# project. The project is very large and only some of the pdbs are build by myself. I can build all the pdb however it's very time consuming. I am debugging a backtrace but a part of the trace is marked with [External Code]. I know some pdb is missing, but how can I know which DLL the external code...

Thread stack backtraces when program running under valgrind is interrupted

I have a server program, which doesn't have a very clean/graceful shutdown (not supposed to terminate in general). When tracing memory leaks, I run it under valgrind, but finally have to kill the process by a signal (^C). Generally I try to terminate the process when the ambiance is quiet but still then some threads might have been busy ...

PHP: Show user custom error, inside body

I am wanting to throw custom errors in many places in some interfaces that I am building. Just using an echo inside my function places that echoed code above the tag in my page. So, I built a custom function to handle errors and give me a backtrace, but again, it prints above the in my page. Here is the function I am using: functio...

GDB backtrace does not show the function names

I compiled my library (specifically protbuf-2.3.0) using -g -O0 on a SunOS 5.10. A sample line in the make log is this: /bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -pthreads -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -g -O0 -MT text_format.lo -MD -MP -MF .deps/text_for...

Automate gdb: show backtrace every 10 ms.

Hello I want to write a script for gdb, which will save backtrace (stack) of process every 10 ms. How can I do this? It can be smth like call graph profiling for 'penniless' (for people, who can't use any sort of advanced profiler). Yes, there are a lot of advanced profilers. For popular CPUs and for popular OSes. Shark is very impres...

Xcode debugger warning: Couldn't find minimal bounds for "_sigtramp" - backtraces may be unreliable

What does this means? Seems to appear in the console occasionally when I run with breakpoints on in the debugger. warning: Couldn't find minimal bounds for "_sigtramp" - backtraces may be unreliable ...

Any porting available of backtrace for uclibc?

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)? ...

Is it normal for C++ static initialization to appear twice in the same backtrace?

I'm trying to debug a C++ program compiled with GCC that freezes at startup. GCC mutex protects function's static local variables, and it appears that waiting to acquire such a lock is why it freezes. How this happens is rather confusing. First module A's static initialization occurs (there are __static_init functions GCC invokes that ar...

How to force Google Chrome to show backtrace on exception?

Is it possible (using plugin or maybe some config option) to make javascript error console to show error backtrace? ...

How to change the default behavior of overwriting when GCC -fstack-protector-all is set?

I would like to use the GCC -fstack-protector-all option on release mode. The main issue is that when there is an override a core is built. I would like to plug something that will just dump the stack and let the program continue. Is there a way to do that? ...