watchdata.cpp 21.1 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Tobias Hunger's avatar
Tobias Hunger committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
Tobias Hunger's avatar
Tobias Hunger committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Tobias Hunger's avatar
Tobias Hunger committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Tobias Hunger's avatar
Tobias Hunger committed
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
Tobias Hunger's avatar
Tobias Hunger committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
Tobias Hunger's avatar
Tobias Hunger committed
29

30
31
32
// NOTE: Don't add dependencies to other files.
// This is used in the debugger auto-tests.

33
#include "watchdata.h"
34
#include "watchutils.h"
35
#include "debuggerprotocol.h"
36

37
#include <QTextDocument> // Qt::escape() in Qt 4
38
#include <QDebug>
39
40
41
42
43
44
45
46
47
48

////////////////////////////////////////////////////////////////////
//
// WatchData
//
////////////////////////////////////////////////////////////////////

namespace Debugger {
namespace Internal {

Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
bool isPointerType(const QByteArray &type)
{
    return type.endsWith('*') || type.endsWith("* const");
}

bool isCharPointerType(const QByteArray &type)
{
    return type == "char *" || type == "const char *" || type == "char const *";
}

bool isIntType(const QByteArray &type)
{
    if (type.isEmpty())
        return false;
    switch (type.at(0)) {
        case 'b':
            return type == "bool";
        case 'c':
            return type == "char";
        case 'i':
69
            return type == "int";
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
70
71
        case 'l':
            return type == "long"
72
73
                || type == "long int"
                || type == "long unsigned int";
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
74
75
76
77
78
        case 'p':
            return type == "ptrdiff_t";
        case 'q':
            return type == "qint16" || type == "quint16"
                || type == "qint32" || type == "quint32"
79
80
                || type == "qint64" || type == "quint64"
                || type == "qlonglong" || type == "qulonglong";
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
81
82
83
84
85
86
        case 's':
            return type == "short"
                || type == "signed"
                || type == "size_t"
                || type == "std::size_t"
                || type == "std::ptrdiff_t"
87
88
89
90
91
92
93
94
                || (type.startsWith("signed") &&
                    (  type == "signed char"
                    || type == "signed short"
                    || type == "signed short int"
                    || type == "signed long"
                    || type == "signed long int"
                    || type == "signed long long"
                    || type == "signed long long int"));
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
95
96
        case 'u':
            return type == "unsigned"
97
98
99
100
                || (type.startsWith("unsigned") &&
                    (  type == "unsigned char"
                    || type == "unsigned short"
                    || type == "unsigned short int"
101
                    || type == "unsigned int"
102
103
104
105
                    || type == "unsigned long"
                    || type == "unsigned long int"
                    || type == "unsigned long long"
                    || type == "unsigned long long int"));
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
106
107
108
109
110
111
112
        default:
            return false;
    }
}

bool isFloatType(const QByteArray &type)
{
Orgad Shaneh's avatar
Orgad Shaneh committed
113
    return type == "float" || type == "double" || type == "qreal";
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
114
115
116
117
118
119
120
}

bool isIntOrFloatType(const QByteArray &type)
{
    return isIntType(type) || isFloatType(type);
}

121
WatchData::WatchData() :
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
122
123
    id(0),
    state(InitialState),
124
    editformat(0),
125
    address(0),
126
    origaddr(0),
127
    size(0),
128
129
    bitpos(0),
    bitsize(0),
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
130
    hasChildren(false),
131
132
133
    valueEnabled(true),
    valueEditable(true),
    error(false),
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
134
135
    sortId(0),
    source(0)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
}

bool WatchData::isEqual(const WatchData &other) const
{
    return iname == other.iname
      && exp == other.exp
      && name == other.name
      && value == other.value
      && editvalue == other.editvalue
      && valuetooltip == other.valuetooltip
      && type == other.type
      && displayedType == other.displayedType
      && variable == other.variable
150
      && address == other.address
151
      && size == other.size
152
153
154
155
156
157
      && hasChildren == other.hasChildren
      && valueEnabled == other.valueEnabled
      && valueEditable == other.valueEditable
      && error == other.error;
}

158
159
160
161
162
163
164
165
bool WatchData::isVTablePointer() const
{
    // First case: Cdb only. No user type can be named like this, this is safe.
    // Second case: Python dumper only.
    return type.startsWith("__fptr()")
        || (type.isEmpty() && name == QLatin1String("[vptr]"));
}

166
167
168
169
170
171
172
173
174
175
176
177
178
void WatchData::setError(const QString &msg)
{
    setAllUnneeded();
    value = msg;
    setHasChildren(false);
    valueEnabled = false;
    valueEditable = false;
    error = true;
}

void WatchData::setValue(const QString &value0)
{
    value = value0;
179
    if (value == QLatin1String("{...}")) {
180
181
182
183
        value.clear();
        hasChildren = true; // at least one...
    }
    // strip off quoted characters for chars.
184
    if (value.endsWith(QLatin1Char('\'')) && type.endsWith("char")) {
185
186
187
188
189
190
        const int blankPos = value.indexOf(QLatin1Char(' '));
        if (blankPos != -1)
            value.truncate(blankPos);
    }

    // avoid duplicated information
191
192
    if (value.startsWith(QLatin1Char('(')) && value.contains(QLatin1String(") 0x")))
        value.remove(0, value.lastIndexOf(QLatin1String(") 0x")) + 2);
193
194
195

    // doubles are sometimes displayed as "@0x6141378: 1.2".
    // I don't want that.
196
197
198
    if (/*isIntOrFloatType(type) && */ value.startsWith(QLatin1String("@0x"))
         && value.contains(QLatin1Char(':'))) {
        value.remove(0, value.indexOf(QLatin1Char(':')) + 2);
199
200
201
202
203
204
        setHasChildren(false);
    }

    // "numchild" is sometimes lying
    //MODEL_DEBUG("\n\n\nPOINTER: " << type << value);
    if (isPointerType(type))
205
        setHasChildren(value != QLatin1String("0x0") && value != QLatin1String("<null>")
206
207
208
209
            && !isCharPointerType(type));

    // pointer type information is available in the 'type'
    // column. No need to duplicate it here.
210
    if (value.startsWith(QLatin1Char('(') + QLatin1String(type) + QLatin1String(") 0x")))
211
212
213
214
215
        value = value.section(QLatin1Char(' '), -1, -1);

    setValueUnneeded();
}

hjk's avatar
hjk committed
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren };

static GuessChildrenResult guessChildren(const QByteArray &type)
{
    if (isIntOrFloatType(type))
        return HasNoChildren;
    if (isCharPointerType(type))
        return HasNoChildren;
    if (isPointerType(type))
        return HasChildren;
    if (type.endsWith("QString"))
        return HasNoChildren;
    return HasPossiblyChildren;
}

231
void WatchData::setType(const QByteArray &str, bool guessChildrenFromType)
232
233
234
235
{
    type = str.trimmed();
    bool changed = true;
    while (changed) {
236
        if (type.endsWith("const"))
237
            type.chop(5);
238
        else if (type.endsWith(' '))
239
            type.chop(1);
240
        else if (type.startsWith("const "))
241
            type = type.mid(6);
242
        else if (type.startsWith("volatile "))
243
            type = type.mid(9);
244
        else if (type.startsWith("class "))
245
            type = type.mid(6);
246
        else if (type.startsWith("struct "))
247
            type = type.mid(6);
248
        else if (type.startsWith(' '))
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
            type = type.mid(1);
        else
            changed = false;
    }
    setTypeUnneeded();
    if (guessChildrenFromType) {
        switch (guessChildren(type)) {
        case HasChildren:
            setHasChildren(true);
            break;
        case HasNoChildren:
            setHasChildren(false);
            break;
        case HasPossiblyChildren:
            setHasChildren(true); // FIXME: bold assumption
            break;
        }
    }
}

269
270
271
void WatchData::setHexAddress(const QByteArray &a)
{
    bool ok;
272
    const qint64 av = a.toULongLong(&ok, 0);
273
274
275
276
277
278
279
    if (ok) {
        address = av;
    } else {
        qWarning("WatchData::setHexAddress(): Failed to parse address value '%s' for '%s', '%s'",
                 a.constData(), iname.constData(), type.constData());
        address = 0;
    }
280
281
282
283
284
285
286
287
288
289
}

QString WatchData::toString() const
{
    const char *doubleQuoteComma = "\",";
    QString res;
    QTextStream str(&res);
    str << QLatin1Char('{');
    if (!iname.isEmpty())
        str << "iname=\"" << iname << doubleQuoteComma;
290
    str << "sortId=\"" << sortId << doubleQuoteComma;
291
    if (!name.isEmpty() && name != QLatin1String(iname))
292
293
294
        str << "name=\"" << name << doubleQuoteComma;
    if (error)
        str << "error,";
295
296
297
298
299
    if (address) {
        str.setIntegerBase(16);
        str << "addr=\"0x" << address << doubleQuoteComma;
        str.setIntegerBase(10);
    }
300
    if (origaddr) {
301
        str.setIntegerBase(16);
302
        str << "referencingaddr=\"0x" << origaddr << doubleQuoteComma;
303
304
        str.setIntegerBase(10);
    }
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
    if (!exp.isEmpty())
        str << "exp=\"" << exp << doubleQuoteComma;

    if (!variable.isEmpty())
        str << "variable=\"" << variable << doubleQuoteComma;

    if (isValueNeeded())
        str << "value=<needed>,";
    if (isValueKnown() && !value.isEmpty())
        str << "value=\"" << value << doubleQuoteComma;

    if (!editvalue.isEmpty())
        str << "editvalue=\"<...>\",";
    //    str << "editvalue=\"" << editvalue << doubleQuoteComma;

320
321
322
    if (!dumperFlags.isEmpty())
        str << "dumperFlags=\"" << dumperFlags << doubleQuoteComma;

323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
    if (isTypeNeeded())
        str << "type=<needed>,";
    if (isTypeKnown() && !type.isEmpty())
        str << "type=\"" << type << doubleQuoteComma;

    if (isHasChildrenNeeded())
        str << "hasChildren=<needed>,";
    if (isHasChildrenKnown())
        str << "hasChildren=\"" << (hasChildren ? "true" : "false") << doubleQuoteComma;

    if (isChildrenNeeded())
        str << "children=<needed>,";
    str.flush();
    if (res.endsWith(QLatin1Char(',')))
        res.truncate(res.size() - 1);
    return res + QLatin1Char('}');
}

// Format a tooltip fow with aligned colon.
static void formatToolTipRow(QTextStream &str,
    const QString &category, const QString &value)
{
345
346
    QString val = Qt::escape(value);
    val.replace(QLatin1Char('\n'), QLatin1String("<br>"));
347
    str << "<tr><td>" << category << "</td><td> : </td><td>"
348
        << val << "</td></tr>";
349
350
351
352
353
354
355
}

QString WatchData::toToolTip() const
{
    QString res;
    QTextStream str(&res);
    str << "<html><body><table>";
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
356
    formatToolTipRow(str, tr("Name"), name);
357
358
    formatToolTipRow(str, tr("Expression"), QLatin1String(exp));
    formatToolTipRow(str, tr("Internal Type"), QLatin1String(type));
359
360
361
    if (!displayedType.isEmpty())
        formatToolTipRow(str, tr("Displayed Type"), displayedType);
    QString val = valuetooltip.isEmpty() ? value : valuetooltip;
362
363
364
365
366
367
368
    // Automatically display hex value for unsigned integers.
    if (!val.isEmpty() && val.at(0).isDigit() && isIntType(type)) {
        bool ok;
        const quint64 intValue = val.toULongLong(&ok);
        if (ok && intValue)
            val += QLatin1String(" (hex) ") + QString::number(intValue, 16);
    }
369
    if (val.size() > 1000) {
370
        val.truncate(1000);
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
371
        val += tr(" ... <cut off>");
372
    }
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
373
    formatToolTipRow(str, tr("Value"), val);
374
375
376
377
    if (address)
        formatToolTipRow(str, tr("Object Address"), formatToolTipAddress(address));
    if (origaddr)
        formatToolTipRow(str, tr("Pointer Address"), formatToolTipAddress(origaddr));
378
    if (size)
Robert Loehning's avatar
Robert Loehning committed
379
        formatToolTipRow(str, tr("Static Object Size"), tr("%n bytes", 0, size));
380
    formatToolTipRow(str, tr("Internal ID"), QLatin1String(iname));
381
382
383
384
385
386
    str << "</table></body></html>";
    return res;
}

QString WatchData::msgNotInScope()
{
387
388
389
390
    //: Value of variable in Debugger Locals display for variables out
    //: of scope (stopped above initialization).
    static const QString rc =
        QCoreApplication::translate("Debugger::Internal::WatchData", "<not in scope>");
391
392
393
394
395
    return rc;
}

const QString &WatchData::shadowedNameFormat()
{
396
397
398
    //: Display of variables shadowed by variables of the same name
    //: in nested scopes: Variable %1 is the variable name, %2 is a
    //: simple count.
399
400
    static const QString format =
        QCoreApplication::translate("Debugger::Internal::WatchData", "%1 <shadowed %2>");
401
402
403
404
405
406
407
    return format;
}

QString WatchData::shadowedName(const QString &name, int seen)
{
    if (seen <= 0)
        return name;
408
    return shadowedNameFormat().arg(name).arg(seen);
409
410
}

411
412
QByteArray WatchData::hexAddress() const
{
413
414
415
    if (address)
        return QByteArray("0x") + QByteArray::number(address, 16);
    return QByteArray();
416
417
}

418
419
420
421
422
423
424
425
426

////////////////////////////////////////////////////
//
// Protocol convienience
//
////////////////////////////////////////////////////

void WatchData::updateValue(const GdbMi &item)
{
427
    GdbMi value = item["value"];
428
    if (value.isValid()) {
429
        int encoding = item["valueencoded"].toInt();
430
431
432
433
434
435
436
437
438
439
        setValue(decodeData(value.data(), encoding));
    } else {
        setValueNeeded();
    }
}

void setWatchDataValueToolTip(WatchData &data, const GdbMi &mi,
    int encoding)
{
    if (mi.isValid())
440
        data.valuetooltip = decodeData(mi.data(), encoding);
441
442
443
444
445
}

void WatchData::updateChildCount(const GdbMi &mi)
{
    if (mi.isValid())
446
        setHasChildren(mi.toInt() > 0);
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
}

static void setWatchDataValueEnabled(WatchData &data, const GdbMi &mi)
{
    if (mi.data() == "true")
        data.valueEnabled = true;
    else if (mi.data() == "false")
        data.valueEnabled = false;
}

static void setWatchDataValueEditable(WatchData &data, const GdbMi &mi)
{
    if (mi.data() == "true")
        data.valueEditable = true;
    else if (mi.data() == "false")
        data.valueEditable = false;
}

465
static void setWatchDataAddress(WatchData &data, quint64 address)
466
{
467
    data.address = address;
468
469
470
471
472
473
474
475
476
477
478

    if (data.exp.isEmpty() && !data.dumperFlags.startsWith('$')) {
        if (data.iname.startsWith("local.") && data.iname.count('.') == 1)
            // Solve one common case of adding 'class' in
            // *(class X*)0xdeadbeef for gdb.
            data.exp = data.name.toLatin1();
        else
            data.exp = "*(" + gdbQuoteTypes(data.type) + "*)" + data.hexAddress();
    }
}

479
void WatchData::updateAddress(const GdbMi &mi)
480
{
481
    if (!mi.isValid())
482
        return;
483
    const QByteArray addressBA = mi.data();
484
485
486
487
    if (!addressBA.startsWith("0x")) { // Item model dumpers pull tricks.
        dumperFlags = addressBA;
        return;
    }
488
489
    const quint64 address = mi.toAddress();
    setWatchDataAddress(*this, address);
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
}

static void setWatchDataSize(WatchData &data, const GdbMi &mi)
{
    if (mi.isValid()) {
        bool ok = false;
        const unsigned size = mi.data().toUInt(&ok);
        if (ok)
            data.size = size;
    }
}

// Find the "type" and "displayedtype" children of root and set up type.
void WatchData::updateType(const GdbMi &item)
{
    if (item.isValid())
        setType(item.data());
    else if (type.isEmpty())
        setTypeNeeded();
}

void WatchData::updateDisplayedType(const GdbMi &item)
{
    if (item.isValid())
        displayedType = QString::fromLatin1(item.data());
}

// Utilities to decode string data returned by the dumper helpers.


template <class T>
void decodeArrayHelper(QList<WatchData> *list, const WatchData &tmplate,
    const QByteArray &rawData)
{
    const QByteArray ba = QByteArray::fromHex(rawData);
    const T *p = (const T *) ba.data();
    WatchData data;
    const QByteArray exp = "*(" + gdbQuoteTypes(tmplate.type) + "*)0x";
    for (int i = 0, n = ba.size() / sizeof(T); i < n; ++i) {
        data = tmplate;
        data.sortId = i;
        data.iname += QByteArray::number(i);
        data.name = QString::fromLatin1("[%1]").arg(i);
        data.value = QString::number(p[i]);
        data.address += i * sizeof(T);
        data.exp = exp + QByteArray::number(data.address, 16);
        data.setAllUnneeded();
        list->append(data);
    }
}

static void decodeArray(QList<WatchData> *list, const WatchData &tmplate,
    const QByteArray &rawData, int encoding)
{
    switch (encoding) {
        case Hex2EncodedInt1:
            decodeArrayHelper<signed char>(list, tmplate, rawData);
            break;
        case Hex2EncodedInt2:
            decodeArrayHelper<short>(list, tmplate, rawData);
            break;
        case Hex2EncodedInt4:
            decodeArrayHelper<int>(list, tmplate, rawData);
            break;
        case Hex2EncodedInt8:
            decodeArrayHelper<qint64>(list, tmplate, rawData);
            break;
        case Hex2EncodedUInt1:
            decodeArrayHelper<uchar>(list, tmplate, rawData);
            break;
        case Hex2EncodedUInt2:
            decodeArrayHelper<ushort>(list, tmplate, rawData);
            break;
        case Hex2EncodedUInt4:
            decodeArrayHelper<uint>(list, tmplate, rawData);
            break;
        case Hex2EncodedUInt8:
            decodeArrayHelper<quint64>(list, tmplate, rawData);
            break;
        case Hex2EncodedFloat4:
            decodeArrayHelper<float>(list, tmplate, rawData);
            break;
        case Hex2EncodedFloat8:
            decodeArrayHelper<double>(list, tmplate, rawData);
            break;
        default:
            qDebug() << "ENCODING ERROR: " << encoding;
    }
}

void parseWatchData(const QSet<QByteArray> &expandedINames,
    const WatchData &data0, const GdbMi &item,
    QList<WatchData> *list)
{
    //qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
    WatchData data = data0;
    bool isExpanded = expandedINames.contains(data.iname);
    if (!isExpanded)
        data.setChildrenUnneeded();

590
    GdbMi children = item["children"];
591
592
593
    if (children.isValid() || !isExpanded)
        data.setChildrenUnneeded();

594
595
    data.updateType(item["type"]);
    GdbMi mi = item["editvalue"];
596
597
    if (mi.isValid())
        data.editvalue = mi.data();
598

599
    mi = item["editformat"];
600
    if (mi.isValid())
601
        data.editformat = mi.toInt();
602

603
    mi = item["typeformats"];
604
605
    if (mi.isValid())
        data.typeFormats = QString::fromUtf8(mi.data());
606

607
    mi = item["bitpos"];
608
    if (mi.isValid())
609
        data.bitpos = mi.toInt();
610

611
    mi = item["bitsize"];
612
    if (mi.isValid())
613
        data.bitsize = mi.toInt();
614

615
    mi = item["origaddr"];
616
617
618
    if (mi.isValid())
        data.origaddr = mi.toAddress();

619
    data.updateAddress(item["addr"]);
620
    data.updateValue(item);
621

622
    setWatchDataSize(data, item["size"]);
623

624
    mi = item["exp"];
625
626
627
    if (mi.isValid())
        data.exp = mi.data();

628
629
630
    setWatchDataValueEnabled(data, item["valueenabled"]);
    setWatchDataValueEditable(data, item["valueeditable"]);
    data.updateChildCount(item["numchild"]);
631
632
633
634
    //qDebug() << "\nAPPEND TO LIST: " << data.toString() << "\n";
    list->append(data);

    bool ok = false;
635
636
    qulonglong addressBase = item["addrbase"].data().toULongLong(&ok, 0);
    qulonglong addressStep = item["addrstep"].data().toULongLong(&ok, 0);
637
638
639

    // Try not to repeat data too often.
    WatchData childtemplate;
640
641
    childtemplate.updateType(item["childtype"]);
    childtemplate.updateChildCount(item["childnumchild"]);
642
643
    //qDebug() << "CHILD TEMPLATE:" << childtemplate.toString();

644
    mi = item["arraydata"];
645
    if (mi.isValid()) {
646
        int encoding = item["arrayencoding"].toInt();
647
648
649
650
651
652
653
654
        childtemplate.iname = data.iname + '.';
        childtemplate.address = addressBase;
        decodeArray(list, childtemplate, mi.data(), encoding);
    } else {
        for (int i = 0, n = children.children().size(); i != n; ++i) {
            const GdbMi &child = children.children().at(i);
            WatchData data1 = childtemplate;
            data1.sortId = i;
655
            GdbMi name = child["name"];
656
657
658
659
            if (name.isValid())
                data1.name = QString::fromLatin1(name.data());
            else
                data1.name = QString::number(i);
660
            GdbMi iname = child["iname"];
661
662
663
664
665
666
667
668
669
670
671
672
673
            if (iname.isValid()) {
                data1.iname = iname.data();
            } else {
                data1.iname = data.iname;
                data1.iname += '.';
                data1.iname += data1.name.toLatin1();
            }
            if (!data1.name.isEmpty() && data1.name.at(0).isDigit())
                data1.name = QLatin1Char('[') + data1.name + QLatin1Char(']');
            if (addressStep) {
                setWatchDataAddress(data1, addressBase);
                addressBase += addressStep;
            }
674
            QByteArray key = child["key"].data();
675
            if (!key.isEmpty()) {
676
                int encoding = child["keyencoded"].toInt();
677
                data1.name = decodeData(key, encoding);
678
679
680
681
682
683
            }
            parseWatchData(expandedINames, data1, child, list);
        }
    }
}

684
685
686
} // namespace Internal
} // namespace Debugger