views:

562

answers:

2

I am trying to use "strace -p" to attach to an already running JBoss process. JBoss is using the 1.5.0_15 Java JDK. Unfortunately, this doesn't work - I only get a single futex() result:

# strace -p 3388
Process 3388 attached - interrupt to quit
[ Process PID=3388 runs in 32 bit mode. ]
futex(0x8f18f7c, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>

Strace works for all other programs but not JBoss. It appears to work fine when I launch the process through strace. It just doesn't work when I try to attach to an already running process.

I'm using 64-bit Linux 2.6.18 with a 32 bit Java JDK (RedHat Enterprise Linux 5.3 if it matters).

Update #1:

I did try running it with "-d", but the output doesn't appear to be any more insightful, at least to me:


[root@]# strace -d -e verbose=all -p 3388
Process 3388 attached - interrupt to quit
 [wait(0x137f) = 3388]
pid 3388 stopped, [SIGSTOP]
 [wait(0x57f) = 3388]
pid 3388 stopped, [SIGTRAP]
[ Process PID=3388 runs in 32 bit mode. ]
futex(0x8f18f7c, FUTEX_WAIT_PRIVATE, 1, NULL
A: 

Have you tried using strace -d -p NNN to get some strace debugging output?

Maybe add a -e verbose?

Has strace been installed setuid to root so you can look into any process?

Rob Wells
I did try running it with "-d", as noted in my edit #1 above (I see that formatting doesn't work as I expected in this section)
curious_george
+3  A: 

If there's multiple threads within that process, you'll need to give strace multiple -p options, specifying the ID of each one. It looks like you're successfully tracing the original parent thread, and it's doing nothing but waiting for some other threads to finish.

(The reason it works when you start the command from strace is that by default, strace picks up the new child processes created and traces them, too).

caf
I'm actually tracing the child thread. Although I did try stracing the parent thread and the child thread, but I didn't get any farther. The parent thread only displayed a wait4() call, as should be expected.
curious_george
Are you *sure* there's only one child thread? That sounds suspiciously few for a `java` process (note that individual threads don't show up in `ps` by default). Take a look in `/proc/<pid>/task/`.
caf
(Or try `ps -eLm`)
caf
ps -eLm showed me the error of my ways. I didn't think any child processes were getting created when I inspected the output of "ps -ef | grep java". "ps -eLm" showed me there were more child processes. Indeed, "strace -f -p PID" was what I needed. I kept on getting "Connection timed out" messages, which I thought was incorrect output from random threads. It was actually correct output from the child threads!
curious_george