From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id AEB4E3858D35 for ; Thu, 22 Jun 2023 13:02:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEB4E3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b45e347266so93441171fa.0 for ; Thu, 22 Jun 2023 06:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687438950; x=1690030950; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zW3R9aKuMpXWxAxZCHThbeOoiHd1J2myJACMzwmKkH0=; b=NTDUTKj6UkU29FiexWlt4iuDlOuNUBjhP+D0jVWgu/hwXdMJF9P7qFIg63SSHWafsJ AsMJLFaGavk+dgin+kTVfMSABwsAMV9VpYcTPPrJaTgq4vAg0e1jkolsYH6xWNBwd2db 4O/TwckzQSpQbQxlvsJBEXTEQk2XQIKHaFEL/QHYTiM6+Sj6GQG95b3X4TQgMt/gg0Dh XxNUQ3QbVoeB1PZ8CUL3b4IWmNtoAyCcQiTXuhQw3RVBf4Hg6PtedcDAd/+SadgColGJ tHqSFpB8m317TZONXWV0PQACxi58f/J4Ug3zOKIbo3Xwjvgo+SEfjATcvotnSJstiBne PhIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687438950; x=1690030950; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zW3R9aKuMpXWxAxZCHThbeOoiHd1J2myJACMzwmKkH0=; b=f/zONfOgCLlpcwQ8Lw/x2c5VL4ngW8uwD3zgd37xBMg+Oe45KbTgVT2Odq3OeZcvKc 0JWU48xfXDcaGeCgWzLdAWGnwQjCpKETASgHrUqDnQKn0wNtvP4Ipm0uYc69v7Swomop 2EElVuhLrme3kYGsgO42N+RldAW1b+rx+pR8PSZp8eag3O9Jl7NtoQ30mE1eMjM9BG5Z p2m54O2r2VaSM7uNV+kxPBJfFa+Dse5AS4zvAaWerhWZiKQjJG+fItgK9yVuNYYg6gxN 0CWxJKz5KInmfqCMANWBWIexYM2XQ1uHWXaGaH8MWABIZCnueeS0gzK3zfvKtTDlLFIe V+BA== X-Gm-Message-State: AC+VfDzGT6vS6dHm1xorcyiCYx2vg0qfxf8pO62LYjDZKElhtu4cyr/M nubQmSeY+gGaiiwT3wtqg2hWtTEPJeo= X-Google-Smtp-Source: ACHHUZ5KAXF7c8huKHQ1UqFMqfI7LbMhn4OlZN03YCvS05QeEfr4potp2j4PKJ1wvqOQXiGfISLKaQ== X-Received: by 2002:a19:e343:0:b0:4f4:1959:b729 with SMTP id c3-20020a19e343000000b004f41959b729mr10267436lfk.68.1687438950187; Thu, 22 Jun 2023 06:02:30 -0700 (PDT) Received: from fedora.. (78-73-77-63-no2450.tbcn.telia.com. [78.73.77.63]) by smtp.gmail.com with ESMTPSA id x5-20020ac259c5000000b004f864434c00sm1100857lfn.171.2023.06.22.06.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 06:02:29 -0700 (PDT) From: Simon Farre To: gdb-patches@sourceware.org Cc: tom@tromey.com, Simon Farre Subject: [PATCH v2] gdb/DAP Few bug fixes & Evaluate Array Watch vars Date: Thu, 22 Jun 2023 15:02:15 +0200 Message-ID: <20230622130215.126932-1-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: v2. EvaluateResult does not need a name, just as what Tom pointed out in previous review. It's only the *children* that need to be made sure that their names are valid. An identifier for a variable, can't ever have an integer as a name, anyhow (not as far as I am aware, no programming languages allow for that). Removed the f-strings and use str() instead as pointed out that f-strings might not be supported fully. v1. This patch fixes a few bugs. First of all, name of VariableReferences must always be of string type. This patch makes sure that this is the case by formatting the name. If (when) the name is an integer, this will cause clients to fail or throw errors. Fixes a bug in NoOpArrayPrinter that calculated children to be N, but only ever retrieves N-1 children, which makes Python at some time later (during fetch_children -> fetch_one_child(N) ) raise an exception (out of list index) which makes the entire request go bad. The result[self.result_name] also f-strings the printer.to_string() value, because this can potentially be a LazyString (which is a Python object, not a string) and is not serializable by json.dumps. --- gdb/python/lib/gdb/dap/varref.py | 2 +- gdb/python/lib/gdb/printing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py index 23f18d647c3..213151fd3d3 100644 --- a/gdb/python/lib/gdb/dap/varref.py +++ b/gdb/python/lib/gdb/dap/varref.py @@ -66,7 +66,7 @@ class BaseReference: "variablesReference": self.ref, } if self.name is not None: - result["name"] = self.name + result["name"] = str(self.name) return result def no_children(self): diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index ab62ef3e45c..353427d000a 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -298,7 +298,7 @@ class NoOpArrayPrinter: return "array" def children(self): - for i in range(self.low, self.high): + for i in range(self.low, self.high + 1): yield (i, self.value[i]) -- 2.41.0