From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 1A351385701D for ; Tue, 30 Jun 2020 12:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1A351385701D IronPort-SDR: 6xHlmqdh8wfGbODkqMPDr/ruo06ZoaT+Q0ScftaRnrjgnT5rnI7iM4lZT9tnxTIGVjMIDQL5Xm UoUSpUxqErNw== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="211283507" X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="211283507" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 05:35:24 -0700 IronPort-SDR: 7MFfmgoS6BG2F/Jp+fDTYScKBJuqxPrIpkY79VzbgzfoB+RXtbt38mas+DzOU91vsl3eKqfrgb ZN1Egof1F/EQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="265107166" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 30 Jun 2020 05:35:24 -0700 Received: from fmsmsx104.amr.corp.intel.com (10.18.124.202) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 05:35:24 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 30 Jun 2020 05:35:22 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.53) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jun 2020 05:35:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=abl4X59MLky3RjaOdKCllLXj3IDVeBpdy4nVBrmkdXMK+iLqR4hXLj3FAGHa/+CI9C3GOXVMyo1jJzP5DNaOCEkDaRKLuT5510mD7M7jbLUgFVg+0wH8gAP1tiiaP6CWMUoZj2gYgpnOuIS1spAHpvKMM97c4v3NaV3lm/oqQ01/2zZ0ws6pnKfxmq9s5gAQwYUrR9hFdHWqjNEsVMeBLIaNPflhgpyo22N375ncNr98YBr3GaSImsUjT0BM1dKBijQt6jmnmznWRLyNI5FXIseE9iafW7kubEMnFUh8nH+6HMQUkAWRTBv8SuLZ1F/z1NYS656yuktqYTe1ZxI0xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wbLNhaGXIvJ7/nuszSNN87Z3ZdE4Dvmg7g+8w+vIFqk=; b=TakvWnMW5RF2iX5BcTM8C0QXUsXWkYFzp0Hzg2Cpr1j/G7a6Fz7gBFupjyPT1iq9hh2MjN3sBeB2zvPtPDaGeRTsQ4EHhBgasETiIqIZreiglTnfoWIGKYPx3SC4E0iHSvKWYz/ThsEvPJDUgimzMjQwen++aWR3fE5T7zwHSEzDZ6FO1X1kS7DE4J7TkDk296/+J4aRVmoCpVBwBrcMWXE6GyQwe+IULufFoagf3d/No3qlXNYthnX0yyoOQlQ9BOJEiyyv+nM5nwJCgT9VNQzDlWi1ZamK5XMfs3KMpEPwGANAMdZeJy5SZEXNjMD68+BDcV3LZ1ThTyJE9a8kuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MWHPR11MB0048.namprd11.prod.outlook.com (2603:10b6:301:6a::31) by MW3PR11MB4620.namprd11.prod.outlook.com (2603:10b6:303:54::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.23; Tue, 30 Jun 2020 12:35:19 +0000 Received: from MWHPR11MB0048.namprd11.prod.outlook.com ([fe80::45d4:8b21:ead1:9215]) by MWHPR11MB0048.namprd11.prod.outlook.com ([fe80::45d4:8b21:ead1:9215%7]) with mapi id 15.20.3131.027; Tue, 30 Jun 2020 12:35:19 +0000 From: "Strasuns, Mihails" To: "gdb-patches@sourceware.org" Subject: RE: [PATCH 2/2] Disable breakpoint locations in unloaded jit objects Thread-Topic: [PATCH 2/2] Disable breakpoint locations in unloaded jit objects Thread-Index: AQHWQ9PHqhsP3NmDyUmyFUlKBB7kO6jxLhHA Date: Tue, 30 Jun 2020 12:35:19 +0000 Message-ID: References: <20200616114530.5068-1-mihails.strasuns@intel.com> <20200616114530.5068-2-mihails.strasuns@intel.com> In-Reply-To: <20200616114530.5068-2-mihails.strasuns@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action x-originating-ip: [134.191.221.120] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dfb4e7b4-65f7-4e8f-3b53-08d81cf20cfa x-ms-traffictypediagnostic: MW3PR11MB4620: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0450A714CB x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y7vsS0a1vckR9KplUVtXXe4lRSWXAaISH8bkdCMeumcDsMmMJ5TfV7TVYC0Ux/w5T55GVSAZDU4jBQR+E5YKRqT+KdJvhkW4LgESM0Pzf4LHGqJL+jc+LvsV3eRNjeexP4OqhUWtkmsAPArafV9H+rdcSGXTlUaW0jhNXcIE0sazdhfjFJnaJ0CveEkE41MYjia1I3SY4UeZ8AXSt5PAS+ZziN7LQh0ERZeu3ZWGhqaHS396CnhhNY7hzLWnmLBGjOWVlOmCkqmZyI7l8eCm8p9VazH90TiVQZSGZg8ZE0T5b+A5jkGivizAx2B8E4HUuVe1KSUA2tRzh0yMuZoFn31iCGTiOZKkgb1IQktfLQ2fREZa1j95kZuh/b8BQdmaejaE7cOQwa/ZMX4dz3SCQZX17kw+7U+Lnx2dlUwkGDgpL2QYZR3ZIdeRJyER/Oo9 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB0048.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(136003)(39860400002)(366004)(346002)(376002)(30864003)(478600001)(8676002)(7696005)(5660300002)(316002)(186003)(53546011)(33656002)(52536014)(6506007)(71200400001)(2906002)(26005)(66946007)(76116006)(8936002)(66476007)(64756008)(83380400001)(66446008)(9686003)(55016002)(66556008)(86362001)(6916009)(2004002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: kVvdeJPVjCO+uKYjA1Yziq/xtgz93zujDfgNwQ5l2GBcJiod0J2dp5gWMS8Ghwxxgecwst/bByp+6fMhnafV6yGrRWWgIZuqi0lU2I/7ia2RCw5WIZgg7sr9rWBcjpkArd7oWOPPWJMWRROo62k3l2539FFz/HGmuN4MLA1LvMl/zGnpnzYtSWpHyTSI3bf0dQiLfBpMMnbm9QmY4GHNAY+fo75kCOPXMrXdzdW5J/OjelcKGQvT8bHW+CW3qT0ovgKmp67POMNMfGzUbNIKp9Y1+STvIfKs76tgKYE3/CwAl+W5R+aSgHTcp8GKxJV/CFnCfe3krEfCPH/vI7WRBjBlZNcqpid6bGA5bHqdD14wWREYkJ7OYiGNGuzdfLzPJ5gb2tQqH4dr7PwETuJ1u4E2rYwjGXvSF3aayWmaRPKBbrkaw+ELJJFyc+odHXKIvaVYSATJDBCwqEvP/Iunl8a5UED5frkh9/qE4UyIqO2IZKBC94DL0sHbnhOizcqd x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB0048.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfb4e7b4-65f7-4e8f-3b53-08d81cf20cfa X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 12:35:19.5755 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tZz3lHYbFWBT5iOFJngdQIjpC3Tk311r3yjU2+OSwVyl5id8IwEhWdLd4QsMM19hxkltKocoFWvLh1/lv1poUwArbkuj9sJ/KimefbYDJ04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4620 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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, 30 Jun 2020 12:35:30 -0000 Ping. > -----Original Message----- > From: Mihails Strasuns > Sent: Tuesday, June 16, 2020 1:46 PM > To: gdb-patches@sourceware.org > Cc: Strasuns, Mihails > Subject: [PATCH 2/2] Disable breakpoint locations in unloaded jit objects > = > Fixes the rare problem when identical JIT code is registered and unregist= ered > several times and its symbols happen to be relocated to the exactly the s= ame > addresses as previous time. In such situation gdb would still think that= old > breakpoint locations are still inserted (because `inserted` flag is set a= nd > objfile/address is the same) despite the fact that code memory was > overwritten and does not contain a breakpoint trap anymore. > = > This fix was suggested by Simon Marchi and extends > `disable_breakpoints_in_unloaded_shlib` to work on any object file and us= es > it to disable breakpoints for both shared libraries and jit objects. > = > gdb/ChangeLog: > 2020-06-16 Mihails Strasuns > = > * breakpoint.c (disable_breakpoints_in_unloaded_shlib): Renamed > to 'disable_breakpoints_in_unloaded_objfile` and changed to > accept an objfile as an argument. > (disable_breakpoints_in_unloaded_shlib): New function. > disable_breakpoints_in_unloaded_jit_objects): New function. > * jit.c (jit_unregister_code): New function, called to handle > JIT_UNREGISTER and discard a jit objfile properly. > * observable.c, observable.h: New observable, > 'jit_object_unloaded'. > = > gdb/testsuite/ChangeLog: > 2020-06-16 Mihails Strasuns > = > * gdb.base/jit-elf-reregister.c, gdb.base/jit-elf-reregister.exp: New > test case, verifies that breakpoints still hit if a jit object > that contains them gets reloaded and mapped again to the same > base address. > --- > gdb/breakpoint.c | 29 +++++-- > gdb/jit.c | 31 +++++--- > gdb/observable.c | 1 + > gdb/observable.h | 2 + > gdb/testsuite/gdb.base/jit-elf-reregister.c | 66 ++++++++++++++++ > gdb/testsuite/gdb.base/jit-elf-reregister.exp | 78 +++++++++++++++++++ > 6 files changed, 190 insertions(+), 17 deletions(-) create mode 100644 > gdb/testsuite/gdb.base/jit-elf-reregister.c > create mode 100644 gdb/testsuite/gdb.base/jit-elf-reregister.exp > = > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index > aead882acd..cc15c47303 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -7487,12 +7487,8 @@ disable_breakpoints_in_shlibs (void) > } > } > = > -/* Disable any breakpoints and tracepoints that are in SOLIB upon > - notification of unloaded_shlib. Only apply to enabled breakpoints, > - disabled ones can just stay disabled. */ > - > static void > -disable_breakpoints_in_unloaded_shlib (struct so_list *solib) > +disable_breakpoints_in_unloaded_objfile (objfile *objfile) > { > struct bp_location *loc, **locp_tmp; > int disabled_shlib_breaks =3D 0; > @@ -7502,7 +7498,7 @@ disable_breakpoints_in_unloaded_shlib (struct > so_list *solib) > /* ALL_BP_LOCATIONS bp_location has LOC->OWNER always non-NULL. > */ > struct breakpoint *b =3D loc->owner; > = > - if (solib->pspace =3D=3D loc->pspace > + if (objfile->pspace =3D=3D loc->pspace > && !loc->shlib_disabled > && (((b->type =3D=3D bp_breakpoint > || b->type =3D=3D bp_jit_event > @@ -7510,7 +7506,7 @@ disable_breakpoints_in_unloaded_shlib (struct > so_list *solib) > && (loc->loc_type =3D=3D bp_loc_hardware_breakpoint > || loc->loc_type =3D=3D bp_loc_software_breakpoint)) > || is_tracepoint (b)) > - && solib_contains_address_p (solib, loc->address)) > + && is_addr_in_objfile (loc->address, objfile)) > { > loc->shlib_disabled =3D 1; > /* At this point, we cannot rely on remove_breakpoint @@ -7526,13 > +7522,29 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) > target_terminal::ours_for_output (); > warning (_("Temporarily disabling breakpoints " > "for unloaded shared library \"%s\""), > - solib->so_name); > + objfile->original_name); > } > disabled_shlib_breaks =3D 1; > } > } > } > = > +/* Disable any breakpoints and tracepoints that are in SOLIB upon > + notification of unloaded_shlib. Only apply to enabled breakpoints, > + disabled ones can just stay disabled. */ > + > +static void > +disable_breakpoints_in_unloaded_shlib (struct so_list *solib) { > + disable_breakpoints_in_unloaded_objfile (solib->objfile); } > + > +static void > +disable_breakpoints_in_unloaded_jit_object (objfile *objfile) { > + disable_breakpoints_in_unloaded_objfile (objfile); } > + > /* Disable any breakpoints and tracepoints in OBJFILE upon > notification of free_objfile. Only apply to enabled breakpoints, > disabled ones can just stay disabled. */ @@ -15435,6 +15447,7 @@ > _initialize_breakpoint () > initialize_breakpoint_ops (); > = > gdb::observers::solib_unloaded.attach > (disable_breakpoints_in_unloaded_shlib); > + gdb::observers::jit_object_unloaded.attach > + (disable_breakpoints_in_unloaded_jit_object); > gdb::observers::free_objfile.attach > (disable_breakpoints_in_freed_objfile); > gdb::observers::memory_changed.attach > (invalidate_bp_value_on_memory_change); > = > diff --git a/gdb/jit.c b/gdb/jit.c > index 1b5ef46469..16e38078bb 100644 > --- a/gdb/jit.c > +++ b/gdb/jit.c > @@ -925,6 +925,27 @@ jit_find_objf_with_entry_addr (CORE_ADDR > entry_addr) > return NULL; > } > = > +/* This function unregisters JITed code and does the necessary cleanup. > +*/ > + > +static void > +jit_unregister_code (struct gdbarch *gdbarch, CORE_ADDR entry_addr) { > + struct objfile *objfile =3D nullptr; > + if (jit_debug) > + fprintf_unfiltered (gdb_stdlog, "jit_unregister_code (%s)\n", > + host_address_to_string (objfile)); > + objfile =3D jit_find_objf_with_entry_addr (entry_addr); > + if (objfile =3D=3D NULL) > + printf_unfiltered (_ ("Unable to find JITed code " > + "entry at address: %s\n"), > + paddress (gdbarch, entry_addr)); > + else > + { > + gdb::observers::jit_object_unloaded.notify (objfile); > + objfile->unlink (); > + } > +} > + > /* This is called when a breakpoint is deleted. It updates the > inferior's cache, if needed. */ > = > @@ -1335,7 +1356,6 @@ jit_event_handler (struct gdbarch *gdbarch) > struct jit_descriptor descriptor; > struct jit_code_entry code_entry; > CORE_ADDR entry_addr; > - struct objfile *objf; > = > /* Read the descriptor from remote memory. */ > if (!jit_read_descriptor (gdbarch, &descriptor, @@ -1353,14 +1373,7 @@ > jit_event_handler (struct gdbarch *gdbarch) > jit_register_code (gdbarch, entry_addr, &code_entry); > break; > case JIT_UNREGISTER: > - objf =3D jit_find_objf_with_entry_addr (entry_addr); > - if (objf =3D=3D NULL) > - printf_unfiltered (_("Unable to find JITed code " > - "entry at address: %s\n"), > - paddress (gdbarch, entry_addr)); > - else > - objf->unlink (); > - > + jit_unregister_code (gdbarch, entry_addr); > break; > default: > error (_("Unknown action_flag value in JIT descriptor!")); diff --= git > a/gdb/observable.c b/gdb/observable.c index 81aa392cc2..92354c64a3 > 100644 > --- a/gdb/observable.c > +++ b/gdb/observable.c > @@ -46,6 +46,7 @@ DEFINE_OBSERVABLE (inferior_created); > DEFINE_OBSERVABLE (record_changed); DEFINE_OBSERVABLE > (solib_loaded); DEFINE_OBSERVABLE (solib_unloaded); > +DEFINE_OBSERVABLE (jit_object_unloaded); > DEFINE_OBSERVABLE (new_objfile); > DEFINE_OBSERVABLE (free_objfile); > DEFINE_OBSERVABLE (new_thread); > diff --git a/gdb/observable.h b/gdb/observable.h index > 070cf0f18e..b60ee7f3ef 100644 > --- a/gdb/observable.h > +++ b/gdb/observable.h > @@ -111,6 +111,8 @@ extern observable > solib_loaded; > been unloaded yet, and thus are still available. */ extern > observable solib_unloaded; > = > +extern observable jit_object_unloaded; > + > /* The symbol file specified by OBJFILE has been loaded. Called > with OBJFILE equal to NULL to indicate previously loaded symbol > table data has now been invalidated. */ diff --git > a/gdb/testsuite/gdb.base/jit-elf-reregister.c b/gdb/testsuite/gdb.base/ji= t- > elf-reregister.c > new file mode 100644 > index 0000000000..2416259dcf > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-elf-reregister.c > @@ -0,0 +1,66 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2020 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see > + . */ > + > +#include "jit-protocol.h" > +#include "jit-elf-util.h" > + > +/* Must be defined by .exp file when compiling to know > + what address to map the ELF binary to. */ #ifndef LOAD_ADDRESS > +#error "Must define LOAD_ADDRESS" > +#endif > + > +int > +main (int argc, char *argv[]) > +{ > + /* Used as backing storage for GDB to populate argv. */ > + char *fake_argv[2]; > + > + size_t obj_size; > + void *load_addr =3D (void *) (size_t) LOAD_ADDRESS; void *addr =3D > + load_elf (argv[1], &obj_size, load_addr); int (*jit_function) () > + =3D (int (*) ()) load_symbol (addr, "jit_function_0001"); > + > + struct jit_code_entry *const entry > + =3D (struct jit_code_entry *) calloc (1, sizeof (*entry)); > + > + entry->symfile_addr =3D (const char *) addr; entry->symfile_size =3D > + obj_size; entry->prev_entry =3D __jit_debug_descriptor.relevant_entry; > + __jit_debug_descriptor.relevant_entry =3D entry; > + __jit_debug_descriptor.first_entry =3D entry; > + __jit_debug_descriptor.action_flag =3D JIT_REGISTER; > + __jit_debug_register_code (); > + > + jit_function (); /* first-call */ > + > + __jit_debug_descriptor.action_flag =3D JIT_UNREGISTER; > + __jit_debug_register_code (); > + > + addr =3D load_elf (argv[1], &obj_size, addr); jit_function =3D (int (= *) > + ()) load_symbol (addr, "jit_function_0001"); > + > + entry->symfile_addr =3D (const char *) addr; entry->symfile_size =3D > + obj_size; __jit_debug_descriptor.relevant_entry =3D entry; > + __jit_debug_descriptor.first_entry =3D entry; > + __jit_debug_descriptor.action_flag =3D JIT_REGISTER; > + __jit_debug_register_code (); > + > + jit_function (); > +} > diff --git a/gdb/testsuite/gdb.base/jit-elf-reregister.exp > b/gdb/testsuite/gdb.base/jit-elf-reregister.exp > new file mode 100644 > index 0000000000..614b7b9795 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-elf-reregister.exp > @@ -0,0 +1,78 @@ > +# Copyright 2019 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or # > +(at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, # but > +WITHOUT ANY WARRANTY; without even the implied warranty of # > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # > GNU > +General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License # > +along with this program. If not, see . > +*/ # # Tests global symbol lookup in case a symbol's name in the kernel > +# coincides with another in the main executable. > + > +if {[skip_shlib_tests]} { > + untested "skipping shared library tests" > + return -1 > +} > + > +load_lib jit-elf-helpers.exp > + > +# The main code that loads and registers JIT objects. > +set main_basename "jit-elf-reregister" > +set main_srcfile ${srcdir}/${subdir}/${main_basename}.c > +set main_binfile [standard_output_file ${main_basename}] > + > +# The shared library that gets loaded as JIT objects. > +set jit_solib_basename jit-elf-solib > +set jit_solib_srcfile ${srcdir}/${subdir}/${jit_solib_basename}.c > + > +# Compile one shared library to use as JIT object. > +set jit_solibs_target [compile_and_download_n_jit_so \ > + $jit_solib_basename $jit_solib_srcfile 1 {debug}] if { > +$jit_solibs_target =3D=3D -1 } { > + return > +} > + > +proc test_inferior_initial {num} { > + global jit_solibs_target main_srcfile main_binfile > +jit_solib_basename > + > + gdb_test "inferior ${num}" > + > + if { ![runto_main] } { > + fail "can't run to main for the inferior ${num}" > + return > + } > + > + # Poke desired values directly into inferior instead of using "set a= rgs" > + # because "set args" does not work under gdbserver. > + gdb_test_no_output "set var argc=3D1" "forging argc in inferior ${nu= m}" > + gdb_test_no_output "set var argv=3Dfake_argv" "forging argv in infer= ior > ${num}" > + set jit_solib_target [lindex $jit_solibs_target 0] > + gdb_test_no_output "set var argv\[1\]=3D\"${jit_solib_target}\"" \ > + "forging argv\[1\] in inferior ${num}" > + > + gdb_breakpoint [gdb_get_line_number "first-call" $main_srcfile] > {temporary} > + gdb_continue_to_breakpoint "first-call in inferior ${num}" > + gdb_breakpoint "jit_function_0001" > + gdb_continue_to_breakpoint "hit before reload inferior ${num}" > ".*$jit_solib_basename.*" > +} > + > +# Compile the main code (which loads the JIT objects). > +if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] !=3D 0 } { > + return > +} > + > +clean_restart ${main_binfile} > +gdb_test "add-inferior -exec ${main_binfile}" "Added inferior 2.*" \ > +"Add second inferior" > +test_inferior_initial 1 > +test_inferior_initial 2 > +gdb_continue_to_breakpoint "hit after reload inferior 2" > ".*$jit_solib_basename.*" > +gdb_test "inferior 1" "Switching to inferior 1.*" "finishing another inf= erior" > +gdb_continue_to_breakpoint "hit after reload inferior 1" > ".*$jit_solib_basename.*" > \ No newline at end of file > -- > 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