Re: inspect a thread’s stack
Mario Torre
neugens at redhat.com
Tue Apr 10 08:35:57 UTC 2018
On Tue, Apr 10, 2018 at 9:26 AM, Pietro Paolini
<Pietro.Paolini at 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
More information about the serviceability-dev
mailing list