public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Omair Javaid <omair.javaid@linaro.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v4 3/5] Support for recording syscall on aarch64-linux
Date: Thu, 19 Feb 2015 16:55:00 -0000	[thread overview]
Message-ID: <86bnkpzvqv.fsf@gmail.com> (raw)
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")

Omair Javaid <omair.javaid@linaro.org> 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) <aarch64_syscall_record>: Defined.
> 	* linux-record.h (struct linux_record_tdep): Add two more syscall
> 	argument fields.

	* linux-record.h (struct linux_record_tdep) <arg7, arg8>: 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 = 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 = 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 = AARCH64_X0_REGNUM + 0;
> +  aarch64_linux_record_tdep.arg2 = AARCH64_X0_REGNUM + 1;
> +  aarch64_linux_record_tdep.arg3 = AARCH64_X0_REGNUM + 2;
> +  aarch64_linux_record_tdep.arg4 = AARCH64_X0_REGNUM + 3;
> +  aarch64_linux_record_tdep.arg5 = AARCH64_X0_REGNUM + 4;
> +  aarch64_linux_record_tdep.arg6 = AARCH64_X0_REGNUM + 5;
> +  aarch64_linux_record_tdep.arg7 = AARCH64_X0_REGNUM + 6;
> +  aarch64_linux_record_tdep.arg8 = 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

>  }
>  
>  /* 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 @@
>  
>  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?

-- 
Yao (齐尧)

  reply	other threads:[~2015-02-19 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03  1:17 [PATCH v4 0/5] Process record and reverse debugging support " Omair Javaid
2015-02-03  1:17 ` [PATCH v4 5/5] Enables gdb.reverse testsuite for aarch64*-linux targets Omair Javaid
2015-02-20  9:57   ` Yao Qi
2015-02-03  1:17 ` [PATCH v4 2/5] Implements aarch64 process record and reverse debugging support Omair Javaid
2015-02-19 12:35   ` Yao Qi
2015-02-03  1:17 ` [PATCH v4 3/5] Support for recording syscall on aarch64-linux Omair Javaid
2015-02-19 16:55   ` Yao Qi [this message]
2015-02-03  1:17 ` [PATCH v4 4/5] Support for recording aarch64 advanced SIMD instructions Omair Javaid
2015-02-20  9:53   ` Yao Qi
2015-02-03  1:17 ` [PATCH v4 1/5] NEWS entry about aarch64-linux record/replay support Omair Javaid
2015-02-03  3:38   ` Eli Zaretskii
2015-02-03  1:32 ` [PATCH v4 0/5] Process record and reverse debugging support on aarch64-linux Omair Javaid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86bnkpzvqv.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=omair.javaid@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).