From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BWN9NVqfuWRBAikAWB0awg (envelope-from ) for ; Thu, 20 Jul 2023 16:55:54 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=G0WnkZJ8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CFC6C1E0BD; Thu, 20 Jul 2023 16:55:54 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BA9191E00F for ; Thu, 20 Jul 2023 16:55:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE3A0385C303 for ; Thu, 20 Jul 2023 20:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE3A0385C303 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689886551; bh=m3jynU1sSEHncNMTKkp3c/xw8WgYoLkm4MIl3cN9x9w=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G0WnkZJ8Ypg051h8ID6wQF/n6qS0TLUEMm0D0/4si6ISfiF+AKlwCa1xZjgT7BvMP orfqhKs2Y2OokkOhNv0mv7n5DaCxSe6aCnpVk4eNgKhcC3ASwsy20XmnDBWzjzxqfl B4MU16rfub7YYKctdcih7wmu87aoxjzOwutznRxg= 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 Date: Thu, 20 Jul 2023 20:55:09 +0000 To: Roger Phillips , "gdb@sourceware.org" 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 X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jan Vrany via Gdb Reply-To: Jan Vrany Errors-To: gdb-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb" 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