[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    =?UTF-8?Q?Re=3A_inspect_a_thread=E2=80=99s_stack?=
From:       Mario Torre <neugens () redhat ! com>
Date:       2018-04-10 8:35:57
Message-ID: CAJwKKmbkY9wKiQW-vPWJ4OF8u7Yw5YgogN17exPjzy5odGGA5A () mail ! gmail ! com
[Download RAW message or body]

On Tue, Apr 10, 2018 at 9:26 AM, Pietro Paolini
<Pietro.Paolini@alfasystems.com> wrote:
> > 
> > I think the conversation will shift a bit if you explain what you mean with:
> > 
> > "// inspect the frames of that thread doing any needed business with them"
> > 
> > What exactly do you have in mind? Do you want to change the stack in some
> > way?
> 
> I would like to inspect the variable's name/value on the stack at a specific point \
> in time for diagnostic purposes, I don't want to change their value. I don't think \
> that should be allowed anyway :-) 
> > 
> > Because, depending on what you want, Andrew's comment on:
> > ThreadMXBean.getThreadInfo(id).getStackTrace() ?
> > 
> > 
> > seems reasonable to me :)
> 
> I had a look to the API's Javadoc, my understanding is that I could to get to the \
> StackTraceElement array with it . That is OK to see the calls' stack but it does \
> not provide any API to inspect what is actually on the stack in terms of variable's \
> <name, value> pair. 
> Did I miss anything ?

Just an idea, but did you try out Byteman too? That may be a simpler
alternative than writing an agent in C. What Martin suggested may also
work, but the API is hidden behind reflection and that may not work
with external programs in 9+, I'm not sure any of that is exported but
you can try it, I haven't used that API much lately unfortunately.
Nevertheless, Byteman seems a more stable option, as this code may
change internally any time.

Cheers,
Mario

-- 
Mario Torre
Associate Manager, Software Engineering
Red Hat GmbH <https://www.redhat.com>
9704 A60C B4BE A8B8 0F30  9205 5D7E 4952 3F65 7898


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic