From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 2E6F5384E786 for ; Sat, 10 Dec 2022 14:41:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E6F5384E786 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4A14F20CC6; Sat, 10 Dec 2022 14:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1670683281; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3n7x0aIfF+RfO2z7nljejR7/iGq/npOOcg3Xuho5MQg=; b=ZEiYujCl9dvJbxNsP+DfqtKqIfVOb/56qZeG9sDYCB4j52zZYBpyP/vNXxBPtF3abKhnCY dSSZ2obHlzbcBqhYWLTQZTnG15ywdT8uGzryJMpwKmQp+s1y98sl49uPCJyU/kWYE2xvbx CSxJ3d3gCFa7kxVG3TX8PBl7jNkCJIE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1670683281; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3n7x0aIfF+RfO2z7nljejR7/iGq/npOOcg3Xuho5MQg=; b=ddm7yIVrw6z1aYTzyao6p01UErK/KoUg4zsAaoDpHPyfTqkQHRVCgSBqhTal8q364rn3lD 0wl3IursmFKbj+BQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 31B42138EB; Sat, 10 Dec 2022 14:41:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eyD+CpGalGOrBwAAMHmgww (envelope-from ); Sat, 10 Dec 2022 14:41:21 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [pushed] [gdb/tdep] Fix larl handling in s390_displaced_step_fixup Date: Sat, 10 Dec 2022 15:41:20 +0100 Message-Id: <20221210144120.19292-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: On s390x-linux with target board unix/-m31, I run into: ... (gdb) PASS: gdb.guile/scm-lazy-string.exp: bad length print ptr^M $1 = 0x804006b0 ^M (gdb) FAIL: gdb.guile/scm-lazy-string.exp: ptr: print ptr ... A minimal example is: ... $ gdb -q -batch -ex "set trace-commands on" -x gdb.in +file scm-lazy-string +break main Breakpoint 1 at 0x4005d2: file scm-lazy-string.c, line 23. +run Breakpoint 1, main () at scm-lazy-string.c:23 23 const char *ptr = "pointer"; +step 24 const char array[] = "array"; +print ptr $1 = 0x804006b0 ... If we delete the breakpoint after running to it, we have instead the expected: ... +delete +step 24 const char array[] = "array"; +print ptr $1 = 0x4006b0 "pointer" ... The problem is in displaced stepping, forced by the presence of the breakpoint, when stepping over this insn: ... 0x4005d2 larl %r1,0x4006b0 ... With normal stepping we have: ... (gdb) p /x $r1 $2 = 0x3ff004006b0 ... but with displaced stepping we have instead (note the 0x80000000 difference): ... (gdb) p /x $r1 $1 = 0x3ff804006b0 (gdb) ... The difference comes from this code in s390_displaced_step_fixup: ... /* Handle LOAD ADDRESS RELATIVE LONG. */ else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2)) { /* Update PC. */ regcache_write_pc (regs, from + insnlen); /* Recompute output address in R1. */ regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, amode | (from + i2 * 2)); } ... where the "amode |" adds the 0x80000000. Fix this by removing the "amode |". Tested on s390-linux, with native and target board unix/-m31. Approved-By: Ulrich Weigand --- gdb/s390-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index d0dba7654bb..2486ecdcb3a 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -557,7 +557,7 @@ s390_displaced_step_fixup (struct gdbarch *gdbarch, regcache_write_pc (regs, from + insnlen); /* Recompute output address in R1. */ regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, - amode | (from + i2 * 2)); + from + i2 * 2); } /* If we executed a breakpoint instruction, point PC right back at it. */ base-commit: b813665fd2ec3a5cbe7cbc8b36ce7aa0271dec44 -- 2.35.3