Tuesday, 14 June 2011

Debugging a Linux process

To debug a compiled C process in RedHat Linux. You will need to install devel and debuginfo of the package you are insterested in. For example to debug python interpreter you will need to install python, python-debuginfo and python-devel packages. Then find the stuck process PID via PS and then:

# gdp --pid <pid num>

Then you will be in gdp prompt. You then can use following commands:

>continue        will continue execution until you press Ctrl-C
>bt                  show backtrace
>next               execute next line
>list                 show source code
>step               step into child function
>finish              execute until finish the current function
>show help      show extra commands that can be used with show
>print <var>    prints content of a variable

Another good tool for debugging is Valgrind

No comments:

Post a Comment