1/*
2 * Copyright 2005-2016, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef KERNEL_ARCH_USER_DEBUGGER_H
6#define KERNEL_ARCH_USER_DEBUGGER_H
7
8
9#include "kernel_debug_config.h"
10
11#ifndef _ASSEMBLER
12
13#include <debugger.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct arch_team_debug_info;
20struct arch_thread_debug_info;
21
22namespace BKernel {
23    struct Thread;
24}
25using BKernel::Thread;
26
27
28void arch_clear_team_debug_info(struct arch_team_debug_info *info);
29void arch_destroy_team_debug_info(struct arch_team_debug_info *info);
30void arch_clear_thread_debug_info(struct arch_thread_debug_info *info);
31void arch_destroy_thread_debug_info(struct arch_thread_debug_info *info);
32
33void arch_update_thread_single_step();
34
35void arch_set_debug_cpu_state(const debug_cpu_state *cpuState);
36void arch_get_debug_cpu_state(debug_cpu_state *cpuState);
37status_t arch_get_thread_debug_cpu_state(Thread *thread,
38	debug_cpu_state *cpuState);
39
40status_t arch_set_breakpoint(void *address);
41status_t arch_clear_breakpoint(void *address);
42status_t arch_set_watchpoint(void *address, uint32 type, int32 length);
43status_t arch_clear_watchpoint(void *address);
44bool arch_has_breakpoints(struct arch_team_debug_info *info);
45
46#if KERNEL_BREAKPOINTS
47status_t arch_set_kernel_breakpoint(void *address);
48status_t arch_clear_kernel_breakpoint(void *address);
49status_t arch_set_kernel_watchpoint(void *address, uint32 type, int32 length);
50status_t arch_clear_kernel_watchpoint(void *address);
51#endif
52
53#ifdef __cplusplus
54}
55#endif
56
57#include <arch_user_debugger.h>
58
59// Defaults for macros defined by the architecture specific header:
60
61// maximum number of instruction breakpoints
62#ifndef DEBUG_MAX_BREAKPOINTS
63#	define DEBUG_MAX_BREAKPOINTS 0
64#endif
65
66// maximum number of data watchpoints
67#ifndef DEBUG_MAX_WATCHPOINTS
68#	define DEBUG_MAX_WATCHPOINTS 0
69#endif
70
71// the software breakpoint instruction
72#if !defined(DEBUG_SOFTWARE_BREAKPOINT)	\
73	|| !defined(DEBUG_SOFTWARE_BREAKPOINT_SIZE)
74#	undef DEBUG_SOFTWARE_BREAKPOINT
75#	undef DEBUG_SOFTWARE_BREAKPOINT_SIZE
76#	define DEBUG_SOFTWARE_BREAKPOINT		NULL
77#	define DEBUG_SOFTWARE_BREAKPOINT_SIZE	0
78#endif
79
80// Boolean whether break- and watchpoints use the same registers. If != 0, then
81// DEBUG_MAX_BREAKPOINTS == DEBUG_MAX_WATCHPOINTS and either specifies the
82// total count of break- plus watchpoints.
83#ifndef DEBUG_SHARED_BREAK_AND_WATCHPOINTS
84#	define DEBUG_SHARED_BREAK_AND_WATCHPOINTS 0
85#endif
86
87#endif	// _ASSEMBLER
88
89#endif	// KERNEL_ARCH_USER_DEBUGGER_H
90