From patchwork Wed May 24 16:37:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 69986 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 179033884587 for ; Wed, 24 May 2023 16:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 179033884587 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684946513; bh=Xt8JOCWFUpLk0uXutifu2Dl78Sinj597hMAY729iO+Q=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xZMscExGqiE8Di5o+e2OXdEK4h76oIiuYn/+ClC6XRmSNkgsypRA9D3aj989is5Ng Cm7ZSm8X4k6ZjVJRdkgJDajzwqmofN6ukrzGsjZ2wf1xG+aXgZlr/5QTMH1CPki0DK 6kQ+psfcBTarzkxvSiP5JmP90UWfDXowHA5tRqSY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by sourceware.org (Postfix) with ESMTPS id 6E6DC3856DDF for ; Wed, 24 May 2023 16:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E6DC3856DDF Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-76c626eb5d1so31673239f.0 for ; Wed, 24 May 2023 09:37:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684946258; x=1687538258; 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=Xt8JOCWFUpLk0uXutifu2Dl78Sinj597hMAY729iO+Q=; b=U0JoXrBZuX5uIwTRcAbzhP3kkECoMCCNYhyXCoGJ0GMzi/0d8pDXUNTO70y13Qhsk4 3TnOMnvSX6zMmX7a7UUREqUUQl5alFBfmnK/T9NkG3Gn2DMQIBbcTQLAU6YvUInuPQAt lvX+3PacKMACfysvcrBSFIsE3wKqgSUXo+AFlG/fjiVyL/U18o+kLSe/aLcgk9OMHJQu XGB5FmM0EpIKYks16lUcHLTf9s2lvom3t/9SOwObaqTOOjgbUdsli2DDUEjE7DU37IcP A6dm9vxUtIDgRNYcZp6gAJLOtN3+7IiA4YUj7KwTRY0X3N6juZyUA+VvTfLwtQpqdgK2 mcuw== X-Gm-Message-State: AC+VfDy/djdUCxvPxFbndZk4ks9rOEvyOTFer6HooSNFdqTEXYbp6Rto dJYzoJjEb/RNZTNRwWUm3D9kop2gXJ/5CS4v+jeUWw== X-Google-Smtp-Source: ACHHUZ4OdNgt3I52cweIKjJvvvj5O3//JOsWu1i2tSlJYh3eqJa2rP37xZN8+1LJz7UFpZDKoqMK0A== X-Received: by 2002:a5d:8ad7:0:b0:76c:6382:8d5b with SMTP id e23-20020a5d8ad7000000b0076c63828d5bmr12169325iot.10.1684946258699; Wed, 24 May 2023 09:37:38 -0700 (PDT) Received: from localhost.localdomain (71-211-130-244.hlrn.qwest.net. [71.211.130.244]) by smtp.gmail.com with ESMTPSA id o22-20020a6bcf16000000b0076c81bf2731sm3397266ioa.20.2023.05.24.09.37.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 09:37:38 -0700 (PDT) Date: Wed, 24 May 2023 10:37:15 -0600 Subject: [PATCH 24/25] Do not report totalFrames from DAP stackTrace request MIME-Version: 1.0 Message-Id: <20230427-ada-catch-exception-v1-24-947caa9905e3@adacore.com> References: <20230427-ada-catch-exception-v1-0-947caa9905e3@adacore.com> In-Reply-To: <20230427-ada-catch-exception-v1-0-947caa9905e3@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-12.1 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Currently, gdb will unwind the entire stack in response to the stackTrace request. I had erroneously thought that the totalFrames attribute was required in the response. However, the spec says: If omitted or if `totalFrames` is larger than the available frames, a client is expected to request frames until a request returns less frames than requested (which indicates the end of the stack). This patch removes this from the response in order to improve performance when the stack trace is very long. --- gdb/python/lib/gdb/dap/bt.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gdb/python/lib/gdb/dap/bt.py b/gdb/python/lib/gdb/dap/bt.py index a38573fbba8..4439b428926 100644 --- a/gdb/python/lib/gdb/dap/bt.py +++ b/gdb/python/lib/gdb/dap/bt.py @@ -50,13 +50,9 @@ def _backtrace(thread_id, levels, startFrame): current_frame = gdb.newest_frame() except gdb.error: current_frame = None - # Note that we always iterate over all frames, which is lame, but - # seemingly necessary to support the totalFrames response. - # FIXME maybe the mildly mysterious note about "monotonically - # increasing totalFrames values" would let us fix this. - while current_frame is not None: + while current_frame is not None and (levels == 0 or len(frames) < levels): # This condition handles the startFrame==0 case as well. - if current_number >= startFrame and (levels == 0 or len(frames) < levels): + if current_number >= startFrame: newframe = { "id": frame_id(current_frame), "name": _frame_name(current_frame), @@ -80,9 +76,11 @@ def _backtrace(thread_id, levels, startFrame): frames.append(newframe) current_number = current_number + 1 current_frame = current_frame.older() + # Note that we do not calculate totalFrames here. Its absence + # tells the client that it may simply ask for frames until a + # response yields fewer frames than requested. return { "stackFrames": frames, - "totalFrames": current_number, }