From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by sourceware.org (Postfix) with ESMTPS id 2E8283858CD1 for ; Thu, 20 Jul 2023 20:55:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E8283858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=vrany.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrany.io Date: Thu, 20 Jul 2023 20:55:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrany.io; s=protonmail; t=1689886521; x=1690145721; bh=m3jynU1sSEHncNMTKkp3c/xw8WgYoLkm4MIl3cN9x9w=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=EK//u4GtBTSIjoEpGdvkXsQWlGnt4esDKeZbM32Q+WtX5P3VxCqjBnCTvTtNSFFjh r+d6zV/xrsqisoBdA56cwn4cJ4Yo7fHUbdu2xwsCqD2mdz3gHVn4LJCfnQTrODAzkO wBTcBswMHiwD7YH25gFSQlTGOJh3ns/WyemAKZ5RJ838Iad+69eV0Dc/HvhtPOtsqp EtAFGJwYA8GjZhoyBg+BbfnBEwnu+vsGhNGFUAvm5aYYRYd36ZzzxOviTyUYWFJMma ut5+P6v7uxSJx8vjo0ZLKV0BskZC8R2OOKXcQg7eB28yZvznxb2d+1IKHUITWc2ook zSORiSW5vPR+A== To: Roger Phillips , "gdb@sourceware.org" From: Jan Vrany Subject: Re: Using symbol map file with gdb? Message-ID: In-Reply-To: References: Feedback-ID: 40767693:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi,=20 On Thu, 2023-07-20 at 20:30 +0000, Roger Phillips via Gdb wrote: > Greetings, >=20 > 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? >=20 > https://github.com/jvm-profiling-tools/perf-map-agent/tree/master I do not think this is possible with current GDB.=20 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 purpos= e, 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 p= arse=C2=A0 the map file in Python and then call the new API to get symbols registered = in=C2=A0 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 =3D gdb.Objfile(name) symtab =3D 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), =20 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=3Dbinutils-gdb.git;a=3Dshortlog;h=3Drefs= /heads/users/jv/wip/feature-py-jit-api