From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 37910382AA87 for ; Mon, 3 Jun 2024 18:17:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37910382AA87 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 37910382AA87 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717438628; cv=none; b=A//jgjEwZ4BQpjkbsqW08VYwXQmqnErcgct7GfxSlh/7Zb2vbLOKP1SSiJ7nycGsQ63ZRi4/tfYqZQq8nOXDdMx0gc6ZbmuPDurCtKkWFUGxraQvCM/k/uk5V1HXGgJ+HlTUzjGHIrkiKmVEESmkNNgChfhM8gHBoD6A0ar0hyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717438628; c=relaxed/simple; bh=vgnZXPMcXonnUZwca7hOW35r4laNr8QWAJUGiDzjLw0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tqn8EYrro8I6zCYL3HPDa/bRMSW+U+QpmTFBWj0h0Zmk39ltyFncKQAe4mUBNIjf4a9C+pEpq33FaCqXDyc6uKq0SBaeJcaW45TJWu96a2L5A7GEXuFTglDg7PYOEHpdxFWd/mRfdvZ3OfVXzwyqbkiubOdpe68i5sRSbLXrBks= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717438625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lWn4gJqXJQFH18cf1HzTevzLH8vvyTvEqIxjO6mX9i0=; b=Cah6r+Lz/NXYsDHPScjJ6AqzL1iRK3Sy9Ku5X1SEuOPV0ay2cNnu7RCCLyvxSnn8ccyUYW Lhb7Te+c9YgjXY4KESPINlCzGYRz+yqWeRiwk9kxqVPdxH0r1NgYHv9pR7YpaRc+vlFiWT EKqm5T+Mb3Zp1p4XxMw1Gmy/v9HVGBo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-GMwhumX3NAeyslNpyMbmWQ-1; Mon, 03 Jun 2024 14:17:04 -0400 X-MC-Unique: GMwhumX3NAeyslNpyMbmWQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-35e0f445846so2180368f8f.0 for ; Mon, 03 Jun 2024 11:17:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717438623; x=1718043423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lWn4gJqXJQFH18cf1HzTevzLH8vvyTvEqIxjO6mX9i0=; b=OoEthmxdLwgKFzMF/3bfl3ZpEDPwjDGGUDYhnZNIptw0lWp7N8PCJ8mmlFZaserRRP vlt4k7k/TYQDWp1ZESJV0MizxYUcCVUSHqPI+08RQ1ui/HlaeVANsgPz1kR45zRWe9vP 3vlllbBJmbDfsL2xs0uJocwBFAAW0hM8/WrNMfTSx1w3hVp3D+S2ne3C/+xdDS5RCP5b d3DEKXOXbl7aycM1sNbkaf0TK7UVojfBWM6UNaTcoIwlEssqaO00qg1FZsMDaqvr5ih9 EoyKnIo3/cizE/OOMsW6qZgmWTptDv2HnyIrcPeFLKDQdaCnOlvJO75UzI0INFNxosGk L3mw== X-Gm-Message-State: AOJu0YwGsZrSDsAaRX2z2CF6oPRXbzJyDFPT53P+NxHTSQ9fcZLtv/8D EYfD4KmTkocuSMP1m2xlOyPsNmQDcgFZM6+VfP5D8V3tpXSeutZWiPe0BtJeXd1zNV9PH57Jyk3 ljTtR8BwdK0G5oiMCIIFM0gDlwlZNr1RnubB4jk/wYnEZSJ53Dnqu0J2pbUoxDvbQ0SKDB0VEQI 8lGGQD7aJP6nAKn0doYRw0OnUYRVMryE8zm3pYsG/WZsQ= X-Received: by 2002:a5d:484d:0:b0:354:f1ba:3b20 with SMTP id ffacd0b85a97d-35e0f30eccdmr6091751f8f.54.1717438622735; Mon, 03 Jun 2024 11:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJO4JPS26Fo6zjV9NDeUdl3c+CTPLIfeHIQB0LYXuE2AsKBhNzicydFloSMSAbq45I5MsieA== X-Received: by 2002:a5d:484d:0:b0:354:f1ba:3b20 with SMTP id ffacd0b85a97d-35e0f30eccdmr6091737f8f.54.1717438622177; Mon, 03 Jun 2024 11:17:02 -0700 (PDT) Received: from localhost (92.40.185.136.threembb.co.uk. [92.40.185.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04cac9asm9407334f8f.34.2024.06.03.11.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:17:01 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/4] gdb/testsuite: remove trailing \r from rust_llvm_version result Date: Mon, 3 Jun 2024 19:16:52 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,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: I noticed that the value returned by rust_llvm_version had a trailing carriage return. I don't think this is causing any problems right now, but looking at the code I don't think this was the desired behaviour. The current code runs 'rustc --version --verbose', splits the output at each '\n' and then loops over every line looking for the line that contains the LLVM version. There are two problems here. First, at the end of each captured line we have '\r\n', so when we split the lines on '\n', each of the lines will still end with a '\r' character. Second, though we loop over the lines, when we try to compare the line contents we actually compare the unsplit full output. Luckily this still finds the match, but this renders the loop over lines redundant. This commit makes two fixes: 1. I use regsub to convert all '\r\n' sequences to '\n'; now when we split on '\n' the lines will not end in '\r'. 2. Within the loop over lines block I now check the line contents rather than the unsplit full output; now we capture a value without a trailing '\r'. There's only one test (gdb.rust/simple.exp) that uses rust_llvm_version, and it doesn't care if there's a trailing '\r' or not, so this change should make no difference there. --- gdb/testsuite/lib/rust-support.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index 6b3da2a69e4..971a4a6c298 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -86,8 +86,9 @@ gdb_caching_proc rust_llvm_version {} { verbose "could not find rustc" } else { set output [lindex [remote_exec host "$rustc --version --verbose"] 1] + set output [regsub -all "\r\n" $output "\n"] foreach line [split $output \n] { - if {[regexp "LLVM version: (.+)\$" $output ignore version]} { + if {[regexp "LLVM version: (.+)\$" $line ignore version]} { return $version } } -- 2.25.4