diff mbox series

accel/tcg: Align data dumped at end of TB

Message ID 20210515104202.241504-1-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series accel/tcg: Align data dumped at end of TB | expand

Commit Message

Philippe Mathieu-Daudé May 15, 2021, 10:42 a.m. UTC
To better visualize the data dumped at the end of a TB,
left-align it (padding it with 0).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/tcg/translate-all.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Richard Henderson May 16, 2021, 2:01 p.m. UTC | #1
On 5/15/21 5:42 AM, Philippe Mathieu-Daudé wrote:
> +                qemu_log("0x%08" PRIxPTR ":  .quad  0x%0*" TCG_PRIlx "\n",
> +                         (uintptr_t)&rx_data_gen_ptr[i],
> +                         2 * sizeof(tcg_target_ulong), rx_data_gen_ptr[i]);

This doesn't quite work, because


> ../qemu/accel/tcg/translate-all.c:2045:26: error: field width specifier ‘*’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]
>  2045 |                 qemu_log("0x%08" PRIxPTR ":  .quad  0x%0*" TCG_PRIlx "\n",
>       |                          ^~~~~~~
>  2046 |                          (uintptr_t)&rx_data_gen_ptr[i],
>  2047 |                          2 * sizeof(tcg_target_ulong), rx_data_gen_ptr[i]);
>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                          |
>       |                          long unsigned int


However, I also noticed that we shouldn't be printing ".quad" for 32-bit hosts 
either.  So I'll just split this into two separate qemu_log invocations, based 
on sizeof(tcg_target_ulong).


r~
Philippe Mathieu-Daudé May 16, 2021, 5:54 p.m. UTC | #2
On 5/16/21 4:01 PM, Richard Henderson wrote:
> On 5/15/21 5:42 AM, Philippe Mathieu-Daudé wrote:
>> +                qemu_log("0x%08" PRIxPTR ":  .quad  0x%0*" TCG_PRIlx
>> "\n",
>> +                         (uintptr_t)&rx_data_gen_ptr[i],
>> +                         2 * sizeof(tcg_target_ulong),
>> rx_data_gen_ptr[i]);
> 
> This doesn't quite work, because
> 
> 
>> ../qemu/accel/tcg/translate-all.c:2045:26: error: field width
>> specifier ‘*’ expects argument of type ‘int’, but argument 3 has type
>> ‘long unsigned int’ [-Werror=format=]
>>  2045 |                 qemu_log("0x%08" PRIxPTR ":  .quad  0x%0*"
>> TCG_PRIlx "\n",
>>       |                          ^~~~~~~
>>  2046 |                          (uintptr_t)&rx_data_gen_ptr[i],
>>  2047 |                          2 * sizeof(tcg_target_ulong),
>> rx_data_gen_ptr[i]);
>>       |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>       |                          |
>>       |                          long unsigned int
> 
> 
> However, I also noticed that we shouldn't be printing ".quad" for 32-bit
> hosts either.  So I'll just split this into two separate qemu_log
> invocations, based on sizeof(tcg_target_ulong).

Thanks :)
diff mbox series

Patch

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index ae7e873713a..387f3dc2303 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2042,8 +2042,9 @@  TranslationBlock *tb_gen_code(CPUState *cpu,
             int i;
             qemu_log("  data: [size=%d]\n", data_size);
             for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) {
-                qemu_log("0x%08" PRIxPTR ":  .quad  0x%" TCG_PRIlx "\n",
-                         (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
+                qemu_log("0x%08" PRIxPTR ":  .quad  0x%0*" TCG_PRIlx "\n",
+                         (uintptr_t)&rx_data_gen_ptr[i],
+                         2 * sizeof(tcg_target_ulong), rx_data_gen_ptr[i]);
             }
         }
         qemu_log("\n");