From patchwork Thu Jan 16 12:36:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 104906 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 F25C13850203 for ; Thu, 16 Jan 2025 12:37:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F25C13850203 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=USelg+rF X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 708F4385843B for ; Thu, 16 Jan 2025 12:36:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 708F4385843B 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 708F4385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737031016; cv=none; b=V9qdN9u1EkEmdDryj6dtE5OQeyPbOePC5mP9TKYl50AlGqV7Ox9xub56bzsrN1yfSRLOw00DwlNP7o6otPaHJWOX6UirEgieDz9SexsmFiDqsAsPMJsnWKBMOA6UiSiBxyYH5ac4+UVZ+mF1l6S+iBRYyrdKj8391DUGIWwoVYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737031016; c=relaxed/simple; bh=RmsctJ6GPhMR+YEMhap8xTUuuj97biz7o93J7Ea+ngE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rmKYOkFQnjzZwl3dFICjjiW0IcFnTnqi/gaik149FEHwf/zAXkhnu6cHd2+VSZxO+nFc2nPmAiIzGZDBUP+gsJVgfRK/X5L3Y4j7XnTojnPwbq9nFRGbSHTT4qxi5WdYtAWOE5I0P5sINzQzXQHNU6QXRXGeRLQpbl6kjD7l9Sw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 708F4385843B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737031016; 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; bh=h/QsI6nSU8JyFl2Q8oHEDOI2BekNpP88n0Xd5oMr3Xs=; b=USelg+rF7oYUJmWr0iPoh18ButilWzJih+nX9vWzRllsbxtkFFfnfhMeD1rbfG/Ibgj4/J Bx4+jFgjtAT5D4cmmMi0G44wCIz6fkytUKmSleNMZpCllg2M6yoTXLaA+nHxSpOMlWC8jU cRT8DvYEN1uncc3deLGokA00RVJWV/A= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-JYTo-WAFPQaDbgDtsUxVQQ-1; Thu, 16 Jan 2025 07:36:54 -0500 X-MC-Unique: JYTo-WAFPQaDbgDtsUxVQQ-1 X-Mimecast-MFC-AGG-ID: JYTo-WAFPQaDbgDtsUxVQQ Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 29E8E1955F54 for ; Thu, 16 Jan 2025 12:36:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.38]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A229219560AB; Thu, 16 Jan 2025 12:36:52 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH] gdb/reverse: Fix recording vmov[u|a]p[s|d] instructions Date: Thu, 16 Jan 2025 09:36:40 -0300 Message-ID: <20250116123640.930813-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: CH61pCRGJwmtLCg2J05vXtQvyKgcpxd2hfj7PjRU2PU_1737031014 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Tromey reported that some of the test for the vmov[u|a]p[s|d] was failing. In my machine xmm3 was consistently set to 0x54, but apparently that is different depending on the system. This commit zeroes out xmm3 at the start of the test instead. While debugging the test failures, I also noticed an issue where the recording wasn't saving all the required memory. That happened because vmovs[s|d] shares its opcode with vmovap[s|d], meaning they seem to share code paths, but the latter encodes memory modification size on VEX.L whereas the former encodes in VEX.pp. So this commit fixed that, and made the relevant tests more robust and complete Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32561 --- gdb/i386-tdep.c | 13 +++++++++---- gdb/testsuite/gdb.reverse/i386-avx-reverse.c | 17 +++++++++-------- .../gdb.reverse/i386-avx-reverse.exp | 19 +++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 5f585b2ca7e..219de3a6c0f 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -4842,10 +4842,15 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r, } else { - /* VEX.pp stores whether we're moving a single or double precision - float. It just happens that pp is exactly one less than - log2(size) so we can use that directly. */ - ir->ot = ir->pp; + /* Opcode 0x29 is trivial, the size of memory written is defined by + VEX.L. Opcode 0x11 can refer to vmovs[s|d] or vmovup[s|d]; they + are differentiated by the most significant bit of VEX.pp, and the + latter works exactly like 0x29, but the former encodes the size + on VEX.pp itself. */ + if (opcode == 0x11 && (ir->pp & 2) != 0) + ir->ot = ir->pp; + else + ir->ot = 4 + ir->l; i386_record_lea_modrm (ir); } break; diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c index 0c26bcd8e85..815657594b0 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c @@ -149,24 +149,24 @@ vmov_test () opcodes, meaning they'll need to be tested separately. */ asm volatile ("vmovups %0, %%xmm0" : : "m"(buf0)); - asm volatile ("vmovupd %0, %%xmm15" : : "m"(buf1)); + asm volatile ("vmovupd %0, %%ymm15" : : "m"(buf1)); asm volatile ("vmovupd %%xmm0, %0" : : "m"(buf1)); - asm volatile ("vmovups %%xmm15, %0" : : "m"(buf1)); + asm volatile ("vmovups %%ymm15, %0" : : "m"(buf1)); asm volatile ("vmovups %0, %%xmm0" : : "m"(global_buf0)); - asm volatile ("vmovupd %0, %%xmm15" : : "m"(global_buf1)); + asm volatile ("vmovupd %0, %%ymm15" : : "m"(global_buf1)); asm volatile ("vmovupd %%xmm0, %0" : : "m"(global_buf1)); - asm volatile ("vmovups %%xmm15, %0" : : "m"(global_buf1)); + asm volatile ("vmovups %%ymm15, %0" : : "m"(global_buf1)); asm volatile ("vmovups %0, %%xmm0" : : "m"(*dyn_buf0)); - asm volatile ("vmovupd %0, %%xmm15" : : "m"(*dyn_buf1)); + asm volatile ("vmovupd %0, %%ymm15" : : "m"(*dyn_buf1)); asm volatile ("vmovupd %%xmm0, %0" : : "m"(*dyn_buf1)); - asm volatile ("vmovups %%xmm15, %0" : : "m"(*dyn_buf1)); + asm volatile ("vmovups %%ymm15, %0" : : "m"(*dyn_buf1)); asm volatile ("vmovaps %0, %%xmm0" : : "m"(*dyn_buf0)); - asm volatile ("vmovapd %0, %%xmm15" : : "m"(*dyn_buf1)); + asm volatile ("vmovapd %0, %%ymm15" : : "m"(*dyn_buf1)); asm volatile ("vmovapd %%xmm0, %0" : : "m"(*dyn_buf1)); - asm volatile ("vmovaps %%xmm15, %0" : : "m"(*dyn_buf1)); + asm volatile ("vmovaps %%ymm15, %0" : : "m"(*dyn_buf1)); /* We have a return statement to deal with epilogue in different compilers. */ @@ -438,6 +438,7 @@ main () asm volatile ("vmovq %0, %%xmm0": : "m" (global_buf1)); asm volatile ("vmovq %0, %%xmm1": : "m" (global_buf1)); asm volatile ("vmovq %0, %%xmm2": : "m" (global_buf1)); + asm volatile ("vmovq %0, %%xmm3": : "m" (global_buf1)); asm volatile ("vmovq %0, %%xmm15": : "m" (global_buf1)); vmov_test (); diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp index 2b2371d2cd1..f927960157e 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp @@ -76,6 +76,8 @@ proc test_one_general_register {insn register value {prefix ""}} { # Shorthand to test reversing through one instruction and # testing if a variable has the expected value. +# Value should always be the start of the stored values in the memory, +# not something found in the middle of it. # Prefix, if used, should end with a colon and space. proc test_one_memory {insn mem value {dynamic false} {prefix ""}} { @@ -147,31 +149,32 @@ global decimal if {[record_full_function "vmov"] == true} { # Now execute backwards, checking all instructions. + # Explicitly test for the start of the array, since the value repeats. test_one_memory "vmovaps" "dyn_buf1" \ - "0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28" true + "\\\{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28" true test_one_memory "vmovapd" "dyn_buf1" \ - "0x54, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28" true + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28" true test_one_register "vmovapd" "xmm15" ".*" "dynamic buffer: " test_one_register "vmovaps" "xmm0" ".*" "dynamic buffer: " test_one_memory "vmovups" "dyn_buf1" \ - "0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28" true + "\\\{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28" true test_one_memory "vmovupd" "dyn_buf1" \ - "0x54, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28" true + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28" true test_one_register "vmovupd" "xmm15" ".*" "dynamic buffer: " test_one_register "vmovups" "xmm0" ".*" "dynamic buffer: " test_one_memory "vmovups" "global_buf1" \ - "0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18" + "\\\{0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18" test_one_memory "vmovupd" "global_buf1" \ - "0x54, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18" + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18" test_one_register "vmovupd" "xmm15" ".*" "global buffer: " test_one_register "vmovups" "xmm0" ".*" "global buffer: " test_one_memory "vmovups" "buf1" \ - "0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38" + "\\\{0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38" test_one_memory "vmovupd" "buf1" \ - "0x54, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x38" + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x38" test_one_register "vmovupd" "xmm15" "0xbff8000000000000" "local buffer: " test_one_register "vmovups" "xmm0" "0xc004000000000000" "local buffer: "