backtrace

Get linux executable load address (__builtin_return_address and addr2line)

笑着哭i 提交于 2019-12-07 19:55:52
问题 I'm writing some code that stores a backtrace for each memory allocation. I'm then writing a list of these to a file for offline analysis. In win32 I use _AddressOfReturnAddress and then manually create the backtrace. Since the address is random for each run I use GetModuleInformation and lpBaseOfDll to get the base address. This works great on x86 without FPO, which is good enough for me. I then load the PDB using win32 API to translate the address to function name. How would I do this on

Django traceback on queries

半腔热情 提交于 2019-12-07 09:55:30
问题 I want a traceback from every query executed during a request, so I can find where they're coming from and reduce the count/complexity. I'm using this excellent snippet of middleware to list and time queries, but I don't know where in the they're coming from. I've poked around in django/db/models/sql/compiler.py but apparent form getting a local version of django and editing that code I can't see how to latch on to queries. Is there a signal I can use? it seems like there isn't a signal on

Get variables in scope at each PHP backtrace level?

冷暖自知 提交于 2019-12-07 01:00:54
问题 Is there a way to view the variables set in each stack frame in a backtrace? I can come pretty close with a combination of debug_backtrace(true) to get the objects, get_object_vars on each object to get $this vars, the args key in each backtrace frame, and get_defined_vars to get globals, but any temporary variables set within a function I can't find a way to retrieve. Here's an example situation: function method1($foo) { $temp = method2($foo + 1); foreach ($temp as $t) { method2($t); } }

Get linux executable load address (__builtin_return_address and addr2line)

[亡魂溺海] 提交于 2019-12-06 10:02:01
I'm writing some code that stores a backtrace for each memory allocation. I'm then writing a list of these to a file for offline analysis. In win32 I use _AddressOfReturnAddress and then manually create the backtrace. Since the address is random for each run I use GetModuleInformation and lpBaseOfDll to get the base address. This works great on x86 without FPO, which is good enough for me. I then load the PDB using win32 API to translate the address to function name. How would I do this on linux? My current approach is to use __builtin_return_address(x) and addr2line offline to get the same

After the Ruby interpreter segfaults, is it possible to get the Ruby backtrace from the corefile?

爷,独闯天下 提交于 2019-12-06 03:31:24
问题 Note: I'm using a segfault that I encountered whilst using the libxml-ruby gem to illustrate the question, but I've since fixed my problem with said gem. What this question is really about is viewing the Ruby backtrace (i.e. the same thing the interpreter prints when Ruby code fails to handle an exception) from gdb with a corefile the interpreter itself encounters a segmentation fault. I'm getting an odd segfault while generating an XML document, of all things: /railsroot/vendor/isolated/ruby

can a program read its own elf section?

你离开我真会死。 提交于 2019-12-06 01:39:20
问题 I would like to use ld's --build-id option in order to add build information to my binary. However, I'm not sure how to make this information available inside the program. Assume I want to write a program that writes a backtrace every time an exception occurs, and a script that parses this information. The script reads the symbol table of the program and searches for the addresses printed in the backtrace (I'm forced to use such a script because the program is statically linked and backtrace

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

和自甴很熟 提交于 2019-12-05 03:27:55
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 like error.log? Thanks In general, you are going to have trouble with this; PHP doesn't provide a

Javascript backtrace

江枫思渺然 提交于 2019-12-05 02:20:42
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 information as a string, which is okay for at-a-glance, but it would be a great help to walk e.stack . Does it

Getting the current stack trace on Mac OS X

送分小仙女□ 提交于 2019-12-04 12:12:55
问题 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/Leopard but it calls dladdr and has the same issue as my own code calling dladdr. Original post: Currently I'm capturing the stack with this code: int BackTrace

OS X kernel panic diagnostics. How to translate backtrace addresses

一曲冷凌霜 提交于 2019-12-04 12:00:51
I'm debugging a driver that cause kernel dump on my mac. It shows long backtrace composed out of series of addresses: panic(cpu 6 caller 0xffffff8004dc9986): trying to interlock destroyed mutex (0xffffff8049deedb0) Backtrace (CPU 6), Frame : Return Address 0xffffff93b1c8bb50 : 0xffffff8004ce5307 0xffffff93b1c8bbd0 : 0xffffff8004dc9986 0xffffff93b1c8bbe0 : 0xffffff8004d099eb 0xffffff93b1c8bc20 : 0xffffff7f85604899 0xffffff93b1c8bc50 : 0xffffff800519776b 0xffffff93b1c8bc90 : 0xffffff80051f336c 0xffffff93b1c8be00 : 0xffffff8005205fb3 0xffffff93b1c8bef0 : 0xffffff80052028a6 0xffffff93b1c8bf60 :