public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Using symbol map file with gdb?
@ 2023-07-20 20:30 Roger Phillips
  2023-07-20 20:55 ` Jan Vrany
  2023-07-21  9:46 ` Andrew Haley
  0 siblings, 2 replies; 6+ messages in thread
From: Roger Phillips @ 2023-07-20 20:30 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 271 bytes --]

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

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

* Re: Using symbol map file with gdb?
  2023-07-20 20:30 Using symbol map file with gdb? Roger Phillips
@ 2023-07-20 20:55 ` Jan Vrany
  2023-07-21  9:46   ` Roger Phillips
  2023-07-22 13:25   ` Roger Phillips
  2023-07-21  9:46 ` Andrew Haley
  1 sibling, 2 replies; 6+ messages in thread
From: Jan Vrany @ 2023-07-20 20:55 UTC (permalink / raw)
  To: Roger Phillips, gdb

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








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

* Re: Using symbol map file with gdb?
  2023-07-20 20:30 Using symbol map file with gdb? Roger Phillips
  2023-07-20 20:55 ` Jan Vrany
@ 2023-07-21  9:46 ` Andrew Haley
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Haley @ 2023-07-21  9:46 UTC (permalink / raw)
  To: gdb

On 7/20/23 21:30, Roger Phillips via Gdb wrote:
> 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?

Just in case you didn't already know this:

If your JVM is HotSpot then it contains the debug helpers to handle
debugging generated/interpreted code.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


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

* Re: Using symbol map file with gdb?
  2023-07-20 20:55 ` Jan Vrany
@ 2023-07-21  9:46   ` Roger Phillips
  2023-07-22 13:25   ` Roger Phillips
  1 sibling, 0 replies; 6+ messages in thread
From: Roger Phillips @ 2023-07-21  9:46 UTC (permalink / raw)
  To: Jan Vrany, gdb

[-- Attachment #1: Type: text/plain, Size: 2057 bytes --]

This would make the life of many java debuggers a lot easier. Is there a ticket that I can put on watchlist?

________________________________
From: Jan Vrany <jan@vrany.io>
Sent: Thursday, July 20, 2023 8:55 PM
To: Roger Phillips <heidegg@hotmail.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: Using symbol map file with gdb?

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








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

* Re: Using symbol map file with gdb?
  2023-07-20 20:55 ` Jan Vrany
  2023-07-21  9:46   ` Roger Phillips
@ 2023-07-22 13:25   ` Roger Phillips
  2023-07-22 17:21     ` Andrew Haley
  1 sibling, 1 reply; 6+ messages in thread
From: Roger Phillips @ 2023-07-22 13:25 UTC (permalink / raw)
  To: gdb, aph

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

For some reason your mail was only in the archive not in my inbox. Let's see if this works out:

Do these debug helpers exists in Zulu VM which is based on OpenJDK?

https://docs.azul.com/core/
Azul Zulu Builds of OpenJDK<https://docs.azul.com/core/>
docs.azul.com
docs.azul.com


If yes, how to activate them? Do they produce full stack frames with parameters etc. ?

________________________________
From: Andrew Haley <aph@redhat.com<mailto:aph%40redhat.com?Subject=Re:%20Re%3A%20Using%20symbol%20map%20file%20with%20gdb%3F&In-Reply-To=%3Ce64d2692-9055-f05e-18e5-6e7e423b3949%40redhat.com%3E>>
Sent: Thursday, July 20, 2023 8:55 PM
To: Roger Phillips <heidegg@hotmail.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: Using symbol map file with gdb?


Just in case you didn't already know this:

If your JVM is HotSpot then it contains the debug helpers to handle
debugging generated/interpreted code.







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

* Re: Using symbol map file with gdb?
  2023-07-22 13:25   ` Roger Phillips
@ 2023-07-22 17:21     ` Andrew Haley
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Haley @ 2023-07-22 17:21 UTC (permalink / raw)
  To: Roger Phillips, gdb

On 7/22/23 14:25, Roger Phillips wrote:
> For some reason your mail was only in the archive not in my inbox. Let's see if this works out:
> 
> Do these debug helpers exists in Zulu VM which is based on OpenJDK?

I doubt it. But trying to debug segfaults in non-debug builds of OpenJDK
is a difficult thing to do anyway.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


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

end of thread, other threads:[~2023-07-22 17:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 20:30 Using symbol map file with gdb? Roger Phillips
2023-07-20 20:55 ` Jan Vrany
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

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).