From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 95A413870924 for ; Tue, 21 Jul 2020 18:06:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 95A413870924 IronPort-SDR: I4Wdgkl9s7N75YsRFwLxBpsCsZ6sx0+2HkulQeiV5BJc2Dwdpr2cBDhA7nP3njhnjbKhsZVshv Q2W8X6pegWpw== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="138289089" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="138289089" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 11:06:33 -0700 IronPort-SDR: gDagb8Vv3C2ICkG2nKEKTOxm+sURrzvKanC+FZz8iVDvUIJ/rX2YkL2O9pCyKirY2SEzOoExp3 Czff2apFtHwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="487709830" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga006.fm.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 06LI6WjO013837; Tue, 21 Jul 2020 19:06:32 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 06LI6VwP004272; Tue, 21 Jul 2020 20:06:31 +0200 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 06LI6VVQ004268; Tue, 21 Jul 2020 20:06:31 +0200 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH v4 3/9] gdb/jit: split jit_objfile_data in two Date: Tue, 21 Jul 2020 20:06:05 +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.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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:37 -0000 From: Simon Marchi The jit_objfile_data is currently used to hold information about both objfiles that are the result of JIT compilation (JITed) and objfiles that can produce JITed objfiles (JITers). I think that this double use of the type is confusing, and that things would be more obvious if we had one type for each role. This patch splits it into: - jited_objfile_data: for data about an objfile that is the result of a JIT compilation - jiter_objfile_data: for data about an objfile which produces JITed objfiles There are now two JIT-related fields in an objfile, one for each kind. With this change, the following invariants hold: - an objfile has a non-null `jiter_data` field iff it defines the required symbols of the JIT interface - an objfile has a non-null `jited_data` field iff it is the product of JIT compilation (has been produced by some JITer) gdb/ChangeLog: 2020-MM-DD Simon Marchi * jit.h (struct jit_objfile_data): Split into... (struct jiter_objfile_data): ... this ... (struct jited_objfile_data): ... and this. * objfiles.h (struct objfile) : Remove. : New fields. * jit.c (jit_objfile_data::~jit_objfile_data): Rename to ... (jiter_objfile_data::~jiter_objfile_data): ... this. (get_jit_objfile_data): Rename to ... (get_jiter_objfile_data): ... this. (add_objfile_entry): Update. (jit_read_descriptor): Use get_jiter_objfile_data. (jit_find_objf_with_entry_addr): Use objfile's jited_data field. (jit_breakpoint_re_set_internal): Use get_jiter_objfile_data. (jit_inferior_exit_hook): Use objfile's jited_data field. --- gdb/jit.c | 34 ++++++++++++++++------------------ gdb/jit.h | 28 +++++++++++++++++----------- gdb/objfiles.h | 9 +++++++-- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/gdb/jit.c b/gdb/jit.c index 39e364101e7..7c8bfcb51bb 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -263,9 +263,9 @@ struct jit_program_space_data static program_space_key jit_program_space_key; -/* Destructor for jit_objfile_data. */ +/* Destructor for jiter_objfile_data. */ -jit_objfile_data::~jit_objfile_data () +jiter_objfile_data::~jiter_objfile_data () { /* Free the data allocated in the jit_program_space_data slot. */ if (this->register_code != NULL) @@ -283,16 +283,16 @@ jit_objfile_data::~jit_objfile_data () } } -/* Fetch the jit_objfile_data associated with OBJF. If no data exists +/* Fetch the jiter_objfile_data associated with OBJF. If no data exists yet, make a new structure and attach it. */ -static struct jit_objfile_data * -get_jit_objfile_data (struct objfile *objf) +static jiter_objfile_data * +get_jiter_objfile_data (objfile *objf) { - if (objf->jit_data == nullptr) - objf->jit_data.reset (new jit_objfile_data (objf)); + if (objf->jiter_data == nullptr) + objf->jiter_data.reset (new jiter_objfile_data (objf)); - return objf->jit_data.get (); + return objf->jiter_data.get (); } /* Remember OBJFILE has been created for struct jit_code_entry located @@ -301,10 +301,9 @@ get_jit_objfile_data (struct objfile *objf) static void add_objfile_entry (struct objfile *objfile, CORE_ADDR entry) { - struct jit_objfile_data *objf_data; + gdb_assert (objfile->jited_data == nullptr); - objf_data = get_jit_objfile_data (objfile); - objf_data->addr = entry; + objfile->jited_data.reset (new jited_objfile_data (entry)); } /* Return jit_program_space_data for current program space. Allocate @@ -335,10 +334,9 @@ jit_read_descriptor (gdbarch *gdbarch, int desc_size; gdb_byte *desc_buf; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct jit_objfile_data *objf_data; gdb_assert (jiter != nullptr); - objf_data = get_jit_objfile_data (jiter); + jiter_objfile_data *objf_data = get_jiter_objfile_data (jiter); if (objf_data->descriptor == NULL) return false; @@ -908,7 +906,7 @@ jit_find_objf_with_entry_addr (CORE_ADDR entry_addr) { for (objfile *objf : current_program_space->objfiles ()) { - if (objf->jit_data != nullptr && objf->jit_data->addr == entry_addr) + if (objf->jited_data != nullptr && objf->jited_data->addr == entry_addr) return objf; } @@ -948,7 +946,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, { struct bound_minimal_symbol reg_symbol; struct bound_minimal_symbol desc_symbol; - struct jit_objfile_data *objf_data; + jiter_objfile_data *objf_data; CORE_ADDR addr; if (ps_data->objfile == NULL) @@ -966,14 +964,14 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, || BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0) return false; - objf_data = get_jit_objfile_data (reg_symbol.objfile); + objf_data = get_jiter_objfile_data (reg_symbol.objfile); objf_data->register_code = reg_symbol.minsym; objf_data->descriptor = desc_symbol.minsym; ps_data->objfile = reg_symbol.objfile; } else - objf_data = get_jit_objfile_data (ps_data->objfile); + objf_data = get_jiter_objfile_data (ps_data->objfile); addr = MSYMBOL_VALUE_ADDRESS (ps_data->objfile, objf_data->register_code); @@ -1315,7 +1313,7 @@ jit_inferior_exit_hook (struct inferior *inf) { for (objfile *objf : current_program_space->objfiles_safe ()) { - if (objf->jit_data != nullptr && objf->jit_data->addr != 0) + if (objf->jited_data != nullptr && objf->jited_data->addr != 0) objf->unlink (); } } diff --git a/gdb/jit.h b/gdb/jit.h index 61092166391..fcef78d4991 100644 --- a/gdb/jit.h +++ b/gdb/jit.h @@ -67,19 +67,16 @@ struct jit_descriptor CORE_ADDR first_entry; }; -/* Per-objfile structure recording the addresses in the program space. - This object serves two purposes: for ordinary objfiles, it may - cache some symbols related to the JIT interface; and for - JIT-created objfiles, it holds some information about the - jit_code_entry. */ +/* An objfile that defines the required symbols of the JIT interface has an + instance of this type attached to it. */ -struct jit_objfile_data +struct jiter_objfile_data { - jit_objfile_data (struct objfile *objfile) + jiter_objfile_data (struct objfile *objfile) : objfile (objfile) {} - ~jit_objfile_data (); + ~jiter_objfile_data (); /* Back-link to the objfile. */ struct objfile *objfile; @@ -89,10 +86,19 @@ struct jit_objfile_data /* Symbol for __jit_debug_descriptor. */ minimal_symbol *descriptor = nullptr; +}; + +/* An objfile that is the product of JIT compilation and was registered + using the JIT interface has an instance of this type attached to it. */ + +struct jited_objfile_data +{ + jited_objfile_data (CORE_ADDR addr) + : addr (addr) + {} - /* Address of struct jit_code_entry in this objfile. This is only - non-zero for objfiles that represent code created by the JIT. */ - CORE_ADDR addr = 0; + /* Address of struct jit_code_entry for this objfile. */ + CORE_ADDR addr; }; /* Looks for the descriptor and registration symbols and breakpoints diff --git a/gdb/objfiles.h b/gdb/objfiles.h index b21b4266360..3fbc6da0796 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -699,8 +699,13 @@ struct objfile allocated on the objfile's obstack. */ htab_up static_links; - /* JIT-related data for this objfile. */ - std::unique_ptr jit_data = nullptr; + /* JIT-related data for this objfile, if the objfile is a JITer; + that is, it produces JITed objfiles. */ + std::unique_ptr jiter_data = nullptr; + + /* JIT-related data for this objfile, if the objfile is JITed; + that is, it was produced by a JITer. */ + std::unique_ptr jited_data = nullptr; }; /* A deleter for objfile. */ -- 2.17.1