Accessing thread stack?

P

pelakh

I have a method that logs on entry (based on a flag), and I would like
to be able to identify the caller in the trace. Now, I can use
Thread.getStackTrace() to get the static thread stack, from which I
can get the invoking class and method. However, I would like to get
hold of the 'this' object reference of the immediate parent stack
frame, so that I can identify the instance of the caller. Is there a
way to do this? The debugging interface seems written to access a
different JVM, and I can't see a way to put it to use.

This code does not have to be very efficient, as it will only be
turned on rarely in fault isolation. Any help is greatly appreciated.
 
S

SadRed

I have a method that logs on entry (based on a flag), and I would like
to be able to identify the caller in the trace. Now, I can use
Thread.getStackTrace() to get the static thread stack, from which I
can get the invoking class and method. However, I would like to get
hold of the 'this' object reference of the immediate parent stack
frame, so that I can identify the instance of the caller. Is there a
way to do this? The debugging interface seems written to access a
different JVM, and I can't see a way to put it to use.

This code does not have to be very efficient, as it will only be
turned on rarely in fault isolation. Any help is greatly appreciated.

If I don't mention very special debugging facilities which I do not
know in their details, the plain default JVM or running objects does
not have names of object references nor other names used in the source
code. Names are only handles for compiler to do its work. In thread
dump gotten from Ctrl\ or CtrlBrk, we only see hex address values.
 
L

Lew

SadRed said:
If I don't mention very special debugging facilities which I do not
know in their details, the plain default JVM or running objects does
not have names of object references nor other names used in the source
code. Names are only handles for compiler to do its work. In thread
dump gotten from Ctrl\ or CtrlBrk, we only see hex address values.

Huh, that's funny, you don't see class names and the like? Maybe the "-g"
compilation option would help.

-- Lew
 
S

SadRed

Huh, that's funny, you don't see class names and the like? Maybe the "-g"
compilation option would help.

-- Lew

OP is not talking about class name and not the debugger
information. He just wants to see object reference names on stack
trace.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top