xref: /haiku/src/system/kernel/debug/debug_commands.h (revision f75a7bf508f3156d63a14f8fd77c5e0ca4d08c42)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KERNEL_DEBUG_COMMANDS_H
6 #define _KERNEL_DEBUG_COMMANDS_H
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 #define MAX_DEBUGGER_COMMAND_PIPE_LENGTH	8
13 
14 
15 typedef struct debugger_command {
16 	struct debugger_command* next;
17 	int				(*func)(int, char **);
18 	const char*		name;
19 	const char*		description;
20 	const char*		usage;
21 	uint32			flags;
22 } debugger_command;
23 
24 typedef struct debugger_command_pipe_segment {
25 	int32				index;
26 	debugger_command*	command;
27 	int					argc;
28 	char**				argv;
29 	int32				invocations;
30 	uint32				user_data[8];	// can be used by the command
31 } debugger_command_pipe_segment;
32 
33 typedef struct debugger_command_pipe {
34 	int32							segment_count;
35 	debugger_command_pipe_segment	segments[MAX_DEBUGGER_COMMAND_PIPE_LENGTH];
36 	bool							broken;
37 } debugger_command_pipe;
38 
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 debugger_command* next_debugger_command(debugger_command* command,
45 	const char* prefix, int prefixLen);
46 debugger_command* find_debugger_command(const char* name, bool partialMatch,
47 	bool& ambiguous);
48 bool in_command_invocation(void);
49 
50 int invoke_debugger_command(struct debugger_command *command, int argc,
51 	char** argv);
52 void abort_debugger_command();
53 
54 int invoke_debugger_command_pipe(debugger_command_pipe* pipe);
55 debugger_command_pipe* get_current_debugger_command_pipe();
56 debugger_command_pipe_segment* get_current_debugger_command_pipe_segment();
57 
58 debugger_command* get_debugger_commands();
59 void sort_debugger_commands();
60 
61 #ifdef __cplusplus
62 }	// extern "C"
63 #endif
64 
65 
66 #endif	// _KERNEL_DEBUG_COMMANDS_H
67