This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch add process record and replay for Linux support file. The main function is "record_linux_system_call" will be called by architecture record function. It is used to record the system call execute log. 2008-11-16 Hui Zhu <teawater@gmail.com> Process record and replay target. * Makefile.in (linux-record.c): New file. * configure.tgt (linux-record.c): New file. * linux-record.c, linux-record.h: New file. Makefile.in | 4 b/linux-record.c | 2501 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ b/linux-record.h | 171 +++ configure.tgt | 6 4 files changed, 2678 insertions(+), 4 deletions(-) Following is the diff with the previous patch: @@ -1,6 +1,6 @@ --- a/configure.tgt +++ b/configure.tgt -@@ -185,7 +185,8 @@ i[34567]86-*-solaris*) +@@ -185,7 +185,8 @@ i[34567]86-*-linux*) # Target: Intel 386 running GNU/Linux gdb_target_obs="i386-tdep.o i386-linux-tdep.o glibc-tdep.o i387-tdep.o \ @@ -10,7 +10,7 @@ build_gdbserver=yes ;; i[34567]86-*-gnu*) -@@ -507,7 +508,8 @@ x86_64-*-linux*) +@@ -508,7 +509,8 @@ # Target: GNU/Linux x86-64 gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o i386-tdep.o \ i387-tdep.o i386-linux-tdep.o glibc-tdep.o \ @@ -20,29 +20,9 @@ build_gdbserver=yes ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) ---- a/Makefile.in -+++ b/Makefile.in -@@ -515,7 +515,7 @@ ALL_TARGET_OBS = \ - xcoffread.o \ - prologue-value.o \ - symfile-mem.o \ -- corelow.o -+ corelow.o linux-record.o - - # Host-dependent makefile fragment comes in here. - @host_makefile_frag@ -@@ -1297,7 +1297,7 @@ ALLDEPFILES = \ - inf-ptrace.c inf-ttrace.c \ - irix5-nat.c \ - libunwind-frame.c \ -- linux-fork.c \ -+ linux-fork.c linux-record.c \ - m68hc11-tdep.c \ - m32r-tdep.c \ - m32r-linux-nat.c m32r-linux-tdep.c \ ---- a/linux-record.c +--- a//dev/null +++ b/linux-record.c -@@ -0,0 +1,2465 @@ +@@ -0,0 +1,2501 @@ +/* Process record and replay target code for GNU/Linux. + + Copyright (C) 2008 Free Software Foundation, Inc. @@ -51,7 +31,7 @@ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or ++ the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, @@ -148,7 +128,7 @@ + target_terminal_ours (); + q = + yquery (_ -+ ("The next instruction is syscall exit. It will make the program exit. Do you want to stop the program.")); ++ ("The next instruction is syscall exit. It will make the program exit. Do you want to stop the program?")); + target_terminal_inferior (); + if (q) + { @@ -453,13 +433,13 @@ + else if (tmpu32 == tdep->ioctl_TIOCSERGSTRUCT) + { + printf_unfiltered (_ -+ ("Record: record and reverse target doesn't support ioctl request TIOCSERGSTRUCT\n")); ++ ("Process record and replay target doesn't support ioctl request TIOCSERGSTRUCT\n")); + return (1); + } + else + { + printf_unfiltered (_ -+ ("Record: record and reverse target doesn't support ioctl request 0x%08x.\n"), ++ ("Process record and replay target doesn't support ioctl request 0x%08x.\n"), + tmpu32); + return (1); + } @@ -616,22 +596,13 @@ + /* old_select */ + case 82: + { -+ /* -+ struct sel_arg_struct { -+ unsigned long n; -+ fd_set *inp; -+ fd_set *outp; -+ fd_set *exp; -+ struct timeval *tvp; -+ }; -+ */ + struct sel_arg_struct + { -+ uint32_t n; -+ uint32_t inp; -+ uint32_t outp; -+ uint32_t exp; -+ uint32_t tvp; ++ CORE_ADDR n; ++ CORE_ADDR inp; ++ CORE_ADDR outp; ++ CORE_ADDR exp; ++ CORE_ADDR tvp; + } sel; + + regcache_raw_read (record_regcache, tdep->arg1, @@ -640,9 +611,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) & sel, sizeof (sel))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (sel)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (sel)); ++ } + return (-1); + } + if (record_arch_list_add_mem (sel.inp, tdep->size_fd_set)) @@ -696,7 +670,7 @@ + target_terminal_ours (); + q = + yquery (_ -+ ("The next instruction is syscall reboot. It will restart the computer. Do you want to stop the program.")); ++ ("The next instruction is syscall reboot. It will restart the computer. Do you want to stop the program?")); + target_terminal_inferior (); + if (q) + { @@ -730,7 +704,7 @@ + target_terminal_ours (); + q = + yquery (_ -+ ("The next instruction is syscall munmap. It will free the memory addr = 0x%s len = %d. It will make record target get error. Do you want to stop the program."), ++ ("The next instruction is syscall munmap. It will free the memory addr = 0x%s len = %d. It will make record target get error. Do you want to stop the program?"), + paddr_nz (tmpu32), len); + target_terminal_inferior (); + if (q) @@ -792,9 +766,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[1], tdep->size_sockaddr)) @@ -818,9 +795,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[3], tdep->size_int)) @@ -842,9 +822,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (a[2]) @@ -852,9 +835,12 @@ + if (target_read_memory + (a[2], (gdb_byte *) & (a[2]), sizeof (a[2]))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (a[2]), sizeof (a[2])); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (a[2]), sizeof (a[2])); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[1], a[2])) @@ -874,9 +860,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (a[2]) @@ -884,9 +873,13 @@ + if (target_read_memory + (a[2], (gdb_byte *) & (a[2]), sizeof (a[2]))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (a[2]), sizeof (a[2])); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (a[2]), ++ sizeof (a[2])); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[1], a[2])) @@ -919,9 +912,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (a[4]) @@ -929,9 +925,12 @@ + if (target_read_memory + (a[4], (gdb_byte *) & av, sizeof (av))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (a[4]), sizeof (av)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (a[4]), sizeof (av)); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[3], av)) @@ -973,9 +972,12 @@ + { + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), sizeof (a)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), sizeof (a)); ++ } + return (-1); + } + if (record_arch_list_add_mem (a[1], tdep->size_msghdr)) @@ -987,9 +989,13 @@ + if (target_read_memory + (a[1], (gdb_byte *) & rec, sizeof (rec))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (a[1]), sizeof (rec)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (a[1]), ++ sizeof (rec)); ++ } + return (-1); + } + if (record_arch_list_add_mem @@ -1010,10 +1016,14 @@ + (rec.msg_iov, (gdb_byte *) & iov, + sizeof (iov))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (rec.msg_iov), -+ sizeof (iov)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (rec. ++ msg_iov), ++ sizeof (iov)); ++ } + return (-1); + } + if (record_arch_list_add_mem @@ -1030,7 +1040,7 @@ + break; + default: + printf_unfiltered (_ -+ ("Record: record and reverse function doesn't support socketcall call 0x%08x\n"), ++ ("Process record and replay target doesn't support socketcall call 0x%08x\n"), + tmpu32); + return (-1); + break; @@ -1378,10 +1388,13 @@ + if (target_read_memory + (vec, (gdb_byte *) & iov, sizeof (struct record_iovec))) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (vec), -+ sizeof (struct record_iovec)); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (vec), ++ sizeof (struct record_iovec)); ++ } + return (-1); + } + if (record_arch_list_add_mem (iov.iov_base, iov.iov_len)) @@ -2016,9 +2029,12 @@ + if (target_read_memory + (tmpu32, (gdb_byte *) iocbp, nr * tdep->size_int)) + { -+ fprintf_unfiltered (gdb_stdlog, -+ "Record: read memory addr = 0x%s len = %d error.\n", -+ paddr_nz (tmpu32), nr * tdep->size_int); ++ if (record_debug) ++ { ++ fprintf_unfiltered (gdb_stdlog, ++ "Process record: error reading memory at addr = 0x%s len = %d.\n", ++ paddr_nz (tmpu32), nr * tdep->size_int); ++ } + return (-1); + } + for (i = 0; i < nr; i++) @@ -2053,7 +2069,7 @@ + target_terminal_ours (); + q = + yquery (_ -+ ("The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program.")); ++ ("The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?")); + target_terminal_inferior (); + if (q) + { @@ -2500,7 +2516,7 @@ + + default: + printf_unfiltered (_ -+ ("Record: record and reverse function doesn't support syscall number 0x%08x\n"), ++ ("Process record and replay target doesn't support syscall number 0x%08x\n"), + tmpu32); + return (-1); + break; @@ -2508,7 +2524,7 @@ + + return (0); +} ---- a/linux-record.h +--- a//dev/null +++ b/linux-record.h @@ -0,0 +1,171 @@ +/* Process record and replay target code for GNU/Linux. @@ -2519,7 +2535,7 @@ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 2 of the License, or ++ the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, @@ -2535,7 +2551,7 @@ + +typedef struct linux_record_tdep_s +{ -+ /* The size of the type that will be use in system call. */ ++ /* The size of the type that will be use in system call. */ + int size__old_kernel_stat; + int size_tms; + int size_loff_t; @@ -2604,7 +2620,7 @@ + int size_serial_icounter_struct; + int size_hayes_esp_config; + -+ /* the values of the second argument of system call "sys_ioctl". */ ++ /* the values of the second argument of system call "sys_ioctl". */ + int ioctl_TCGETS; + int ioctl_TCSETS; + int ioctl_TCSETSW; @@ -2671,7 +2687,7 @@ + int ioctl_TIOCSHAYESESP; + int ioctl_FIOQSIZE; + -+ /* The number of the registers that use to be the arguments of system call. */ ++ /* The number of the registers that use to be the arguments of system call. */ + int arg1; + int arg2; + int arg3; @@ -2682,3 +2698,23 @@ +extern int record_linux_system_call (int num, linux_record_tdep_t * tdep); + +#endif /* _LINUX_RECORD_H_ */ +--- a/Makefile.in ++++ b/Makefile.in +@@ -515,7 +515,7 @@ + xcoffread.o \ + prologue-value.o \ + symfile-mem.o \ +- corelow.o ++ corelow.o linux-record.o + + # Host-dependent makefile fragment comes in here. + @host_makefile_frag@ +@@ -1297,7 +1297,7 @@ + inf-ptrace.c inf-ttrace.c \ + irix5-nat.c \ + libunwind-frame.c \ +- linux-fork.c \ ++ linux-fork.c linux-record.c \
Attachment:
5-linux-record.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |