From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103716 invoked by alias); 23 Nov 2018 18:26:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 103703 invoked by uid 89); 23 Nov 2018 18:26:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,SPF_PASS autolearn=ham version=3.3.2 spammy=pm, UD:p.m, p.m, stays X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Nov 2018 18:26:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1542997573; x=1545589573; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tsjHgYkWgWZ4q1tCHBmWBMqH6zaGXMMpOSqOl4G+JeY=; b=IprNlPhe0Nnc36i8PifvqdR7GXPzRiSzbk8NuB/hurCCDC4sQdv5Gi/EWKCBqhFf ZtUX9jK/gQcjSK9jFpYJ/zRnRqhiJc9Ry4uNS6RFlKwbZVPQLtfoCgE3ypZ4hhGY l77aasAxylrXjkgVcebrkrF3HNtlOyay1w1W3usmxO8=; Received: from ESESSMB505.ericsson.se (Unknown_Domain [153.88.183.123]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id BA.5B.10055.54648FB5; Fri, 23 Nov 2018 19:26:13 +0100 (CET) Received: from ESESBMR501.ericsson.se (153.88.183.129) by ESESSMB505.ericsson.se (153.88.183.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 23 Nov 2018 19:26:12 +0100 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESBMR501.ericsson.se (153.88.183.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 23 Nov 2018 19:26:12 +0100 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Fri, 23 Nov 2018 19:26:12 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tsjHgYkWgWZ4q1tCHBmWBMqH6zaGXMMpOSqOl4G+JeY=; b=JQmh4lfeHQL5afD3xIIqeZG+7QOcO1kwQLuQHokgMyzSjYeFikVd2LtXmldiqJ/o8avpHGK5UeMZaYsfRMdxGQNvGSo1eO0KoQELa0h2AP2H4GpfZOoWH+/6r9mA/f8lrq5nAdB+swRMoSlUX8Juk7h5+729rfXxgInznq+0CMM= Received: from BYAPR15MB2390.namprd15.prod.outlook.com (52.135.198.30) by BYAPR15MB2392.namprd15.prod.outlook.com (52.135.198.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.18; Fri, 23 Nov 2018 18:26:10 +0000 Received: from BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::2978:b8d7:86fd:94ed]) by BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::2978:b8d7:86fd:94ed%3]) with mapi id 15.20.1361.018; Fri, 23 Nov 2018 18:26:10 +0000 From: Simon Marchi To: Pedro Alves , Simon Marchi CC: "gdb-patches@sourceware.org" , "dblaikie@gmail.com" Subject: Re: [PATCH] Use std::vector for displaced_step_inferior_states Date: Fri, 23 Nov 2018 18:26:00 -0000 Message-ID: <1930813a-3552-a940-64e8-05ec2f1b159f@ericsson.com> References: <20181122031229.15621-1-simon.marchi@ericsson.com> <68730078c8a3a37d65ad3046348ccbc6@polymtl.ca> <1f966d70-b48d-35a9-9841-8d580371c710@redhat.com> In-Reply-To: <1f966d70-b48d-35a9-9841-8d580371c710@redhat.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) Content-Type: text/plain; charset="utf-8" Content-ID: <6BEA5670A31C0644BA30AE0E82BDB46E@namprd15.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00391.txt.bz2 T24gMjAxOC0xMS0yMiAxMjoxNyBwLm0uLCBQZWRybyBBbHZlcyB3cm90ZToN Cj4+IEkgZGlkIGEgcXVpY2sgdGVzdCBvZiBoYXZpbmcgYSBwb2ludGVyIHRv IGRpc3BsYWNlZF9zdGVwX2luZmVyaW9yX3N0YXRlIGluIHRoZSBpbmZlcmlv ciBzdHJ1Y3R1cmUgKHRoZSBpbXBsZW1lbnRhdGlvbiBvZiBkaXNwbGFjZWRf c3RlcF9pbmZlcmlvcl9zdGF0ZSBzdGF5cyBpbiBpbmZydW4uYyksIGl0IHNl ZW1zIHRvIHdvcmsgd2VsbC4gwqBXb3VsZCB5b3UgcHJlZmVyIHRoYXQ/DQo+ IA0KPiBJIHRoaW5rIHRoYXQgd291bGQgYmUgYmV0dGVyLCB5ZWFoLiAgRWl0 aGVyIHBvaW50ZXIgb3Igb2JqZWN0IChhbmQgbW92aW5nIHRoZQ0KPiBzdHJ1 Y3QgdG8gc29tZSBoZWFkZXIpLCBib3RoIGFyZSBmaW5lIHdpdGggbWUuDQoN CkRyb3BwaW5nIHRoaXMgcGF0Y2ggaW4gZmF2b3Igb2Y6DQoNCmh0dHBzOi8v c291cmNld2FyZS5vcmcvbWwvZ2RiLXBhdGNoZXMvMjAxOC0xMS9tc2cwMDM5 MC5odG1sDQoNClNpbW9uDQo= >From gdb-patches-return-152441-listarch-gdb-patches=sources.redhat.com@sourceware.org Fri Nov 23 19:01:31 2018 Return-Path: Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 3500 invoked by alias); 23 Nov 2018 19:01:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3490 invoked by uid 89); 23 Nov 2018 19:01:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=notable, all_inferiors, ALL_INFERIORS, 2584 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Nov 2018 19:01:28 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61961315484B; Fri, 23 Nov 2018 19:01:27 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BFA05C26C; Fri, 23 Nov 2018 19:01:26 +0000 (UTC) Subject: Re: [PATCH] Place displaced step data directly in inferior structure To: Simon Marchi , "gdb-patches@sourceware.org" References: <20181123182429.9045-1-simon.marchi@ericsson.com> Cc: "dblaikie@gmail.com" From: Pedro Alves Message-ID: Date: Fri, 23 Nov 2018 19:01:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181123182429.9045-1-simon.marchi@ericsson.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-11/txt/msg00392.txt.bz2 Content-length: 3236 On 11/23/2018 06:24 PM, Simon Marchi wrote: > This patch moves the per-inferior data related to displaced stepping to > be directly in the inferior structure, rather than in a container on the > side. > > On notable difference is that previously, we deleted the state on > inferior exit, which guaranteed a clean state if re-using the inferior > for a new run or attach. We now need to reset the state manually. > Thanks. This LGTM. See a couple nits below. > > /* Returns true if any inferior has a thread doing a displaced > @@ -1531,9 +1490,11 @@ get_displaced_stepping_state (inferior *inf) > static bool > displaced_step_in_progress_any_inferior () > { > - for (auto *state : displaced_step_inferior_states) > + inferior *i; > + > + ALL_INFERIORS (i) This won't compile in current master. :-) Use for (inferior *inf : all_inferiors ()) > { > - if (state->step_thread != nullptr) > + if (i->displaced_step_state.step_thread != nullptr) > return true; > } > if (debug_infrun) > diff --git a/gdb/infrun.h b/gdb/infrun.h > index a701f0ca47f..81b3c326163 100644 > --- a/gdb/infrun.h > +++ b/gdb/infrun.h > @@ -258,4 +258,51 @@ struct buf_displaced_step_closure : displaced_step_closure > gdb::byte_vector buf; > }; > > +/* Per-inferior displaced stepping state. */ > +struct displaced_step_inferior_state > +{ > + /* Put this object back in its original state. s*/ Typo: the "s" at the end. > +/* Per-inferior displaced stepping state. */ > +struct displaced_step_inferior_state > +{ > + /* Put this object back in its original state. s*/ > + void reset () > + { > + /* These should have been cleaned after the last displaced step > + operation, so if there are still set, it's a bug. */ > + gdb_assert (step_thread == nullptr); > + gdb_assert (step_closure == nullptr); > + > + failed_before = 0; > + step_gdbarch = nullptr; > + step_original = 0; > + step_copy = 0; > + > + if (step_saved_copy != nullptr) > + { > + xfree (step_saved_copy); > + step_saved_copy = nullptr; > + } > + } > + > + /* True if preparing a displaced step ever failed. If so, we won't > + try displaced stepping for this inferior again. */ > + int failed_before = 0; > + > + /* If this is not nullptr, this is the thread carrying out a > + displaced single-step in process PID. This thread's state will > + require fixing up once it has completed its step. */ > + thread_info *step_thread = nullptr; > + > + /* The architecture the thread had when we stepped it. */ > + gdbarch *step_gdbarch = nullptr; > + > + /* The closure provided gdbarch_displaced_step_copy_insn, to be used > + for post-step cleanup. */ > + displaced_step_closure *step_closure = nullptr; > + > + /* The address of the original instruction, and the copy we > + made. */ > + CORE_ADDR step_original = 0, step_copy = 0; > + > + /* Saved contents of copy area. */ > + gdb_byte *step_saved_copy = nullptr; I'm fine with this, but I thought I'd mention another possibility, which is to not initialize the field in-class, but instead add a ctor that calls reset(), thus keeping the initializations all in the same place. Thanks, Pedro Alves