qemu/disas/tci.c
Peter Maydell 16c1321bd7 tci: Fix compile failure by including qemu-common.h
Compilation of TCI was accidentally broken by the recent disassembler
changes:

  CC    x86_64-softmmu/arch_init.o
In file included from target-i386/cpu-qom.h:23:0,
                 from target-i386/cpu.h:986,
                 from include/qemu-common.h:122,
                 from include/disas/bfd.h:12,
                 from disas/tci.c:20:
include/qom/cpu.h:178:43: error: unknown type name ‘disassemble_info’
     void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
                                           ^
include/qom/cpu.h:179:1: error:
no semicolon at end of struct or union [-Werror]
 } CPUClass;
 ^
cc1: all warnings being treated as errors

The underlying cause of this is an include loop:
 bfd.h -> qemu-common.h -> target-arm/cpu.h ->  target-arm/cpu-qom.h
  -> qom/cpu.h -> bfd.h

which means that if bfd.h is included first then qom/cpu.h doesn't
get the definition of the disassemble_info type that it wanted.
The easiest fix for this is to include qemu-common.h from tci.c
before including disas/bfd.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-07-09 17:50:27 +01:00

61 lines
1.8 KiB
C

/*
* Tiny Code Interpreter for QEMU - disassembler
*
* Copyright (c) 2011 Stefan Weil
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu-common.h"
#include "disas/bfd.h"
#include "tcg/tcg.h"
/* Disassemble TCI bytecode. */
int print_insn_tci(bfd_vma addr, disassemble_info *info)
{
int length;
uint8_t byte;
int status;
TCGOpcode op;
status = info->read_memory_func(addr, &byte, 1, info);
if (status != 0) {
info->memory_error_func(status, addr, info);
return -1;
}
op = byte;
addr++;
status = info->read_memory_func(addr, &byte, 1, info);
if (status != 0) {
info->memory_error_func(status, addr, info);
return -1;
}
length = byte;
if (op >= tcg_op_defs_max) {
info->fprintf_func(info->stream, "illegal opcode %d", op);
} else {
const TCGOpDef *def = &tcg_op_defs[op];
int nb_oargs = def->nb_oargs;
int nb_iargs = def->nb_iargs;
int nb_cargs = def->nb_cargs;
/* TODO: Improve disassembler output. */
info->fprintf_func(info->stream, "%s\to=%d i=%d c=%d",
def->name, nb_oargs, nb_iargs, nb_cargs);
}
return length;
}