summaryrefslogtreecommitdiffstats
path: root/public/sdk/inc/dbgpoint.hxx
blob: 960586ec80c6dccbb3aff50c79a0e772b3dccd78 (plain) (blame)
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358

//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1992.
//
//  File:       dbgpoint.hxx
//
//  Contents:   Support for visual debug values
//
//  Classes:    CDebugBaseClass
//              CDebugBreakPoint
//              CDebugValue
//
//  Functions:
//
//  History:    12-Mar-93  KevinRo  Created
//
//  This module handles debug values, such as breakpoints and settable
//  values. By using this module, the values can be examined and changed
//  in a debugging window. The debugging window uses its own thread, so
//  changes can be effected asynchronously.
//
//--------------------------------------------------------------------------


#ifndef     __DBGPOINT_HXX__
#define     __DBGPOINT_HXX__

#if defined(__cplusplus)

enum DebugValueType
{
    dvtBreakPoint,
    dvtInfoLevel,
    dvtValue
};

class CDebugBaseClass;

//
// The following routines are exported from commnot.dll
//

extern "C"
EXPORTDEF
void APINOT dbgRegisterGroup(WCHAR const *pwzName,HANDLE *hGroup);

extern "C"
EXPORTDEF
void APINOT dbgRemoveGroup(HANDLE hGroup);

extern "C"
EXPORTDEF
void APINOT dbgRegisterValue(WCHAR const *pwzName,HANDLE hGroup,CDebugBaseClass *pdv);

extern "C"
EXPORTDEF
void APINOT dbgRemoveValue(HANDLE hGroup,CDebugBaseClass *pdv);

extern "C"
EXPORTDEF
void APINOT dbgNotifyChange(HANDLE hGroup,CDebugBaseClass *pdv);

extern "C"
EXPORTDEF
ULONG APINOT dbgGetIniInfoLevel(WCHAR const *pwzName,ULONG ulDefault);

extern "C"
EXPORTDEF
ULONG APINOT dbgBreakDialog(char const *pszFileName,ULONG ulLineNumber,WCHAR const *pwzName,long ulCode);

// The following values may be returned by dbgBreakDialog

#define CDBG_BREAKPOINT_CONTINUE  0x01
#define CDBG_BREAKPOINT_BREAK     0x02
#define CDBG_BREAKPOINT_DISABLE   0x04

//
// The following group is for the Infolevel Group. The group is automatically
// registered when a value is added to it.
//

#define HANDLE_INFOLEVELGROUP    ((HANDLE)-1)


//+-------------------------------------------------------------------------
//
//  Class:      CDebugBaseClass
//
//  Purpose:    Defines a base class used by visual debug value system
//
//  Interface:
//
//  History:    12-Mar-93  KevinRo  Created
//
//  Notes:
//
//--------------------------------------------------------------------------

class CDebugBaseClass
{
public:
    CDebugBaseClass(WCHAR const *pwzValueName,
                HANDLE hGroupHandle,
                DebugValueType dvtType):
    _dvtType(dvtType),
    _hGroupHandle(hGroupHandle)
    {
    }

    void Register(WCHAR const *pwzValueName)
    {
        dbgRegisterValue(pwzValueName,_hGroupHandle,this);
    }


virtual ~CDebugBaseClass()
    {
        dbgRemoveValue(_hGroupHandle,this);
    }

virtual void NotifyChange()
    {
        dbgNotifyChange(_hGroupHandle,this);
    }

DebugValueType  GetValueType() {return _dvtType;}
HANDLE          GetGroupHandle() { return _hGroupHandle;}

private:
    HANDLE          _hGroupHandle;
    DebugValueType  _dvtType;
};



//+-------------------------------------------------------------------------
//
//  Class:      CDebugBreakPoint
//
//  Purpose:    Defines an externally switchable break point. By using the
//              visual debug window, you can set or clear this breakpoint
//              while a program runs.
//
//  Interface:
//
//  History:    12-Mar-93 KevinRo   Created
//
//  Notes:
//
//--------------------------------------------------------------------------


class CDebugBreakPoint : public CDebugBaseClass
{
public:
    CDebugBreakPoint(WCHAR const *pwzName,HANDLE hGroup,ULONG fBreakSet):
        _fBreakSet(fBreakSet),
        _pwzName(pwzName),
        CDebugBaseClass(pwzName,hGroup,dvtBreakPoint)
    {

        Register(pwzName);
    }
    ~CDebugBreakPoint()
    {
    }

    void ToggleBreakPoint()
    {
        _fBreakSet = !_fBreakSet;
        NotifyChange();
    }

    ULONG GetBreakPoint()
    {
        return(_fBreakSet);
    }

    ULONG SetBreakPoint()
    {
        register ret = _fBreakSet;
        _fBreakSet = TRUE;
        NotifyChange();
        return(ret);
    }

    ULONG ClearBreakPoint()
    {
        register ret = _fBreakSet;
        _fBreakSet = FALSE;
        NotifyChange();
        return(ret);
    }

inline    BOOL    BreakPointTest()
    {
        return _fBreakSet;
    }

inline  BOOL BreakPointMessage(char *pszFileName,ULONG ulLineNo,long lCode=0)
    {
        ULONG rc = dbgBreakDialog(pszFileName,ulLineNo,_pwzName,lCode);

        if(rc & CDBG_BREAKPOINT_DISABLE) ClearBreakPoint();

        return(rc & CDBG_BREAKPOINT_BREAK);
    }

public:
    WCHAR const * _pwzName;
    BOOL    _fBreakSet;

};



//+-------------------------------------------------------------------------
//
//  Class:      CDebugValue
//
//  Purpose:    A DebugValue makes a ULONG value visible and settable
//              from the debugging window. By accepting a ULONG reference,
//              it is possible to expose a ULONG value to the debugging
//              window.
//
//  Interface:
//
//  History:    12-Mar-93 KevinRo   Created
//
//  Notes:
//
//--------------------------------------------------------------------------

class CDebugValue : public CDebugBaseClass
{
public:
    CDebugValue(WCHAR const *pwzName,HANDLE hGroup,ULONG & ulValue):
        _ulValue(ulValue),
        CDebugBaseClass(pwzName,hGroup,dvtValue)
    {
        Register(pwzName);
    }

    ~CDebugValue()
    {
    }

    ULONG GetValue()
    {
        return(_ulValue);
    }

    ULONG SetValue(ULONG ulValue)
    {
        register ret = _ulValue;

        _ulValue = ulValue;
        NotifyChange();
        return(ret);
    }

private:

    ULONG  & _ulValue;

};


//+-------------------------------------------------------------------------
//
//  Class:      CInfoLevel
//
//  Purpose:    A CInfoLevel makes an InfoLevel value accessable by the
//              debugging window.
//
//  Interface:
//
//  History:    12-Mar-93 KevinRo   Created
//
//  Notes:
//
//--------------------------------------------------------------------------




class CInfoLevel : public CDebugBaseClass
{
public:
    CInfoLevel(WCHAR const *pwzName,ULONG & ulValue,ULONG deflvl = DEF_INFOLEVEL):
        _ulInfoLevel(ulValue),
        CDebugBaseClass(pwzName,HANDLE_INFOLEVELGROUP,dvtInfoLevel)
    {
        _ulInfoLevel = dbgGetIniInfoLevel(pwzName,deflvl);

        Register(pwzName);
    }

    ~CInfoLevel()
    {
    }

    ULONG GetInfoLevel()
    {
        return(_ulInfoLevel);
    }

    ULONG SetInfoLevel(ULONG ulValue)
    {
        register ret = _ulInfoLevel;

        _ulInfoLevel = ulValue;
        NotifyChange();
        return(ret);
    }

private:

    ULONG  & _ulInfoLevel;

};

//+-------------------------------------------------------------------------
//
//  Class:      CDebugGroupClass
//
//  Purpose:    Encapsulates a Debug Group
//
//  Notes:
//
//--------------------------------------------------------------------------


class CDebugGroupClass
{
public:
   CDebugGroupClass(WCHAR *pwzName)
   {
       dbgRegisterGroup(pwzName,&_hGroup);
   }

   ~CDebugGroupClass()
   {
       dbgRemoveGroup(_hGroup);
   }

   operator HANDLE() { return(_hGroup); }

private:
   HANDLE   _hGroup;
};


#endif  // defined(__cplusplus)
#endif  //     __DBGPOINT_HXX__