-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaltdebug.c
150 lines (137 loc) · 3.48 KB
/
altdebug.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
/***************************************************************************
*
* Copyright (c) 1997, 1998 Timpanogas Research Group, Inc. All Rights
* Reserved.
*
* AUTHOR : Jeff V. Merkey
* FILE : ALTDEBUG.C
* DESCRIP : Alternate Debugger Interface for MANOS v1.0
* DATE : July 27, 1998
*
*
***************************************************************************/
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "string.h"
#include "kernel.h"
#include "keyboard.h"
#include "screen.h"
#include "types.h"
#include "emit.h"
#include "os.h"
#include "dos.h"
#include "tss.h"
#include "mps.h"
#include "hal.h"
#include "xcall.h"
#include "window.h"
#include "line.h"
#include "loader.h"
#include "menu.h"
#include "rlock.h"
#include "event.h"
#include "altdebug.h"
LONG altDebugLock = 0;
ALT_DEBUGGER *altDebugHead = 0;
ALT_DEBUGGER *altDebugTail = 0;
LONG AlternateDebuggerRoutine(SCREEN *screen, StackFrame *stackFrame,
LONG Exception, LONG processor)
{
register ALT_DEBUGGER *altDebug;
register LONG flags, retCode;
flags = get_flags();
spin_lock(&altDebugLock);
altDebug = altDebugHead;
while (altDebug)
{
if (altDebug->AlternateDebugger)
{
retCode = (altDebug->AlternateDebugger)(screen, stackFrame, Exception, processor);
if (retCode)
{
spin_unlock(&altDebugLock);
set_flags(flags);
return retCode;
}
}
altDebug = altDebug->altDebugNext;
}
spin_unlock(&altDebugLock);
set_flags(flags);
return 0;
}
LONG AddAlternateDebugger(ALT_DEBUGGER *Debugger)
{
register ALT_DEBUGGER *altDebug;
register LONG flags;
flags = get_flags();
spin_lock(&altDebugLock);
altDebug = altDebugHead;
while (altDebug)
{
if (altDebug == Debugger)
{
spin_unlock(&altDebugLock); // already exists
set_flags(flags);
return 1;
}
altDebug = altDebug->altDebugNext;
}
if (!altDebugHead)
{
altDebugHead = Debugger;
altDebugTail = Debugger;
Debugger->altDebugNext = 0;
Debugger->altDebugPrior = 0;
}
else
{
altDebugTail->altDebugNext = Debugger;
Debugger->altDebugNext = 0;
Debugger->altDebugPrior = altDebugTail;
altDebugTail = Debugger;
}
spin_unlock(&altDebugLock);
set_flags(flags);
return 0;
}
LONG RemoveAlternateDebugger(ALT_DEBUGGER *Debugger)
{
register ALT_DEBUGGER *altDebug;
register LONG flags;
flags = get_flags();
spin_lock(&altDebugLock);
altDebug = altDebugHead;
while (altDebug)
{
if (altDebug == Debugger) // found, remove from list
{
if (altDebugHead == Debugger)
{
altDebugHead = (void *) Debugger->altDebugNext;
if (altDebugHead)
altDebugHead->altDebugPrior = NULL;
else
altDebugTail = NULL;
}
else
{
Debugger->altDebugPrior->altDebugNext = Debugger->altDebugNext;
if (Debugger != altDebugTail)
Debugger->altDebugNext->altDebugPrior = Debugger->altDebugPrior;
else
altDebugTail = Debugger->altDebugPrior;
}
Debugger->altDebugNext = Debugger->altDebugPrior = 0;
spin_unlock(&altDebugLock);
set_flags(flags);
return 0;
}
altDebug = altDebug->altDebugNext;
}
spin_unlock(&altDebugLock);
set_flags(flags);
return -1;
}