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.133.124]) by sourceware.org (Postfix) with ESMTPS id 6414F3858C98 for ; Thu, 16 Nov 2023 10:12:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6414F3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6414F3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700129555; cv=none; b=p1LoMyryYWDyoZk+lEzsdRtnMXUFurg7VxW53D1LK4h2DghooMM1yo40uinM+xgt8Yx0cMNEKip00fIJnXCRSsApnrMVNcQhhqO9sh5XCUEjW0L20U2KMni5ssdfijQh2g8E1DEWdkXCd1FMZEtrcCh3vm3taDxYfigsEA89068= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700129555; c=relaxed/simple; bh=F52QuFc1BYV25ONOa68aruItD/vpiNg2ipxWh5b/Lkk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=T0R+rRd8q/rmde6oScUT/w+9j2ASLXslkHdabEAYBNO6x1QuYKszfPNLwJntQOgyWjJiYnxRiWJiVUKDEjbmkssj9+FK5t4dIAaFm/pl1xXTzgEUJXwU/RUICKuisT8sPQp01a+ThLkBxfO+ohAzGooNol4QhuBndSbZH51mwHE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700129553; 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=cEB0hW68bu2S/EF7fzrcB5sgcwOSvRbArQhpylRAOyo=; b=PrxSx/UxNriu51eixvS8/C82iH5VH2p0NtD26hzH8hP1nYckI+7QLLTrwuPsENzAAkbHkA LwlUxCJPA+Vb45+glw1ThOgc/O5bLdP04J2nuVsLpjwyqjL6H3nZELVkQ8LwmmobwdCpqT 8fCPa+JKeNDz6KMZtWLf8uZnfUsw9M8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-lfoLxZtgMRe0qDze1mZLTA-1; Thu, 16 Nov 2023 05:12:31 -0500 X-MC-Unique: lfoLxZtgMRe0qDze1mZLTA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4083fec2c30so3502905e9.1 for ; Thu, 16 Nov 2023 02:12:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700129550; x=1700734350; 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=cEB0hW68bu2S/EF7fzrcB5sgcwOSvRbArQhpylRAOyo=; b=fqPJXuYj/teWi0p1xkylAcr8dKVTC0gdZy2a3TPpzK2r3L+h+MOFm25639BWzzBwE+ kgxm8Dl1BLVv6Fh4EdGeXuYuVCqaz0rMrl+MpA1AVpL/mbGOEo4jwJ3dEsu1X4neP9cH hrfFMFTJddzpU5WfS+l1JHTm+BnJeL4FpHtMg119hM3zLrnp4l/ewuC4BG9SC6WnN8zd 3v3wkfCZrpWz3cAlRy5mgvIT8s3xji2EKvB6ORqC+tHHnM0KcpkZL3fubzJYgepUE/UY LnpMdznnHisWExu4q8OhDO378KnqtuFEWtvnNDx3tzz6dQNj3Q3wAgbUc126xteiNEWO +X+w== X-Gm-Message-State: AOJu0Yyfuk2lTGMyKJI4xuktRyI68fgybdvzwM7NgNgyPL+k/pgcfTvh vWrTq9BsxzFpzs+gtEL+o7c5xr+eaaEKTXHdYoObItWAQ+raxeFyG9xaRPXpspxJnMpjJDJl+UE AYxE4jOX9/dOY3HGOJ9R+OA== X-Received: by 2002:a05:600c:19c8:b0:401:73b2:f043 with SMTP id u8-20020a05600c19c800b0040173b2f043mr12544390wmq.1.1700129550603; Thu, 16 Nov 2023 02:12:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEEWgh+vWQIAzMsMUhsiNCwkiptkU+bzAStJqZHRNuRa1+dpvREerklgjCl43J434wSf60qg== X-Received: by 2002:a05:600c:19c8:b0:401:73b2:f043 with SMTP id u8-20020a05600c19c800b0040173b2f043mr12544368wmq.1.1700129550153; Thu, 16 Nov 2023 02:12:30 -0800 (PST) Received: from localhost (105.226.159.143.dyn.plus.net. [143.159.226.105]) by smtp.gmail.com with ESMTPSA id n21-20020a7bc5d5000000b003fbe4cecc3bsm2884143wmk.16.2023.11.16.02.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:12:29 -0800 (PST) From: Andrew Burgess To: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Call target_can_do_single_step from maybe_software_singlestep In-Reply-To: <20230612-sw-single-step-v1-1-c06d648e121b@adacore.com> References: <20230612-sw-single-step-v1-0-c06d648e121b@adacore.com> <20230612-sw-single-step-v1-1-c06d648e121b@adacore.com> Date: Thu, 16 Nov 2023 10:12:28 +0000 Message-ID: <87il62qa5v.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.8 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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Tom Tromey via Gdb-patches writes: > When the PikeOS osabi sniffer was added, Pedro suggested that a target > could omit stepping from its vCont? reply packet to tell gdb that > software single-step must be used: > > https://sourceware.org/legacy-ml/gdb-patches/2018-09/msg00312.html > > This patch implements this idea by moving the call to > target_can_do_single_step into maybe_software_singlestep. So this changes the behaviour for record-full.c, which includes two calls to insert_single_step_breakpoints, which bypasses maybe_software_singlestep. If I'm reading the code correctly, after this change, we'll switch from using h/w stepping to s/w stepping. I'm assuming this isn't an intentional change as it's not mentioned. I'm tempted to suggest that the two calls to insert_single_step_breakpoints in record-full.c should really be calling maybe_software_singlestep; I don't believe we can be recording in a backward direction -- that makes no sense, we record forward, and use the record to move backward. And other than a duplicate call to gdbarch_software_single_step_p, calling maybe_software_singlestep seems otherwise harmless .... and after this patch we'd pick up the target_can_do_single_step call, which is probably what we want. Of course, if we did change record-full.c to use maybe_software_singlestep then there would only be one call to insert_single_step_breakpoints, so we could possibly fold this into maybe_software_singlestep? Thanks, Andrew > > I've also removed some FIXME comments from gdbarch_components.py, and > slightly updated the documentation for gdbarch_software_single_step. > I think these comments are somewhat obsolete now that > target_can_do_single_step exists -- the current approach isn't exactly > what the comments intended, but on the other hand, it exists and > works. > --- > gdb/arm-linux-tdep.c | 5 ----- > gdb/gdbarch-gen.h | 12 +++--------- > gdb/gdbarch_components.py | 12 +++--------- > gdb/infrun.c | 12 +++++++++--- > 4 files changed, 15 insertions(+), 26 deletions(-) > > diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c > index dfa816990ff..f4da996728b 100644 > --- a/gdb/arm-linux-tdep.c > +++ b/gdb/arm-linux-tdep.c > @@ -923,11 +923,6 @@ arm_linux_software_single_step (struct regcache *regcache) > struct gdbarch *gdbarch = regcache->arch (); > struct arm_get_next_pcs next_pcs_ctx; > > - /* If the target does have hardware single step, GDB doesn't have > - to bother software single step. */ > - if (target_can_do_single_step () == 1) > - return {}; > - > arm_get_next_pcs_ctor (&next_pcs_ctx, > &arm_linux_get_next_pcs_ops, > gdbarch_byte_order (gdbarch), > diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h > index 101b1b73636..1d86879f00a 100644 > --- a/gdb/gdbarch-gen.h > +++ b/gdb/gdbarch-gen.h > @@ -721,16 +721,10 @@ extern void set_gdbarch_get_memtag (struct gdbarch *gdbarch, gdbarch_get_memtag_ > extern CORE_ADDR gdbarch_memtag_granule_size (struct gdbarch *gdbarch); > extern void set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, CORE_ADDR memtag_granule_size); > > -/* FIXME/cagney/2001-01-18: This should be split in two. A target method that > - indicates if the target needs software single step. An ISA method to > - implement it. > +/* Return a vector of addresses at which the software single step > + breakpoints should be inserted. An empty vector means software single > + step is not used. > > - FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the > - target can single step. If not, then implement single step using breakpoints. > - > - Return a vector of addresses on which the software single step > - breakpoints should be inserted. NULL means software single step is > - not used. > Multiple breakpoints may be inserted for some instructions such as > conditional branch. However, each implementation must always evaluate > the condition and only put the breakpoint at the branch destination if > diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py > index 23e5789327c..7f2380ae0a7 100644 > --- a/gdb/gdbarch_components.py > +++ b/gdb/gdbarch_components.py > @@ -1301,16 +1301,10 @@ For a non-zero value, this represents the number of bytes of memory per tag. > > Function( > comment=""" > -FIXME/cagney/2001-01-18: This should be split in two. A target method that > -indicates if the target needs software single step. An ISA method to > -implement it. > +Return a vector of addresses at which the software single step > +breakpoints should be inserted. An empty vector means software single > +step is not used. > > -FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the > -target can single step. If not, then implement single step using breakpoints. > - > -Return a vector of addresses on which the software single step > -breakpoints should be inserted. NULL means software single step is > -not used. > Multiple breakpoints may be inserted for some instructions such as > conditional branch. However, each implementation must always evaluate > the condition and only put the breakpoint at the branch destination if > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 58da1cef29e..d1dce33bd3a 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -2242,9 +2242,15 @@ maybe_software_singlestep (struct gdbarch *gdbarch) > { > bool hw_step = true; > > - if (execution_direction == EXEC_FORWARD > - && gdbarch_software_single_step_p (gdbarch)) > - hw_step = !insert_single_step_breakpoints (gdbarch); > + if (execution_direction == EXEC_FORWARD) > + { > + if (target_can_do_single_step () == 1) > + { > + /* The target definitely has hardware single step. */ > + } > + else if (gdbarch_software_single_step_p (gdbarch)) > + hw_step = !insert_single_step_breakpoints (gdbarch); > + } > > return hw_step; > } > > -- > 2.40.1