From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119039 invoked by alias); 2 Nov 2015 20:35:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 119027 invoked by uid 89); 2 Nov 2015 20:35:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp16.uk.ibm.com Received: from e06smtp16.uk.ibm.com (HELO e06smtp16.uk.ibm.com) (195.75.94.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 02 Nov 2015 20:35:30 +0000 Received: from localhost by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Nov 2015 20:35:27 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 2 Nov 2015 20:35:24 -0000 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: uweigand@de.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 86AB617D8059 for ; Mon, 2 Nov 2015 20:35:38 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA2KZNXU62521554 for ; Mon, 2 Nov 2015 20:35:23 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA2KZNHm026345 for ; Mon, 2 Nov 2015 13:35:23 -0700 Received: from oc7340732750.ibm.com (icon-9-164-158-208.megacenter.de.ibm.com [9.164.158.208]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tA2KZNNd026341; Mon, 2 Nov 2015 13:35:23 -0700 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id 5E5472665; Mon, 2 Nov 2015 21:35:22 +0100 (CET) Subject: Re: [PATCH 1/2] gdb: Add process record and replay support for s390. To: koriakin@0x04.net (=?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?=) Date: Mon, 02 Nov 2015 20:35:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, koriakin@0x04.net (=?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?=) In-Reply-To: <1446491482-3703-2-git-send-email-koriakin@0x04.net> from "=?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?=" at Nov 02, 2015 08:11:21 PM MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-Id: <20151102203522.5E5472665@oc7340732750.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15110220-0025-0000-0000-000007A02505 X-SW-Source: 2015-11/txt/msg00046.txt.bz2 Marcin KoÅcielnicki wrote: >gdb/ChangeLog: > > * gdb/configure.tgt: Add linux-record.o to s390*-linux. > * gdb/s390-linux-tdep.c (s390_all_but_pc_registers_record): New function. > (s390_canonicalize_syscall): New function. > (s390_linux_syscall_record): New function. > (s390_linux_record_signal): New function. > (s390_record_calc_disp_common): New function. > (s390_record_calc_disp): New function. > (s390_record_calc_disp_vsce): New function. > (s390_record_calc_rl): New function. > (s390_record_gpr_g): New function. > (s390_record_gpr_h): New function. > (s390_record_vr): New function. > (s390_process_record): New function. > (s390_init_linux_record_tdep): New function. > (s390_gdbarch_init): Fill record function slots. > >gdb/testsuite/ChangeLog: > > * gdb.reverse/s390-mvcle.c: New test. > * gdb.reverse/s390-mvcle.exp: New file. > * lib/gdb.exp: Enable reverse tests on s390*-linux. This is all looking really good! Just a small number of issues -- mostly cosmetic, except for the A(L)GSI bug. >+#include "linux-record.h" >+#include "record-full.h" Adding those includes should be mentioned in the ChangeLog. >+static struct linux_record_tdep s390_linux_record_tdep; >+static struct linux_record_tdep s390x_linux_record_tdep; Likewise these new global variables. >+static enum gdb_syscall >+s390_canonicalize_syscall (int syscall, enum s390_abi_kind abi) >+{ >+ switch (syscall) >+ { >+ /* s390 syscall numbers < 222 are mostly the same as x86, so just list the exceptions. */ Line too long. Two spaces after ".". (The same coding style issue appears in a number of other comments.) >+ case 223: >+ return gdb_sys_sendfile64; This is 32-bit only. >+static int >+s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, >+ enum gdb_signal signal) >+{ >+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); >+ /* There are two kinds of signal frames on s390. rt_sigframe is always >+ the larger one, so don't even bother with sigframe. */ >+ const int sizeof_rt_sigframe = (tdep->abi == ABI_LINUX_ZSERIES ? 160 + 8 + 128 + 1024 : 96 + 8 + 128 + 1000); Line too long. >+static CORE_ADDR >+s390_record_calc_disp_common (struct gdbarch *gdbarch, struct regcache *regcache, >+ ULONGEST x, uint16_t bd, int8_t dh) >+{ >+ uint8_t rb = bd >> 12 & 0xf; >+ int32_t d = (bd & 0xfff) | ((int32_t)dh << 12); >+ ULONGEST b; >+ CORE_ADDR res = d + x; >+ int am; Unused. >+static int >+s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache, >+ CORE_ADDR addr) >+{ >+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); >+ uint16_t insn[3] = {0}; >+ /* Instruction as bytes. */ >+ uint8_t ibyte[6]; >+ /* Instruction as nibbles. */ >+ uint8_t inib[12]; >+ /* Instruction vector registers. */ >+ uint8_t ivec[4]; >+ CORE_ADDR oaddr, oaddr2, oaddr3; >+ ULONGEST tmp; >+ int i, n; >+ /* if EX/EXRL instruction used, here's the reg parameter */ >+ int ex = -1; >+ >+ /* Attempting to use EX or EXRL jumps back here */ >+ex: >+ >+ /* Read instruction. */ >+ insn[0] = read_memory_unsigned_integer (addr, 2, BFD_ENDIAN_BIG); While s390 is indeed always big-endian, I'd still prefer to avoid hard-coding this here; just use gdbarch_byte_order. >+ case 0x4e: /* CVD - convert to binary */ "convert to decimal" >+ /* 0x80 priviledged: SSM - set system mask */ "privileged" (also various other places) >+ case 0xb255: /* MVST - move string [partial] */ >+ { >+ /* XXX - partial instruction with long memory write */ >+ uint8_t end; >+ gdb_byte cur; >+ ULONGEST num = 0; >+ /* Read ending byte. */ >+ regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); >+ end = tmp & 0xff; >+ /* Get address of second operand. */ >+ regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[7], &tmp); >+ oaddr = s390_record_address_mask (gdbarch, regcache, tmp); >+ /* Search for ending byte and compute length. */ >+ do { >+ num++; >+ if (target_read_memory (oaddr, &cur, 1)) >+ return -1; >+ oaddr++; >+ } while (cur != end); It would be more efficient to read larger chunks at a time ... But I guess that can be fixed if/when it turns out to be a problem. >+ case 0xeb7a: /* AGSI - add immediate */ >+ case 0xeb7e: /* ALGSI - add immediate */ >+ oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); >+ if (record_full_arch_list_add_mem (oaddr, 4)) This needs to record 8 bytes. >+/* Initialize linux_record_tdep if not initialized yet. */ >+ >+static void >+s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep, >+ enum s390_abi_kind abi) >+{ >+ if (abi == ABI_LINUX_ZSERIES) >+ record_tdep->size_msqid_ds = 120; This seems to be 104 on my kernel >+ record_tdep->size_shmid_ds = 112; and this 82. >+ else if (abi == ABI_LINUX_S390) >+ record_tdep->size_msqid_ds = 88; and 56 on s390 >+ record_tdep->size_shmid_ds = 84; and this 48. >+ record_tdep->arg6 = S390_R7_REGNUM; R7 is never used as argument register; all s390 syscalls use at most 5 GPR arguments (r2 .. r6). >+ record_tdep->ioctl_TIOCGPTN = 0x40045430; Looks like this should be 0x80045430 ... >+ record_tdep->ioctl_TIOCSPTLCK = 0x80045431; ... and this 0x40045431 Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com