1

For a reason I need to find, a C++ application looks being stuck in a docker container.
I did a docker exec -it a_template_cpp bash and entered into it.

I know the top and pmap commands, and also that I can generate a map file at linkage time to help me.

But I don't know the Linux command(s) that can show me the address my program is currently executing at the moment I'm asking. What's the value of the program counter register at that moment.

What's the command I should execute to know it?

1
  • I don't think in the age of dynamic linking and address space randomization, knowing the address alone will be of much use; after all, a process on Linux is different then a program running on real-mode MS-DOS! As Stephen's answer says, you'll want a debugger – and that debugger doesn't need to run from within the same container's namespaces; it could. Commented Jul 5 at 14:19

1 Answer 1

5

In practice, the only way to see what a process is currently doing is to attach to it with a debugger.

It used to be possible to see the instruction pointer of a process in the 30th field of /proc/<pid>/stat, if you have sufficient privileges to ptrace a process (strictly speaking, PTRACE_MODE_ATTACH_FSCREDS and PTRACE_MODE_NOAUDIT):

awk '{ print $30 }' /proc/$$/stat

This is still documented in man 5 proc or man 5 proc_pid_stat but it has been disabled for a while, unless the process is dumping core.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .