38
40
void Breakpoints::setBreakpoints(const QString& str)
40
43
QStringList bps = str.split('\n');
43
44
for (QStringList::Iterator it = bps.begin(); it != bps.end(); ++it) {
46
newBp.type = BREAKPOINT;
45
47
int p = it->indexOf(' ');
46
48
newBp.id = it->left(p).trimmed();
47
if(newBp.id.isEmpty()) break;
48
int q = it->indexOf(' ', p+1);
49
if (newBp.id.isEmpty()) break;
50
int q = it->indexOf(' ', p + 1);
50
newBp.address = it->mid(p).toUShort(0,0);
52
newBp.address = it->mid(p).toUShort(0, 0);
52
newBp.address = it->mid(p, q-p).trimmed().toUShort(0,0);
54
newBp.address = it->mid(p, q - p).trimmed().toUShort(0, 0);
53
55
newBp.condition = it->mid(q).trimmed();
57
newBp.regionEnd = newBp.address;
55
58
parseCondition(newBp);
56
59
insertBreakpoint(newBp);
63
QString Breakpoints::mergeBreakpoints(const QString& str)
66
BreakpointList oldBps(breakpoints);
69
// check old list against new one
71
while (!oldBps.empty()) {
72
Breakpoint& old = oldBps.first();
73
BreakpointList::iterator newit = breakpoints.begin();
74
for (/**/; newit != breakpoints.end(); ++newit) {
75
// check for identical location
76
// TODO [wouter]: why is condition not compared?
77
// maybe better use some sort of find algorithm?
78
// and use BreakPoint::operator==()
79
if (old.type == newit->type &&
80
old.address == newit->address &&
81
old.regionEnd == newit->regionEnd &&
82
old.ps == newit->ps &&
83
old.ss == newit->ss &&
84
old.segment == newit->segment) {
88
if (newit == breakpoints.end()) {
89
// create command to set this breakpoint again
91
cmd.sprintf("debug set_bp %i { [ pc_in_slot %c %c %i ] }",
92
old.address, old.ps, old.ss, old.segment);
97
return mergeSet.join(" ; ");
60
100
static QString getNextArgument(QString& data, int& pos)
63
while (data[pos] == ' ' || data[pos]=='\t') ++pos;
103
while (data[pos] == ' ' || data[pos] == '\t') ++pos;
65
105
if (data[pos] == ' ' || data[pos] == '\t') break;
66
106
if (data[pos] == '}' || data[pos] == ']') break;
183
223
// will implement findfirst/findnext scheme for speed
228
void Breakpoints::saveBreakpoints(QXmlStreamWriter& xml)
231
for (BreakpointList::iterator it = breakpoints.begin();
232
it != breakpoints.end(); ++it) {
233
xml.writeStartElement("Breakpoint");
238
xml.writeAttribute("type", "breakpoint");
240
case WATCHPOINT_IOREAD:
241
xml.writeAttribute("type", "ioread");
243
case WATCHPOINT_IOWRITE:
244
xml.writeAttribute("type", "iowrite");
246
case WATCHPOINT_MEMREAD:
247
xml.writeAttribute("type", "memread");
249
case WATCHPOINT_MEMWRITE:
250
xml.writeAttribute("type", "memwrite");
255
xml.writeAttribute("id", it->id);
258
xml.writeAttribute("primarySlot", QString(it->ps));
259
xml.writeAttribute("secondarySlot", QString(it->ss));
260
xml.writeAttribute("segment", QString::number(it->segment));
263
if (it->type == BREAKPOINT) {
264
xml.writeTextElement("address", QString::number(it->address));
266
xml.writeTextElement("regionStart", QString::number(it->address));
267
xml.writeTextElement("regionEnd", QString::number(it->regionEnd));
270
// condition not supported yet
273
xml.writeEndElement();
277
void Breakpoints::loadBreakpoints(QXmlStreamReader& xml)
280
while (!xml.atEnd()) {
282
// exit if closing of main tag
283
if (xml.isEndElement()) {
284
if (xml.name() == "Breakpoints") {
286
} else if (xml.name() == "Breakpoint") {
287
insertBreakpoint(bp);
291
if (xml.isStartElement()) {
292
if (xml.name() == "Breakpoint") {
294
QString type = xml.attributes().value("type").toString().toLower();
295
if (type == "ioread") {
296
bp.type = WATCHPOINT_IOREAD;
297
} else if (type == "iowrite") {
298
bp.type = WATCHPOINT_IOWRITE;
299
} else if (type == "memread") {
300
bp.type = WATCHPOINT_MEMREAD;
301
} else if (type == "memwrite") {
302
bp.type = WATCHPOINT_MEMWRITE;
304
bp.type = BREAKPOINT;
308
bp.id = xml.attributes().value("id").toString();
311
bp.ps = xml.attributes().value("primarySlot").at(0).toAscii();
312
bp.ss = xml.attributes().value("secondarySlot").at(0).toAscii();
313
bp.segment = xml.attributes().value("segment").toString().toInt();
315
} else if (xml.name() == "address" || xml.name() == "regionStart") {
317
bp.address = xml.readElementText().toInt();
318
if (bp.type == BREAKPOINT) bp.regionEnd = bp.address;
320
} else if (xml.name() == "regionEnd") {
322
bp.regionEnd = xml.readElementText().toInt();