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 Sent: Thursday, July 20, 2023 8:55 PM To: Roger Phillips ; 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