backtrace

Implementing stack backtrace without using ebp

邮差的信 提交于 2019-12-12 04:16:52
问题 How a stack backtrace can be implemented when the compiler is explicitly told not to use ebp as stack frame pointer? 回答1: The answer to this was only ever in comments on the accepted answer on What is the purpose of the EBP frame pointer register?. Modern debuggers can do stack backtraces even in code compiled with -fomit-frame-pointer. That setting is the default in recent gcc. gcc puts the necessary stack-unwind info into a .eh_frame_hdr section. See this blog post for more details. It's

Backtrace inside Signal Handler

孤人 提交于 2019-12-11 12:36:38
问题 I'm trying to following the code from this post to have signal handlers print a backtrace on errors such as floating point and segmentation faults. I'm using seg fault signals as a starting point. Here is the code: #include <cstdlib> //for exit() #include <signal.h> //signal handling #include <execinfo.h> //backtrace, backtrace_symbols and backtrace_fd #include <iostream> #include <string.h> #include <stdio.h> #define TRACE_MSG fprintf(stderr, "TRACE at: %s() [%s:%d]\n", \ __FUNCTION__, _

How to get C++ backtrace on Android

孤者浪人 提交于 2019-12-11 00:53:20
问题 I am developing a game on android using native C++ and NDK(with eclipse) to build it. I found very difficult to debug the native c++ code with eclipse and NDK when it hits a crash, is there any way to get C++ backtrace when programe crashes ? Please advise. 回答1: You can do that with ndk-stack executable that is located in root of NDK. Read the docs about it in docs/NDK-STACK.html file. 来源: https://stackoverflow.com/questions/13924582/how-to-get-c-backtrace-on-android

Local labels in GNU assembler; gdb printing backtrace as though labels are functions

妖精的绣舞 提交于 2019-12-10 21:24:13
问题 Two pieces of example code; first some C++ code calling into assembly: /* test1.cc */ #include <stdio.h> extern "C" void blah(); extern "C" void stuff() { printf( "This is a test\n" ); } int main( int argc, char *argv[] ) { blah(); return 0; } ... then the assembly: .file "test2.s" .text .globl blah, stuff .type blah,@function .type stuff,@function .align 16 blah: /* normal function preamble */ pushl %ebp movl %esp, %ebp label1: call stuff leave retn Built with: as -g --32 test2.s -o test2.o

Return type in demangled member function name

耗尽温柔 提交于 2019-12-10 21:11:42
问题 What is the reason for the g++ abi::__cxa_demangle function to not return the return value for member functions? Here's a working example of this behavior #include <execinfo.h> #include <cxxabi.h> #include <iostream> struct Foo { void operator()() const { constexpr int buf_size = 100; static void *buffer[buf_size]; int nptrs = backtrace(buffer, buf_size); char **strings = backtrace_symbols(buffer, nptrs); for(int i = 0; i < nptrs; ++i) { auto str = std::string(strings[i]); auto first = str

java: printing current backtrace [duplicate]

陌路散爱 提交于 2019-12-10 15:48:29
问题 This question already has answers here : How can I get the current stack trace in Java? (22 answers) Closed 6 years ago . is there a way to add a command in Java to add the current backtrace ? I'm writing a red5 application and the appDisconnect function is being called twice. whenever a user changes room. I want to add a function at the beginning of the appDisconnect function that shows the current backtrace and then I can see what called it. thanks 回答1: You can output the stack trace to the

In MAXIMA, how do I get entire call stack printed?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:38:18
问题 Sorry if this is a novice question, but I couldn't find any documentation or other stackoverflow questions on this. I want to see entire stack trace of all maxima functions called in solving an expression or an equation. I tried trace, backtrace, and debugmode. Looked at different display and print functions, but none worked. Example1: (%i1) is(equal( (a+b)^2, a^2+b^2+2*a*b )); (%o1) true Example2: (%i2) trace(factor); (%o2) [factor] (%i3) trace_options(factor, info); (%o3) [info] (%i4)

How to log all calls to a function in PHP? (mail() function)

冷暖自知 提交于 2019-12-10 03:26:42
问题 I have a dedicated server with tens of virtual hosts. I want to determine what file is calling mail() function and log this globally. I need something like that: [Wed Feb 13 10:42:39 2013] mail() called from /var/www/example1.php on line 70 [Wed Feb 13 10:42:40 2013] mail() called from /var/www/example2.php on line 70 I can't use debug_backtrace() or similar because I can't add this to any PHP file in the server. Can I log all function calls globally in a file like errors are logged to a file

Javascript backtrace

匆匆过客 提交于 2019-12-10 03:26:14
问题 How to I get a backtrace in Javascript? Ideal features: entry function name, or some meaningful identifier for anonymous functions, argument list at each level, line numbers. Can this be done in standard ECMAScript? If not, can it be done in the common web browser dialects? Thanks. Edit -- Thanks for your suggestions. My dialect doesnot support arguments.caller or arguments.callee . I can do this: try { let x = null; x .foo (); } catch (e) { debug (dump (e.stack)); } Which gets me the

Printing full backtrace in c++

对着背影说爱祢 提交于 2019-12-09 16:26:29
问题 I want to dump a backtrace from a C++ program in Linux in a similar format as it is done in gdb. I tried to use the backtrace() and backtrace_symbols() functions for this purpose. These returned function names and offsets. I can use the __cxa_demangle() function to get a readable function name. Is there any way to get the file/line positions too, as it is done by gdb? 回答1: How it's better to invoke gdb from program to print its stacktrace?` Methode #4, shows a way to get filename and line.