From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-xd2a.google.com with SMTP id ca18e2360f4ac-76c626eb5d1so31673239f.0 for ; Wed, 24 May 2023 09:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684946258; x=1687538258; 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=Xt8JOCWFUpLk0uXutifu2Dl78Sinj597hMAY729iO+Q=; b=jI6rs0WL6WEiizy5b/gS7mfDbFFAx/RU+L85SDvI20XU9Y2QTbq+V0knkKKlBSBdNe TrNdI7uLVHuuXKQyQ/DbzNdk1EOrOLoYVEuDlwv07iM1vpo7JRs4rVh2fTyEdiGq179P g0ivcnnqE7uXF2Kgh3WpAYwU0ZqI5vQnx2Dj/4hFEfHGX5ZGaDjtXJ4gAvJSSSdfM5x+ mkkPUG5z9NKuAc1atcI1yzuKC+CDW9LsX9IsKVEYAr4WpzMwPby1F/Y2NwSVnwSyXmki ShjIrB2EIYfIIMUL8yc2Gl5/ZrBd/oPmX3ZNS2tVAP6tXbohLO060eeBg49Ylhd3M/6l 5kaw== 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) From: Tom Tromey 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 List-Id: 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, } -- 2.40.0