From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MJ8fIw4g72XFkAIAWB0awg (envelope-from ) for ; Mon, 11 Mar 2024 11:15:26 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=U1CqDONz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 873871E0D2; Mon, 11 Mar 2024 11:15:26 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0F28C1E0AC for ; Mon, 11 Mar 2024 11:15:24 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A96553858433 for ; Mon, 11 Mar 2024 15:15:23 +0000 (GMT) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 0E6A9385842B for ; Mon, 11 Mar 2024 15:15:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E6A9385842B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E6A9385842B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710170103; cv=none; b=aQAKVbs9ZKMgVt1GNWlbrfk19aO5sSPr2JvP/XocZmkTC3ImtmXMpxM2czHBeq30sr90jv/v4tcniwwkNXSSsw+E1e+Rr6pnssP6/o/XcT6Og/zSIsFcoeuQH6mIAGJLEaGKFwvYp14wjQilj733d2CQGzIxAWiG7SL20754+/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710170103; c=relaxed/simple; bh=iqRmaH/j8tdw7zFXV6c/EeZJVDweixjGl3a8o/VLO8M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wPVWP1Yr2GRdueoRXszi8b4sqBOkbW7tbM96hlreI+QQH1p2MO3rjJTnSSUckQjHQ7RzQNOxUlA4bPZnsAVlDuolSJFEGybOIkWlhwByKF8eP2fg7iGBYmqv8j41AWBAc13rQQ66CzvPl2vANpNVQJDKrVN8cStQ3mUqMqeI6bI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3663c6fba33so19958255ab.1 for ; Mon, 11 Mar 2024 08:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1710170100; x=1710774900; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eC6jK9cBfWNWVd2Re5G5HfGgDnkqAbbBwA9aNUM34LM=; b=U1CqDONzSZWy/+/rvpZ4VKMX1jmJjQc9GSmYApMRvkvKrT12iyZ+9Hrz6cUIeAgNR5 19gFp6Tn70T9tr3is9dP4BxqO7MD4Vn2iF46c9WwkCiJQTizfgSW6rP6+XdC5Py1Dqc9 6xTT9AYoQLuCuuWwaxPJQg2IJiPg8UZzoG/J6OyI72Q7uxxecRrvwKL0WaRfxg/WTim8 CwSbIYGhbuh2x2OuSUfEAOz+sOHad2h60VlIz3tqJ5lmmLT2M9QheEFBIdmFnUTCNmrs 7Gx+mQsVBLMWI7g2iRotEH3IqV8IuwDpxfZ5HuQ/rlble12DpIVKEckTnPtGbI0rVFwc VkGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710170100; x=1710774900; 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=eC6jK9cBfWNWVd2Re5G5HfGgDnkqAbbBwA9aNUM34LM=; b=URst0uoozYPDZL5PMl/p5/tXMvKO3ztBLRkYOVdcM1fBAocweMCDpJl0l/pn1VEPxr vfWc8+/+8ocPIAqcM+X0KY2zBrlprPKj0YymWxO2Na36+FDUt0WMWHJ3gMD7BLQAOxlA V1ipqLaQcVuGxEth5sXETGKvVsYfF2VBtYYEXEAibvmzN3aUQbkAsXH1b/wGsQwlv6Bg ksQq1KGcZAxcTId4R8KgLaERowrYlylUeEJ66eezOf3hO+ap+pAPX38fD1sn/zHa33a5 jvzYDNS9bFe2H1IbSDhnYzdVZk8UZx+CJbftlr3Zj9WbPgqr4RE8gRG6AzVp7/R+ZEyW 7Lxw== X-Gm-Message-State: AOJu0YztFG/IRFEXmA/sZwpIHDF+3s9S+5BKYsCv8UN2PkGBNXNuxiew 0h8xZAKluF3yJmDvgHCELYARtyV3kVVv90K/iOzN9vrQHH1lrKSW8q/0xVPUkINkSHzIkMPE2vw = X-Google-Smtp-Source: AGHT+IE9TSgPa+LGNgsjBXD4caLB8uYqNrui0Yq9anmV/ewJeY+8wTJglFOxt0ZPzdq6XlRqHRKhiQ== X-Received: by 2002:a5d:980f:0:b0:7c8:249f:78f5 with SMTP id a15-20020a5d980f000000b007c8249f78f5mr7433464iol.0.1710170099894; Mon, 11 Mar 2024 08:14:59 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id v3-20020a02cba3000000b00476efc5cc38sm424246jap.98.2024.03.11.08.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 08:14:58 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Print type name when printing Rust slice Date: Mon, 11 Mar 2024 09:14:51 -0600 Message-ID: <20240311151451.3745299-1-tromey@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org The recent change to how unsized Rust values are printed included a small regression from past behavior. Previously, a slice's type would be printed, like: (gdb) print slice $80 = &[i32] [3] The patch changed this to just (gdb) print slice $80 = [3] This patch restores the previous behavior. --- gdb/rust-lang.c | 11 +++++++++++ gdb/testsuite/gdb.rust/simple.exp | 2 +- gdb/testsuite/gdb.rust/unsized.exp | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index ab537cc9752..d7265f72770 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -476,6 +476,17 @@ rust_language::val_print_slice } } + /* Print the slice type here. This was gdb's historical behavior + (from before unsized types were generically handled) and helps + make it clear that the user is seeing a slice, not an array. + Only arrays must be handled as the other cases are handled by + value_print_inner. */ + if (type->code () == TYPE_CODE_ARRAY) + { + type_print (orig_type, "", stream, -1); + gdb_printf (stream, " "); + } + value_print_inner (val, stream, recurse, options); } diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 7f5fbad7a3f..1e6fc94400e 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -317,7 +317,7 @@ proc test_one_slice {svar length base range} { global hex # Just accept any array here. - set result " = \\\[.*\\\]" + set result " = &\\\[.*\\\] \\\[.*\\\]" gdb_test "print $svar" $result gdb_test "print &${base}\[${range}\]" $result diff --git a/gdb/testsuite/gdb.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp index fab655790e6..ea5f281cb3d 100644 --- a/gdb/testsuite/gdb.rust/unsized.exp +++ b/gdb/testsuite/gdb.rust/unsized.exp @@ -33,6 +33,6 @@ if {![runto ${srcfile}:$line]} { gdb_test "ptype us" " = .*V<\\\[u8\\\]>.*" if {[rust_at_least 1.61]} { - gdb_test "print us2" " = \\\[1, 2, 3\\\]" + gdb_test "print us2" " = .*u8.* \\\[1, 2, 3\\\]" gdb_test "ptype us2" "type = .*" } -- 2.43.0