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
15typedef 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
24typedef struct debugger_command_pipe_segment {
25	int32				index;
26	debugger_command*	command;
27	int					argc;
28	char**				argv;
29	int32				invocations;
30	uint64				user_data[4];	// can be used by the command
31} debugger_command_pipe_segment;
32
33typedef 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
39extern bool gInvokeCommandDirectly;
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45debugger_command* next_debugger_command(debugger_command* command,
46	const char* prefix, int prefixLen);
47debugger_command* find_debugger_command(const char* name, bool partialMatch,
48	bool& ambiguous);
49bool in_command_invocation(void);
50
51int invoke_debugger_command(struct debugger_command *command, int argc,
52	char** argv);
53void abort_debugger_command();
54
55int invoke_debugger_command_pipe(debugger_command_pipe* pipe);
56debugger_command_pipe* get_current_debugger_command_pipe();
57debugger_command_pipe_segment* get_current_debugger_command_pipe_segment();
58
59debugger_command* get_debugger_commands();
60void sort_debugger_commands();
61
62#ifdef __cplusplus
63}	// extern "C"
64#endif
65
66
67#endif	// _KERNEL_DEBUG_COMMANDS_H
68