2009-04-07 17:07:11 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-04-07 17:07:11 +02:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-04-07 17:07:11 +02:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2009-04-07 17:07:11 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cdbbreakpoint.h"
|
2009-04-15 10:05:40 +02:00
|
|
|
#include "cdbmodules.h"
|
2009-04-07 17:07:11 +02:00
|
|
|
|
2009-05-12 14:28:27 +02:00
|
|
|
|
2009-04-07 17:07:11 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-02-04 13:19:49 +01:00
|
|
|
enum { debugBP = 0 };
|
2009-05-12 14:28:27 +02:00
|
|
|
|
2009-04-15 10:05:40 +02:00
|
|
|
|
2009-06-30 15:50:56 +02:00
|
|
|
static inline QString msgCannotSetBreakAtFunction(const QString &func, const QString &why)
|
|
|
|
|
{
|
|
|
|
|
return QString::fromLatin1("Cannot set a breakpoint at '%1': %2").arg(func, why);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-07 17:07:11 +02:00
|
|
|
// Synchronize (halted) engine breakpoints with those of the BreakHandler.
|
2010-02-04 13:19:49 +01:00
|
|
|
bool synchronizeBreakPoints(CIDebugControl* debugControl,
|
|
|
|
|
CIDebugSymbols *syms,
|
|
|
|
|
BreakHandler *handler,
|
|
|
|
|
QString *errorMessage,
|
|
|
|
|
QStringList *warnings)
|
2010-01-29 21:33:57 +01:00
|
|
|
{
|
2009-06-30 15:50:56 +02:00
|
|
|
errorMessage->clear();
|
|
|
|
|
warnings->clear();
|
2009-05-12 14:28:27 +02:00
|
|
|
// Do an initial check whether we are in a state that allows
|
|
|
|
|
// for modifying breakPoints
|
|
|
|
|
ULONG engineCount;
|
2010-02-04 13:19:49 +01:00
|
|
|
if (!CdbCore::BreakPoint::getBreakPointCount(debugControl, &engineCount, errorMessage)) {
|
2009-05-12 14:28:27 +02:00
|
|
|
*errorMessage = QString::fromLatin1("Cannot modify breakpoints: %1").arg(*errorMessage);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-06-30 15:50:56 +02:00
|
|
|
QString warning;
|
2009-05-12 14:28:27 +02:00
|
|
|
// Insert new ones
|
|
|
|
|
bool updateMarkers = false;
|
|
|
|
|
foreach (BreakpointData *nbd, handler->insertedBreakpoints()) {
|
2009-06-30 15:50:56 +02:00
|
|
|
warning.clear();
|
2009-04-15 10:05:40 +02:00
|
|
|
// Function breakpoints: Are the module names specified?
|
|
|
|
|
bool breakPointOk = false;
|
2009-05-12 14:28:27 +02:00
|
|
|
if (nbd->funcName.isEmpty()) {
|
2009-04-15 10:05:40 +02:00
|
|
|
breakPointOk = true;
|
|
|
|
|
} else {
|
2009-06-30 15:50:56 +02:00
|
|
|
switch (resolveSymbol(syms, &nbd->funcName, &warning)) {
|
2009-04-15 10:05:40 +02:00
|
|
|
case ResolveSymbolOk:
|
|
|
|
|
breakPointOk = true;
|
|
|
|
|
break;
|
|
|
|
|
case ResolveSymbolAmbiguous:
|
2009-06-30 15:50:56 +02:00
|
|
|
warnings->push_back(msgCannotSetBreakAtFunction(nbd->funcName, warning));
|
|
|
|
|
warning.clear();
|
2009-04-15 10:05:40 +02:00
|
|
|
breakPointOk = true;
|
|
|
|
|
break;
|
|
|
|
|
case ResolveSymbolNotFound:
|
|
|
|
|
case ResolveSymbolError:
|
2009-06-30 15:50:56 +02:00
|
|
|
warnings->push_back(msgCannotSetBreakAtFunction(nbd->funcName, warning));
|
|
|
|
|
warning.clear();
|
2009-04-15 10:05:40 +02:00
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
} // function breakpoint
|
2009-05-12 14:28:27 +02:00
|
|
|
// Now add...
|
|
|
|
|
if (breakPointOk) {
|
|
|
|
|
quint64 address;
|
|
|
|
|
unsigned long id;
|
2010-02-04 13:19:49 +01:00
|
|
|
const CdbCore::BreakPoint ncdbbp = breakPointFromBreakPointData(*nbd);
|
2009-09-30 17:13:52 +02:00
|
|
|
breakPointOk = ncdbbp.add(debugControl, &warning, &id, &address);
|
2009-05-12 14:28:27 +02:00
|
|
|
if (breakPointOk) {
|
|
|
|
|
if (debugBP)
|
|
|
|
|
qDebug() << "Added " << id << " at " << address << ncdbbp;
|
|
|
|
|
handler->takeInsertedBreakPoint(nbd);
|
|
|
|
|
updateMarkers = true;
|
|
|
|
|
nbd->pending = false;
|
2010-01-05 16:51:55 +01:00
|
|
|
nbd->bpNumber = QByteArray::number(uint(id));
|
2010-02-05 16:20:33 +01:00
|
|
|
nbd->bpAddress = "0x" + QByteArray::number(address, 16);
|
2009-05-12 14:28:27 +02:00
|
|
|
// Take over rest as is
|
|
|
|
|
nbd->bpCondition = nbd->condition;
|
|
|
|
|
nbd->bpIgnoreCount = nbd->ignoreCount;
|
|
|
|
|
nbd->bpFileName = nbd->fileName;
|
|
|
|
|
nbd->bpLineNumber = nbd->lineNumber;
|
|
|
|
|
nbd->bpFuncName = nbd->funcName;
|
2009-04-07 17:07:11 +02:00
|
|
|
}
|
2009-05-12 14:28:27 +02:00
|
|
|
} // had symbol
|
2009-06-30 15:50:56 +02:00
|
|
|
if (!breakPointOk && !warning.isEmpty())
|
|
|
|
|
warnings->push_back(warning); }
|
2009-05-12 14:28:27 +02:00
|
|
|
// Delete
|
|
|
|
|
foreach (BreakpointData *rbd, handler->takeRemovedBreakpoints()) {
|
2010-02-04 13:19:49 +01:00
|
|
|
if (!CdbCore::BreakPoint::removeBreakPointById(debugControl, rbd->bpNumber.toUInt(), &warning))
|
2009-06-30 15:50:56 +02:00
|
|
|
warnings->push_back(warning);
|
2009-05-12 14:28:27 +02:00
|
|
|
delete rbd;
|
2009-04-07 17:07:11 +02:00
|
|
|
}
|
2009-05-12 14:28:27 +02:00
|
|
|
// Enable/Disable
|
|
|
|
|
foreach (BreakpointData *ebd, handler->takeEnabledBreakpoints())
|
2010-02-04 13:19:49 +01:00
|
|
|
if (!CdbCore::BreakPoint::setBreakPointEnabledById(debugControl, ebd->bpNumber.toUInt(), true, &warning))
|
2009-06-30 15:50:56 +02:00
|
|
|
warnings->push_back(warning);
|
2009-05-12 14:28:27 +02:00
|
|
|
foreach (BreakpointData *dbd, handler->takeDisabledBreakpoints())
|
2010-02-04 13:19:49 +01:00
|
|
|
if (!CdbCore::BreakPoint::setBreakPointEnabledById(debugControl, dbd->bpNumber.toUInt(), false, &warning))
|
2009-06-30 15:50:56 +02:00
|
|
|
warnings->push_back(warning);
|
2009-05-12 14:28:27 +02:00
|
|
|
|
|
|
|
|
if (updateMarkers)
|
|
|
|
|
handler->updateMarkers();
|
|
|
|
|
|
|
|
|
|
if (debugBP > 1) {
|
2010-02-04 13:19:49 +01:00
|
|
|
QList<CdbCore::BreakPoint> bps;
|
|
|
|
|
CdbCore::BreakPoint::getBreakPoints(debugControl, &bps, errorMessage);
|
2009-04-07 17:07:11 +02:00
|
|
|
qDebug().nospace() << "### Breakpoints in engine: " << bps;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-15 14:26:08 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|