From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id B0B993858D38 for ; Mon, 12 Jun 2023 19:21:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0B993858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-777ac4344f9so182779739f.0 for ; Mon, 12 Jun 2023 12:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686597699; x=1689189699; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6Rt8SCRUB8g9XzNvvTkiKakl6gItpmCRfB4bTWsq2ug=; b=BFKpWgO0gCWyxYP7GL5WdTQIYDdUVCuCdsVl90MqloAroqF329sCfliW3j0ACEj45f 6xm7qN9V1f3yDIMP8BwXXiMT8Y+MgrRWHzB1/0Bi950YM80fyb0SZi0KP4pJg0AHzWTI itA71VcG5PA4xu3MvcGcg78VPJpSFm6Jw0UlgSailiY+0OKHJhwzkoYm2yRLO3/yNTz7 I9emdpPKz/YEem1tPrK+q4WEw6skNmPxCxmepJ4/FgWuPajs3cHZfhCGPCBPxj38i92W dQhrTCJOGA6cwRRVhNvov6dj2u56cbpvh05t9KxLNcGysdcmjTcB4WfhddwC4i0gSuYA ex+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686597699; x=1689189699; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Rt8SCRUB8g9XzNvvTkiKakl6gItpmCRfB4bTWsq2ug=; b=ebqBhV33Zg3rQZTLOSOEQqfgjL9JsmsV2nHwrR/gBuh5wyEBLeiFXmzg893dFaDt8S 2M8FgRdrN847txXS9QEZuCMzSC6+WVgXxNfFEDkprvxjA1/Ns1VxLe5jU8IxBl8wssCw Cq5WSdSjbZ+adJj5IozcqJD+IwS3eGc+0mGJzH8OsuzgVyboMN7njpV8Vq8tCYAPCH8Q 8lGbV8pVHenpFfGx+vrty5gnfAA3ollhxTkG2PPQXIeH9VzMQPU4361Q8ikHY8Aq1r2F 7fIT3ztznpw4Vl7zdJ8ptt2keZbu1FyzQZkLqOUHKs2OPVWreId8u3JfBRxRx8ice89D LRng== X-Gm-Message-State: AC+VfDwu4AoUrTEKvLiiXCyCdrRJK7rkAEGFvlVz/lPc6V2hZSmvFPH6 lUlh3weXdNQzf4avz0puxIe5koPMHWoovWZIyOzTXA== X-Google-Smtp-Source: ACHHUZ44CLiNXok9pXizgW05zxA9q7V6Q7hmQIZrXyYqBSoqDksWWES0WxlnlbDKHP3s8YtHOCVEhw== X-Received: by 2002:a5e:da0a:0:b0:76f:f2f5:5502 with SMTP id x10-20020a5eda0a000000b0076ff2f55502mr9257125ioj.12.1686597698951; Mon, 12 Jun 2023 12:21:38 -0700 (PDT) Received: from localhost.localdomain (75-166-136-83.hlrn.qwest.net. [75.166.136.83]) by smtp.gmail.com with ESMTPSA id k27-20020a02ccdb000000b0041aaebd2017sm2871283jaq.82.2023.06.12.12.21.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 12:21:38 -0700 (PDT) From: Tom Tromey Date: Mon, 12 Jun 2023 13:21:36 -0600 Subject: [PATCH 1/2] Call target_can_do_single_step from maybe_software_singlestep MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230612-sw-single-step-v1-1-c06d648e121b@adacore.com> References: <20230612-sw-single-step-v1-0-c06d648e121b@adacore.com> In-Reply-To: <20230612-sw-single-step-v1-0-c06d648e121b@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: 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. 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