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 code to make I386 architecture support process record and replay. 2008-11-16 Hui Zhu <teawater@gmail.com> I386 architecture process record and replay support. * i386-tdep.c (PREFIX_REPZ, PREFIX_REPNZ, PREFIX_LOCK, PREFIX_DATA, PREFIX_ADDR): New macros. Help decode the I386 instruction. (aflag, dflag, override, modrm, mod, reg, rm, ot, i386_record_pc): New variables. Ditto. (i386_record_modrm, i386_record_lea_modrm_addr, i386_record_lea_modrm): New functions. Ditto. (i386_process_record): New function. Parse the instruction in address "addr" and record the values of registers and memory that will be change in this instruction. (i386_gdbarch_init): Set "i386_process_record" to GDBARCH "process_record" interface. * i386-tdep.h (gdbarch_tdep): New function pointers "i386_intx80_record" and "i386_sysenter_record" that point to the function can record "intx80" and "sysenter" execute log. i386-tdep.c | 2964 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ i386-tdep.h | 3 2 files changed, 2967 insertions(+) Following is the diff with the previous patch: @@ -10,7 +10,7 @@ /* Register names. */ static char *i386_register_names[] = -@@ -2638,6 +2641,2707 @@ i386_skip_permanent_breakpoint (struct r +@@ -2638,6 +2641,2965 @@ i386_skip_permanent_breakpoint (struct r } @@ -56,8 +56,12 @@ +{ + if (target_read_memory (i386_record_pc, &modrm, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -92,8 +96,12 @@ + havesib = 1; + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -110,8 +118,12 @@ + base = 0xff; + if (target_read_memory (i386_record_pc, (gdb_byte *) addr, 4)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 4.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 4; @@ -124,8 +136,12 @@ + case 1: + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -134,8 +150,12 @@ + case 2: + if (target_read_memory (i386_record_pc, (gdb_byte *) addr, 4)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 4.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 4; @@ -166,8 +186,12 @@ + if (target_read_memory + (i386_record_pc, (gdb_byte *) & tmpu16, 2)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 2.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 2; @@ -183,8 +207,12 @@ + case 1: + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -193,8 +221,12 @@ + case 2: + if (target_read_memory (i386_record_pc, (gdb_byte *) & tmpu16, 2)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 2.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 2; @@ -276,7 +308,7 @@ + { + if (record_debug) + printf_unfiltered (_ -+ ("Process record ignores the memory change of instruction in address 0x%s because it can't get the value of the segment register.\n"), ++ ("Process record ignores the memory change of instruction at address 0x%s because it can't get the value of the segment register.\n"), + paddr_nz (i386_record_pc)); + return (0); + } @@ -322,8 +354,12 @@ + { + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -385,8 +421,12 @@ + case 0x0f: + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -395,14 +435,54 @@ + break; + + /* arith & logic */ -+ case 0x00 ... 0x05: -+ case 0x08 ... 0x0d: -+ case 0x10 ... 0x15: -+ case 0x18 ... 0x1d: -+ case 0x20 ... 0x25: -+ case 0x28 ... 0x2d: -+ case 0x30 ... 0x35: -+ case 0x38 ... 0x3d: ++ case 0x00: ++ case 0x01: ++ case 0x02: ++ case 0x03: ++ case 0x04: ++ case 0x05: ++ case 0x08: ++ case 0x09: ++ case 0x0a: ++ case 0x0b: ++ case 0x0c: ++ case 0x0d: ++ case 0x10: ++ case 0x11: ++ case 0x12: ++ case 0x13: ++ case 0x14: ++ case 0x15: ++ case 0x18: ++ case 0x19: ++ case 0x1a: ++ case 0x1b: ++ case 0x1c: ++ case 0x1d: ++ case 0x20: ++ case 0x21: ++ case 0x22: ++ case 0x23: ++ case 0x24: ++ case 0x25: ++ case 0x28: ++ case 0x29: ++ case 0x2a: ++ case 0x2b: ++ case 0x2c: ++ case 0x2d: ++ case 0x30: ++ case 0x31: ++ case 0x32: ++ case 0x33: ++ case 0x34: ++ case 0x35: ++ case 0x38: ++ case 0x39: ++ case 0x3a: ++ case 0x3b: ++ case 0x3c: ++ case 0x3d: + if (((opcode >> 3) & 7) != OP_CMPL) + { + if ((opcode & 1) == 0) @@ -472,7 +552,10 @@ + break; + + /* GRP1 */ -+ case 0x80 ... 0x83: ++ case 0x80: ++ case 0x81: ++ case 0x82: ++ case 0x83: + if (i386_record_modrm ()) + { + return (-1); @@ -511,9 +594,23 @@ + break; + + /* inv */ -+ case 0x40 ... 0x47: ++ case 0x40: ++ case 0x41: ++ case 0x42: ++ case 0x43: ++ case 0x44: ++ case 0x45: ++ case 0x46: ++ case 0x47: + /* dec */ -+ case 0x48 ... 0x4f: ++ case 0x48: ++ case 0x49: ++ case 0x4a: ++ case 0x4b: ++ case 0x4c: ++ case 0x4d: ++ case 0x4e: ++ case 0x4f: + if (record_arch_list_add_reg (opcode & 7)) + { + return (-1); @@ -913,7 +1010,14 @@ + break; + + /* push */ -+ case 0x50 ... 0x57: ++ case 0x50: ++ case 0x51: ++ case 0x52: ++ case 0x53: ++ case 0x54: ++ case 0x55: ++ case 0x56: ++ case 0x57: + case 0x68: + case 0x6a: + /* push es */ @@ -942,7 +1046,14 @@ + break; + + /* pop */ -+ case 0x58 ... 0x5f: ++ case 0x58: ++ case 0x59: ++ case 0x5a: ++ case 0x5b: ++ case 0x5c: ++ case 0x5d: ++ case 0x5e: ++ case 0x5f: + ot = dflag + OT_WORD; + if (record_arch_list_add_reg (I386_ESP_REGNUM)) + { @@ -1315,7 +1426,7 @@ + { + if (record_debug) + printf_unfiltered (_ -+ ("Process record ignores the memory change of instruction in address 0x%s because it can't get the value of the segment register.\n"), ++ ("Process record ignores the memory change of instruction at address 0x%s because it can't get the value of the segment register.\n"), + paddr_nz (i386_record_pc)); + } + else @@ -1333,9 +1444,12 @@ + if (target_read_memory + (i386_record_pc, (gdb_byte *) & addr, 4)) + { -+ printf_unfiltered (_ -+ ("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 4.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 4; @@ -1345,9 +1459,12 @@ + if (target_read_memory + (i386_record_pc, (gdb_byte *) & tmpu16, 4)) + { -+ printf_unfiltered (_ -+ ("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 4.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc += 2; @@ -1362,7 +1479,14 @@ + break; + + /* mov R, Ib */ -+ case 0xb0 ... 0xb7: ++ case 0xb0: ++ case 0xb1: ++ case 0xb2: ++ case 0xb3: ++ case 0xb4: ++ case 0xb5: ++ case 0xb6: ++ case 0xb7: + if (record_arch_list_add_reg ((opcode & 0x7) & 0x3)) + { + return (-1); @@ -1370,7 +1494,14 @@ + break; + + /* mov R, Iv */ -+ case 0xb8 ... 0xbf: ++ case 0xb8: ++ case 0xb9: ++ case 0xba: ++ case 0xbb: ++ case 0xbc: ++ case 0xbd: ++ case 0xbe: ++ case 0xbf: + if (record_arch_list_add_reg (opcode & 0x7)) + { + return (-1); @@ -1378,7 +1509,13 @@ + break; + + /* xchg R, EAX */ -+ case 0x91 ... 0x97: ++ case 0x91: ++ case 0x92: ++ case 0x93: ++ case 0x94: ++ case 0x95: ++ case 0x96: ++ case 0x97: + if (record_arch_list_add_reg (I386_EAX_REGNUM)) + { + return (-1); @@ -1569,7 +1706,14 @@ + + /* floats */ + /* It just record the memory change of instrcution. */ -+ case 0xd8 ... 0xdf: ++ case 0xd8: ++ case 0xd9: ++ case 0xda: ++ case 0xdb: ++ case 0xdc: ++ case 0xdd: ++ case 0xde: ++ case 0xdf: + if (i386_record_modrm ()) + { + return (-1); @@ -1586,17 +1730,54 @@ + } + switch (reg) + { -+ case 0x00 ... 0x07: -+ case 0x10 ... 0x17: -+ case 0x20 ... 0x27: -+ case 0x30 ... 0x37: ++ case 0x00: ++ case 0x01: ++ case 0x02: ++ case 0x03: ++ case 0x04: ++ case 0x05: ++ case 0x06: ++ case 0x07: ++ case 0x10: ++ case 0x11: ++ case 0x12: ++ case 0x13: ++ case 0x14: ++ case 0x15: ++ case 0x16: ++ case 0x17: ++ case 0x20: ++ case 0x21: ++ case 0x22: ++ case 0x23: ++ case 0x24: ++ case 0x25: ++ case 0x26: ++ case 0x27: ++ case 0x30: ++ case 0x31: ++ case 0x32: ++ case 0x33: ++ case 0x34: ++ case 0x35: ++ case 0x36: ++ case 0x37: + break; + case 0x08: + case 0x0a: + case 0x0b: -+ case 0x18 ... 0x1b: -+ case 0x28 ... 0x2b: -+ case 0x38 ... 0x3b: ++ case 0x18: ++ case 0x19: ++ case 0x1a: ++ case 0x1b: ++ case 0x28: ++ case 0x29: ++ case 0x2a: ++ case 0x2b: ++ case 0x38: ++ case 0x39: ++ case 0x3a: ++ case 0x3b: + switch (reg & 7) + { + case 0: @@ -1767,7 +1948,7 @@ + /* addr += ((uint32_t)read_register (I386_ES_REGNUM)) << 4; */ + if (record_debug) + printf_unfiltered (_ -+ ("Process record ignores the memory change of instruction in address 0x%s because it can't get the value of the segment register.\n"), ++ ("Process record ignores the memory change of instruction at address 0x%s because it can't get the value of the segment register.\n"), + paddr_nz (i386_record_pc)); + } + @@ -1988,13 +2169,58 @@ + /* jmp Jb */ + case 0xeb: + /* jcc Jb */ -+ case 0x70 ... 0x7f: ++ case 0x70: ++ case 0x71: ++ case 0x72: ++ case 0x73: ++ case 0x74: ++ case 0x75: ++ case 0x76: ++ case 0x77: ++ case 0x78: ++ case 0x79: ++ case 0x7a: ++ case 0x7b: ++ case 0x7c: ++ case 0x7d: ++ case 0x7e: ++ case 0x7f: + /* jcc Jv */ -+ case 0x0f80 ... 0x0f8f: ++ case 0x0f80: ++ case 0x0f81: ++ case 0x0f82: ++ case 0x0f83: ++ case 0x0f84: ++ case 0x0f85: ++ case 0x0f86: ++ case 0x0f87: ++ case 0x0f88: ++ case 0x0f89: ++ case 0x0f8a: ++ case 0x0f8b: ++ case 0x0f8c: ++ case 0x0f8d: ++ case 0x0f8e: ++ case 0x0f8f: + break; + + /* setcc Gv */ -+ case 0x0f90 ... 0x0f9f: ++ case 0x0f90: ++ case 0x0f91: ++ case 0x0f92: ++ case 0x0f93: ++ case 0x0f94: ++ case 0x0f95: ++ case 0x0f96: ++ case 0x0f97: ++ case 0x0f98: ++ case 0x0f99: ++ case 0x0f9a: ++ case 0x0f9b: ++ case 0x0f9c: ++ case 0x0f9d: ++ case 0x0f9e: ++ case 0x0f9f: + ot = OT_BYTE; + if (i386_record_modrm ()) + { @@ -2017,7 +2243,22 @@ + break; + + /* cmov Gv, Ev */ -+ case 0x0f40 ... 0x0f4f: ++ case 0x0f40: ++ case 0x0f41: ++ case 0x0f42: ++ case 0x0f43: ++ case 0x0f44: ++ case 0x0f45: ++ case 0x0f46: ++ case 0x0f47: ++ case 0x0f48: ++ case 0x0f49: ++ case 0x0f4a: ++ case 0x0f4b: ++ case 0x0f4c: ++ case 0x0f4d: ++ case 0x0f4e: ++ case 0x0f4f: + if (i386_record_modrm ()) + { + return (-1); @@ -2189,7 +2430,7 @@ + /* XXX */ + case 0x9b: + printf_unfiltered (_ -+ ("Process record don't support instruction fwait.\n")); ++ ("Process record doesn't support instruction fwait.\n")); + i386_record_pc -= 1; + goto no_support; + break; @@ -2210,8 +2451,12 @@ + int ret; + if (target_read_memory (i386_record_pc, &tmpu8, 1)) + { -+ printf_unfiltered (_("Process record: read memeory 0x%s error.\n"), -+ paddr_nz (i386_record_pc)); ++ if (record_debug) ++ { ++ printf_unfiltered (_ ++ ("Process record: error reading memory at addr 0x%s len = 1.\n"), ++ paddr_nz (i386_record_pc)); ++ } + return (-1); + } + i386_record_pc++; @@ -2256,7 +2501,14 @@ + break; + + /* bswap reg */ -+ case 0x0fc8 ... 0x0fcf: ++ case 0x0fc8: ++ case 0x0fc9: ++ case 0x0fca: ++ case 0x0fcb: ++ case 0x0fcc: ++ case 0x0fcd: ++ case 0x0fce: ++ case 0x0fcf: + if (record_arch_list_add_reg (opcode & 7)) + { + return (-1); @@ -2440,7 +2692,7 @@ + { + if (record_debug) + printf_unfiltered (_ -+ ("Process record ignores the memory change of instruction in address 0x%s because it can't get the value of the segment register.\n"), ++ ("Process record ignores the memory change of instruction at address 0x%s because it can't get the value of the segment register.\n"), + paddr_nz (i386_record_pc)); +error("3"); + } @@ -2491,7 +2743,7 @@ + { + if (record_debug) + printf_unfiltered (_ -+ ("Process record ignores the memory change of instruction in address 0x%s because it can't get the value of the segment register.\n"), ++ ("Process record ignores the memory change of instruction at address 0x%s because it can't get the value of the segment register.\n"), + paddr_nz (i386_record_pc)); + } + else @@ -2607,7 +2859,13 @@ + break; + + /* nop (multi byte) */ -+ case 0x0f19 ... 0x0f1f: ++ case 0x0f19: ++ case 0x0f1a: ++ case 0x0f1b: ++ case 0x0f1c: ++ case 0x0f1d: ++ case 0x0f1e: ++ case 0x0f1f: + break; + + /* mov reg, crN */ @@ -2718,7 +2976,7 @@ static struct gdbarch * i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) -@@ -2829,6 +5533,8 @@ i386_gdbarch_init (struct gdbarch_info i +@@ -2829,6 +5791,8 @@ i386_gdbarch_init (struct gdbarch_info i set_gdbarch_skip_permanent_breakpoint (gdbarch, i386_skip_permanent_breakpoint);
Attachment:
8-i386-tdep.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |