Message ID | 20250127115426.51355-11-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | disas: Have CPUClass::disas_set_info() callback set the endianness | expand |
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote: > All CPUClass implementations must implement disas_set_info() > which sets the disassemble_info::endian value. > > Ensure that by: > > 1/ assert disas_set_info() handler is not NULL > 2/ set %endian to BFD_ENDIAN_UNKNOWN before calling the > CPUClass::disas_set_info() handler, then assert %endian > is not BFD_ENDIAN_UNKNOWN after the call. > > This allows removing the target_words_bigendian() call in disas/. > > Suggested-by: Richard Henderson <richard.henderson@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > disas/disas-common.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) Reviewed-by: Thomas Huth <thuth@redhat.com>
diff --git a/disas/disas-common.c b/disas/disas-common.c index 57505823cb7..42e911e36be 100644 --- a/disas/disas-common.c +++ b/disas/disas-common.c @@ -7,7 +7,6 @@ #include "disas/disas.h" #include "disas/capstone.h" #include "hw/core/cpu.h" -#include "exec/tswap.h" #include "disas-internal.h" @@ -61,15 +60,11 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) s->cpu = cpu; s->info.print_address_func = print_address; - if (target_words_bigendian()) { - s->info.endian = BFD_ENDIAN_BIG; - } else { - s->info.endian = BFD_ENDIAN_LITTLE; - } + s->info.endian = BFD_ENDIAN_UNKNOWN; - if (cpu->cc->disas_set_info) { - cpu->cc->disas_set_info(cpu, &s->info); - } + g_assert(cpu->cc->disas_set_info); + cpu->cc->disas_set_info(cpu, &s->info); + g_assert(s->info.endian != BFD_ENDIAN_UNKNOWN); } int disas_gstring_printf(FILE *stream, const char *fmt, ...)
All CPUClass implementations must implement disas_set_info() which sets the disassemble_info::endian value. Ensure that by: 1/ assert disas_set_info() handler is not NULL 2/ set %endian to BFD_ENDIAN_UNKNOWN before calling the CPUClass::disas_set_info() handler, then assert %endian is not BFD_ENDIAN_UNKNOWN after the call. This allows removing the target_words_bigendian() call in disas/. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- disas/disas-common.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)