From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 924A3387091B for ; Tue, 21 Jul 2020 18:06:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 924A3387091B IronPort-SDR: excPQTWBpFVpaEfMA56N5KBxQL+aJ317HBxRyBJBP8xutgYdx40u9LCP2Nv43I2HHDiWTirnP3 3xtHzTxN5VLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="147701809" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="147701809" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 11:06:33 -0700 IronPort-SDR: I7LdtWqKNVFCbY94w4lCvQLrV8jogSChkibVyzG3TJ5TeRG6reEoTEtbu8dJNHU8iI7cPqKQ0l 1A4NM+e/rHZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="283941875" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 21 Jul 2020 11:06:32 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 06LI6VcT013774; Tue, 21 Jul 2020 19:06:31 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 06LI6VAV004258; Tue, 21 Jul 2020 20:06:31 +0200 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 06LI6VOj004254; Tue, 21 Jul 2020 20:06:31 +0200 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH v4 1/9] gdb/jit: pass the jiter objfile as an argument to jit_event_handler Date: Tue, 21 Jul 2020 20:06:03 +0200 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-19.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 21 Jul 2020 18:06:36 -0000 This is a refactoring that adds a new parameter to the `jit_event_handler` function: the JITer objfile. The goal is to distinguish which JITer triggered the JIT event, in case there are multiple JITers -- a capability that is added in a subsequent patch. gdb/ChangeLog: 2020-06-15 Tankut Baris Aktemur * jit.h: Forward-declare `struct objfile`. (jit_event_handler): Add a second parameter, the JITer objfile. * jit.c (jit_read_descriptor): Change the signature to take the JITer objfile as an argument instead of the jit_program_space_data. (jit_inferior_init): Update the call to jit_read_descriptor. (jit_event_handler): Use the new JITer objfile argument when calling jit_read_descriptor. * breakpoint.c (handle_jit_event): Update the call to jit_event_handler to pass the JITer objfile. --- gdb/breakpoint.c | 3 ++- gdb/jit.c | 27 +++++++++++++++------------ gdb/jit.h | 7 +++++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 6d81323dd92..414208469f9 100644 --- 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); target_terminal::inferior (); } diff --git a/gdb/jit.c b/gdb/jit.c index e8a843de390..41ed81ab4b0 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -332,9 +332,9 @@ get_jit_program_space_data () memory. Returns true if all went well, false otherwise. */ static bool -jit_read_descriptor (struct gdbarch *gdbarch, - struct jit_descriptor *descriptor, - struct jit_program_space_data *ps_data) +jit_read_descriptor (gdbarch *gdbarch, + jit_descriptor *descriptor, + objfile *jiter) { int err; struct type *ptr_type; @@ -344,16 +344,16 @@ jit_read_descriptor (struct gdbarch *gdbarch, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct jit_objfile_data *objf_data; - if (ps_data->objfile == NULL) - return false; - objf_data = get_jit_objfile_data (ps_data->objfile); + gdb_assert (jiter != nullptr); + objf_data = get_jit_objfile_data (jiter); + if (objf_data->descriptor == NULL) return false; if (jit_debug) fprintf_unfiltered (gdb_stdlog, "jit_read_descriptor, descriptor_addr = %s\n", - paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (ps_data->objfile, + paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (jiter, objf_data->descriptor))); /* Figure out how big the descriptor is on the remote and how to read it. */ @@ -363,7 +363,7 @@ jit_read_descriptor (struct gdbarch *gdbarch, desc_buf = (gdb_byte *) alloca (desc_size); /* Read the descriptor. */ - err = target_read_memory (MSYMBOL_VALUE_ADDRESS (ps_data->objfile, + err = target_read_memory (MSYMBOL_VALUE_ADDRESS (jiter, objf_data->descriptor), desc_buf, desc_size); if (err) @@ -1255,9 +1255,13 @@ jit_inferior_init (struct gdbarch *gdbarch) if (!jit_breakpoint_re_set_internal (gdbarch, ps_data)) return; + /* There must be a JITer registered, otherwise we would exit early + above. */ + objfile *jiter = ps_data->objfile; + /* Read the descriptor so we can check the version number and load any already JITed functions. */ - if (!jit_read_descriptor (gdbarch, &descriptor, ps_data)) + if (!jit_read_descriptor (gdbarch, &descriptor, jiter)) return; /* Check that the version number agrees with that we support. */ @@ -1330,7 +1334,7 @@ jit_inferior_exit_hook (struct inferior *inf) } void -jit_event_handler (struct gdbarch *gdbarch) +jit_event_handler (gdbarch *gdbarch, objfile *jiter) { struct jit_descriptor descriptor; struct jit_code_entry code_entry; @@ -1338,8 +1342,7 @@ jit_event_handler (struct gdbarch *gdbarch) struct objfile *objf; /* Read the descriptor from remote memory. */ - if (!jit_read_descriptor (gdbarch, &descriptor, - get_jit_program_space_data ())) + if (!jit_read_descriptor (gdbarch, &descriptor, jiter)) return; entry_addr = descriptor.relevant_entry; diff --git a/gdb/jit.h b/gdb/jit.h index cc135037812..71e78a5167d 100644 --- a/gdb/jit.h +++ b/gdb/jit.h @@ -20,6 +20,8 @@ #ifndef JIT_H #define JIT_H +struct objfile; + /* When the JIT breakpoint fires, the inferior wants us to take one of these actions. These values are used by the inferior, so the values of these enums cannot be changed. */ @@ -76,8 +78,9 @@ extern void jit_inferior_created_hook (void); extern void jit_breakpoint_re_set (void); /* This function is called by handle_inferior_event when it decides - that the JIT event breakpoint has fired. */ + that the JIT event breakpoint has fired. JITER is the objfile + whose JIT event breakpoint has been hit. */ -extern void jit_event_handler (struct gdbarch *gdbarch); +extern void jit_event_handler (gdbarch *gdbarch, objfile *jiter); #endif /* JIT_H */ -- 2.17.1