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
|
/***************************************************************************
begin : Tue May 13 2003
copyright : (C) 2003 by John Birch
email : jbb@kdevelop.org
Adapted for ruby debugging
--------------------------
begin : Mon Nov 1 2004
copyright : (C) 2004 by Richard Dale
email : Richard_Dale@tipitina.demon.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "breakpoint.h"
#include <klocale.h>
#include <tqfileinfo.h>
#include <tqfontmetrics.h>
#include <tqpainter.h>
#include <tqregexp.h>
#include <tqstring.h>
#include <stdio.h>
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
namespace RDBDebugger
{
static int BPKey_ = 0;
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
Breakpoint::Breakpoint(bool temporary, bool enabled)
: s_pending_(true),
s_actionAdd_(true),
s_actionClear_(false),
s_actionModify_(false),
s_actionDie_(false),
s_dbgProcessing_(false),
s_enabled_(enabled),
s_temporary_(temporary),
s_changedEnable_(false),
key_(BPKey_++),
active_(-1)
{
}
/***************************************************************************/
Breakpoint::~Breakpoint()
{
}
/***************************************************************************/
TQString Breakpoint::dbgRemoveCommand() const
{
// if (dbgId_>0)
// return TQString("delete %1").arg(dbgId_); // gdb command - not translatable
return TQString();
}
/***************************************************************************/
// called when debugger ends
void Breakpoint::reset()
{
dbgId_ = -1;
s_pending_ = true;
s_actionAdd_ = true; // waiting for the debugger to start
s_actionClear_ = false;
s_changedEnable_ = !s_enabled_;
s_actionModify_ = s_changedEnable_;
s_dbgProcessing_ = false;
// hits_ = 0;
active_ = -1;
}
/***************************************************************************/
void Breakpoint::setActive(int active, int id)
{
active_ = active;
dbgId_ = id;
if (s_pending_ && !(s_actionAdd_ && s_actionModify_)) {
s_pending_ = false;
s_actionModify_ = false;
}
s_actionAdd_ = false;
s_actionClear_ = false;
s_actionDie_ = false;
s_dbgProcessing_ = false;
if (!s_actionModify_) {
s_changedEnable_ = false;
}
}
/***************************************************************************/
TQString Breakpoint::statusDisplay(int activeFlag) const
{
TQString status="";
if (!s_enabled_)
status = i18n("Disabled");
else
if (s_pending_)
{
if (s_actionAdd_)
status = i18n("Pending (add)");
if (s_actionClear_)
status = i18n("Pending (clear)");
if (s_actionModify_)
status = i18n("Pending (modify)");
}
else
if (isActive(activeFlag))
status = i18n("Active");
return status;
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
FilePosBreakpoint::FilePosBreakpoint(const TQString &fileName, int lineNum,
bool temporary, bool enabled)
: Breakpoint(temporary, enabled),
fileName_(fileName),
lineNo_(lineNum)
{
}
/***************************************************************************/
FilePosBreakpoint::~FilePosBreakpoint()
{
}
/***************************************************************************/
TQString FilePosBreakpoint::dbgSetCommand() const
{
TQString cmdStr;
if (fileName_.isEmpty())
cmdStr = TQString("break %1").arg(lineNo_); // gdb command - not translatable
else {
cmdStr = TQString("break %1:%2").arg(fileName_).arg(lineNo_);
}
if (isTemporary())
cmdStr = "t"+cmdStr; // gdb command
return cmdStr;
}
/***************************************************************************/
bool FilePosBreakpoint::match(const Breakpoint *brkpt) const
{
// simple case
if (this == brkpt)
return true;
// Type case
const FilePosBreakpoint* check = dynamic_cast<const FilePosBreakpoint*>(brkpt);
if (!check)
return false;
// member case
return ( (fileName_ == check->fileName_) &&
(lineNo_ == check->lineNo_));
}
/***************************************************************************/
TQString FilePosBreakpoint::location(bool compact)
{
if (compact)
return TQFileInfo(fileName_).fileName()+":"+TQString::number(lineNo_);
return fileName_+":"+TQString::number(lineNo_);
}
/***************************************************************************/
void FilePosBreakpoint::setLocation(const TQString& location)
{
TQRegExp regExp1("(.*):(\\d+)$");
regExp1.setMinimal(true);
if ( regExp1.search(location, 0) >= 0 )
{
TQString t = regExp1.cap(1);
TQString dirPath = TQFileInfo(t).dirPath();
if ( dirPath == "." )
fileName_ = TQFileInfo(fileName_).dirPath()+"/"+regExp1.cap(1);
else
fileName_ = regExp1.cap(1);
lineNo_ = regExp1.cap(2).toInt();
}
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
Watchpoint::Watchpoint(const TQString& varName, bool temporary, bool enabled)
: Breakpoint(temporary, enabled),
varName_(varName)
{
}
/***************************************************************************/
Watchpoint::~Watchpoint()
{
}
/***************************************************************************/
TQString Watchpoint::dbgSetCommand() const
{
return TQString("watch ")+varName_; // gdb command - not translatable
}
/***************************************************************************/
bool Watchpoint::match(const Breakpoint* brkpt) const
{
// simple case
if (this == brkpt)
return true;
// Type case
const Watchpoint *watch = dynamic_cast<const Watchpoint*>(brkpt);
if (watch == 0)
return false;
// member case
return (varName_ == watch->varName_);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
Catchpoint::Catchpoint(const TQString& varName, bool temporary, bool enabled)
: Breakpoint(temporary, enabled),
varName_(varName)
{
}
/***************************************************************************/
Catchpoint::~Catchpoint()
{
}
/***************************************************************************/
TQString Catchpoint::dbgSetCommand() const
{
return TQString("catch ")+varName_; // gdb command - not translatable
}
/***************************************************************************/
bool Catchpoint::match(const Breakpoint* brkpt) const
{
// simple case
if (this == brkpt)
return true;
// Type case
const Catchpoint *check = dynamic_cast<const Catchpoint*>(brkpt);
if (check == 0)
return false;
// member case
return (varName_ == check->varName_);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
FunctionBreakpoint::FunctionBreakpoint(const TQString& functionName, bool temporary, bool enabled)
: Breakpoint(temporary, enabled),
m_functionName(functionName)
{
}
/***************************************************************************/
FunctionBreakpoint::~FunctionBreakpoint()
{
}
/***************************************************************************/
TQString FunctionBreakpoint::dbgSetCommand() const
{
return TQString("break ")+m_functionName; // gdb command - not translatable
}
/***************************************************************************/
bool FunctionBreakpoint::match(const Breakpoint* brkpt) const
{
// simple case
if (this == brkpt)
return true;
// Type case
const FunctionBreakpoint *check = dynamic_cast<const FunctionBreakpoint*>(brkpt);
if (!check)
return false;
// member case
return (m_functionName == check->m_functionName);
}
}
|