fielding 98/10/09 13:53:45
Modified: . debugging.html Log: Add notes about getting a live backtrace. Revision Changes Path 1.4 +54 -2 apache-devsite/debugging.html Index: debugging.html =================================================================== RCS file: /export/home/cvs/apache-devsite/debugging.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- debugging.html 1998/10/09 20:28:59 1.3 +++ debugging.html 1998/10/09 20:53:45 1.4 @@ -20,6 +20,7 @@ <OL> <LI><A HREF="#gdb">Using '<CODE>gdb</CODE>'</A> +<LI><A HREF="#backtrace">Getting a live backtrace</A> </OL> <HR> @@ -152,12 +153,63 @@ <P>If you are debugging a system crash and you have a core file from the crash, then do the following: <PRE> - % gdb httpd -c core - (gdb) where + % <font color=green>gdb httpd -c core</font> + (gdb) <font color=green>where</font> </PRE> and it will (hopefully) print a stack backtrace of where the core dump occurred during processing. <P> + +<HR> + +<P><A NAME="backtrace"><B>Getting a live backtrace</B></A> + +<P>A backtrace will let you know the hierarchy of procedures that +were called to get to a particular point in the process. On some platforms +you can get a live backtrace of any process. + +<P>For SVR4-based variants of Unix, the pstack command for proc can +be used to display a a live backtrace. For example, on Solaris it looks like +<PRE> + % <font color=green>/usr/proc/bin/pstack 10623</font> + 10623: httpd -d /usr/local/apache + ef5b68d8 poll (efffcd08, 0, 3e8) + ef5d21e0 select (0, ef612c28, 0, 0, 3e8, efffcd08) + 288 + 00042574 wait_or_timeout (0, 75000, 75000, 7c3e8, 60f40, 52c00) + 78 + 00044310 standalone_main (5fd68, 75800, 75c00, 75000, 2, 64) + 240 + 000449f4 main (3, efffeee4, efffeef4, 75fe4, 1, 0) + 374 + 000162fc _start (0, 0, 0, 0, 0, 0) + 5c +</PRE> + +<P>Another technique is to use gdb to attach to the running process +and then using "where" to print the backtrace, as in +<PRE> + % <font color=green>gdb httpd 10623</font> + GDB is free software and you are welcome to distribute copies of it + under certain conditions; type "show copying" to see the conditions. + There is absolutely no warranty for GDB; type "show warranty" for details. + GDB 4.16.gnat.1.13 (sparc-sun-solaris2.5), + Copyright 1996 Free Software Foundation, Inc... + + /usr/local/apache/src/10623: No such file or directory. + Attaching to program `/usr/local/apache/src/httpd', process 10623 + Reading symbols from /usr/lib/libsocket.so.1...done. + Reading symbols from /usr/lib/libnsl.so.1...done. + Reading symbols from /usr/lib/libc.so.1...done. + Reading symbols from /usr/lib/libdl.so.1...done. + Reading symbols from /usr/lib/libintl.so.1...done. + Reading symbols from /usr/lib/libmp.so.1...done. + Reading symbols from /usr/lib/libw.so.1...done. + Reading symbols from /usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1...done. + 0xef5b68d8 in () + (gdb) <font color=green>where</font> + #0 0xef5b68d8 in () + #1 0xef5d21e8 in select () + #2 0x4257c in wait_or_timeout (status=0x0) at http_main.c:2357 + #3 0x44318 in standalone_main (argc=392552, argv=0x75800) at http_main.c:4273 + #4 0x449fc in main (argc=3, argv=0xefffeee4) at http_main.c:4534 + (gdb) +</PRE> <HR>