|
9 | 9 | #include "frame_buffer.h" |
10 | 10 | #include "qemu-plugin.h" |
11 | 11 | #include "trace_consts.h" |
| 12 | +#include "trace_meta.h" |
12 | 13 | #include "tracing.h" |
13 | 14 |
|
14 | 15 | static TraceState state = {0}; |
@@ -52,6 +53,7 @@ static void add_post_reg_state(VCPU *vcpu, unsigned int vcpu_index, |
52 | 53 | &g_array_index(current_regs, qemu_plugin_reg_descriptor, i); |
53 | 54 | int s = qemu_plugin_read_register(reg->handle, rdata); |
54 | 55 | assert(s == prev_reg->content->len); |
| 56 | + swap_to_le(rdata->data, s, state.is_big_endian); |
55 | 57 | if (!memcmp(rdata->data, prev_reg->content->data, s)) { |
56 | 58 | // No change |
57 | 59 | // Flush byte array |
@@ -79,7 +81,7 @@ static void add_pre_reg_state(VCPU *vcpu, unsigned int vcpu_index, |
79 | 81 | Register *prev_reg = g_ptr_array_index(vcpu->registers, i); |
80 | 82 | g_assert(!strcmp(prev_reg->name, reg->name) && |
81 | 83 | prev_reg->handle == reg->handle); |
82 | | - memcpy(prev_reg->content->data, rdata->data, prev_reg->content->len); |
| 84 | + memcpy_le(prev_reg->content->data, rdata->data, prev_reg->content->len, state.is_big_endian); |
83 | 85 | frame_buffer_append_reg_info(fbuf, reg->name, rdata, s, OperandRead); |
84 | 86 | // Flush byte array |
85 | 87 | g_byte_array_set_size(rdata, 0); |
@@ -338,6 +340,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, |
338 | 340 | qemu_plugin_outs("Pass it with 'out=<output_file>'.\n\n"); |
339 | 341 | exit(1); |
340 | 342 | } |
| 343 | + char *endianess = get_argv_val(argv, argc, "endianess"); |
| 344 | + if (!endianess || (strcmp(endianess, "b") && strcmp(endianess, "l"))) { |
| 345 | + qemu_plugin_outs("'endianess' argument is missing or is not 'b' or 'l'.\n"); |
| 346 | + qemu_plugin_outs("This is required until QEMU plugins get a richer API.\n"); |
| 347 | + qemu_plugin_outs("Pass it with 'endianess=[b/l]'.\n\n"); |
| 348 | + exit(1); |
| 349 | + } |
| 350 | + state.is_big_endian = endianess[0] == 'b'; |
341 | 351 |
|
342 | 352 | state.target_name = g_strdup(info->target_name); |
343 | 353 | state.frame_buffer = g_ptr_array_new(); |
|
0 commit comments