summaryrefslogtreecommitdiff
path: root/src/arch/x86/processor.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2008-09-06 22:07:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2008-09-06 22:07:54 (GMT)
commitb52f03ab912cd5e51dc2abea20edee6ad38c26fe (patch)
treec9399ca4d23c1355a83828e95889da5c0d1eedfd /src/arch/x86/processor.c
parent4946ffe81e3edf35061a07cf4425f9accff11888 (diff)
Better handled the case where decoding fails.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@26 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/x86/processor.c')
-rw-r--r--src/arch/x86/processor.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/arch/x86/processor.c b/src/arch/x86/processor.c
index c7382ed..118dbd6 100644
--- a/src/arch/x86/processor.c
+++ b/src/arch/x86/processor.c
@@ -302,6 +302,7 @@ asm_instr *x86_fetch_instruction(const asm_x86_processor *proc, const uint8_t *d
asm_x86_instr *result; /* Résultat à faire remonter */
X86Opcodes i; /* Boucle de parcours */
off_t tmp; /* Tête de lecture */
+ off_t old_pos; /* Sauvegarde de la position */
result = NULL;
@@ -326,9 +327,15 @@ asm_instr *x86_fetch_instruction(const asm_x86_processor *proc, const uint8_t *d
if (proc->opcodes[i].has_op_ext && (data[tmp] & EXT_OPCODE_MASK) != proc->opcodes[i].op_ext)
continue;
+ old_pos = *pos;
+
result = proc->opcodes[i].read(data, pos, len, offset, proc);
if (result != NULL) result->type = i;
- else printf("err while decoding :: [0x%02hhx] 0x%02hhx\n", proc->opcodes[i].prefix, proc->opcodes[i].opcode);
+ else
+ {
+ *pos = old_pos;
+ printf("err while decoding at 0x%08llx :: [0x%02hhx] 0x%02hhx\n", offset, proc->opcodes[i].prefix, proc->opcodes[i].opcode);
+ }
break;
}