| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Created by: Jason Wessel <[email protected]> |
| 4 |
* |
| 5 |
* Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef _DEBUG_CORE_H_ |
| 9 |
#define _DEBUG_CORE_H_ |
| 10 |
/* |
| 11 |
* These are the private implementation headers between the kernel |
| 12 |
* debugger core and the debugger front end code. |
| 13 |
*/ |
| 14 |
|
| 15 |
/* kernel debug core data structures */ |
| 16 |
struct kgdb_state { |
| 17 |
int ex_vector; |
| 18 |
int signo; |
| 19 |
int err_code; |
| 20 |
int cpu; |
| 21 |
int pass_exception; |
| 22 |
unsigned long thr_query; |
| 23 |
unsigned long threadid; |
| 24 |
long kgdb_usethreadid; |
| 25 |
struct pt_regs *linux_regs; |
| 26 |
atomic_t *send_ready; |
| 27 |
}; |
| 28 |
|
| 29 |
/* Exception state values */ |
| 30 |
#define DCPU_WANT_MASTER 0x1 /* Waiting to become a master kgdb cpu */ |
| 31 |
#define DCPU_NEXT_MASTER 0x2 /* Transition from one master cpu to another */ |
| 32 |
#define DCPU_IS_SLAVE 0x4 /* Slave cpu enter exception */ |
| 33 |
#define DCPU_WANT_BT 0x8 /* Slave cpu should backtrace then clear flag */ |
| 34 |
|
| 35 |
struct debuggerinfo_struct { |
| 36 |
void *debuggerinfo; |
| 37 |
struct task_struct *task; |
| 38 |
int exception_state; |
| 39 |
int ret_state; |
| 40 |
int irq_depth; |
| 41 |
int enter_kgdb; |
| 42 |
bool rounding_up; |
| 43 |
}; |
| 44 |
|
| 45 |
extern struct debuggerinfo_struct kgdb_info[]; |
| 46 |
|
| 47 |
/* kernel debug core break point routines */ |
| 48 |
extern int dbg_remove_all_break(void); |
| 49 |
extern int dbg_set_sw_break(unsigned long addr); |
| 50 |
extern int dbg_remove_sw_break(unsigned long addr); |
| 51 |
extern int dbg_activate_sw_breakpoints(void); |
| 52 |
extern int dbg_deactivate_sw_breakpoints(void); |
| 53 |
|
| 54 |
/* polled character access to i/o module */ |
| 55 |
extern int dbg_io_get_char(void); |
| 56 |
|
| 57 |
/* stub return value for switching between the gdbstub and kdb */ |
| 58 |
#define DBG_PASS_EVENT -12345 |
| 59 |
/* Switch from one cpu to another */ |
| 60 |
#define DBG_SWITCH_CPU_EVENT -123456 |
| 61 |
extern int dbg_switch_cpu; |
| 62 |
|
| 63 |
/* gdbstub interface functions */ |
| 64 |
extern int gdb_serial_stub(struct kgdb_state *ks); |
| 65 |
extern void gdbstub_msg_write(const char *s, int len); |
| 66 |
|
| 67 |
/* gdbstub functions used for kdb <-> gdbstub transition */ |
| 68 |
extern int gdbstub_state(struct kgdb_state *ks, char *cmd); |
| 69 |
extern int dbg_kdb_mode; |
| 70 |
|
| 71 |
#ifdef CONFIG_KGDB_KDB |
| 72 |
extern int kdb_stub(struct kgdb_state *ks); |
| 73 |
extern int kdb_parse(const char *cmdstr); |
| 74 |
extern int kdb_common_init_state(struct kgdb_state *ks); |
| 75 |
extern int kdb_common_deinit_state(void); |
| 76 |
extern void kdb_dump_stack_on_cpu(int cpu); |
| 77 |
#else /* ! CONFIG_KGDB_KDB */ |
| 78 |
static inline int kdb_stub(struct kgdb_state *ks) |
| 79 |
{ |
| 80 |
return DBG_PASS_EVENT; |
| 81 |
} |
| 82 |
#endif /* CONFIG_KGDB_KDB */ |
| 83 |
|
| 84 |
#endif /* _DEBUG_CORE_H_ */ |