From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 80A173858D37 for ; Mon, 3 Apr 2023 14:12:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 80A173858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680531135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UbPtThgrXg2/RoVUqUZw798LpBF7rlrv1/rU+kRdwSU=; b=U/Ynlm20XxzIiPZj5gT5jqzZ0iii12E6SlzHxtVzXYW+2qhZXZKx9q4I96KEAVmm6Ms0Wf MHYlOsJPvj16s4lg5KclFYZcnZoOOqS7jrASGYUwzej+bgv1T1W+R7yZGYruCmdfHgfRil NVw2TOf1lH0TPvZU2ZWGf8h9rQFzYlA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-BXwZLG3COBSpiXyZjuhc0Q-1; Mon, 03 Apr 2023 10:12:13 -0400 X-MC-Unique: BXwZLG3COBSpiXyZjuhc0Q-1 Received: by mail-qt1-f200.google.com with SMTP id u22-20020a05622a011600b003dfd61e8594so19887251qtw.15 for ; Mon, 03 Apr 2023 07:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680531133; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UbPtThgrXg2/RoVUqUZw798LpBF7rlrv1/rU+kRdwSU=; b=6Aaygk532EVENeDHKUd9GwbK6JhZjASgRUJ/92iHLR7OLailRN+vprcOAagvOxXUC6 n/l/6Rt3tVwwV3v4ji5MYpIveb/1JITXSAdANFhyCnT+3o90jRbejx+fqCuuLqyZGGvO 5OcPt2HmgkZFTgV6UAPy+uI8pADsIB5rGJdMuFuj7NXqqBG7/0hMOG+YAA0K2TbORsk4 4QIgVtXMNOe/rV6jfPw/g5IaHSE0KnZBHGwmtSkSVuNOGgelF1pOwl+TA7jwwLtQyxLA tDW409JGXhD1XhFaEU80WyiXv6mlorgzxy6Vyvhp9bYTdRvd6YdA2oHcWUO4d2NlCN2F MVXQ== X-Gm-Message-State: AAQBX9fcIIE4dvE5jJsbWLMyShtRULC8rGMVGhRTzGTsAeKD853zNwFn wFgDTeGIJ25YGtvTAL3y9Ya94THNUF2HrqROhxR2gv5e1Y5ZuQH8Pf40bNXl2w4OzL/GrhkxE5e DyD8Ast//zCmX7Ude4wVQQonGtMwanZrEwyHyYgH4gXKYA0eU6eiKK8RPR1IVa8LdZhag+ORFOL 994qTG9g== X-Received: by 2002:a05:6214:248f:b0:5cd:d042:263a with SMTP id gi15-20020a056214248f00b005cdd042263amr58709585qvb.51.1680531133245; Mon, 03 Apr 2023 07:12:13 -0700 (PDT) X-Google-Smtp-Source: AKy350YsU5aWY77B2puqJPWRyEBTJMrDMNyj/g89skCywk7nDGCh3rc8jWNI4ab4Mjzt8RmEpancLA== X-Received: by 2002:a05:6214:248f:b0:5cd:d042:263a with SMTP id gi15-20020a056214248f00b005cdd042263amr58709549qvb.51.1680531132842; Mon, 03 Apr 2023 07:12:12 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id q30-20020a37f71e000000b007468765b411sm2786663qkj.45.2023.04.03.07.12.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:12:12 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCHv3 1/2] gdb: cleanup around some set_momentary_breakpoint_at_pc calls In-Reply-To: References: Date: Mon, 03 Apr 2023 15:12:10 +0100 Message-ID: <87cz4lcax1.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Andrew Burgess writes: > I noticed a couple of places in infrun.c where we call > set_momentary_breakpoint_at_pc, and then set the newly created > breakpoint's thread field, these are in: > > insert_exception_resume_breakpoint > insert_exception_resume_from_probe > > Function set_momentary_breakpoint_at_pc calls > set_momentary_breakpoint, which always creates the breakpoint as > thread-specific for the current inferior_thread(). > > The two insert_* functions mentioned above take an arbitrary > thread_info* as an argument and set the breakpoint::thread to hold the > thread number of that arbitrary thread. > > However, the insert_* functions store the breakpoint pointer within > the current inferior_thread(), so we know that the thread being passed > in must be the currently selected thread. > > What this means is that we can: > > 1. Assert that the thread being passed in is the currently selected > thread, and > > 2. No longer adjust the breakpoint::thread field, this will already > have been set correctly be calling set_momentary_breakpoint_at_pc. > > There should be no user visible changes after this commit. I went ahead and pushed this patch. Let me know if there are any objections. Thanks, Andrew > --- > gdb/infrun.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 33aa0c8794b..35c3d2b8f58 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -8138,6 +8138,9 @@ insert_exception_resume_breakpoint (struct thread_info *tp, > infrun_debug_printf ("exception resume at %lx", > (unsigned long) handler); > > + /* set_momentary_breakpoint_at_pc creates a thread-specific > + breakpoint for the current inferior thread. */ > + gdb_assert (tp == inferior_thread ()); > bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), > handler, > bp_exception_resume).release (); > @@ -8145,8 +8148,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, > /* set_momentary_breakpoint_at_pc invalidates FRAME. */ > frame = nullptr; > > - bp->thread = tp->global_num; > - inferior_thread ()->control.exception_resume_breakpoint = bp; > + tp->control.exception_resume_breakpoint = bp; > } > } > catch (const gdb_exception_error &e) > @@ -8176,10 +8178,12 @@ insert_exception_resume_from_probe (struct thread_info *tp, > infrun_debug_printf ("exception resume at %s", > paddress (probe->objfile->arch (), handler)); > > + /* set_momentary_breakpoint_at_pc creates a thread-specific breakpoint > + for the current inferior thread. */ > + gdb_assert (tp == inferior_thread ()); > bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame), > handler, bp_exception_resume).release (); > - bp->thread = tp->global_num; > - inferior_thread ()->control.exception_resume_breakpoint = bp; > + tp->control.exception_resume_breakpoint = bp; > } > > /* This is called when an exception has been intercepted. Check to > -- > 2.25.4