P. 1
Linux Certification Bible

Linux Certification Bible


|Views: 2.327|Likes:
Publicado porMarcelo

More info:

Published by: Marcelo on Dec 18, 2008
Direitos Autorais:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





By using the gdb(GNU Debugger) program, you can analyze your program’s
coredump files and also debug the application while it is actually running.
Youcaninvoke the program on a core file by issuing the following command:

gdb -c core

This command launches the gdbprogram on a core file called “core,” and displays
the name of the program that created the core file and the signal on which the pro-
gram terminated.

The following is an example of the output of the gdbcommand on a core file from
the Apache Web server:

Core was generated by `httpd’.
Program terminated with signal 11, Segmentation fault.
gdb> bt
#0 0x5c8b1674 in ?? ()
#1 0x4018df03 in zend_hash_add_or_update (ht=0x143280,
arKey=0x4018aa3d “stdclass”, nKeyLength=9, pData=0x40253000,
nDataSize=128, pDest=0x0, flag=2) at zend_hash.c:284
#2 0x4018ab45 in register_standard_class () at zend.c:243
#3 0x4018ad06 in zend_startup (utility_functions=0xefbfd770, extensions=0x0,
start_builtin_functions=1) at zend.c:371
#4 0x401a548e in php_module_startup (sf=0xc8000) at main.c:807
#5 0x401a26dc in php_apache_startup (sapi_module=0xc8000) at mod_php4.c:270
#6 0x401a313c in php_init_handler (s=0xf6034, p=0xf600c) at mod_php4.c:694
#7 0x3d5d9 in ap_init_modules ()
#8 0x4b2b9 in main ()

The average user or system administrator may never need to use this information,
but it is very valuable to programmers. The following is a list of commands that can
be used in gdb.

✦quit: Terminate gdb

✦where: Show the call stack where execution has been halted

✦p: Print the value of a variable or expression

184881-6 ch12.F 11/12/01 8:31 AM Page 392


Chapter 12 ✦Linux Disk and System Management

✦up: Refocus gdbup one function in the call stack

✦down: Refocus gdbdown one function in the call stack

✦help: Get help for a command

✦run: Start execution of a program

✦b: Set a breakpoint at a line or function

✦clear: Clear a breakpoint from a line or function

✦commands: Set commands to be executed when a breakpoint is hit

✦s: Execute one more line (possibly in a subroutine)

✦n: Execute to next line of current function

✦continue: Continue execution to next breakpoint

✦watch: Watch for a change in an expression (this can be slow)

✦list: List source lines of a function

You dont need to know the gdbtool in detail, but you do need to know its func-
tion, and when to delete a core dump or forward it to a programmer.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->