LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   View inside a process? (http://www.linuxquestions.org/questions/linux-general-1/view-inside-a-process-594639/)

xeon123 10-25-2007 06:12 PM

View inside a process?
 
Hi,

Is there any program that allow us to view inside a process.

For example, if I'm debugging a program, and in a certain moment I would like to see how my stack is, what registers I'm using, which file descriptors I've open, etc...

And, is it possible programatically?

Thanks,

PatrickNew 10-25-2007 11:18 PM

Most if not all of that can be done with gdb. I assume that by "programmatically" you mean, is there a language binding? Within the program, sure there's ways of displaying the current state - printf. I'm not sure I understand that last question, but definitely look up gdb.

zulfilee 10-26-2007 01:46 AM

Gdb should do that.

Just open the process exe with GDB and once inside GDB attach the process with the process pid.
$ gdb file.exe
gdb > attach <pid_of_file.exe>


If you want to see the system calls the process is making while running try this

$ strace -p <pid>

This will giv a cool output of the system calls the process is making,files being opened,sockets being connected etc.

$ ltrace -p <pid>

Will give info on library call the process makes.[like fprint,printf,etc...]

$ lsof | grep processname

Will give list of all files opened by that process.


/proc/pid/
Will have some info on process like the segments [code,data,stack] info , env info of that process.


All times are GMT -5. The time now is 09:28 PM.