blob: 42652b28a747aa214b0098b8cdc5ca99c5f187c9 [file] [log] [blame]
Alex Bennéeae7467b2022-09-29 12:42:24 +01001/*
2 * gdbstub user-mode helper routines.
3 *
4 * We know for user-mode we are using TCG so we can call stuff directly.
5 *
6 * Copyright (c) 2022 Linaro Ltd
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11#include "qemu/osdep.h"
12#include "exec/hwaddr.h"
13#include "exec/gdbstub.h"
14#include "hw/core/cpu.h"
15#include "internals.h"
16
17int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len)
18{
19 CPUState *cpu;
20 int err = 0;
21
22 switch (type) {
23 case GDB_BREAKPOINT_SW:
24 case GDB_BREAKPOINT_HW:
25 CPU_FOREACH(cpu) {
26 err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL);
27 if (err) {
28 break;
29 }
30 }
31 return err;
32 default:
33 /* user-mode doesn't support watchpoints */
34 return -ENOSYS;
35 }
36}
37
38int gdb_breakpoint_remove(CPUState *cs, int type, hwaddr addr, hwaddr len)
39{
40 CPUState *cpu;
41 int err = 0;
42
43 switch (type) {
44 case GDB_BREAKPOINT_SW:
45 case GDB_BREAKPOINT_HW:
46 CPU_FOREACH(cpu) {
47 err = cpu_breakpoint_remove(cpu, addr, BP_GDB);
48 if (err) {
49 break;
50 }
51 }
52 return err;
53 default:
54 /* user-mode doesn't support watchpoints */
55 return -ENOSYS;
56 }
57}
58
59void gdb_breakpoint_remove_all(CPUState *cs)
60{
61 cpu_breakpoint_remove_all(cs, BP_GDB);
62}