diff mbox series

[v4,8/9] disas: Remove monitor_disas_is_physical

Message ID 20170928165414.7339-9-richard.henderson@linaro.org
State Superseded
Headers show
Series Support the Capstone disassembler | expand

Commit Message

Richard Henderson Sept. 28, 2017, 4:54 p.m. UTC
Even though there is only one monitor, and thus no race on this
global data object, there is also no point in having it.  We can
just as well record the decision in the read_memory_function that
we select.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 disas.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

-- 
2.13.5

Comments

Philippe Mathieu-Daudé Oct. 2, 2017, 1:55 p.m. UTC | #1
On 09/28/2017 01:54 PM, Richard Henderson wrote:
> Even though there is only one monitor, and thus no race on this

> global data object, there is also no point in having it.  We can

> just as well record the decision in the read_memory_function that

> we select.

> 

> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>   disas.c | 16 ++++------------

>   1 file changed, 4 insertions(+), 12 deletions(-)

> 

> diff --git a/disas.c b/disas.c

> index 0d212f2ac5..194c523885 100644

> --- a/disas.c

> +++ b/disas.c

> @@ -513,19 +513,11 @@ const char *lookup_symbol(target_ulong orig_addr)

>   

>   #include "monitor/monitor.h"

>   

> -static int monitor_disas_is_physical;

> -

>   static int

> -monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,

> +physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,

>                        struct disassemble_info *info)

>   {

> -    CPUDebug *s = container_of(info, CPUDebug, info);

> -

> -    if (monitor_disas_is_physical) {

> -        cpu_physical_memory_read(memaddr, myaddr, length);

> -    } else {

> -        cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);

> -    }

> +    cpu_physical_memory_read(memaddr, myaddr, length);

>       return 0;

>   }

>   

> @@ -540,8 +532,8 @@ void monitor_disas(Monitor *mon, CPUState *cpu,

>       INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);

>   

>       s.cpu = cpu;

> -    monitor_disas_is_physical = is_physical;

> -    s.info.read_memory_func = monitor_read_memory;

> +    s.info.read_memory_func

> +        = (is_physical ? physical_read_memory : target_read_memory);

>       s.info.print_address_func = generic_print_address;

>       s.info.buffer_vma = pc;

>       s.info.cap_arch = -1;

>
diff mbox series

Patch

diff --git a/disas.c b/disas.c
index 0d212f2ac5..194c523885 100644
--- a/disas.c
+++ b/disas.c
@@ -513,19 +513,11 @@  const char *lookup_symbol(target_ulong orig_addr)
 
 #include "monitor/monitor.h"
 
-static int monitor_disas_is_physical;
-
 static int
-monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
+physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,
                      struct disassemble_info *info)
 {
-    CPUDebug *s = container_of(info, CPUDebug, info);
-
-    if (monitor_disas_is_physical) {
-        cpu_physical_memory_read(memaddr, myaddr, length);
-    } else {
-        cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
-    }
+    cpu_physical_memory_read(memaddr, myaddr, length);
     return 0;
 }
 
@@ -540,8 +532,8 @@  void monitor_disas(Monitor *mon, CPUState *cpu,
     INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);
 
     s.cpu = cpu;
-    monitor_disas_is_physical = is_physical;
-    s.info.read_memory_func = monitor_read_memory;
+    s.info.read_memory_func
+        = (is_physical ? physical_read_memory : target_read_memory);
     s.info.print_address_func = generic_print_address;
     s.info.buffer_vma = pc;
     s.info.cap_arch = -1;