Search
lxdream.org :: lxdream :: r1094:d2324eb67223
lxdream 0.9.1
released Jun 29
Download Now
changeset1094:d2324eb67223
parent1093:34faf227070e
child1095:a8b798030464
authornkeynes
dateMon Dec 21 08:23:54 2009 +1000 (14 years ago)
Fix symbol output in 64-bit disassembly
Add sh4_translate_dump_block(pc) function
src/sh4/sh4.h
src/sh4/sh4trans.c
src/x86dasm/i386-dis.c
src/x86dasm/x86dasm.c
src/x86dasm/x86dasm.h
1.1 --- a/src/sh4/sh4.h Sun Dec 20 21:19:09 2009 +1000
1.2 +++ b/src/sh4/sh4.h Mon Dec 21 08:23:54 2009 +1000
1.3 @@ -131,6 +131,9 @@
1.4 /** Dump current SH4 core state (for crashdump purposes) */
1.5 void sh4_crashdump();
1.6
1.7 +/** Dump a translated block with SH4 and target assembly side by side. */
1.8 +void sh4_translate_dump_block( uint32_t pc );
1.9 +
1.10 #ifdef __cplusplus
1.11 }
1.12 #endif
2.1 --- a/src/sh4/sh4trans.c Sun Dec 20 21:19:09 2009 +1000
2.2 +++ b/src/sh4/sh4trans.c Mon Dec 21 08:23:54 2009 +1000
2.3 @@ -274,3 +274,24 @@
2.4 void *native_pc = xlat_get_native_pc( code, xlat_get_code_size(code) );
2.5 sh4_translate_disasm_block( stderr, code, sh4r.pc, native_pc );
2.6 }
2.7 +
2.8 +/**
2.9 + * Dual-dump the translated block and original SH4 code for the basic block
2.10 + * starting at sh4_pc. If there is no translated block, this prints an error
2.11 + * and returns.
2.12 + */
2.13 +void sh4_translate_dump_block( uint32_t sh4_pc )
2.14 +{
2.15 + if( !IS_IN_ICACHE(sh4_pc) ) {
2.16 + fprintf( stderr, "** Address %08x not in current instruction region **\n", sh4_pc );
2.17 + return;
2.18 + }
2.19 + uint32_t pma = GET_ICACHE_PHYS(sh4_pc);
2.20 + void *code = xlat_get_code( pma );
2.21 + if( code == NULL ) {
2.22 + fprintf( stderr, "** No translated block for address %08x **\n", sh4_pc );
2.23 + return;
2.24 + }
2.25 + sh4_translate_disasm_block( stderr, code, sh4_pc, NULL );
2.26 +}
2.27 +
3.1 --- a/src/x86dasm/i386-dis.c Sun Dec 20 21:19:09 2009 +1000
3.2 +++ b/src/x86dasm/i386-dis.c Mon Dec 21 08:23:54 2009 +1000
3.3 @@ -57,7 +57,6 @@
3.4 static void oappend (const char *);
3.5 static void append_seg (void);
3.6 static void OP_indirE (int, int);
3.7 -static void print_operand_value (char *, int, bfd_vma);
3.8 static void OP_E (int, int);
3.9 static void OP_G (int, int);
3.10 static bfd_vma get64 (void);
3.11 @@ -3058,66 +3057,6 @@
3.12 }
3.13
3.14 static void
3.15 -print_operand_value (char *buf, int hex, bfd_vma disp)
3.16 -{
3.17 - if (mode_64bit)
3.18 - {
3.19 - if (hex)
3.20 - {
3.21 - char tmp[30];
3.22 - int i;
3.23 - buf[0] = '0';
3.24 - buf[1] = 'x';
3.25 - sprintf_vma (tmp, disp);
3.26 - for (i = 0; tmp[i] == '0' && tmp[i + 1]; i++);
3.27 - strcpy (buf + 2, tmp + i);
3.28 - }
3.29 - else
3.30 - {
3.31 - bfd_signed_vma v = disp;
3.32 - char tmp[30];
3.33 - int i;
3.34 - if (v < 0)
3.35 - {
3.36 - *(buf++) = '-';
3.37 - v = -disp;
3.38 - /* Check for possible overflow on 0x8000000000000000. */
3.39 - if (v < 0)
3.40 - {
3.41 - strcpy (buf, "9223372036854775808");
3.42 - return;
3.43 - }
3.44 - }
3.45 - if (!v)
3.46 - {
3.47 - strcpy (buf, "0");
3.48 - return;
3.49 - }
3.50 -
3.51 - i = 0;
3.52 - tmp[29] = 0;
3.53 - while (v)
3.54 - {
3.55 - tmp[28 - i] = (v % 10) + '0';
3.56 - v /= 10;
3.57 - i++;
3.58 - }
3.59 - strcpy (buf, tmp + 29 - i);
3.60 - }
3.61 - }
3.62 - else
3.63 - {
3.64 - x86_print_symbolic_operand( buf, hex, disp );
3.65 - /*
3.66 - if (hex)
3.67 - sprintf (buf, "0x%x", (unsigned int) disp);
3.68 - else
3.69 - sprintf (buf, "%d", (int) disp);
3.70 - */
3.71 - }
3.72 -}
3.73 -
3.74 -static void
3.75 OP_E (int bytemode, int sizeflag)
3.76 {
3.77 bfd_vma disp;
3.78 @@ -3236,7 +3175,7 @@
3.79 if (!intel_syntax)
3.80 if (mod != 0 || (base & 7) == 5)
3.81 {
3.82 - print_operand_value (scratchbuf, !riprel, disp);
3.83 + x86_print_symbolic_operand (scratchbuf, !riprel, disp);
3.84 oappend (scratchbuf);
3.85 if (riprel)
3.86 {
3.87 @@ -3342,7 +3281,7 @@
3.88 *obufp = '\0';
3.89 }
3.90
3.91 - print_operand_value (scratchbuf, 0, disp);
3.92 + x86_print_symbolic_operand (scratchbuf, 0, disp);
3.93 oappend (scratchbuf);
3.94 }
3.95 }
3.96 @@ -3362,7 +3301,7 @@
3.97 oappend (names_seg[ds_reg - es_reg]);
3.98 oappend (":");
3.99 }
3.100 - print_operand_value (scratchbuf, 1, disp);
3.101 + x86_print_symbolic_operand (scratchbuf, 1, disp);
3.102 oappend (scratchbuf);
3.103 }
3.104 }
3.105 @@ -3395,7 +3334,7 @@
3.106 if (!intel_syntax)
3.107 if (mod != 0 || (rm & 7) == 6)
3.108 {
3.109 - print_operand_value (scratchbuf, 0, disp);
3.110 + x86_print_symbolic_operand (scratchbuf, 0, disp);
3.111 oappend (scratchbuf);
3.112 }
3.113
3.114 @@ -3693,7 +3632,7 @@
3.115
3.116 op &= mask;
3.117 scratchbuf[0] = '$';
3.118 - print_operand_value (scratchbuf + 1, 1, op);
3.119 + x86_print_symbolic_operand (scratchbuf + 1, 1, op);
3.120 oappend (scratchbuf + intel_syntax);
3.121 scratchbuf[0] = '\0';
3.122 }
3.123 @@ -3744,7 +3683,7 @@
3.124
3.125 op &= mask;
3.126 scratchbuf[0] = '$';
3.127 - print_operand_value (scratchbuf + 1, 1, op);
3.128 + x86_print_symbolic_operand (scratchbuf + 1, 1, op);
3.129 oappend (scratchbuf + intel_syntax);
3.130 scratchbuf[0] = '\0';
3.131 }
3.132 @@ -3794,7 +3733,7 @@
3.133 }
3.134
3.135 scratchbuf[0] = '$';
3.136 - print_operand_value (scratchbuf + 1, 1, op);
3.137 + x86_print_symbolic_operand (scratchbuf + 1, 1, op);
3.138 oappend (scratchbuf + intel_syntax);
3.139 }
3.140
3.141 @@ -3830,7 +3769,7 @@
3.142 }
3.143 disp = (start_pc + codep - start_codep + disp) & mask;
3.144 set_op (disp, 0);
3.145 - print_operand_value (scratchbuf, 1, disp);
3.146 + x86_print_symbolic_operand (scratchbuf, 1, disp);
3.147 oappend (scratchbuf);
3.148 }
3.149
3.150 @@ -3884,7 +3823,7 @@
3.151 oappend (":");
3.152 }
3.153 }
3.154 - print_operand_value (scratchbuf, 1, off);
3.155 + x86_print_symbolic_operand (scratchbuf, 1, off);
3.156 oappend (scratchbuf);
3.157 }
3.158
3.159 @@ -3912,7 +3851,7 @@
3.160 oappend (":");
3.161 }
3.162 }
3.163 - print_operand_value (scratchbuf, 1, off);
3.164 + x86_print_symbolic_operand (scratchbuf, 1, off);
3.165 oappend (scratchbuf);
3.166 }
3.167
4.1 --- a/src/x86dasm/x86dasm.c Sun Dec 20 21:19:09 2009 +1000
4.2 +++ b/src/x86dasm/x86dasm.c Mon Dec 21 08:23:54 2009 +1000
4.3 @@ -105,7 +105,7 @@
4.4 }
4.5 }
4.6
4.7 -void x86_print_symbolic_operand( char *buf, int hex, unsigned int disp )
4.8 +void x86_print_symbolic_operand( char *buf, int hex, uintptr_t disp )
4.9 {
4.10 const char *sym = x86_find_symbol(disp, NULL);
4.11 if( sym != NULL ) {
5.1 --- a/src/x86dasm/x86dasm.h Sun Dec 20 21:19:09 2009 +1000
5.2 +++ b/src/x86dasm/x86dasm.h Mon Dec 21 08:23:54 2009 +1000
5.3 @@ -31,4 +31,4 @@
5.4 void x86_set_symtab( x86_symbol *symtab, int num_symbols );
5.5 void x86_disasm_init();
5.6 uintptr_t x86_disasm_instruction( uintptr_t pc, char *buf, int len, char *opcode );
5.7 -void x86_print_symbolic_operand( char *buf, int hex, unsigned int disp );
5.8 +void x86_print_symbolic_operand( char *buf, int hex, uintptr_t disp );
.