Skip to contentSkip to conversation

Debugging a Process ...

DISCUSSION Ivan Deras 4 participants 5 messages Oct 24, 2002 – Oct 31, 2002

lore
Share & tools
lore

Ivan Deras

author
#0 lore raw

I want to know how to debug a process in Linux, i know that in Windows i can use Windows-API to attach a debugger process to the debugged process, but in Linux i don't know ...

#1 lore raw

* find out PID of the process (man pidof)

* call gdb with name of the program you want to debug as an argument

* in gdb type `attach PID'

Quoted 3 lines · Ivan Deras

I want to know how to debug a process in Linux, i know that in Windows i can use Windows-API to attach a debugger process to the debugged process, but in Linux i don't know ...

#2 lore raw
In reply to Ivan Deras
Quoted 3 lines

I want to know how to debug a process in Linux, i know that in Windows i can use Windows-API to attach a debugger process to the debugged process, but in Linux i don't know ...

If you want to attach an existing debugger, look at the documentation for that debugger (in gdb, it's ``gdb <program_name> <pid of program>''). If you're thinking of writing your own, have a look at man ptrace. This isn't the clearest of documents, so you may want to have a look at the source to a few programs which use it, like gdb, strace, or ltrace, before starting on your own.

Steven Smith,
[email protected].

author
#3 lore raw
In reply to Ivan Deras

This is very helpful for me ... Thanks ...

Quoted 14 lines · Steven Smith
Quoted 3 lines

I want to know how to debug a process in Linux, i know that in Windows i can use Windows-API to attach a debugger process to the debugged process, but in Linux i don't know ...

If you want to attach an existing debugger, look at the documentation for that debugger (in gdb, it's ``gdb <program_name> <pid of program>''). If you're thinking of writing your own, have a look at man ptrace. This isn't the clearest of documents, so you may want to have a look at the source to a few programs which use it, like gdb, strace, or ltrace, before starting on your own.

Steven Smith,
[email protected].

#4 lore raw
In reply to Ivan Deras
Quoted 1 line

* in gdb type `attach PID'

You might find the "ddd" will provide a nice graphical interface to gdb. I've used it frequently, and am very pleased with it. All gdb commands should work within it.

Signature · 5 lines
_________________________________________
Nat Ersoz             [email protected]  -o) 
Myrio Corporation     Phone: 425.897.7278  /\\
3500 Carillon Point   Cell:  425.417.5182 _\_V
Kirkland, WA 98033    Fax:   425.897.5600