public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Sasha Smundak <asmundak@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC][PATCH] Allow JIT unwinder provide symbol information
Date: Thu, 24 Apr 2014 13:22:00 -0000	[thread overview]
Message-ID: <5359101B.1080603@redhat.com> (raw)
In-Reply-To: <20131226183618.D264CA18A0@sasha2.mtv.corp.google.com>

On 12/26/2013 06:36 PM, Sasha Smundak wrote:
> The change proposed in this RFC is part of the effort to support
> debugging applications containing Java code executed with the help of
> Java interpreter/ just-in-time (JIT) compiler. Here's the fragment of
> the backtrace of an application being debugged by the GDB modified to
> provide such support:
> 
> #8 0x00007fffea743b03 in JNIEnv_::CallVoidMethod (this=0x7ffff001f220, obj=0x7ffff665d810, methodID=0x7ffff019d6d0) at <...>/jdk/include/jni.h:1054
> #9 0x00007fffea7439c2 in Java_Util_callObjectMethod (env=0x7ffff001f220, myclass=0x7ffff665d840, target_object=0x7ffff665d810, method_name=0x7ffff665d818) at <...>/testjni.cc:48
> #10 0x00007fffed05ef7b in Util.callObjectMethod+0x15b[C] (java.lang.Object=???) at Util.java:-1
> #11 0x00007fffed061188 in Myclass.method1+0x68[C] (this=@f665d2a8) at Myclass.java:18
> #12 0x00007fffed005f98 in Myclass.main#I ([]=[...]) at Myclass.java:48
> #13 0x00007fffed000438 in <StubRoutines> ()
> 
> I.e., Myclass.main() calls Myclass.method1() calls
> Util.callObjectMethod(), which is implemented as a C function
> Java_Util_callObjectMethod(). Myclass.main() is interpreted, while
> Myclass.method1() is JIT-compiled.
> 
> The implementation uses GDB's JIT API, and this RFC is the GDB patch
> needed for that. The implementation of the actual debugging support
> for Java (that is, the code that unwinds Java frames and is able to
> provide symbol information for them) is not presented here; hopefully
> it will make it into OpenJDK at some point, or will be distributed
> standalone.
> 
> GDB's current JIT API is sufficient to unwind the stack frames created
> by the Java Virtual Machine (JVM). However, it needs to be extended in
> order to be able to display correct symbol information, for two
> reasons. First, there is no need to add and remove symbol information
> as JIT compiles the code and disposes of it if JIT handler can provide
> this information on demand. Second, when JVM runs Java code in the
> interpreted mode, the code address in the frame points to the
> interpreter code, which is not what should be displayed.
> 
> The solution proposed here is to add a "symbol provider" function to
> the unwinder interface and modify the code displaying frames to get
> the symbol information associated with the frame (function name,
> source location, arguments) from the frame's unwinder if it has
> symbol provider and use the current logic as a fallback strategy.
> 
> There are additional changes in this RFC exposing more GDB
> functions to the JIT handler.

Apologies for only now taking a look at what this is used for.

AFAICS, this only allows providing these.

+  JIT_FRAME_SYMBOL_ATTR_FUNCTION_NAME,
+  JIT_FRAME_SYMBOL_ATTR_LANGUAGE,
+  JIT_FRAME_SYMBOL_ATTR_SOURCE_FILE,
+  JIT_FRAME_SYMBOL_ATTR_SOURCE_LINE,
+  JIT_FRAME_SYMBOL_ATTR_FUNCTION_ARGS,

It seems to me that what you want to do here is what Python
frame filters were invented for.  IOW, I think you should
be able to write a frame filter that interacts with the Java
JIT to expose the same info to the user your API extension
is proposing.  But I think that direction would be more
flexible, even.  You could for example, hide functions
if you want (say, the JIT innards), and probably give more
detail of the args (this solution seems to provide their names
as strings only).

-- 
Pedro Alves

  parent reply	other threads:[~2014-04-24 13:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26 18:36 Sasha Smundak
2014-01-13 18:25 ` Alexander Smundak
2014-02-07 21:54   ` Alexander Smundak
2014-01-13 18:46 ` Doug Evans
2014-01-15  0:39   ` Alexander Smundak
2014-02-11 22:26     ` Doug Evans
2014-02-12  7:50       ` Doug Evans
2014-02-19  3:30         ` Alexander Smundak
2014-02-19  3:50           ` Eli Zaretskii
2014-02-19  5:23             ` Alexander Smundak
2014-04-11 18:47           ` Doug Evans
2014-04-11 18:58           ` Doug Evans
2014-04-21  1:35             ` Alexander Smundak
2014-04-21  7:14               ` Eli Zaretskii
2014-04-21 16:43                 ` Alexander Smundak
2014-02-25  1:19         ` Doug Evans
2014-02-25  3:00           ` Alexander Smundak
2014-03-11  1:46           ` Alexander Smundak
2014-02-08  7:08 ` Yao Qi
2014-02-10  2:16   ` Alexander Smundak
2014-02-11 22:00     ` Doug Evans
2014-04-24 13:22 ` Pedro Alves [this message]
2014-04-25 23:40   ` Alexander Smundak
2014-04-29 15:22     ` Pedro Alves
2014-05-02 16:58       ` Alexander Smundak
2014-05-19 21:30         ` Alexander Smundak
2014-05-29  1:07       ` Alexander Smundak
2014-06-02  1:15       ` Alexander Smundak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5359101B.1080603@redhat.com \
    --to=palves@redhat.com \
    --cc=asmundak@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).