diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2015-07-09 15:00:37 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-07-09 15:00:37 +0100 |
commit | 032624868df264d395ee9900331f08bad1431022 (patch) | |
tree | 3c265b22c87638dec3e52948428d70e5fe67484e /disas | |
parent | 5a2db89615c8efabbeca74fe5e0f14f312d3bbe3 (diff) | |
parent | 6b625fde5eb8d1c969969392f1c92b58beed2183 (diff) |
Merge remote-tracking branch 'remotes/afaerber/tags/qom-cpu-for-peter' into staging
QOM CPUState and X86CPU
* Further QOM'ification of CPU initialization
* Propagation of CPUState arguments and elimination of ENV_GET_CPU() usage
* cpu_set_pc() abstraction
* CPUClass::disas_set_info() hook
# gpg: Signature made Thu Jul 9 14:23:12 2015 BST using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg: aka "Andreas Färber <afaerber@suse.com>"
* remotes/afaerber/tags/qom-cpu-for-peter: (22 commits)
disas: cris: QOMify target specific disas setup
disas: cris: Fix 0 buffer length case
disas: microblaze: QOMify target specific disas setup
disas: arm: QOMify target specific disas setup
disas: arm-a64: Make printfer and stream variable
disas: QOMify target specific setup
disas: Add print_insn to disassemble info
microblaze: boot: Use cpu_set_pc()
hw/arm/boot: Use cpu_set_pc()
gdbstub: Use cpu_set_pc() helper
cpu: Add wrapper for the set_pc() hook
cpu-exec: Purge all uses of ENV_GET_CPU()
cpu: Change cpu_exec_init() arg to cpu, not env
cpu: Change tcg_cpu_exec() arg to cpu, not env
gdbstub: Change gdbserver_fork() to accept cpu instead of env
translate-all: Change tb_flush() env argument to cpu
target-ppc: Move cpu_exec_init() call to realize function
cpu: Convert cpu_index into a bitmap
cpu: Add Error argument to cpu_exec_init()
cpu: Reorder cpu->as, cpu->thread_id, cpu->memory_dispatch init
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'disas')
-rw-r--r-- | disas/arm-a64.cc | 22 | ||||
-rw-r--r-- | disas/cris.c | 6 |
2 files changed, 20 insertions, 8 deletions
diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc index e04f946ca3..b0803f9cc3 100644 --- a/disas/arm-a64.cc +++ b/disas/arm-a64.cc @@ -35,16 +35,25 @@ static Disassembler *vixl_disasm = NULL; */ class QEMUDisassembler : public Disassembler { public: - explicit QEMUDisassembler(FILE *stream) : stream_(stream) { } + QEMUDisassembler() : printf_(NULL), stream_(NULL) { } ~QEMUDisassembler() { } + void SetStream(FILE *stream) { + stream_ = stream; + } + + void SetPrintf(int (*printf_fn)(FILE *, const char *, ...)) { + printf_ = printf_fn; + } + protected: virtual void ProcessOutput(const Instruction *instr) { - fprintf(stream_, "%08" PRIx32 " %s", + printf_(stream_, "%08" PRIx32 " %s", instr->InstructionBits(), GetOutput()); } private: + int (*printf_)(FILE *, const char *, ...); FILE *stream_; }; @@ -53,9 +62,9 @@ static int vixl_is_initialized(void) return vixl_decoder != NULL; } -static void vixl_init(FILE *f) { +static void vixl_init() { vixl_decoder = new Decoder(); - vixl_disasm = new QEMUDisassembler(f); + vixl_disasm = new QEMUDisassembler(); vixl_decoder->AppendVisitor(vixl_disasm); } @@ -78,9 +87,12 @@ int print_insn_arm_a64(uint64_t addr, disassemble_info *info) } if (!vixl_is_initialized()) { - vixl_init(info->stream); + vixl_init(); } + ((QEMUDisassembler *)vixl_disasm)->SetPrintf(info->fprintf_func); + ((QEMUDisassembler *)vixl_disasm)->SetStream(info->stream); + instrval = bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24; instr = reinterpret_cast<const Instruction *>(&instrval); vixl_disasm->MapCodeAddress(addr, instr); diff --git a/disas/cris.c b/disas/cris.c index e6cff7a765..1b76a09dbf 100644 --- a/disas/cris.c +++ b/disas/cris.c @@ -2575,9 +2575,9 @@ print_insn_cris_generic (bfd_vma memaddr, If we can't get any data, or we do not get enough data, we print the error message. */ - nbytes = info->buffer_length; - if (nbytes > MAX_BYTES_PER_CRIS_INSN) - nbytes = MAX_BYTES_PER_CRIS_INSN; + nbytes = info->buffer_length ? info->buffer_length + : MAX_BYTES_PER_CRIS_INSN; + nbytes = MIN(nbytes, MAX_BYTES_PER_CRIS_INSN); status = (*info->read_memory_func) (memaddr, buffer, nbytes, info); /* If we did not get all we asked for, then clear the rest. |