From patchwork Thu Sep 21 14:51:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 76531 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 CDF2D3857C45 for ; Thu, 21 Sep 2023 14:52:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDF2D3857C45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695307952; bh=pAI+NYawSsEyRIC6js41njtn/CtnfDJF4lZoloaO86M=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=gfMoNJD0UIj9P6xp7xed0cuUHS643Oddj3gULT9TscsG4qafe9sGaM+WlA+MEbbJ8 vOI9q8HTsV9uquUaP2AapyamoRLOOOMD5owjcY2wjiPhwdEOH5cHE6iapG6o8WvbOm eoH63E0Qcpm9EA3iMQIo7VDBmLMuBDlAldVRaUSo= 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 290613858D39 for ; Thu, 21 Sep 2023 14:52:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 290613858D39 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79f95cd15dfso3849939f.0 for ; Thu, 21 Sep 2023 07:52:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695307926; x=1695912726; 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=pAI+NYawSsEyRIC6js41njtn/CtnfDJF4lZoloaO86M=; b=bQgwZvNbKAqEcWEHsomiFyhvaEsJTPS73ebawDUjqIq7tEtVcFRaUMxaaBoaVPviYR lWfW4dPriNnlXa3psbMqwA9yOHKH4Iy9yIVUtwn59vDD9SrBCh0RHDXS5wzJeqBw72cA 7APiFlmfqKrveduXMKJMrSprW1d1jHRCYus79+z5x8SRjzPuJ8URZz8TUmnlpkw0BQxM n9fpODSlSTIbBoCoZQFaPwkedhDQnKsA4MHZlIQG87gs6yOB9yJPgEWvTYov+gLIjqNv 9SpxOK5pCh08AJSTIa5SOYg6x8gHbFmYIwb1S9cO4ojJJ7eHbRVcob3BS2Ny/N8OsfoK fLfA== X-Gm-Message-State: AOJu0YyVBfs5nXu0lJr+7nC9CL0ZnAwSR5Ugw14hQ779jIbjKmBJuIgV JcOD7TDnJwkXr+C4dHjAiEAnIqX60V7BbQZpwLF71A== X-Google-Smtp-Source: AGHT+IEskijh19qn7aaZBBoY9jeyCwo7eE0srsSOexCGnui1GJ8pT8SsbUg+wjXSGBPF+dbO4xdeng== X-Received: by 2002:a6b:7202:0:b0:792:8d16:91ea with SMTP id n2-20020a6b7202000000b007928d1691eamr6279522ioc.0.1695307926322; Thu, 21 Sep 2023 07:52:06 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id x20-20020a02ac94000000b0042916ad15bcsm401431jan.31.2023.09.21.07.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 07:52:05 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add regression test for instructionReference change Date: Thu, 21 Sep 2023 08:51:59 -0600 Message-Id: <20230921145159.476643-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 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 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.30 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" Yesterday I pushed a patch to fix a small oversight in the DAP code that caused an instructionReference to be an array instead of a string. This patch adds a test case for that regression. This required exposing the TON form of the response -- something I mentioned might be necessary when this code was changed to return just the Tcl form. I tested this by backing out yesterday's bug fix and verifying that a failure is seen. --- gdb/testsuite/gdb.dap/bt-nodebug.exp | 15 ++++++++++++++- gdb/testsuite/lib/dap-support.exp | 14 +++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.dap/bt-nodebug.exp b/gdb/testsuite/gdb.dap/bt-nodebug.exp index abd394adbff..62cc0d16a11 100644 --- a/gdb/testsuite/gdb.dap/bt-nodebug.exp +++ b/gdb/testsuite/gdb.dap/bt-nodebug.exp @@ -58,6 +58,19 @@ set obj [dap_check_request_and_response "set breakpoint on no_debug_info" \ setFunctionBreakpoints \ {o breakpoints [a [o name [s no_debug_info]]]}] set breakpoints [dict get [lindex $obj 0] body breakpoints] -gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} "breakpoint has instructionReference" +gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} \ + "breakpoint has instructionReference" + +# instructionReference is specified as a string, but it's form is not +# otherwise given in the spec. gdb always emits it as hex. A bug +# slipped in that caused this to be incorrect, so we test both parts +# here; to test whether a string was given, we have to reach into the +# TON form. +set list_form [namespace eval ton::2list $last_ton] +set ref [namespace eval ton::2list { + get $list_form body breakpoints 0 instructionReference +}] +gdb_assert {[regexp "^$hex\$" $ref]} \ + "instructionReference is a hex string" dap_shutdown diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 2a0cb886528..82d83d95b9f 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -125,7 +125,8 @@ proc _dap_send_request {command {obj {}}} { } # Read a JSON response from gdb. This will return a dict on -# success, or throw an exception on error. +# success, or throw an exception on error. On success, the global +# "last_ton" will be set to the TON form of the result. proc _dap_read_json {} { set length "" gdb_expect { @@ -171,16 +172,19 @@ proc _dap_read_json {} { incr length -$this_len } - set ton [ton::json2ton $json] - return [namespace eval ton::2dict $ton] + global last_ton + set last_ton [ton::json2ton $json] + return [namespace eval ton::2dict $last_ton] } # Read a sequence of JSON objects from gdb, until a response object is # seen. If the response object has the request sequence number NUM, # and is for command CMD, return a list of two elements: the response # object and a list of any preceding events, in the order they were -# emitted. The objects are dicts. If a response object is seen but has -# the wrong sequence number or command, throw an exception +# emitted. The objects are dicts. If a response object is seen but +# has the wrong sequence number or command, throw an exception If a +# response is seen, this leaves the global "last_ton" set to the TON +# for the response. proc _dap_read_response {cmd num} { set result {}