Skip to content

Commit

Permalink
watchpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 ERROR: space prohibited between function name and open parenthesis '('
 qemu#26: FILE: include/hw/core/cpu.h:199:
 +    vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
  • Loading branch information
philmd committed Mar 11, 2020
1 parent fb3c3bd commit 5bef036
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,7 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr)
return block->offset + offset;
}

#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
/* Generate a debug exception if a watchpoint has been hit. */
void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
MemTxAttrs attrs, int flags, uintptr_t ra)
Expand Down Expand Up @@ -2734,6 +2735,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
}
}
}
#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */

static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
MemTxAttrs attrs, void *buf, hwaddr len);
Expand Down
17 changes: 10 additions & 7 deletions hw/core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,19 @@ static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg)
return 0;
}

#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
static bool cpu_common_debug_check_watchpoint(CPUState *cpu, CPUWatchpoint *wp)
{
/* If no extra check is required, QEMU watchpoint match can be considered
* as an architectural match.
*/
return true;
}
static vaddr cpu_adjust_watchpoint_address(CPUState *cpu, vaddr addr, int len)
{
return addr;
}
#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */

static bool cpu_common_virtio_is_big_endian(CPUState *cpu)
{
Expand Down Expand Up @@ -399,11 +405,6 @@ static int64_t cpu_common_get_arch_id(CPUState *cpu)
return cpu->cpu_index;
}

static vaddr cpu_adjust_watchpoint_address(CPUState *cpu, vaddr addr, int len)
{
return addr;
}

static void generic_handle_interrupt(CPUState *cpu, int mask)
{
cpu->interrupt_request |= mask;
Expand Down Expand Up @@ -433,14 +434,16 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
k->virtio_is_big_endian = cpu_common_virtio_is_big_endian;
k->debug_check_watchpoint = cpu_common_debug_check_watchpoint;
k->cpu_exec_enter = cpu_common_noop;
k->cpu_exec_exit = cpu_common_noop;
k->cpu_exec_interrupt = cpu_common_exec_interrupt;
#if defined(CONFIG_TCG)
k->debug_excp_handler = cpu_common_noop;
#endif /* CONFIG_TCG */
#if !defined(CONFIG_USER_ONLY)
k->debug_check_watchpoint = cpu_common_debug_check_watchpoint;
k->adjust_watchpoint_address = cpu_adjust_watchpoint_address;
#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
#endif /* CONFIG_TCG */
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
dc->realize = cpu_common_realizefn;
dc->unrealize = cpu_common_unrealizefn;
Expand Down
4 changes: 2 additions & 2 deletions include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ typedef struct CPUClass {
void (*synchronize_from_tb)(CPUState *cpu, struct TranslationBlock *tb);
int (*gdb_read_register)(CPUState *cpu, uint8_t *buf, int reg);
int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp);

const char *gdb_core_xml_file;
gchar * (*gdb_arch_name)(CPUState *cpu);
Expand All @@ -188,7 +187,6 @@ typedef struct CPUClass {
bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);

void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
void (*tcg_initialize)(void);

#if defined(CONFIG_TCG)
Expand All @@ -197,6 +195,8 @@ typedef struct CPUClass {
bool probe, uintptr_t retaddr);
void (*debug_excp_handler)(CPUState *cpu);
#if !defined(CONFIG_USER_ONLY)
bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp);
vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len);
void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr);
Expand Down
2 changes: 1 addition & 1 deletion target/arm/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
cc->tcg_initialize = arm_translate_init;
cc->tlb_fill = arm_cpu_tlb_fill;
cc->debug_excp_handler = arm_debug_excp_handler;
cc->debug_check_watchpoint = arm_debug_check_watchpoint;
#if !defined(CONFIG_USER_ONLY)
cc->debug_check_watchpoint = arm_debug_check_watchpoint;
cc->do_unaligned_access = arm_cpu_do_unaligned_access;
cc->do_transaction_failed = arm_cpu_do_transaction_failed;
cc->adjust_watchpoint_address = arm_adjust_watchpoint_address;
Expand Down

0 comments on commit 5bef036

Please sign in to comment.