-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdebugcmd.c
212 lines (197 loc) · 5.41 KB
/
debugcmd.c
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
/***************************************************************************
*
* Copyright (c) 1997, 1998 Timpanogas Research Group, Inc. All Rights
* Reserved.
*
* AUTHOR : Jeff V. Merkey
* FILE : DEBUGCMD.C
* DESCRIP : Installable Debugger Command Parser for MANOS v1.0
* DATE : July 27, 1998
*
*
***************************************************************************/
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "string.h"
#include "keyboard.h"
#include "screen.h"
#include "types.h"
#include "emit.h"
#include "os.h"
#include "dos.h"
#include "tss.h"
#include "kernel.h"
#include "mps.h"
#include "hal.h"
#include "xcall.h"
#include "window.h"
#include "source.h"
#include "loader.h"
#include "menu.h"
#include "rlock.h"
#include "event.h"
#include "debugcmd.h"
LONG debugParserLock = 0;
DEBUGGER_PARSER *debugParserHead = 0;
DEBUGGER_PARSER *debugParserTail = 0;
LONG DebugParserRoutine(SCREEN *screen,
BYTE *command,
BYTE *commandLine,
StackFrame *stackFrame,
LONG Exception)
{
register DEBUGGER_PARSER *debugParser;
register LONG flags, retCode;
flags = get_flags();
spin_lock(&debugParserLock);
debugParser = debugParserHead;
while (debugParser)
{
if (debugParser->parserFlags &&
debugParser->DebugCommandParser &&
strlen(debugParser->debugCommandName) == strlen(command) &&
!stricmp(debugParser->debugCommandName, command))
{
retCode = (debugParser->DebugCommandParser)(screen,
commandLine,
stackFrame,
Exception,
debugParser);
if (retCode)
{
spin_unlock(&debugParserLock);
set_flags(flags);
return 1;
}
cli();
}
debugParser = debugParser->debugNext;
}
spin_unlock(&debugParserLock);
set_flags(flags);
return 0;
}
LONG DebugParserHelpRoutine(SCREEN *screen,
BYTE *command,
BYTE *commandLine,
StackFrame *stackFrame,
LONG Exception)
{
register DEBUGGER_PARSER *debugParser;
register LONG flags, retCode;
SetPauseMode(screen, screen->nLines - 2);
debugParser = debugParserHead;
if (*command)
{
while (debugParser)
{
if (debugParser->parserFlags &&
strlen(debugParser->debugCommandName) == strlen(command) &&
!stricmp(debugParser->debugCommandName, command))
{
if (debugParser->DebugCommandParserHelp)
{
printfScreen(screen, "\nHelp for Command %s\n", debugParser->debugCommandName);
(debugParser->DebugCommandParserHelp)(screen, commandLine, stackFrame,
Exception, debugParser);
}
printfScreen(screen, "\nHelp for Command %s\n", debugParser->debugCommandName);
return 1;
}
debugParser = debugParser->debugNext;
}
printfScreen(screen, "\nHelp for Command [%s] not found\n", strupr(command));
return 1;
}
else
{
while (debugParser)
{
if (debugParser->parserFlags && debugParser->debugCommandName &&
!debugParser->supervisorCommand)
printfScreen(screen, "\n%15s - %s",
debugParser->debugCommandName, debugParser->shortHelp);
debugParser = debugParser->debugNext;
}
}
ClearPauseMode(screen);
return 0;
}
LONG AddDebuggerCommandParser(DEBUGGER_PARSER *parser)
{
register DEBUGGER_PARSER *debugParser;
register LONG flags;
flags = get_flags();
spin_lock(&debugParserLock);
debugParser = debugParserHead;
while (debugParser)
{
if (debugParser == parser ||
(strlen(parser->debugCommandName) == strlen(debugParser->debugCommandName) &&
(!stricmp(parser->debugCommandName, debugParser->debugCommandName))))
{
spin_unlock(&debugParserLock); // already exists
set_flags(flags);
return 1;
}
debugParser = debugParser->debugNext;
}
if (!debugParserHead)
{
debugParserHead = parser;
debugParserTail = parser;
parser->debugNext = 0;
parser->debugPrior = 0;
}
else
{
debugParserTail->debugNext = parser;
parser->debugNext = 0;
parser->debugPrior = debugParserTail;
debugParserTail = parser;
}
spin_unlock(&debugParserLock);
set_flags(flags);
return 0;
}
LONG RemoveDebuggerCommandParser(DEBUGGER_PARSER *parser)
{
register DEBUGGER_PARSER *debugParser;
register LONG flags;
flags = get_flags();
spin_lock(&debugParserLock);
debugParser = debugParserHead;
while (debugParser)
{
if (debugParser == parser) // found, remove from list
{
if (debugParserHead == parser)
{
debugParserHead = (void *) parser->debugNext;
if (debugParserHead)
debugParserHead->debugPrior = NULL;
else
debugParserTail = NULL;
}
else
{
parser->debugPrior->debugNext = parser->debugNext;
if (parser != debugParserTail)
parser->debugNext->debugPrior = parser->debugPrior;
else
debugParserTail = parser->debugPrior;
}
parser->debugNext = parser->debugPrior = 0;
parser->parserFlags = 0;
spin_unlock(&debugParserLock);
set_flags(flags);
return 0;
}
debugParser = debugParser->debugNext;
}
spin_unlock(&debugParserLock);
set_flags(flags);
return -1;
}