public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jan Vrany <jan@vrany.io>
To: Roger Phillips <heidegg@hotmail.com>,
	"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Using symbol map file with gdb?
Date: Thu, 20 Jul 2023 20:55:09 +0000	[thread overview]
Message-ID: <d5a048222b7a2de204c9839bef5822b428499af8.camel@vrany.io> (raw)
In-Reply-To: <SJ0PR06MB86415123B1B1371A7E2D4E13AA3EA@SJ0PR06MB8641.namprd06.prod.outlook.com>

Hi, 

On Thu, 2023-07-20 at 20:30 +0000, Roger Phillips via Gdb wrote:
> Greetings,
> 
> I need to debug a segfault in java native code but the callstacks have no method names. Is it possible to import a symbol map file created with, say perf map agent into gdb? If yes, how?
> 
> https://github.com/jvm-profiling-tools/perf-map-agent/tree/master

I do not think this is possible with current GDB. 

However, a year ago or so I implemented new Python API that allows one to
register new functions (symbols) at runtime. I used this for similar purpose,
to get a meaningful backtrace of Java code in GDB [1]

The code is at sourceware.org. To use perf map. you'd essentially need to parse 
the map file in Python and then call the new API to get symbols registered in 
GDB, in essence you'd need to do something like:

     # assuming that
     #  name contains Java method descriptor
     #  code is method's entry point
     #  size is method's code size
     objfile = gdb.Objfile(name)
     symtab = gdb.Symtab(objfile, "SomeJavaClass.java")
     symtab.add_block(name, code, code + size)

     # If you have line number info, you may want to
     # build a linetable and GDB would show the source
     # code...
     symtab.set_linetable([
          gdb.LineTableEntry(29, code, True),
          gdb.LineTableEntry(30, code+3, True),            
          gdb.LineTableEntry(31, code+6, True)
     ])

I plan to upstream the code, but sadly it is still not polished
enough to submit it :-(

HTH, Jan


[1]: https://github.com/janvrany/openj9-gdb/tree/master
[2]: https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/jv/wip/feature-py-jit-api








  reply	other threads:[~2023-07-20 20:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 20:30 Roger Phillips
2023-07-20 20:55 ` Jan Vrany [this message]
2023-07-21  9:46   ` Roger Phillips
2023-07-22 13:25   ` Roger Phillips
2023-07-22 17:21     ` Andrew Haley
2023-07-21  9:46 ` Andrew Haley

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=d5a048222b7a2de204c9839bef5822b428499af8.camel@vrany.io \
    --to=jan@vrany.io \
    --cc=gdb@sourceware.org \
    --cc=heidegg@hotmail.com \
    /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).