From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qUaMGPe9hl9GJAAAWB0awg (envelope-from ) for ; Wed, 14 Oct 2020 04:59:35 -0400 Received: by simark.ca (Postfix, from userid 112) id 57BC61EF6F; Wed, 14 Oct 2020 04:59:35 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 4533A1E58C for ; Wed, 14 Oct 2020 04:59:34 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0D8C3854827; Wed, 14 Oct 2020 08:59:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0D8C3854827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1602665973; bh=YnY09JrmK4Pm9xo8ioUOPM2ubWZgNRPl9qWBV08+h9E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VxgSSEp/6UuA/eu3Xk+gv1fmsSliOS8nz/cSOgEQ1vCGePiHKxx50wXg0ytDSB6BD GyswiFaACsnwu9TsNMzNVjaAze9uZokTo3QCbEE6Wc2UVWmJhnUTVJI1nmp8YPThgv kQkqUkj6fsN5YT0RsQJSRtCZqBfvEhZ+xtB1X0ZU= Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id B35643854822 for ; Wed, 14 Oct 2020 08:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B35643854822 IronPort-SDR: vuK38vf3lQ+a3B3OX5uiHEibTBHxc7+t0GBXet78enc8NFPH0wQ9HevgCjLZC5ILESb8Gu2fwG tE8mOdA1Bx9A== X-IronPort-AV: E=McAfee;i="6000,8403,9773"; a="145379277" X-IronPort-AV: E=Sophos;i="5.77,374,1596524400"; d="scan'208";a="145379277" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 01:59:29 -0700 IronPort-SDR: xlqWCzagQfUHgc4RBAZ8HaR3RVEc0dU3Gt6lBaQKqZI9DEYtNGCR9ybjT28jJ/S1iKjydH/pfQ JKHqHIvdyPBA== X-IronPort-AV: E=Sophos;i="5.77,374,1596524400"; d="scan'208";a="463810230" Received: from labpc7920x-08.iul.intel.com (HELO localhost) ([172.28.48.67]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 01:59:28 -0700 To: gdb-patches@sourceware.org Subject: [PATCH] gdb: get jiter objfile from a bound minsym Date: Wed, 14 Oct 2020 11:00:03 +0200 Message-Id: <20201014090003.17736-1-mihails.strasuns@intel.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mihails Strasuns via Gdb-patches Reply-To: Mihails Strasuns Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This fixes a regression introduced by the following commit: fe053b9e853 gdb/jit: pass the jiter objfile as an argument to jit_event_handler In the refactoring `handle_jit_event` function was changed to pass a matching objfile pointer to the `jit_event_handler` explicitly, rather using internal storage: ``` --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5448,8 +5448,9 @@ handle_jit_event (void) frame = get_current_frame (); gdbarch = get_frame_arch (frame); + objfile *jiter = symbol_objfile (get_frame_function (frame)); - jit_event_handler (gdbarch); + jit_event_handler (gdbarch, jiter); ``` This was needed to add support for a multiple jiters in a following commits. However it has also introduced a regression, because `get_frame_function (frame)` here may return `nullptr`, resulting in a crash. A more resilient way would be to use an approach mirroring `jit_breakpoint_re_set` - to find a minimal symbol matching the breakpoint location and use its object file. We know that this breakpoint events comes from a breakpoint set by `jit_breakpoint_re_set`, thus using the reverse approach should be reliable enough. gdb/Changelog: 2020-10-14 Mihails Strasuns * breakpoint.c (handle_jit_event): and an argument, change how `jit_event_handler` is called. --- gdb/breakpoint.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 414208469f9..878d48c5984 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5434,9 +5434,8 @@ bpstat_stop_status (const address_space *aspace, } static void -handle_jit_event (void) +handle_jit_event (CORE_ADDR address) { - struct frame_info *frame; struct gdbarch *gdbarch; if (debug_infrun) @@ -5446,11 +5445,9 @@ handle_jit_event (void) breakpoint_re_set. */ target_terminal::ours_for_output (); - frame = get_current_frame (); - gdbarch = get_frame_arch (frame); - objfile *jiter = symbol_objfile (get_frame_function (frame)); - - jit_event_handler (gdbarch, jiter); + gdbarch = get_frame_arch (get_current_frame ()); + bound_minimal_symbol jit_bp_sym = lookup_minimal_symbol_by_pc (address); + jit_event_handler (gdbarch, jit_bp_sym.objfile); target_terminal::inferior (); } @@ -5651,7 +5648,7 @@ bpstat_run_callbacks (bpstat bs_head) switch (b->type) { case bp_jit_event: - handle_jit_event (); + handle_jit_event (bs->bp_location_at->address); break; case bp_gnu_ifunc_resolver: gnu_ifunc_resolver_stop (b); -- 2.17.1 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928