2009-03-26 16:49:28 +01: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-03-26 16:49:28 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-26 16:49:28 +01: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-03-26 16:49:28 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cdbstacktracecontext.h"
|
|
|
|
|
#include "cdbsymbolgroupcontext.h"
|
2009-04-29 14:15:09 +02:00
|
|
|
#include "cdbdumperhelper.h"
|
2010-02-04 13:19:49 +01:00
|
|
|
#include "cdbdebugengine_p.h"
|
2009-10-16 16:26:28 +02:00
|
|
|
#include "debuggeractions.h"
|
2010-02-04 13:19:49 +01:00
|
|
|
#include "watchutils.h"
|
2009-03-26 16:49:28 +01:00
|
|
|
|
2010-03-18 11:10:07 +01:00
|
|
|
#include <utils/savedaction.h>
|
|
|
|
|
|
2009-10-16 16:26:28 +02:00
|
|
|
#include <QtCore/QDebug>
|
2010-02-04 13:19:49 +01:00
|
|
|
|
2010-03-18 11:10:07 +01:00
|
|
|
enum { debug = 0 };
|
2009-04-07 17:07:11 +02:00
|
|
|
|
2009-03-26 16:49:28 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-04-29 14:15:09 +02:00
|
|
|
CdbStackTraceContext::CdbStackTraceContext(const QSharedPointer<CdbDumperHelper> &dumper) :
|
2010-02-04 13:19:49 +01:00
|
|
|
CdbCore::StackTraceContext(dumper->comInterfaces()),
|
|
|
|
|
m_dumper(dumper)
|
2009-03-26 16:49:28 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-29 14:15:09 +02:00
|
|
|
CdbStackTraceContext *CdbStackTraceContext::create(const QSharedPointer<CdbDumperHelper> &dumper,
|
2009-03-26 16:49:28 +01:00
|
|
|
QString *errorMessage)
|
2010-01-29 21:33:57 +01:00
|
|
|
{
|
2009-04-29 14:15:09 +02:00
|
|
|
CdbStackTraceContext *ctx = new CdbStackTraceContext(dumper);
|
2010-02-04 13:19:49 +01:00
|
|
|
if (!ctx->init(UINT_MAX, errorMessage)) {
|
2009-03-26 16:49:28 +01:00
|
|
|
delete ctx;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-04 13:19:49 +01:00
|
|
|
CdbCore::SymbolGroupContext
|
|
|
|
|
*CdbStackTraceContext::createSymbolGroup(const CdbCore::ComInterfaces & /* cif */,
|
|
|
|
|
int index,
|
|
|
|
|
const QString &prefix,
|
|
|
|
|
CIDebugSymbolGroup *comSymbolGroup,
|
|
|
|
|
QString *errorMessage)
|
2009-05-20 14:20:38 +02:00
|
|
|
{
|
2010-01-11 10:22:55 +01:00
|
|
|
// Exclude uninitialized variables if desired
|
2009-10-16 16:26:28 +02:00
|
|
|
QStringList uninitializedVariables;
|
2010-02-04 13:19:49 +01:00
|
|
|
const CdbCore::StackFrame &frame = stackFrameAt(index);
|
|
|
|
|
if (theDebuggerAction(UseCodeModel)->isChecked())
|
|
|
|
|
getUninitializedVariables(DebuggerManager::instance()->cppCodeModelSnapshot(), frame.function, frame.fileName, frame.line, &uninitializedVariables);
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << frame << uninitializedVariables;
|
|
|
|
|
CdbSymbolGroupContext *sc = CdbSymbolGroupContext::create(prefix,
|
|
|
|
|
comSymbolGroup,
|
|
|
|
|
m_dumper,
|
|
|
|
|
uninitializedVariables,
|
|
|
|
|
errorMessage);
|
2009-05-20 14:20:38 +02:00
|
|
|
if (!sc) {
|
2010-02-04 13:19:49 +01:00
|
|
|
*errorMessage = msgFrameContextFailed(index, frame, *errorMessage);
|
2009-04-29 14:15:09 +02:00
|
|
|
return 0;
|
2009-05-20 14:20:38 +02:00
|
|
|
}
|
2010-02-04 13:19:49 +01:00
|
|
|
return sc;
|
2009-03-26 16:49:28 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-04 13:19:49 +01:00
|
|
|
CdbSymbolGroupContext *CdbStackTraceContext::cdbSymbolGroupContextAt(int index, QString *errorMessage)
|
2009-03-26 16:49:28 +01:00
|
|
|
{
|
2010-02-04 13:19:49 +01:00
|
|
|
return static_cast<CdbSymbolGroupContext *>(symbolGroupContextAt(index, errorMessage));
|
2009-04-21 12:30:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-04 13:19:49 +01:00
|
|
|
QList<StackFrame> CdbStackTraceContext::stackFrames() const
|
2009-04-21 12:30:12 +02:00
|
|
|
{
|
2010-02-04 13:19:49 +01:00
|
|
|
// Convert from Core data structures
|
|
|
|
|
QList<StackFrame> rc;
|
|
|
|
|
const int count = frameCount();
|
|
|
|
|
const QString hexPrefix = QLatin1String("0x");
|
|
|
|
|
for(int i = 0; i < count; i++) {
|
|
|
|
|
const CdbCore::StackFrame &coreFrame = stackFrameAt(i);
|
|
|
|
|
StackFrame frame;
|
|
|
|
|
frame.level = i;
|
|
|
|
|
frame.file = coreFrame.fileName;
|
|
|
|
|
frame.line = coreFrame.line;
|
|
|
|
|
frame.function =coreFrame.function;
|
|
|
|
|
frame.from = coreFrame.module;
|
|
|
|
|
frame.address = hexPrefix + QString::number(coreFrame.address, 16);
|
|
|
|
|
rc.push_back(frame);
|
2009-10-05 17:20:38 +02:00
|
|
|
}
|
2010-02-04 13:19:49 +01:00
|
|
|
return rc;
|
2009-10-05 17:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-22 17:15:33 +01:00
|
|
|
bool CdbStackTraceContext::getThreads(const CdbCore::ComInterfaces &cif,
|
2009-10-05 17:20:38 +02:00
|
|
|
QList<ThreadData> *threads,
|
|
|
|
|
ULONG *currentThreadId,
|
|
|
|
|
QString *errorMessage)
|
|
|
|
|
{
|
2010-02-04 13:19:49 +01:00
|
|
|
// Convert from Core data structures
|
2009-10-05 17:20:38 +02:00
|
|
|
threads->clear();
|
2010-02-04 13:19:49 +01:00
|
|
|
ThreadIdFrameMap threadMap;
|
|
|
|
|
if (!CdbCore::StackTraceContext::getThreads(cif, &threadMap,
|
|
|
|
|
currentThreadId, errorMessage))
|
2009-10-05 17:20:38 +02:00
|
|
|
return false;
|
2010-02-04 13:19:49 +01:00
|
|
|
const QChar slash = QLatin1Char('/');
|
|
|
|
|
const ThreadIdFrameMap::const_iterator cend = threadMap.constEnd();
|
|
|
|
|
for (ThreadIdFrameMap::const_iterator it = threadMap.constBegin(); it != cend; ++it) {
|
|
|
|
|
ThreadData data(it.key());
|
|
|
|
|
const CdbCore::StackFrame &coreFrame = it.value();
|
|
|
|
|
data.address = coreFrame.address;
|
|
|
|
|
data.function = coreFrame.function;
|
2010-05-17 17:38:31 +02:00
|
|
|
data.lineNumber = coreFrame.line;
|
2010-02-04 13:19:49 +01:00
|
|
|
// Basename only for brevity
|
|
|
|
|
const int slashPos = coreFrame.fileName.lastIndexOf(slash);
|
2010-05-17 17:38:31 +02:00
|
|
|
data.fileName = slashPos == -1 ? coreFrame.fileName : coreFrame.fileName.mid(slashPos + 1);
|
2010-02-04 13:19:49 +01:00
|
|
|
threads->push_back(data);
|
2009-10-05 17:30:45 +02:00
|
|
|
}
|
2009-10-05 17:20:38 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-15 14:26:08 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|