Commit 4357bf1b authored by dt's avatar dt
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 66bea14f 7364d8ba
......@@ -32,6 +32,9 @@
// this relies on contents copied from qobject_p.h
#define PRIVATE_OBJECT_ALLOWED 1
#ifdef HAS_QOBJECT_P_H
# include <QtCore/private/qobject_p.h>
#endif
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QDir>
......@@ -146,8 +149,7 @@ int qtGhVersion = QT_VERSION;
# define NSY ""
#endif
#if PRIVATE_OBJECT_ALLOWED
#if PRIVATE_OBJECT_ALLOWED && !HAS_QOBJECT_P_H
#if defined(QT_BEGIN_NAMESPACE)
QT_BEGIN_NAMESPACE
......@@ -1532,6 +1534,13 @@ static void qDumpQObject(QDumper &d)
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
const QMetaObject *mo = ob->metaObject();
unsigned childrenOffset = d.extraInt[0];
#ifdef HAS_QOBJECT_P_H
// QObject child offset if known
if (!childrenOffset) {
QObjectPrivate qop;
childrenOffset = (char*)&qop.children - (char*)&qop;
}
#endif
P(d, "value", ob->objectName());
P(d, "valueencoded", "2");
P(d, "type", NS"QObject");
......@@ -1588,7 +1597,8 @@ static void qDumpQObject(QDumper &d)
P(d, "numchild", slotCount);
d.endHash();
#endif
d.beginHash();
if (childrenOffset) {
d.beginHash();
P(d, "name", "children");
// works always, but causes additional traffic on the list
//P(d, "exp", "((class '"NS"QObject'*)" << d.data << ")->children()");
......@@ -1597,9 +1607,10 @@ static void qDumpQObject(QDumper &d)
//P(d, "type", NS"QList<QObject *>");
//P(d, "value", "<" << children.size() << " items>");
qDumpInnerValue(d, NS"QList<"NS"QObject *>",
addOffset(dfunc(ob), childrenOffset));
addOffset(dfunc(ob), childrenOffset));
P(d, "numchild", children.size());
d.endHash();
d.endHash();
}
#if 0
// Unneeded (and not working): Connections are listes as childen
// of the signal or slot they are connected to.
......
......@@ -5,3 +5,7 @@ CONFIG -= release
CONFIG += debug
}
SOURCES=gdbmacros.cpp
exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h) {
DEFINES+=HAS_QOBJECT_P_H
}
......@@ -14,3 +14,8 @@ TEMPLATE = app
SOURCES += main.cpp \
../gdbmacros.cpp
exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h) {
DEFINES+=HAS_QOBJECT_P_H
}
......@@ -133,6 +133,17 @@ static int dumpStdString()
return 0;
}
static int dumpStdWString()
{
std::wstring test = L"hallo";
prepareInBuffer("std::wstring", "local.wstring", "local.wstring", "");
qDumpObjectData440(2, 42, &test, 1, 0, 0, 0, 0);
fputs(qDumpOutBuffer, stdout);
fputc('\n', stdout);
return 0;
}
static int dumpStdStringList()
{
std::list<std::string> test;
......@@ -145,6 +156,18 @@ static int dumpStdStringList()
return 0;
}
static int dumpStdStringQList()
{
QList<std::string> test;
test.push_back("item1");
test.push_back("item2");
prepareInBuffer("QList", "local.stringqlist", "local.stringqlist", "std::string");
qDumpObjectData440(2, 42, &test, 1, sizeof(std::string), 0, 0, 0);
fputs(qDumpOutBuffer, stdout);
fputc('\n', stdout);
return 0;
}
static int dumpStdIntList()
{
std::list<int> test;
......@@ -169,11 +192,28 @@ static int dumpStdIntVector()
return 0;
}
static int dumpStdStringVector()
{
std::vector<std::string> test;
test.push_back("item1");
test.push_back("item2");
prepareInBuffer("std::vector", "local.stringvector", "local.stringvector", "std::string");
qDumpObjectData440(2, 42, &test, 1, sizeof(std::string), sizeof(std::list<int>::allocator_type), 0, 0);
fputs(qDumpOutBuffer, stdout);
fputc('\n', stdout);
return 0;
}
static int dumpQObject()
{
QTimer t;
QObjectPrivate *tp = reinterpret_cast<QObjectPrivate *>(&t);
#ifdef KNOWS_OFFSET
const int childOffset = (char*)&tp->children - (char*)tp;
#else
const int childOffset = 0;
#endif
printf("Qt version %s Child offset: %d\n", QT_VERSION_STR, childOffset);
prepareInBuffer("QObject", "local.qobject", "local.qobject", "");
qDumpObjectData440(2, 42, &t, 1, childOffset, 0, 0, 0);
......@@ -200,16 +240,22 @@ int main(int argc, char *argv[])
dumpQStringList();
if (!qstrcmp(arg, "QList<int>"))
dumpQIntList();
if (!qstrcmp(arg, "QList<std::string>"))
dumpStdStringQList();
if (!qstrcmp(arg, "QVector<int>"))
dumpQIntVector();
if (!qstrcmp(arg, "string"))
dumpStdString();
if (!qstrcmp(arg, "wstring"))
dumpStdWString();
if (!qstrcmp(arg, "list<int>"))
dumpStdIntList();
if (!qstrcmp(arg, "list<string>"))
dumpStdStringList();
if (!qstrcmp(arg, "vector<int>"))
dumpStdIntVector();
if (!qstrcmp(arg, "vector<string>"))
dumpStdStringVector();
if (!qstrcmp(arg, "QObject"))
dumpQObject();
}
......
......@@ -49,12 +49,6 @@
\enum Command::CommandAttribute
*/
/*!
\fn void Command::setCategory(const QString &name)
Sets the category to \a name.
*/
/*!
\fn virtual void Command::setDefaultKeySequence(const QKeySequence &key)
*/
......@@ -118,18 +112,6 @@ int CommandPrivate::stateFlags() const
return (m_type & CS_Mask);
}
void CommandPrivate::setCategory(const QString &name)
{
m_category = name;
}
QString CommandPrivate::category() const
{
if (m_category.isEmpty())
return tr("Other");
return m_category;
}
void CommandPrivate::setDefaultKeySequence(const QKeySequence &key)
{
m_defaultKey = key;
......
......@@ -63,8 +63,6 @@ public:
virtual void setDefaultText(const QString &text) = 0;
virtual QString defaultText() const = 0;
virtual void setCategory(const QString &name) = 0;
virtual int id() const = 0;
virtual CommandType type() const = 0;
......
......@@ -60,9 +60,6 @@ public:
virtual QString name() const = 0;
void setCategory(const QString &name);
QString category() const;
void setDefaultKeySequence(const QKeySequence &key);
QKeySequence defaultKeySequence() const;
......
......@@ -33,7 +33,7 @@
<item>
<widget class="QCheckBox" name="checkBoxUseAlternatingRowColors">
<property name="text">
<string>Use alternating row colors in debug views.</string>
<string>Use alternating row colors in debug views</string>
</property>
</widget>
</item>
......
......@@ -30,6 +30,7 @@
#include "debuggermanager.h"
#include "debuggeractions.h"
#include "debuggerrunner.h"
#include "debuggerconstants.h"
#include "idebuggerengine.h"
......@@ -172,7 +173,7 @@ void DebuggerManager::init()
m_busy = false;
m_attachedPID = 0;
m_startMode = StartInternal;
m_runControl = 0;
m_disassemblerHandler = 0;
m_modulesHandler = 0;
......@@ -295,21 +296,6 @@ void DebuggerManager::init()
connect(m_watchHandler, SIGNAL(watchModelUpdateRequested()),
this, SLOT(updateWatchModel()));
m_startExternalAction = new QAction(this);
m_startExternalAction->setText(tr("Start and Debug External Application..."));
m_attachExternalAction = new QAction(this);
m_attachExternalAction->setText(tr("Attach to Running External Application..."));
m_attachCoreAction = new QAction(this);
m_attachCoreAction->setText(tr("Attach to Core..."));
connect(m_attachCoreAction, SIGNAL(triggered()), this, SLOT(attachCore()));
m_attachRemoteAction = new QAction(this);
m_attachRemoteAction->setText(tr("Attach to Running Remote Application..."));
connect(m_attachRemoteAction, SIGNAL(triggered()),
this, SLOT(attachRemoteApplication()));
m_continueAction = new QAction(this);
m_continueAction->setText(tr("Continue"));
m_continueAction->setIcon(QIcon(":/gdbdebugger/images/debugger_continue_small.png"));
......@@ -371,11 +357,6 @@ void DebuggerManager::init()
connect(m_continueAction, SIGNAL(triggered()),
this, SLOT(continueExec()));
connect(m_startExternalAction, SIGNAL(triggered()),
this, SLOT(startExternalApplication()));
connect(m_attachExternalAction, SIGNAL(triggered()),
this, SLOT(attachExternalApplication()));
connect(m_stopAction, SIGNAL(triggered()),
this, SLOT(interruptDebuggingRequest()));
connect(m_resetAction, SIGNAL(triggered()),
......@@ -798,30 +779,6 @@ void DebuggerManager::setConfigValue(const QString &name, const QVariant &value)
emit setConfigValueRequested(name, value);
}
void DebuggerManager::startExternalApplication()
{
if (!startNewDebugger(StartExternal))
emit debuggingFinished();
}
void DebuggerManager::attachExternalApplication()
{
if (!startNewDebugger(AttachExternal))
emit debuggingFinished();
}
void DebuggerManager::attachCore()
{
if (!startNewDebugger(AttachCore))
emit debuggingFinished();
}
void DebuggerManager::attachRemoteApplication()
{
if (!startNewDebugger(AttachRemote))
emit debuggingFinished();
}
// Figure out the debugger type of an executable
static bool determineDebuggerType(const QString &executable,
DebuggerManager::DebuggerType *dt,
......@@ -869,12 +826,13 @@ static bool determineDebuggerType(int /* pid */,
return true;
}
bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl)
{
m_runControl = runControl;
if (Debugger::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << mode;
qDebug() << Q_FUNC_INFO << startMode();
m_startMode = mode;
// FIXME: Clean up
switch (startMode()) {
......@@ -884,8 +842,10 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
configValue(_("LastExternalExecutableFile")).toString());
dlg.setExecutableArguments(
configValue(_("LastExternalExecutableArguments")).toString());
if (dlg.exec() != QDialog::Accepted)
return false;
if (dlg.exec() != QDialog::Accepted) {
runControl->debuggingFinished();
return;
}
setConfigValue(_("LastExternalExecutableFile"),
dlg.executableFile());
setConfigValue(_("LastExternalExecutableArguments"),
......@@ -898,8 +858,10 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
}
case AttachExternal: {
AttachExternalDialog dlg(mainWindow());
if (dlg.exec() != QDialog::Accepted)
return false;
if (dlg.exec() != QDialog::Accepted) {
runControl->debuggingFinished();
return;
}
m_executable = QString();
m_processArgs = QStringList();
m_workingDir = QString();
......@@ -907,7 +869,8 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
if (m_attachedPID == 0) {
QMessageBox::warning(mainWindow(), tr("Warning"),
tr("Cannot attach to PID 0"));
return false;
runControl->debuggingFinished();
return;
}
break;
}
......@@ -924,8 +887,10 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
}
StartExternalDialog dlg(mainWindow());
dlg.setExecutableFile(startDirectory);
if (dlg.exec() != QDialog::Accepted)
return false;
if (dlg.exec() != QDialog::Accepted) {
runControl->debuggingFinished();
return;
}
m_executable = dlg.executableFile();
m_processArgs = dlg.executableArguments().split(' ');
m_workingDir = QString();
......@@ -943,8 +908,10 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
configValue(_("LastExternalExecutableFile")).toString());
dlg.setCoreFile(
configValue(_("LastExternalCoreFile")).toString());
if (dlg.exec() != QDialog::Accepted)
return false;
if (dlg.exec() != QDialog::Accepted) {
runControl->debuggingFinished();
return;
}
setConfigValue(_("LastExternalExecutableFile"),
dlg.executableFile());
setConfigValue(_("LastExternalCoreFile"),
......@@ -963,8 +930,10 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
dlg.setRemoteArchitectures(arches);
dlg.setRemoteChannel(configValue(_("LastRemoteChannel")).toString());
dlg.setRemoteArchitecture(configValue(_("LastRemoteArchtecture")).toString());
if (dlg.exec() != QDialog::Accepted)
return false;
if (dlg.exec() != QDialog::Accepted) {
runControl->debuggingFinished();
return;
}
setConfigValue(_("LastRemoteChannel"), dlg.remoteChannel());
setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture());
m_remoteChannel = dlg.remoteChannel();
......@@ -983,8 +952,8 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
if (!hasDebugger) {
QMessageBox::warning(mainWindow(), tr("Warning"),
tr("Cannot debug '%1': %2").arg(m_executable, errorMessage));
return false;
debuggingFinished();
return;
}
if (Debugger::Constants::Internal::debug)
qDebug() << m_executable << type;
......@@ -994,10 +963,11 @@ bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
setStatus(DebuggerProcessStartingUp);
if (!m_engine->startDebugger()) {
setStatus(DebuggerProcessNotReady);
return false;
debuggingFinished();
return;
}
return true;
return;
}
void DebuggerManager::cleanupViews()
......@@ -1257,20 +1227,21 @@ void DebuggerManager::setStatus(int status)
|| status == DebuggerInferiorStopRequested
|| status == DebuggerInferiorStopped;
const bool starting = status == DebuggerProcessStartingUp;
//const bool starting = status == DebuggerProcessStartingUp;
const bool running = status == DebuggerInferiorRunning;
const bool ready = status == DebuggerInferiorStopped
&& startMode() != AttachCore;
m_startExternalAction->setEnabled(!started && !starting);
m_attachExternalAction->setEnabled(!started && !starting);
#ifdef Q_OS_WIN
m_attachCoreAction->setEnabled(false);
#else
m_attachCoreAction->setEnabled(!started && !starting);
#endif
m_attachRemoteAction->setEnabled(!started && !starting);
// FIXME
// m_startExternalAction->setEnabled(!started && !starting);
// m_attachExternalAction->setEnabled(!started && !starting);
//#ifdef Q_OS_WIN
// m_attachCoreAction->setEnabled(false);
//#else
// m_attachCoreAction->setEnabled(!started && !starting);
//#endif
// m_attachRemoteAction->setEnabled(!started && !starting);
m_watchAction->setEnabled(ready);
m_breakAction->setEnabled(true);
......@@ -1570,6 +1541,12 @@ void DebuggerManager::showQtDumperLibraryWarning(const QString &details)
}
}
DebuggerStartMode DebuggerManager::startMode() const
{
return m_runControl->startMode();
}
//////////////////////////////////////////////////////////////////////
//
// Testing
......@@ -1581,8 +1558,7 @@ void DebuggerManager::runTest(const QString &fileName)
m_executable = fileName;
m_processArgs = QStringList() << "--run-debuggee";
m_workingDir = QString();
if (!startNewDebugger(StartInternal))
emit debuggingFinished();
//startNewDebugger(StartInternal);
}
#include "debuggermanager.moc"
......@@ -56,6 +56,7 @@ namespace Debugger {
namespace Internal {
class DebuggerOutputWindow;
class DebuggerRunControl;
class DebuggerPlugin;
class DebugMode;
......@@ -204,7 +205,7 @@ public:
enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger };
public slots:
bool startNewDebugger(DebuggerStartMode mode);
void startNewDebugger(DebuggerRunControl *runControl);
void exitDebugger();
void setSimpleDockWidgetArrangement();
......@@ -223,10 +224,6 @@ public slots:
void resetLocation();
void interruptDebuggingRequest();
void startExternalApplication();
void attachExternalApplication();
void attachCore();
void attachRemoteApplication();
void jumpToLineExec();
void runToLineExec();
......@@ -328,7 +325,8 @@ public:
// one of the interfaces
QAbstractItemModel *threadsModel();
int status() const { return m_status; }
DebuggerStartMode startMode() const { return m_startMode; }
DebuggerStartMode startMode() const;
DebuggerRunControl *runControl() const { return m_runControl; }
QList<Symbol> moduleSymbols(const QString &moduleName);
......@@ -377,7 +375,7 @@ private:
BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
void setToolTipExpression(const QPoint &pos, const QString &exp0);
DebuggerStartMode m_startMode;
DebuggerRunControl *m_runControl;
DebuggerType m_debuggerType;
/// Views
......@@ -405,10 +403,6 @@ private:
/// Actions
friend class DebuggerPlugin;
QAction *m_startExternalAction;
QAction *m_attachExternalAction;
QAction *m_attachCoreAction;
QAction *m_attachRemoteAction;
QAction *m_continueAction;
QAction *m_stopAction;
QAction *m_resetAction; // FIXME: Should not be needed in a stable release
......
......@@ -463,31 +463,48 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
//Core::ActionContainer *mcppcontext =
// am->actionContainer(CppEditor::Constants::M_CONTEXT);
// External apps
m_startExternalAction = new QAction(this);
m_startExternalAction->setText(tr("Start and Debug External Application..."));
connect(m_startExternalAction, SIGNAL(triggered()),
this, SLOT(startExternalApplication()));
m_attachExternalAction = new QAction(this);
m_attachExternalAction->setText(tr("Attach to Running External Application..."));
connect(m_attachExternalAction, SIGNAL(triggered()),
this, SLOT(attachExternalApplication()));
m_attachCoreAction = new QAction(this);
m_attachCoreAction->setText(tr("Attach to Core..."));
connect(m_attachCoreAction, SIGNAL(triggered()), this, SLOT(attachCore()));
m_attachRemoteAction = new QAction(this);
m_attachRemoteAction->setText(tr("Attach to Running Remote Application..."));
connect(m_attachRemoteAction, SIGNAL(triggered()),
this, SLOT(attachRemoteApplication()));
Core::ActionContainer *mdebug =
am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
Core::Command *cmd = 0;
cmd = am->registerAction(m_manager->m_startExternalAction,
cmd = am->registerAction(m_startExternalAction,
Constants::STARTEXTERNAL, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
cmd = am->registerAction(m_manager->m_attachExternalAction,
cmd = am->registerAction(m_attachExternalAction,
Constants::ATTACHEXTERNAL, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
if (m_manager->m_attachCoreAction) {
cmd = am->registerAction(m_manager->m_attachCoreAction,
Constants::ATTACHCORE, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
}
cmd = am->registerAction(m_attachCoreAction,
Constants::ATTACHCORE, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
#if 0
#if 1
// FIXME: not yet functional
if (m_manager->m_attachRemoteAction) {
cmd = am->registerAction(m_manager->m_attachRemoteAction,
Constants::ATTACHREMOTE, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
}
cmd = am->registerAction(m_attachRemoteAction,
Constants::ATTACHREMOTE, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
#endif
cmd = am->registerAction(m_manager->m_continueAction,
......@@ -642,7 +659,9 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_debugMode = new DebugMode(this);
//addAutoReleasedObject(m_debugMode);
addAutoReleasedObject(new DebuggerRunner(m_manager));
// register factory of DebuggerRunControl
m_debuggerRunner = new DebuggerRunner(m_manager);
addAutoReleasedObject(m_debuggerRunner);
QList<int> context;
context.append(uidm->uniqueIdentifier(Core::Constants::C_EDITORMANAGER));
......@@ -1036,6 +1055,48 @@ void DebuggerPlugin::showSettingsDialog()
QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_PAGE));
}
static QSharedPointer<RunConfiguration> activeRunConfiguration()
{
ProjectExplorer::Project *project =
ProjectExplorerPlugin::instance()->currentProject();
if (project)