Pages

May 13, 2011

GNU/GDB World




Automake
Automake helps to create portable Makefile
http://sources.redhat.com/automake/
Profiling
Execution time of all functions in a code can be generated.
http://sourceware.org/binutils/docs/gprof/
BinUtils
  • ar: Create, modify, and extract from archives
  • nm: List symbols from object files
  • objcopy: Copy and translate object files
  • objdump: Display information from object files
  • ranlib: Generate index to archive contents
  • readelf: Display the contents of ELF format files
  • size: List section sizes and total size
  • strings: List printable strings from files
  • strip: Discard symbols
  • elfedit: Update the ELF header of ELF files
  • c++filt: Filter to demangle encoded C++ symbols
  • cxxfilt: MS-DOS name for c++filt
  • addr2line: Convert addresses to file and line
  • nlmconv: Converts object code into an NLM
  • windres: Manipulate Windows resources
  • windmc: Generator for Windows message resources
  • dlltool: Create files needed to build and use DLLs
Check out seperate section on binutils

GDB:
Ensure compilation is done with -g flag ,which will generate symbol table to run gdb.Usually it wont be included by default as the image size would become too high

gcc app.c –g –o app –l(libs to be linked with you application)

Start GDB :
gdb
Most Used GDB Commands:
b [ file:]function set breakpoint at function
c continue running your program
n next line, stepping over function calls
s next line, stepping into function call
watch expr set a watchpoint for expression expr

info break show de ned breakpoints
info watch show de ned watchpoints

examine memory at address expr :
>x /100 pointername
100 represents units
>x /100xb pointername

Enable CoreDump generation
On Shell:
"ulimit -c unlimited"
Once core file is created, you can use it with typing "gdb -c core.xxx "
and check backtrace
Quit from GDB
quit



No comments: