[PATCH v2 07/13] gdb/linux-record: Support time, waitpid, pipe syscalls

Marcin Kościelnicki
2015-10-22T13:39:50Z

gdb/ChangeLog:

* aarch64-linux-tdep.c (aarch64_linux_init_abi): Add size_time_t.
* amd64-linux-tdep.c (amd64_linux_init_abi): Add size_time_t.
(amd64_x32_linux_init_abi): Add size_time_t.
* arm-linux-tdep.c (arm_linux_init_abi): Add size_time_t.
* i386-linux-tdep.c (i386_linux_init_abi): Add size_time_t.
* linux-record.c (record_linux_system_call): Add time, waitpid, pipe
handling.
* linux-record.h (struct linux_record_tdep): Add size_time_t.
* ppc-linux-tdep.c (ppc_init_linux_record_tdep): Add size_time_t.
---
gdb/ChangeLog | 12 ++++++++++++
gdb/aarch64-linux-tdep.c | 1 +
gdb/amd64-linux-tdep.c | 2 ++
gdb/arm-linux-tdep.c | 1 +
gdb/i386-linux-tdep.c | 1 +
gdb/linux-record.c | 23 +++++++++++++++++++++++
gdb/linux-record.h | 1 +
gdb/ppc-linux-tdep.c | 2 ++
8 files changed, 43 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c7796c9..ce717ae 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
2015-10-22 Marcin KoÅ›cielnicki <koriakin@0x04.net>

+ * aarch64-linux-tdep.c (aarch64_linux_init_abi): Add size_time_t.
+ * amd64-linux-tdep.c (amd64_linux_init_abi): Add size_time_t.
+ (amd64_x32_linux_init_abi): Add size_time_t.
+ * arm-linux-tdep.c (arm_linux_init_abi): Add size_time_t.
+ * i386-linux-tdep.c (i386_linux_init_abi): Add size_time_t.
+ * linux-record.c (record_linux_system_call): Add time, waitpid, pipe
+ handling.
+ * linux-record.h (struct linux_record_tdep): Add size_time_t.
+ * ppc-linux-tdep.c (ppc_init_linux_record_tdep): Add size_time_t.
+
+2015-10-22 Marcin KoÅ›cielnicki <koriakin@0x04.net>
+
* linux-record.c (record_linux_msghdr): Fix msg_namelen handling.

2015-10-22 Marcin KoÅ›cielnicki <koriakin@0x04.net>
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 0a3fbb3..a1dcd5b 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1062,6 +1062,7 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
aarch64_linux_record_tdep.size_hayes_esp_config = 12;
aarch64_linux_record_tdep.size_size_t = 8;
aarch64_linux_record_tdep.size_iovec = 16;
+ aarch64_linux_record_tdep.size_time_t = 8;

/* These values are the second argument of system call "sys_ioctl".
They are obtained from Linux Kernel source. */
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 0b068c3..829d9b7 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1959,6 +1959,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
amd64_linux_record_tdep.size_hayes_esp_config = 12;
amd64_linux_record_tdep.size_size_t = 8;
amd64_linux_record_tdep.size_iovec = 16;
+ amd64_linux_record_tdep.size_time_t = 8;

/* These values are the second argument of system call "sys_fcntl"
and "sys_fcntl64". They are obtained from Linux Kernel source. */
@@ -2175,6 +2176,7 @@ amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
amd64_x32_linux_record_tdep.size_hayes_esp_config = 12;
amd64_x32_linux_record_tdep.size_size_t = 8;
amd64_x32_linux_record_tdep.size_iovec = 16;
+ amd64_x32_linux_record_tdep.size_time_t = 8;

/* These values are the second argument of system call "sys_fcntl"
and "sys_fcntl64". They are obtained from Linux Kernel source. */
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index a820e74..73e1271 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1550,6 +1550,7 @@ arm_linux_init_abi (struct gdbarch_info info,
arm_linux_record_tdep.size_hayes_esp_config = 12;
arm_linux_record_tdep.size_size_t = 4;
arm_linux_record_tdep.size_iovec = 8;
+ arm_linux_record_tdep.size_time_t = 4;

/* These values are the second argument of system call "sys_ioctl".
They are obtained from Linux Kernel source. */
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 8847ad3..86fe09e 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -869,6 +869,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
i386_linux_record_tdep.size_hayes_esp_config = 12;
i386_linux_record_tdep.size_size_t = 4;
i386_linux_record_tdep.size_iovec = 8;
+ i386_linux_record_tdep.size_time_t = 4;

/* These values are the second argument of system call "sys_ioctl".
They are obtained from Linux Kernel source. */
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 8832ef4..dbd8f14 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -272,13 +272,31 @@ record_linux_system_call (enum gdb_syscall syscall,
case gdb_sys_write:
case gdb_sys_open:
case gdb_sys_close:
+ break;
+
case gdb_sys_waitpid:
+ regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
+ if (tmpulongest)
+ if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
+ tdep->size_int))
+ return -1;
+ break;
+
case gdb_sys_creat:
case gdb_sys_link:
case gdb_sys_unlink:
case gdb_sys_execve:
case gdb_sys_chdir:
+ break;
+
case gdb_sys_time:
+ regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
+ if (tmpulongest)
+ if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
+ tdep->size_time_t))
+ return -1;
+ break;
+
case gdb_sys_mknod:
case gdb_sys_chmod:
case gdb_sys_lchown16:
@@ -330,7 +348,12 @@ record_linux_system_call (enum gdb_syscall syscall,
case gdb_sys_mkdir:
case gdb_sys_rmdir:
case gdb_sys_dup:
+ break;
+
case gdb_sys_pipe:
+ regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
+ if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
+ tdep->size_int * 2))
break;

case gdb_sys_times:
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 9af0bdb..3683edc 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -89,6 +89,7 @@ struct linux_record_tdep
int size_hayes_esp_config;
int size_size_t;
int size_iovec;
+ int size_time_t;

/* The values of the second argument of system call "sys_ioctl". */
int ioctl_TCGETS;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index cf71cf3..ab20e78 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1479,6 +1479,7 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
record_tdep->size_serial_icounter_struct = 80;
record_tdep->size_size_t = 8;
record_tdep->size_iovec = 16;
+ record_tdep->size_time_t = 8;
}
else if (wordsize == 4)
{
@@ -1545,6 +1546,7 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
record_tdep->size_serial_icounter_struct = 80;
record_tdep->size_size_t = 4;
record_tdep->size_iovec = 8;
+ record_tdep->size_time_t = 4;
}
else
internal_error (__FILE__, __LINE__, _("unexpected wordsize"));
--
2.6.1