File: kdbprivate.h

package info (click to toggle)
kernel-patch-kdb 2.1-3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,900 kB
  • ctags: 421
  • sloc: ansic: 3,819; makefile: 74
file content (313 lines) | stat: -rw-r--r-- 9,638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#ifndef _KDBPRIVATE_H
#define _KDBPRIVATE_H

/*
 * Minimalist Kernel Debugger
 *
 * Copyright (C) 1999 Silicon Graphics, Inc.
 * Copyright (C) Scott Lurndal (slurn@engr.sgi.com)
 * Copyright (C) Scott Foehner (sfoehner@engr.sgi.com)
 * Copyright (C) Srinivasa Thirumalachar (sprasad@engr.sgi.com)
 *
 * See the file LIA-COPYRIGHT for additional information.
 *
 * Written March 1999 by Scott Lurndal at Silicon Graphics, Inc.
 *
 * Modifications from:
 *      Richard Bass                    1999/07/20
 *              Many bug fixes and enhancements.
 *      Scott Foehner
 *              Port to ia64
 *	Scott Lurndal			1999/12/12
 *		v1.0 restructuring.
 *	Keith Owens			2000/05/23
 *		KDB v1.2
 */

#include <linux/dis-asm.h>
#include <asm/kdbprivate.h>

#include "bfd.h"

/*
 * Kernel Debugger Error codes.  Must not overlap with command codes.
 */

#define KDB_NOTFOUND	(-1)
#define KDB_ARGCOUNT	(-2)
#define KDB_BADWIDTH	(-3)
#define KDB_BADRADIX	(-4)
#define KDB_NOTENV	(-5)
#define KDB_NOENVVALUE	(-6)
#define KDB_NOTIMP	(-7)
#define KDB_ENVFULL	(-8)
#define KDB_ENVBUFFULL	(-9 )
#define KDB_TOOMANYBPT	(-10)
#define KDB_TOOMANYDBREGS (-11)
#define KDB_DUPBPT	(-12)
#define KDB_BPTNOTFOUND	(-13)
#define KDB_BADMODE	(-14)
#define KDB_BADINT	(-15)
#define KDB_INVADDRFMT  (-16)
#define KDB_BADREG      (-17)
#define KDB_BADCPUNUM   (-18)
#define KDB_BADLENGTH	(-19)
#define KDB_NOBP	(-20)
#define KDB_BADADDR	(-21)

/*
 * Kernel Debugger Command codes.  Must not overlap with error codes.
 */
#define KDB_CMD_GO	(-1001)
#define KDB_CMD_CPU	(-1002)
#define KDB_CMD_SS	(-1003)
#define KDB_CMD_SSB	(-1004)

	/*
	 * kdb_nextline
	 *
	 * 	Contains the current line number on the screen.  Used
	 *	to handle the built-in pager (LINES env variable)
	 */
extern volatile int kdb_nextline;

	/*
	 * Breakpoint state
	 *
	 * 	Each active and inactive breakpoint is represented by
	 * 	an instance of the following data structure.  
	 */

typedef struct _kdb_bp {
	bfd_vma 	bp_addr;	/* Address breakpoint is present at */
	kdb_machinst_t	bp_inst;	/* Replaced instruction */

	unsigned int	bp_free:1;	/* This entry is available */

	unsigned int	bp_enabled:1;	/* Breakpoint is active in register */
	unsigned int	bp_global:1;	/* Global to all processors */

	unsigned int	bp_hardtype:1;	/* Uses hardware register */
	unsigned int	bp_forcehw:1;	/* Force hardware register */
	unsigned int	bp_installed:1;	/* Breakpoint is installed */
	unsigned int	bp_delay:1;	/* Do delayed bp handling */
	unsigned int	bp_delayed:1;	/* Delayed breakpoint */

	int		bp_cpu;		/* Cpu #  (if bp_global == 0) */
	kdbhard_bp_t	bp_template;	/* Hardware breakpoint template */
	kdbhard_bp_t	*bp_hard;	/* Hardware breakpoint structure */
	int		bp_adjust;	/* Adjustment to PC for real instruction */
} kdb_bp_t;

	/*
	 * Breakpoint handling subsystem global variables
	 */
extern kdb_bp_t		kdb_breakpoints[/* KDB_MAXBPT */];

	/*
	 * Breakpoint architecture dependent functions.  Must be provided
	 * in some form for all architectures.
	 */
extern void 		kdba_initbp(void);
extern void		kdba_printbp(kdb_bp_t *);
extern void		kdba_printbpreg(kdbhard_bp_t *);
extern kdbhard_bp_t	*kdba_allocbp(kdbhard_bp_t *, int *);
extern void		kdba_freebp(kdbhard_bp_t *);
extern int		kdba_parsebp(int, const char**, int *, kdb_bp_t*);
extern char 		*kdba_bptype(kdbhard_bp_t *);
extern void		kdba_setsinglestep(kdb_eframe_t);
extern void		kdba_clearsinglestep(kdb_eframe_t);

	/*
	 * Adjust instruction pointer architecture dependent function.  Must be
	 * provided in some form for all architectures.
	 */
extern void		kdba_adjust_ip(kdb_reason_t, int, kdb_eframe_t);

	/*
	 * KDB-only global function prototypes.
	 */
extern void	     kdb_id1(unsigned long);
extern void	     kdb_id_init(void);

	/*
	 * Architecture dependent function to enable any
	 * processor machine check exception handling modes.
	 */
extern void	     kdba_enable_mce(void);

extern void	     kdba_enable_lbr(void);
extern void	     kdba_disable_lbr(void);
extern void	     kdba_print_lbr(void);

	/*
	 * Initialization functions.
	 */
extern void	     kdba_init(void);
extern void	     kdb_io_init(void);

	/*
	 * Architecture specific function to read a string.
	 */
extern char *	     kdba_read(char *, size_t);

	/*
	 * Data for a single activation record on stack.
	 */

typedef struct __kdb_activation_record {
	kdb_machreg_t	start;		/* -> start of activation record */
	kdb_machreg_t	end;		/* -> end+1 of activation record */
	kdb_machreg_t	ret;		/* Return address to caller */
	kdb_machreg_t	oldfp;		/* Frame pointer for caller's frame */
	kdb_machreg_t	fp;		/* Frame pointer for callee's frame */
	kdb_machreg_t	arg0;		/* -> First argument on stack (in previous ar) */
	unsigned long	locals;		/* Bytes allocated for local variables */
	unsigned long	regs;		/* Bytes allocated for saved registers */
	unsigned long	args;		/* Bytes allocated for arguments (in previous ar) */
	unsigned long	setup;		/* Bytes allocated for setup data */
} kdb_ar_t;

	/* 
	 * General Stack Traceback functions.
	 */

extern int	     kdb_get_next_ar(kdb_machreg_t, kdb_machreg_t,
				     kdb_machreg_t, kdb_machreg_t,
				     kdb_machreg_t,
				     kdb_ar_t *, kdb_symtab_t *);

	/* 
	 * Architecture specific Stack Traceback functions.
	 */

struct task_struct;

extern int	     kdba_bt_stack(struct pt_regs *, kdb_machreg_t *, 
				   int, struct task_struct *);
extern int	     kdba_bt_process(struct task_struct *, int);
extern int	     kdba_prologue(const kdb_symtab_t *, kdb_machreg_t,
				   kdb_machreg_t, kdb_machreg_t, kdb_machreg_t,
				   int, kdb_ar_t *);
	/*
	 * KDB Command Table
	 */

typedef struct _kdbtab {
        char    *cmd_name;		/* Command name */
        kdb_func_t cmd_func;		/* Function to execute command */
        char    *cmd_usage;		/* Usage String for this command */
        char    *cmd_help;		/* Help message for this command */
        short    cmd_flags;		/* Parsing flags */
        short    cmd_minlen;		/* Minimum legal # command chars required */
	kdb_repeat_t cmd_repeat;	/* Does command auto repeat on enter? */
} kdbtab_t;

	/*
	 * External command function declarations
	 */

extern int kdb_id(int, const char **, const char **, kdb_eframe_t);
extern int kdb_bp(int, const char **, const char **, kdb_eframe_t);
extern int kdb_bc(int, const char **, const char **, kdb_eframe_t);
extern int kdb_bt(int, const char **, const char **, kdb_eframe_t);
extern int kdb_ss(int, const char **, const char **, kdb_eframe_t);

	/*
	 * External utility function declarations 
	 */
extern char* kdb_getstr(char *, size_t, char *);

	/*
	 * Register contents manipulation
	 */
extern int kdba_getregcontents(const char *, kdb_eframe_t, kdb_machreg_t *);
extern int kdba_setregcontents(const char *, kdb_eframe_t, kdb_machreg_t);
extern int kdba_dumpregs(struct pt_regs *, const char *, const char *);
extern int kdba_setpc(kdb_eframe_t, kdb_machreg_t);
extern kdb_machreg_t   kdba_getpc(kdb_eframe_t);

	/*
	 * Debug register handling. 
	 */
extern void kdba_installdbreg(kdb_bp_t*);
extern void kdba_removedbreg(kdb_bp_t*);

	/*
	 * Breakpoint handling - External interfaces
	 */
extern void kdb_initbptab(void);
extern void kdb_bp_install_global(kdb_eframe_t);
extern void kdb_bp_install_local(kdb_eframe_t);
extern void kdb_bp_remove_global(void);
extern void kdb_bp_remove_local(void);

	/*
	 * Breakpoint handling - Internal to kdb_bp.c/kdba_bp.c
	 */
extern int kdba_installbp(kdb_eframe_t ef, kdb_bp_t *);
extern int kdba_removebp(kdb_bp_t *);


typedef enum {
	KDB_DB_BPT,	/* Breakpoint */
	KDB_DB_SS,	/* Single-step trap */
	KDB_DB_SSB,	/* Single step to branch */
	KDB_DB_SSBPT,	/* Single step over breakpoint */
	KDB_DB_NOBPT	/* Spurious breakpoint */
} kdb_dbtrap_t;

extern kdb_dbtrap_t kdba_db_trap(kdb_eframe_t, int);	/* DEBUG trap/fault handler */
extern kdb_dbtrap_t kdba_bp_trap(kdb_eframe_t, int);	/* Breakpoint trap/fault hdlr */

	/*
	 * Interrupt Handling
	 */
typedef int kdb_intstate_t;

extern void kdba_disableint(kdb_intstate_t *);
extern void kdba_restoreint(kdb_intstate_t *);

	/*
	 * SMP and process stack manipulation routines.
	 */
extern int	     kdba_ipi(kdb_eframe_t, void (*)(void));
extern int	     kdba_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, kdb_eframe_t);
extern int           kdb_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, kdb_eframe_t);

	/*
	 * General Disassembler interfaces
	 */
extern int kdb_dis_fprintf(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
extern int kdb_dis_fprintf_dummy(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
extern disassemble_info	kdb_di;

	/*
	 * Architecture Dependent Disassembler interfaces
	 */
extern void kdba_printaddress(kdb_machreg_t, disassemble_info *, int);
extern int  kdba_id_printinsn(kdb_machreg_t, disassemble_info *);
extern int  kdba_id_parsemode(const char *, disassemble_info*);
extern void kdba_id_init(disassemble_info *);
extern void kdba_check_pc(kdb_machreg_t *);

	/*
	 * Miscellaneous functions and data areas
	 */
#ifndef kdba_getcurrentframe
extern int  kdba_getcurrentframe(kdb_eframe_t);
#endif
extern char *kdb_cmds[];

	/*
	 * Defines for kdb_symbol_print.
	 */
#define KDB_SP_SPACEB	0x0001		/* Space before string */
#define KDB_SP_SPACEA	0x0002		/* Space after string */
#define KDB_SP_PAREN	0x0004		/* Parenthesis around string */
#define KDB_SP_VALUE	0x0008		/* Print the value of the address */
#define KDB_SP_SYMSIZE	0x0010		/* Print the size of the symbol */
#define KDB_SP_NEWLINE	0x0020		/* Newline after string */
#define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN)

#endif	/* !_KDBPRIVATE_H */