[PATCH 4/6] monitor/hmp: Inline ld[uw, l, q]_p() calls in memory_dump()

Philippe Mathieu-Daudé posted 6 patches 1 month, 2 weeks ago
Maintainers: "Dr. David Alan Gilbert" <dave@treblig.org>
There is a newer version of this series
[PATCH 4/6] monitor/hmp: Inline ld[uw, l, q]_p() calls in memory_dump()
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
Remove the last target-specificity in this file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 monitor/hmp-cmds-target.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/monitor/hmp-cmds-target.c b/monitor/hmp-cmds-target.c
index d2bdf44dafd..efab133cf2f 100644
--- a/monitor/hmp-cmds-target.c
+++ b/monitor/hmp-cmds-target.c
@@ -129,6 +129,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
     uint64_t v;
     CPUState *cs = mon_get_cpu(mon);
     const unsigned int addr_width = is_physical ? 8 : (target_long_bits() * 2);
+    const bool big_endian = target_big_endian();
 
     if (!cs && (format == 'i' || !is_physical)) {
         monitor_printf(mon, "Can not dump without CPU\n");
@@ -192,13 +193,13 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
                 v = ldub_p(buf + i);
                 break;
             case 2:
-                v = lduw_p(buf + i);
+                v = (big_endian ? lduw_be_p : lduw_le_p)(buf + i);
                 break;
             case 4:
-                v = (uint32_t)ldl_p(buf + i);
+                v = (uint32_t)(big_endian ? ldl_be_p : ldl_le_p)(buf + i);
                 break;
             case 8:
-                v = ldq_p(buf + i);
+                v = (big_endian ? ldq_be_p : ldq_le_p)(buf + i);
                 break;
             }
             monitor_printf(mon, " ");
-- 
2.52.0


Re: [PATCH 4/6] monitor/hmp: Inline ld[uw, l, q]_p() calls in memory_dump()
Posted by Manos Pitsidianakis 1 month, 2 weeks ago
On Wed, Dec 24, 2025 at 3:40 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Remove the last target-specificity in this file.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

>  monitor/hmp-cmds-target.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/monitor/hmp-cmds-target.c b/monitor/hmp-cmds-target.c
> index d2bdf44dafd..efab133cf2f 100644
> --- a/monitor/hmp-cmds-target.c
> +++ b/monitor/hmp-cmds-target.c
> @@ -129,6 +129,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
>      uint64_t v;
>      CPUState *cs = mon_get_cpu(mon);
>      const unsigned int addr_width = is_physical ? 8 : (target_long_bits() * 2);
> +    const bool big_endian = target_big_endian();
>
>      if (!cs && (format == 'i' || !is_physical)) {
>          monitor_printf(mon, "Can not dump without CPU\n");
> @@ -192,13 +193,13 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
>                  v = ldub_p(buf + i);
>                  break;
>              case 2:
> -                v = lduw_p(buf + i);
> +                v = (big_endian ? lduw_be_p : lduw_le_p)(buf + i);
>                  break;
>              case 4:
> -                v = (uint32_t)ldl_p(buf + i);
> +                v = (uint32_t)(big_endian ? ldl_be_p : ldl_le_p)(buf + i);
>                  break;
>              case 8:
> -                v = ldq_p(buf + i);
> +                v = (big_endian ? ldq_be_p : ldq_le_p)(buf + i);
>                  break;
>              }
>              monitor_printf(mon, " ");
> --
> 2.52.0
>