public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Question about java probe
@ 2017-03-27 16:45 Shuxin Yang
  2017-03-27 21:39 ` David Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Shuxin Yang @ 2017-03-27 16:45 UTC (permalink / raw)
  To: systemtap

Hi, There:

   I have bunch of questions about java probe. The stap I'm using is 
built from the most recent release without any special flags.Tons thanks 
in advance for the help!

   Q1: I find an example here: 
https://developers.redhat.com/blog/2014/01/10/probing-java-w-systemtap/

         The statement 'printf("hit ... %d\n", $arg1)' print a wrong 
value. However, if I change this statement to 'printf("hit ... %s\n", 
arg1)', then it works. Why so?

   Q2: follow the example in Q1. What if the function being probed has a 
non-primitive typed parameter. Say argument foo of type Foo. Is it 
possible to access foo's data member, or call its member function.

   Q3: Look like print_java_stack() only prints the stack of the thread 
in question; It does *not* print all threads' stack. Am I right?

   Q4: How to print java stack when a system call is hit? I try to call 
print_java_stack() inside system call probe function, and get nothing. 
Should I call other function? Or it's impossible for now? If this is the 
case, is it possible to hack the systemtap to take advantage of the 
perf-jit support (https://lwn.net/Articles/633846/) to print the java 
stack of JIT-ed code?

Thanks

Shuxin




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about java probe
  2017-03-27 16:45 Question about java probe Shuxin Yang
@ 2017-03-27 21:39 ` David Smith
  2017-03-28 15:06   ` Shuxin Yang
  0 siblings, 1 reply; 3+ messages in thread
From: David Smith @ 2017-03-27 21:39 UTC (permalink / raw)
  To: Shuxin Yang; +Cc: systemtap

On Mon, Mar 27, 2017 at 11:45 AM, Shuxin Yang <shuxinyang.oss@gmail.com> wrote:
> Hi, There:
>
>   I have bunch of questions about java probe. The stap I'm using is built
> from the most recent release without any special flags.Tons thanks in
> advance for the help!
>
>   Q1: I find an example here:
> https://developers.redhat.com/blog/2014/01/10/probing-java-w-systemtap/
>
>         The statement 'printf("hit ... %d\n", $arg1)' print a wrong value.
> However, if I change this statement to 'printf("hit ... %s\n", arg1)', then
> it works. Why so?

It looks like this behavior was changed in version 3.1 (see sourceware
PR21020 <https://sourceware.org/bugzilla/show_bug.cgi?id=21020>). If
you want the original behavior, you'd add the command line argument
'--compatible=3.0'.

>   Q2: follow the example in Q1. What if the function being probed has a
> non-primitive typed parameter. Say argument foo of type Foo. Is it possible
> to access foo's data member, or call its member function.

I'm not sure (this isn't really my area).

>   Q3: Look like print_java_stack() only prints the stack of the thread in
> question; It does *not* print all threads' stack. Am I right?

I believe that to be correct.

>   Q4: How to print java stack when a system call is hit? I try to call
> print_java_stack() inside system call probe function, and get nothing.
> Should I call other function? Or it's impossible for now?

Trying to get a java backtrace when a system call is hit is an
interesting question. It is a question of context. When you aren't in
a java probe, you don't have the information around to do a java-level
backtrace.

So, what can you do? Basically probe up a level (or several). Let's
say you want a java backtrace when java opens a file. You'd need to
put java probes in methods that open files.

> If this is the
> case, is it possible to hack the systemtap to take advantage of the perf-jit
> support (https://lwn.net/Articles/633846/) to print the java stack of JIT-ed
> code?

From my reading of that link, it is possible that systemtap could use
the JVMTI interface in a manner similar to how perf is using it. If
you'd like to take that on, we can try to guide you through the
process.

(Now like I said before java probing really isn't my area of
expertise, but I believe the above to be reasonably correct.)

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about java probe
  2017-03-27 21:39 ` David Smith
@ 2017-03-28 15:06   ` Shuxin Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Shuxin Yang @ 2017-03-28 15:06 UTC (permalink / raw)
  To: David Smith; +Cc: systemtap

Hi, David:

     Thank you very much for the response. Since I have very little 
knowledge of JVM internal and JVM TI, I don't think I'm ready to take on 
the challenge. I guess my best bet for now is to fall back to perf for 
java profiling and probing.

Thank you very much!

Shuxin


On 3/27/17 2:39 PM, David Smith wrote:
> On Mon, Mar 27, 2017 at 11:45 AM, Shuxin Yang <shuxinyang.oss@gmail.com> wrote:
>> Hi, There:
>>
>>    I have bunch of questions about java probe. The stap I'm using is built
>> from the most recent release without any special flags.Tons thanks in
>> advance for the help!
>>
>>    Q1: I find an example here:
>> https://developers.redhat.com/blog/2014/01/10/probing-java-w-systemtap/
>>
>>          The statement 'printf("hit ... %d\n", $arg1)' print a wrong value.
>> However, if I change this statement to 'printf("hit ... %s\n", arg1)', then
>> it works. Why so?
> It looks like this behavior was changed in version 3.1 (see sourceware
> PR21020 <https://sourceware.org/bugzilla/show_bug.cgi?id=21020>). If
> you want the original behavior, you'd add the command line argument
> '--compatible=3.0'.
>
>>    Q2: follow the example in Q1. What if the function being probed has a
>> non-primitive typed parameter. Say argument foo of type Foo. Is it possible
>> to access foo's data member, or call its member function.
> I'm not sure (this isn't really my area).
>
>>    Q3: Look like print_java_stack() only prints the stack of the thread in
>> question; It does *not* print all threads' stack. Am I right?
> I believe that to be correct.
>
>>    Q4: How to print java stack when a system call is hit? I try to call
>> print_java_stack() inside system call probe function, and get nothing.
>> Should I call other function? Or it's impossible for now?
> Trying to get a java backtrace when a system call is hit is an
> interesting question. It is a question of context. When you aren't in
> a java probe, you don't have the information around to do a java-level
> backtrace.
>
> So, what can you do? Basically probe up a level (or several). Let's
> say you want a java backtrace when java opens a file. You'd need to
> put java probes in methods that open files.
>
>> If this is the
>> case, is it possible to hack the systemtap to take advantage of the perf-jit
>> support (https://lwn.net/Articles/633846/) to print the java stack of JIT-ed
>> code?
>  From my reading of that link, it is possible that systemtap could use
> the JVMTI interface in a manner similar to how perf is using it. If
> you'd like to take that on, we can try to guide you through the
> process.
>
> (Now like I said before java probing really isn't my area of
> expertise, but I believe the above to be reasonably correct.)
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-28 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 16:45 Question about java probe Shuxin Yang
2017-03-27 21:39 ` David Smith
2017-03-28 15:06   ` Shuxin Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).