From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2624 invoked by alias); 19 Feb 2015 16:55:46 -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 2615 invoked by uid 89); 19 Feb 2015 16:55:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 19 Feb 2015 16:55:45 +0000 Received: by paceu11 with SMTP id eu11so980065pac.7 for ; Thu, 19 Feb 2015 08:55:42 -0800 (PST) X-Received: by 10.66.119.238 with SMTP id kx14mr9095602pab.41.1424364942871; Thu, 19 Feb 2015 08:55:42 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id mi9sm6542335pab.3.2015.02.19.08.55.39 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 08:55:41 -0800 (PST) From: Yao Qi To: Omair Javaid Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v4 3/5] Support for recording syscall on aarch64-linux References: <1422926216-15740-1-git-send-email-omair.javaid@linaro.org> <1422926216-15740-4-git-send-email-omair.javaid@linaro.org> Date: Thu, 19 Feb 2015 16:55:00 -0000 In-Reply-To: <1422926216-15740-4-git-send-email-omair.javaid@linaro.org> (Omair Javaid's message of "Tue, 3 Feb 2015 06:16:54 +0500") Message-ID: <86bnkpzvqv.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00548.txt.bz2 Omair Javaid writes: > * aarch64-linux-tdep.c (linux-record): Include. s/linux-record/linux-record.h/ > (record-full.h): Include. > (struct linux_record_tdep aarch64_linux_record_tdep): Declare. > (aarch64_canonicalize_syscall): New function to translate syscall > numbers from aarch64 to canonical. "New function" only should be fine. > (aarch64_all_but_pc_registers_record): New function. > (aarch64_linux_syscall_record): New function. > (aarch64_linux_init_abi): Update to handle syscall recording. > * aarch64-linux-tdep.h (aarch64_syscall): New enum. > * aarch64-tdep.c (aarch64_record_branch_except_sys): Add code to > handle recording of syscalls. > * aarch64-tdep.h > (struct gdbarch_tdep) : Defined. > * linux-record.h (struct linux_record_tdep): Add two more syscall > argument fields. * linux-record.h (struct linux_record_tdep) : New fields. > +/* aarch64_canonicalize_syscall maps syscall ids from the native AArch64 > + linux set of syscall ids into a canonical set of syscall ids used by > + process record. */ > + > +static enum gdb_syscall > +aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number) > +{ > + switch (syscall_number) { > + case aarch64_sys_read: > + return gdb_sys_read; > + Can we add a macro which does such replacement, SYSCALL_MAP (read) -> case aarch64_sys_read: return gdb_sys_read; so that this function should be shorter. > + > + case aarch64_sys_mmap: > + return gdb_sys_mmap2; > + > + default: > + return -1; > + } > +} > + > +/* Record all registers but PC register for process-record. */ > + > +static int > +aarch64_all_but_pc_registers_record (struct regcache *regcache) > +{ > + int i; > + > + for (i =3D 0; i < AARCH64_PC_REGNUM; i++) > + if (record_full_arch_list_add_reg (regcache, AARCH64_X0_REGNUM + i)) > + return -1; Nit, better that "i" starts from AARCH64_X0_REGNUM, like, for (i =3D AARCH64_X0_REGNUM; i < AARCH64_PC_REGNUM; i++) if (record_full_arch_list_add_reg (regcache, i)) return -1; > + > + /* The AArch64 syscall calling convention: reg x0-x7 for arguments, > + reg x8 for syscall number and return value in reg x0. */ > + aarch64_linux_record_tdep.arg1 =3D AARCH64_X0_REGNUM + 0; > + aarch64_linux_record_tdep.arg2 =3D AARCH64_X0_REGNUM + 1; > + aarch64_linux_record_tdep.arg3 =3D AARCH64_X0_REGNUM + 2; > + aarch64_linux_record_tdep.arg4 =3D AARCH64_X0_REGNUM + 3; > + aarch64_linux_record_tdep.arg5 =3D AARCH64_X0_REGNUM + 4; > + aarch64_linux_record_tdep.arg6 =3D AARCH64_X0_REGNUM + 5; > + aarch64_linux_record_tdep.arg7 =3D AARCH64_X0_REGNUM + 6; > + aarch64_linux_record_tdep.arg8 =3D AARCH64_X0_REGNUM + 7; x7 is not used for arguments in linux syscall. At least, that is what I am told from glibc source sysdeps/unix/sysv/linux/aarch64/sysdep.h: /* Linux takes system call args in registers: syscall number x8 arg 1 x0 arg 2 x1 arg 3 x2 arg 4 x3 arg 5 x4 arg 6 x5 arg 7 x6 > } >=20=20 > /* Provide a prototype to silence -Wmissing-prototypes. */ > diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h > index 9d09ae6..4475f2e 100644 > --- a/gdb/aarch64-linux-tdep.h > +++ b/gdb/aarch64-linux-tdep.h > @@ -32,3 +32,269 @@ >=20=20 > extern const struct regset aarch64_linux_gregset; > extern const struct regset aarch64_linux_fpregset; > + > +/* Enum that defines the AArch64 linux specific syscall identifiers used= for > + process record/replay. */ > + > +enum aarch64_syscall { .... > +}; Why don't define this enum in aarch64-linux-tdep.c? --=20 Yao (=E9=BD=90=E5=B0=A7)