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 ED9FC3858D35 for ; Thu, 16 Mar 2023 17:03:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED9FC3858D35 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=1678986232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QTnQjodTY3o9+cU9K45u5BCtawYuvc7ZC1W6rm9Q0l0=; b=M9S0sqJhCtGp3LDQFqmv7j+YrFD4llzcbJrckiGbJzARqZPjKCxPYrZCmAgB/bSVIdSPoo ZgU94k66gRkOnLPfiNT8xMZh/E/eh9XbhzDrmn/rHse+kUHn1iq+vv+MOM1xcDmi3yttFs xCdFFdU2hC5+EIWYQIgnYMqZYpGtG2s= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-EQBW5Ub1PAmlKHVW56oFrA-1; Thu, 16 Mar 2023 13:03:50 -0400 X-MC-Unique: EQBW5Ub1PAmlKHVW56oFrA-1 Received: by mail-ed1-f70.google.com with SMTP id y24-20020aa7ccd8000000b004be3955a42eso3963546edt.22 for ; Thu, 16 Mar 2023 10:03:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678986229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QTnQjodTY3o9+cU9K45u5BCtawYuvc7ZC1W6rm9Q0l0=; b=717hUaaz6ziseuOhNJyFj9koLtKcfsK+CXJvZrTa2XxVs1CLtRnsDwE9OhKRonRkBa MNIvbPVLYwQl75OtlOXEtcWQqwUQeDmBitWDe23bHgTcDQVIVsyDZQr9glg1VQLOuEFh y2OLlFQFu9mSrugoS2m2RPWgLAIdAR3ZuRLuDnYs0eYafuC7hzpL8tmpbJo3XiUutP4r wUKlRshH39YKnYwaK1QrCIczvKy+cfRE5HS+m2dECN85vX4QynrK1WP9aEppCgZt3xu/ 229qQwwwVLfCquWw/n8k58n/XPzzfGHIYxksNBDORBexZ99xT2oKes1DBPTpS7ZVceIE fUrQ== X-Gm-Message-State: AO0yUKXDeoygbVZe9lwXNY8L0o6hXXBwcBJLaAHjOZbJtZXLErdwfloN pvNkle8nfMdgbls4szawPVaX7Md3IevuJxpwGgu8+2c9sX3O2sfBOcgz9pG4KOzEtofIeUmh0EQ aJFf3wLZLfz8cPI7DtDHnehqPd95rQCJHBaceIeb0JOV/0jpDM0POZLiObgdSlyfbWdXxZaQvoC T79y7xRw== X-Received: by 2002:a17:907:8e9a:b0:92f:3fbb:a077 with SMTP id tx26-20020a1709078e9a00b0092f3fbba077mr6550993ejc.72.1678986229617; Thu, 16 Mar 2023 10:03:49 -0700 (PDT) X-Google-Smtp-Source: AK7set+F/Y2ROiAuAOEONYZ5S8I7XsiwxXX4VSfx89Kwh7j9ZyiD8h25xJrNa8yQzclNiGJnLm1i9w== X-Received: by 2002:a17:907:8e9a:b0:92f:3fbb:a077 with SMTP id tx26-20020a1709078e9a00b0092f3fbba077mr6550967ejc.72.1678986229219; Thu, 16 Mar 2023 10:03:49 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id i24-20020a508718000000b004aef147add6sm6613edb.47.2023.03.16.10.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 10:03:48 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 1/2] gdb: cleanup around some set_momentary_breakpoint_at_pc calls Date: Thu, 16 Mar 2023 17:03:44 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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: 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. --- 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