]>
Commit | Line | Data |
---|---|---|
b9adb4a6 | 1 | /* General "disassemble this chunk" code. Used for debugging. */ |
5bbe9299 | 2 | #include "config.h" |
76cad711 | 3 | #include "disas/bfd.h" |
b9adb4a6 | 4 | #include "elf.h" |
aa0aa4fa | 5 | #include <errno.h> |
b9adb4a6 | 6 | |
c6105c0a | 7 | #include "cpu.h" |
76cad711 | 8 | #include "disas/disas.h" |
c6105c0a | 9 | |
f4359b9f BS |
10 | typedef struct CPUDebug { |
11 | struct disassemble_info info; | |
12 | CPUArchState *env; | |
13 | } CPUDebug; | |
14 | ||
b9adb4a6 | 15 | /* Filled in by elfload.c. Simplistic, but will do for now. */ |
e80cfcfc | 16 | struct syminfo *syminfos = NULL; |
b9adb4a6 | 17 | |
aa0aa4fa FB |
18 | /* Get LENGTH bytes from info's buffer, at target address memaddr. |
19 | Transfer them to myaddr. */ | |
20 | int | |
3a742b76 PB |
21 | buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, |
22 | struct disassemble_info *info) | |
aa0aa4fa | 23 | { |
c6105c0a FB |
24 | if (memaddr < info->buffer_vma |
25 | || memaddr + length > info->buffer_vma + info->buffer_length) | |
26 | /* Out of bounds. Use EIO because GDB uses it. */ | |
27 | return EIO; | |
28 | memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length); | |
29 | return 0; | |
aa0aa4fa FB |
30 | } |
31 | ||
c6105c0a FB |
32 | /* Get LENGTH bytes from info's buffer, at target address memaddr. |
33 | Transfer them to myaddr. */ | |
34 | static int | |
c27004ec FB |
35 | target_read_memory (bfd_vma memaddr, |
36 | bfd_byte *myaddr, | |
37 | int length, | |
38 | struct disassemble_info *info) | |
c6105c0a | 39 | { |
f4359b9f BS |
40 | CPUDebug *s = container_of(info, CPUDebug, info); |
41 | ||
f17ec444 | 42 | cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0); |
c6105c0a FB |
43 | return 0; |
44 | } | |
c6105c0a | 45 | |
aa0aa4fa FB |
46 | /* Print an error message. We can assume that this is in response to |
47 | an error return from buffer_read_memory. */ | |
48 | void | |
3a742b76 | 49 | perror_memory (int status, bfd_vma memaddr, struct disassemble_info *info) |
aa0aa4fa FB |
50 | { |
51 | if (status != EIO) | |
52 | /* Can't happen. */ | |
53 | (*info->fprintf_func) (info->stream, "Unknown error %d\n", status); | |
54 | else | |
55 | /* Actually, address between memaddr and memaddr + len was | |
56 | out of bounds. */ | |
57 | (*info->fprintf_func) (info->stream, | |
26a76461 | 58 | "Address 0x%" PRIx64 " is out of bounds.\n", memaddr); |
aa0aa4fa FB |
59 | } |
60 | ||
a31f0531 | 61 | /* This could be in a separate file, to save minuscule amounts of space |
aa0aa4fa FB |
62 | in statically linked executables. */ |
63 | ||
64 | /* Just print the address is hex. This is included for completeness even | |
65 | though both GDB and objdump provide their own (to print symbolic | |
66 | addresses). */ | |
67 | ||
68 | void | |
3a742b76 | 69 | generic_print_address (bfd_vma addr, struct disassemble_info *info) |
aa0aa4fa | 70 | { |
26a76461 | 71 | (*info->fprintf_func) (info->stream, "0x%" PRIx64, addr); |
aa0aa4fa FB |
72 | } |
73 | ||
636bd289 PM |
74 | /* Print address in hex, truncated to the width of a target virtual address. */ |
75 | static void | |
76 | generic_print_target_address(bfd_vma addr, struct disassemble_info *info) | |
77 | { | |
78 | uint64_t mask = ~0ULL >> (64 - TARGET_VIRT_ADDR_SPACE_BITS); | |
79 | generic_print_address(addr & mask, info); | |
80 | } | |
81 | ||
82 | /* Print address in hex, truncated to the width of a host virtual address. */ | |
83 | static void | |
84 | generic_print_host_address(bfd_vma addr, struct disassemble_info *info) | |
85 | { | |
86 | uint64_t mask = ~0ULL >> (64 - (sizeof(void *) * 8)); | |
87 | generic_print_address(addr & mask, info); | |
88 | } | |
89 | ||
aa0aa4fa FB |
90 | /* Just return the given address. */ |
91 | ||
92 | int | |
3a742b76 | 93 | generic_symbol_at_address (bfd_vma addr, struct disassemble_info *info) |
aa0aa4fa FB |
94 | { |
95 | return 1; | |
96 | } | |
97 | ||
903ec55c AJ |
98 | bfd_vma bfd_getl64 (const bfd_byte *addr) |
99 | { | |
100 | unsigned long long v; | |
101 | ||
102 | v = (unsigned long long) addr[0]; | |
103 | v |= (unsigned long long) addr[1] << 8; | |
104 | v |= (unsigned long long) addr[2] << 16; | |
105 | v |= (unsigned long long) addr[3] << 24; | |
106 | v |= (unsigned long long) addr[4] << 32; | |
107 | v |= (unsigned long long) addr[5] << 40; | |
108 | v |= (unsigned long long) addr[6] << 48; | |
109 | v |= (unsigned long long) addr[7] << 56; | |
110 | return (bfd_vma) v; | |
111 | } | |
112 | ||
aa0aa4fa FB |
113 | bfd_vma bfd_getl32 (const bfd_byte *addr) |
114 | { | |
115 | unsigned long v; | |
116 | ||
117 | v = (unsigned long) addr[0]; | |
118 | v |= (unsigned long) addr[1] << 8; | |
119 | v |= (unsigned long) addr[2] << 16; | |
120 | v |= (unsigned long) addr[3] << 24; | |
121 | return (bfd_vma) v; | |
122 | } | |
123 | ||
124 | bfd_vma bfd_getb32 (const bfd_byte *addr) | |
125 | { | |
126 | unsigned long v; | |
127 | ||
128 | v = (unsigned long) addr[0] << 24; | |
129 | v |= (unsigned long) addr[1] << 16; | |
130 | v |= (unsigned long) addr[2] << 8; | |
131 | v |= (unsigned long) addr[3]; | |
132 | return (bfd_vma) v; | |
133 | } | |
134 | ||
6af0bf9c FB |
135 | bfd_vma bfd_getl16 (const bfd_byte *addr) |
136 | { | |
137 | unsigned long v; | |
138 | ||
139 | v = (unsigned long) addr[0]; | |
140 | v |= (unsigned long) addr[1] << 8; | |
141 | return (bfd_vma) v; | |
142 | } | |
143 | ||
144 | bfd_vma bfd_getb16 (const bfd_byte *addr) | |
145 | { | |
146 | unsigned long v; | |
147 | ||
148 | v = (unsigned long) addr[0] << 24; | |
149 | v |= (unsigned long) addr[1] << 16; | |
150 | return (bfd_vma) v; | |
151 | } | |
152 | ||
c2d551ff FB |
153 | #ifdef TARGET_ARM |
154 | static int | |
155 | print_insn_thumb1(bfd_vma pc, disassemble_info *info) | |
156 | { | |
157 | return print_insn_arm(pc | 1, info); | |
158 | } | |
159 | #endif | |
160 | ||
c46ffd57 RH |
161 | static int print_insn_objdump(bfd_vma pc, disassemble_info *info, |
162 | const char *prefix) | |
163 | { | |
164 | int i, n = info->buffer_length; | |
165 | uint8_t *buf = g_malloc(n); | |
166 | ||
167 | info->read_memory_func(pc, buf, n, info); | |
168 | ||
169 | for (i = 0; i < n; ++i) { | |
170 | if (i % 32 == 0) { | |
171 | info->fprintf_func(info->stream, "\n%s: ", prefix); | |
172 | } | |
173 | info->fprintf_func(info->stream, "%02x", buf[i]); | |
174 | } | |
175 | ||
176 | g_free(buf); | |
177 | return n; | |
178 | } | |
179 | ||
180 | static int print_insn_od_host(bfd_vma pc, disassemble_info *info) | |
181 | { | |
182 | return print_insn_objdump(pc, info, "OBJD-H"); | |
183 | } | |
184 | ||
185 | static int print_insn_od_target(bfd_vma pc, disassemble_info *info) | |
186 | { | |
187 | return print_insn_objdump(pc, info, "OBJD-T"); | |
188 | } | |
189 | ||
e91c8a77 | 190 | /* Disassemble this for me please... (debugging). 'flags' has the following |
c2d551ff | 191 | values: |
e99722f6 | 192 | i386 - 1 means 16 bit code, 2 means 64 bit code |
999b53ec | 193 | arm - bit 0 = thumb, bit 1 = reverse endian, bit 2 = A64 |
6a00d601 | 194 | ppc - nonzero means little endian |
c2d551ff FB |
195 | other targets - unused |
196 | */ | |
f4359b9f BS |
197 | void target_disas(FILE *out, CPUArchState *env, target_ulong code, |
198 | target_ulong size, int flags) | |
b9adb4a6 | 199 | { |
c27004ec | 200 | target_ulong pc; |
b9adb4a6 | 201 | int count; |
f4359b9f | 202 | CPUDebug s; |
c46ffd57 | 203 | int (*print_insn)(bfd_vma pc, disassemble_info *info) = NULL; |
b9adb4a6 | 204 | |
f4359b9f | 205 | INIT_DISASSEMBLE_INFO(s.info, out, fprintf); |
b9adb4a6 | 206 | |
f4359b9f BS |
207 | s.env = env; |
208 | s.info.read_memory_func = target_read_memory; | |
209 | s.info.buffer_vma = code; | |
210 | s.info.buffer_length = size; | |
211 | s.info.print_address_func = generic_print_target_address; | |
c27004ec FB |
212 | |
213 | #ifdef TARGET_WORDS_BIGENDIAN | |
f4359b9f | 214 | s.info.endian = BFD_ENDIAN_BIG; |
c27004ec | 215 | #else |
f4359b9f | 216 | s.info.endian = BFD_ENDIAN_LITTLE; |
c27004ec FB |
217 | #endif |
218 | #if defined(TARGET_I386) | |
f4359b9f BS |
219 | if (flags == 2) { |
220 | s.info.mach = bfd_mach_x86_64; | |
221 | } else if (flags == 1) { | |
222 | s.info.mach = bfd_mach_i386_i8086; | |
223 | } else { | |
224 | s.info.mach = bfd_mach_i386_i386; | |
225 | } | |
c27004ec FB |
226 | print_insn = print_insn_i386; |
227 | #elif defined(TARGET_ARM) | |
999b53ec CF |
228 | if (flags & 4) { |
229 | /* We might not be compiled with the A64 disassembler | |
230 | * because it needs a C++ compiler; in that case we will | |
231 | * fall through to the default print_insn_od case. | |
232 | */ | |
233 | #if defined(CONFIG_ARM_A64_DIS) | |
234 | print_insn = print_insn_arm_a64; | |
235 | #endif | |
236 | } else if (flags & 1) { | |
d8fd2954 PB |
237 | print_insn = print_insn_thumb1; |
238 | } else { | |
239 | print_insn = print_insn_arm; | |
240 | } | |
241 | if (flags & 2) { | |
242 | #ifdef TARGET_WORDS_BIGENDIAN | |
f4359b9f | 243 | s.info.endian = BFD_ENDIAN_LITTLE; |
d8fd2954 | 244 | #else |
f4359b9f | 245 | s.info.endian = BFD_ENDIAN_BIG; |
d8fd2954 PB |
246 | #endif |
247 | } | |
c27004ec FB |
248 | #elif defined(TARGET_SPARC) |
249 | print_insn = print_insn_sparc; | |
3475187d | 250 | #ifdef TARGET_SPARC64 |
f4359b9f | 251 | s.info.mach = bfd_mach_sparc_v9b; |
3b46e624 | 252 | #endif |
c27004ec | 253 | #elif defined(TARGET_PPC) |
f4359b9f BS |
254 | if (flags >> 16) { |
255 | s.info.endian = BFD_ENDIAN_LITTLE; | |
256 | } | |
237c0af0 JM |
257 | if (flags & 0xFFFF) { |
258 | /* If we have a precise definitions of the instructions set, use it */ | |
f4359b9f | 259 | s.info.mach = flags & 0xFFFF; |
237c0af0 | 260 | } else { |
a2458627 | 261 | #ifdef TARGET_PPC64 |
f4359b9f | 262 | s.info.mach = bfd_mach_ppc64; |
a2458627 | 263 | #else |
f4359b9f | 264 | s.info.mach = bfd_mach_ppc; |
a2458627 | 265 | #endif |
237c0af0 | 266 | } |
88770fec | 267 | s.info.disassembler_options = (char *)"any"; |
c27004ec | 268 | print_insn = print_insn_ppc; |
e6e5906b PB |
269 | #elif defined(TARGET_M68K) |
270 | print_insn = print_insn_m68k; | |
6af0bf9c | 271 | #elif defined(TARGET_MIPS) |
76b3030c | 272 | #ifdef TARGET_WORDS_BIGENDIAN |
6af0bf9c | 273 | print_insn = print_insn_big_mips; |
76b3030c FB |
274 | #else |
275 | print_insn = print_insn_little_mips; | |
276 | #endif | |
fdf9b3e8 | 277 | #elif defined(TARGET_SH4) |
f4359b9f | 278 | s.info.mach = bfd_mach_sh4; |
fdf9b3e8 | 279 | print_insn = print_insn_sh; |
eddf68a6 | 280 | #elif defined(TARGET_ALPHA) |
f4359b9f | 281 | s.info.mach = bfd_mach_alpha_ev6; |
eddf68a6 | 282 | print_insn = print_insn_alpha; |
a25fd137 | 283 | #elif defined(TARGET_CRIS) |
b09cd072 | 284 | if (flags != 32) { |
f4359b9f | 285 | s.info.mach = bfd_mach_cris_v0_v10; |
b09cd072 EI |
286 | print_insn = print_insn_crisv10; |
287 | } else { | |
f4359b9f | 288 | s.info.mach = bfd_mach_cris_v32; |
b09cd072 EI |
289 | print_insn = print_insn_crisv32; |
290 | } | |
db500609 | 291 | #elif defined(TARGET_S390X) |
f4359b9f | 292 | s.info.mach = bfd_mach_s390_64; |
db500609 | 293 | print_insn = print_insn_s390; |
e90e390c | 294 | #elif defined(TARGET_MICROBLAZE) |
f4359b9f | 295 | s.info.mach = bfd_arch_microblaze; |
e90e390c | 296 | print_insn = print_insn_microblaze; |
bd86a88e AG |
297 | #elif defined(TARGET_MOXIE) |
298 | s.info.mach = bfd_arch_moxie; | |
299 | print_insn = print_insn_moxie; | |
79368f49 | 300 | #elif defined(TARGET_LM32) |
f4359b9f | 301 | s.info.mach = bfd_mach_lm32; |
79368f49 | 302 | print_insn = print_insn_lm32; |
c6105c0a | 303 | #endif |
c46ffd57 RH |
304 | if (print_insn == NULL) { |
305 | print_insn = print_insn_od_target; | |
306 | } | |
c6105c0a | 307 | |
7e000c2e | 308 | for (pc = code; size > 0; pc += count, size -= count) { |
fa15e030 | 309 | fprintf(out, "0x" TARGET_FMT_lx ": ", pc); |
f4359b9f | 310 | count = print_insn(pc, &s.info); |
c27004ec FB |
311 | #if 0 |
312 | { | |
313 | int i; | |
314 | uint8_t b; | |
315 | fprintf(out, " {"); | |
316 | for(i = 0; i < count; i++) { | |
f4359b9f | 317 | target_read_memory(pc + i, &b, 1, &s.info); |
c27004ec FB |
318 | fprintf(out, " %02x", b); |
319 | } | |
320 | fprintf(out, " }"); | |
321 | } | |
322 | #endif | |
323 | fprintf(out, "\n"); | |
324 | if (count < 0) | |
325 | break; | |
754d00ae | 326 | if (size < count) { |
327 | fprintf(out, | |
328 | "Disassembler disagrees with translator over instruction " | |
329 | "decoding\n" | |
330 | "Please report this to [email protected]\n"); | |
331 | break; | |
332 | } | |
c27004ec FB |
333 | } |
334 | } | |
335 | ||
336 | /* Disassemble this for me please... (debugging). */ | |
337 | void disas(FILE *out, void *code, unsigned long size) | |
338 | { | |
b0b0f1c9 | 339 | uintptr_t pc; |
c27004ec | 340 | int count; |
f4359b9f | 341 | CPUDebug s; |
c46ffd57 | 342 | int (*print_insn)(bfd_vma pc, disassemble_info *info) = NULL; |
c27004ec | 343 | |
f4359b9f BS |
344 | INIT_DISASSEMBLE_INFO(s.info, out, fprintf); |
345 | s.info.print_address_func = generic_print_host_address; | |
c27004ec | 346 | |
f4359b9f BS |
347 | s.info.buffer = code; |
348 | s.info.buffer_vma = (uintptr_t)code; | |
349 | s.info.buffer_length = size; | |
b9adb4a6 | 350 | |
e2542fe2 | 351 | #ifdef HOST_WORDS_BIGENDIAN |
f4359b9f | 352 | s.info.endian = BFD_ENDIAN_BIG; |
b9adb4a6 | 353 | #else |
f4359b9f | 354 | s.info.endian = BFD_ENDIAN_LITTLE; |
b9adb4a6 | 355 | #endif |
5826e519 SW |
356 | #if defined(CONFIG_TCG_INTERPRETER) |
357 | print_insn = print_insn_tci; | |
358 | #elif defined(__i386__) | |
f4359b9f | 359 | s.info.mach = bfd_mach_i386_i386; |
c27004ec | 360 | print_insn = print_insn_i386; |
bc51c5c9 | 361 | #elif defined(__x86_64__) |
f4359b9f | 362 | s.info.mach = bfd_mach_x86_64; |
c27004ec | 363 | print_insn = print_insn_i386; |
e58ffeb3 | 364 | #elif defined(_ARCH_PPC) |
66d4f6a3 | 365 | s.info.disassembler_options = (char *)"any"; |
c27004ec | 366 | print_insn = print_insn_ppc; |
999b53ec CF |
367 | #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) |
368 | print_insn = print_insn_arm_a64; | |
a993ba85 | 369 | #elif defined(__alpha__) |
c27004ec | 370 | print_insn = print_insn_alpha; |
aa0aa4fa | 371 | #elif defined(__sparc__) |
c27004ec | 372 | print_insn = print_insn_sparc; |
f4359b9f | 373 | s.info.mach = bfd_mach_sparc_v9b; |
5fafdf24 | 374 | #elif defined(__arm__) |
c27004ec | 375 | print_insn = print_insn_arm; |
6af0bf9c FB |
376 | #elif defined(__MIPSEB__) |
377 | print_insn = print_insn_big_mips; | |
378 | #elif defined(__MIPSEL__) | |
379 | print_insn = print_insn_little_mips; | |
48024e4a FB |
380 | #elif defined(__m68k__) |
381 | print_insn = print_insn_m68k; | |
8f860bb8 TS |
382 | #elif defined(__s390__) |
383 | print_insn = print_insn_s390; | |
f54b3f92 AJ |
384 | #elif defined(__hppa__) |
385 | print_insn = print_insn_hppa; | |
903ec55c AJ |
386 | #elif defined(__ia64__) |
387 | print_insn = print_insn_ia64; | |
b9adb4a6 | 388 | #endif |
c46ffd57 RH |
389 | if (print_insn == NULL) { |
390 | print_insn = print_insn_od_host; | |
391 | } | |
b0b0f1c9 SW |
392 | for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) { |
393 | fprintf(out, "0x%08" PRIxPTR ": ", pc); | |
f4359b9f | 394 | count = print_insn(pc, &s.info); |
b9adb4a6 FB |
395 | fprintf(out, "\n"); |
396 | if (count < 0) | |
397 | break; | |
398 | } | |
399 | } | |
400 | ||
401 | /* Look up symbol for debugging purpose. Returns "" if unknown. */ | |
c27004ec | 402 | const char *lookup_symbol(target_ulong orig_addr) |
b9adb4a6 | 403 | { |
49918a75 | 404 | const char *symbol = ""; |
e80cfcfc | 405 | struct syminfo *s; |
3b46e624 | 406 | |
e80cfcfc | 407 | for (s = syminfos; s; s = s->next) { |
49918a75 PB |
408 | symbol = s->lookup_symbol(s, orig_addr); |
409 | if (symbol[0] != '\0') { | |
410 | break; | |
411 | } | |
b9adb4a6 | 412 | } |
49918a75 PB |
413 | |
414 | return symbol; | |
b9adb4a6 | 415 | } |
9307c4c1 FB |
416 | |
417 | #if !defined(CONFIG_USER_ONLY) | |
418 | ||
83c9089e | 419 | #include "monitor/monitor.h" |
3d2cfdf1 | 420 | |
9307c4c1 FB |
421 | static int monitor_disas_is_physical; |
422 | ||
423 | static int | |
a5f1b965 BS |
424 | monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, |
425 | struct disassemble_info *info) | |
9307c4c1 | 426 | { |
f4359b9f BS |
427 | CPUDebug *s = container_of(info, CPUDebug, info); |
428 | ||
9307c4c1 | 429 | if (monitor_disas_is_physical) { |
54f7b4a3 | 430 | cpu_physical_memory_read(memaddr, myaddr, length); |
9307c4c1 | 431 | } else { |
f17ec444 | 432 | cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0); |
9307c4c1 FB |
433 | } |
434 | return 0; | |
435 | } | |
436 | ||
8b7968f7 SW |
437 | static int GCC_FMT_ATTR(2, 3) |
438 | monitor_fprintf(FILE *stream, const char *fmt, ...) | |
3d2cfdf1 FB |
439 | { |
440 | va_list ap; | |
441 | va_start(ap, fmt); | |
376253ec | 442 | monitor_vprintf((Monitor *)stream, fmt, ap); |
3d2cfdf1 FB |
443 | va_end(ap); |
444 | return 0; | |
445 | } | |
446 | ||
9349b4f9 | 447 | void monitor_disas(Monitor *mon, CPUArchState *env, |
6a00d601 | 448 | target_ulong pc, int nb_insn, int is_physical, int flags) |
9307c4c1 | 449 | { |
9307c4c1 | 450 | int count, i; |
f4359b9f | 451 | CPUDebug s; |
9307c4c1 FB |
452 | int (*print_insn)(bfd_vma pc, disassemble_info *info); |
453 | ||
f4359b9f | 454 | INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); |
9307c4c1 | 455 | |
f4359b9f | 456 | s.env = env; |
9307c4c1 | 457 | monitor_disas_is_physical = is_physical; |
f4359b9f BS |
458 | s.info.read_memory_func = monitor_read_memory; |
459 | s.info.print_address_func = generic_print_target_address; | |
9307c4c1 | 460 | |
f4359b9f | 461 | s.info.buffer_vma = pc; |
9307c4c1 FB |
462 | |
463 | #ifdef TARGET_WORDS_BIGENDIAN | |
f4359b9f | 464 | s.info.endian = BFD_ENDIAN_BIG; |
9307c4c1 | 465 | #else |
f4359b9f | 466 | s.info.endian = BFD_ENDIAN_LITTLE; |
9307c4c1 FB |
467 | #endif |
468 | #if defined(TARGET_I386) | |
f4359b9f BS |
469 | if (flags == 2) { |
470 | s.info.mach = bfd_mach_x86_64; | |
471 | } else if (flags == 1) { | |
472 | s.info.mach = bfd_mach_i386_i8086; | |
473 | } else { | |
474 | s.info.mach = bfd_mach_i386_i386; | |
475 | } | |
9307c4c1 FB |
476 | print_insn = print_insn_i386; |
477 | #elif defined(TARGET_ARM) | |
478 | print_insn = print_insn_arm; | |
cbd669da TS |
479 | #elif defined(TARGET_ALPHA) |
480 | print_insn = print_insn_alpha; | |
9307c4c1 FB |
481 | #elif defined(TARGET_SPARC) |
482 | print_insn = print_insn_sparc; | |
682c4f15 | 483 | #ifdef TARGET_SPARC64 |
f4359b9f | 484 | s.info.mach = bfd_mach_sparc_v9b; |
682c4f15 | 485 | #endif |
9307c4c1 | 486 | #elif defined(TARGET_PPC) |
a2458627 | 487 | #ifdef TARGET_PPC64 |
f4359b9f | 488 | s.info.mach = bfd_mach_ppc64; |
a2458627 | 489 | #else |
f4359b9f | 490 | s.info.mach = bfd_mach_ppc; |
a2458627 | 491 | #endif |
9307c4c1 | 492 | print_insn = print_insn_ppc; |
e6e5906b PB |
493 | #elif defined(TARGET_M68K) |
494 | print_insn = print_insn_m68k; | |
6af0bf9c | 495 | #elif defined(TARGET_MIPS) |
76b3030c | 496 | #ifdef TARGET_WORDS_BIGENDIAN |
6af0bf9c | 497 | print_insn = print_insn_big_mips; |
76b3030c FB |
498 | #else |
499 | print_insn = print_insn_little_mips; | |
500 | #endif | |
b4e1f077 | 501 | #elif defined(TARGET_SH4) |
f4359b9f | 502 | s.info.mach = bfd_mach_sh4; |
b4e1f077 | 503 | print_insn = print_insn_sh; |
db500609 | 504 | #elif defined(TARGET_S390X) |
f4359b9f | 505 | s.info.mach = bfd_mach_s390_64; |
db500609 | 506 | print_insn = print_insn_s390; |
bd86a88e AG |
507 | #elif defined(TARGET_MOXIE) |
508 | s.info.mach = bfd_arch_moxie; | |
509 | print_insn = print_insn_moxie; | |
79368f49 | 510 | #elif defined(TARGET_LM32) |
f4359b9f | 511 | s.info.mach = bfd_mach_lm32; |
79368f49 | 512 | print_insn = print_insn_lm32; |
9307c4c1 | 513 | #else |
376253ec AL |
514 | monitor_printf(mon, "0x" TARGET_FMT_lx |
515 | ": Asm output not supported on this arch\n", pc); | |
9307c4c1 FB |
516 | return; |
517 | #endif | |
518 | ||
519 | for(i = 0; i < nb_insn; i++) { | |
376253ec | 520 | monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc); |
f4359b9f | 521 | count = print_insn(pc, &s.info); |
376253ec | 522 | monitor_printf(mon, "\n"); |
9307c4c1 FB |
523 | if (count < 0) |
524 | break; | |
525 | pc += count; | |
526 | } | |
527 | } | |
528 | #endif |