Debugger[CDB]: Add thread names.

This commit is contained in:
Friedemann Kleint
2010-09-17 13:28:50 +02:00
parent fd6084532b
commit 88bc157b7c
8 changed files with 34 additions and 7 deletions

View File

@@ -43,7 +43,7 @@
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
//////////////////////////////////////////////////////////////////
//
@@ -239,7 +239,7 @@ QString BreakpointData::toToolTip() const
QTextStream str(&rc);
str << "<html><body><table>"
<< "<tr><td>" << BreakHandler::tr("Marker File:")
<< "</td><td>" << m_markerFileName << "</td></tr>"
<< "</td><td>" << QDir::toNativeSeparators(m_markerFileName) << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Marker Line:")
<< "</td><td>" << m_markerLineNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Breakpoint Number:")
@@ -257,7 +257,7 @@ QString BreakpointData::toToolTip() const
<< "<tr><td>" << BreakHandler::tr("Internal Number:")
<< "</td><td>&mdash;</td><td>" << bpNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("File Name:")
<< "</td><td>" << fileName << "</td><td>" << bpFileName << "</td></tr>"
<< "</td><td>" << fileName << "</td><td>" << QDir::toNativeSeparators(bpFileName) << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Function Name:")
<< "</td><td>" << funcName << "</td><td>" << bpFuncName << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Line Number:")

View File

@@ -47,6 +47,7 @@ typedef IDebugDataSpaces4 CIDebugDataSpaces;
typedef IDebugSymbolGroup2 CIDebugSymbolGroup;
typedef IDebugBreakpoint2 CIDebugBreakpoint;
typedef IDebugAdvanced2 CIDebugAdvanced;
#else

View File

@@ -141,6 +141,7 @@ bool CdbStackTraceContext::getThreads(const CdbCore::ComInterfaces &cif,
const CdbCore::Thread &coreThread = coreThreads.at(i);
ThreadData data(coreThread.id);
data.targetId = QLatin1String("0x") + QString::number(coreThread.systemId);
data.name = coreThread.name;
if (stopped) {
const CdbCore::StackFrame &coreFrame = frames.at(i);
data.address = coreFrame.address;

View File

@@ -152,7 +152,8 @@ ComInterfaces::ComInterfaces() :
debugSystemObjects(0),
debugSymbols(0),
debugRegisters(0),
debugDataSpaces(0)
debugDataSpaces(0),
debugAdvanced(0)
{
}
@@ -250,6 +251,8 @@ CoreEngine::~CoreEngine()
m_cif.debugRegisters->Release();
if (m_cif.debugDataSpaces)
m_cif.debugDataSpaces->Release();
if (m_cif.debugAdvanced)
m_cif.debugAdvanced->Release();
}
bool CoreEngine::init(const QString &dllEnginePath, QString *errorMessage)
@@ -310,6 +313,12 @@ bool CoreEngine::init(const QString &dllEnginePath, QString *errorMessage)
return false;
}
hr = lib.debugCreate( __uuidof(IDebugAdvanced2), reinterpret_cast<void**>(&m_cif.debugAdvanced));
if (FAILED(hr)) {
*errorMessage = QString::fromLatin1("Creation of IDebugAdvanced2 failed: %1").arg(msgDebugEngineComResult(hr));
return false;
}
if (debug)
qDebug() << QString::fromLatin1("CDB Initialization succeeded, interrupt time out %1s.").arg(getInterruptTimeOutSecs(m_cif.debugControl));
return true;

View File

@@ -52,6 +52,7 @@ struct ComInterfaces
CIDebugSymbols* debugSymbols;
CIDebugRegisters* debugRegisters;
CIDebugDataSpaces* debugDataSpaces;
CIDebugAdvanced* debugAdvanced;
};
class CoreEngine : public QObject

View File

@@ -84,7 +84,8 @@ QString Thread::toString() const
{
QString rc;
QTextStream str(&rc);
str << "Thread id " << id << " System id " << systemId << " Data at 0x";
str << "Thread id " << id << " System id " << systemId
<< " name='" << name <<"' Data at 0x";
str.setIntegerBase(16);
str << dataOffset;
return rc;
@@ -401,13 +402,23 @@ bool StackTraceContext::getThreadList(const CdbCore::ComInterfaces &cif,
return false;
}
// Create entries
static WCHAR name[256];
for (ULONG i= 0; i < threadCount ; i++) {
threads->push_back(Thread(ids[i], systemIds[i]));
const ULONG id = ids[i];
Thread thread(id, systemIds[i]);
if (ids[i] == *currentThreadId) { // More info for current
ULONG64 offset;
if (SUCCEEDED(cif.debugSystemObjects->GetCurrentThreadDataOffset(&offset)))
threads->back().dataOffset = offset;
thread.dataOffset = offset;
}
// Name
ULONG bytesReceived = 0;
hr = cif.debugAdvanced->GetSystemObjectInformation(DEBUG_SYSOBJINFO_THREAD_NAME_WIDE,
0, id, name,
sizeof(name), &bytesReceived);
if (SUCCEEDED(hr) && bytesReceived)
thread.name = QString::fromWCharArray(name);
threads->push_back(thread);
}
return true;
}

View File

@@ -70,6 +70,7 @@ struct Thread {
unsigned long id;
unsigned long systemId;
quint64 dataOffset; // Only for current.
QString name;
};
inline bool operator<(const Thread &t1, const Thread &t2) { return t1.id < t2.id; }

View File

@@ -73,6 +73,9 @@ static inline QString threadToolTip(const ThreadData &thread)
if (!thread.targetId.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("Target&nbsp;id:")
<< tableRowSeparatorC << thread.targetId << tableRowEndC;
if (!thread.name.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("Name:")
<< tableRowSeparatorC << thread.name << tableRowEndC;
if (!thread.state.isEmpty())
str << tableRowStartC << ThreadsHandler::tr("State:")
<< tableRowSeparatorC << thread.state << tableRowEndC;