Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
1d64e169
Commit
1d64e169
authored
Sep 21, 2009
by
hjk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugger: rework startup logic
parent
ae2cfdaa
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
923 additions
and
466 deletions
+923
-466
src/plugins/debugger/gdb/abstractgdbadapter.h
src/plugins/debugger/gdb/abstractgdbadapter.h
+26
-12
src/plugins/debugger/gdb/gdb.pri
src/plugins/debugger/gdb/gdb.pri
+4
-2
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/debugger/gdb/gdbengine.cpp
+383
-340
src/plugins/debugger/gdb/gdbengine.h
src/plugins/debugger/gdb/gdbengine.h
+43
-60
src/plugins/debugger/gdb/plaingdbadapter.cpp
src/plugins/debugger/gdb/plaingdbadapter.cpp
+291
-0
src/plugins/debugger/gdb/plaingdbadapter.h
src/plugins/debugger/gdb/plaingdbadapter.h
+98
-0
src/plugins/debugger/gdb/trkgdbadapter.cpp
src/plugins/debugger/gdb/trkgdbadapter.cpp
+65
-39
src/plugins/debugger/gdb/trkgdbadapter.h
src/plugins/debugger/gdb/trkgdbadapter.h
+11
-11
src/plugins/duieditor/parser/qmljsastvisitor.cpp
src/plugins/duieditor/parser/qmljsastvisitor.cpp
+2
-2
No files found.
src/plugins/debugger/gdb/abstractgdbadapter.h
View file @
1d64e169
...
...
@@ -33,6 +33,8 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include "gdbengine.h"
namespace
Debugger
{
namespace
Internal
{
...
...
@@ -48,15 +50,10 @@ class AbstractGdbAdapter : public QObject
Q_OBJECT
public:
AbstractGdbAdapter
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{}
AbstractGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
)
:
QObject
(
parent
),
m_engine
(
engine
)
{}
virtual
void
setEngine
(
GdbEngine
*
engine
)
{
m_engine
=
engine
;
}
virtual
void
start
(
const
QString
&
program
,
const
QStringList
&
args
,
QIODevice
::
OpenMode
mode
=
QIODevice
::
ReadWrite
)
=
0
;
virtual
void
kill
()
=
0
;
virtual
void
terminate
()
=
0
;
//virtual bool waitForStarted(int msecs = 30000) = 0;
virtual
bool
waitForFinished
(
int
msecs
=
30000
)
=
0
;
virtual
QProcess
::
ProcessState
state
()
const
=
0
;
virtual
QString
errorString
()
const
=
0
;
virtual
QByteArray
readAllStandardError
()
=
0
;
...
...
@@ -66,18 +63,35 @@ public:
virtual
void
setEnvironment
(
const
QStringList
&
env
)
=
0
;
virtual
bool
isAdapter
()
const
=
0
;
virtual
void
attach
()
=
0
;
virtual
void
startAdapter
(
const
DebuggerStartParametersPtr
&
sp
)
=
0
;
virtual
void
prepareInferior
()
=
0
;
virtual
void
startInferior
()
=
0
;
virtual
void
shutdownInferior
()
=
0
;
virtual
void
shutdownAdapter
()
=
0
;
virtual
void
interruptInferior
()
=
0
;
signals:
void
adapterStarted
();
void
adapterStartFailed
(
const
QString
&
msg
);
void
adapterShutDown
();
void
adapterShutdownFailed
(
const
QString
&
msg
);
void
adapterCrashed
();
void
inferiorPrepared
();
void
inferiorPreparationFailed
(
const
QString
&
msg
);
void
inferiorStarted
();
void
inferiorStartFailed
(
const
QString
&
msg
);
void
inferiorShutDown
();
void
inferiorShutdownFailed
(
const
QString
&
msg
);
void
inferiorPidChanged
(
qint64
pid
);
void
error
(
QProcess
::
ProcessError
);
void
started
();
void
readyReadStandardOutput
();
void
readyReadStandardError
();
void
finished
(
int
,
QProcess
::
ExitStatus
);
protected:
GdbEngine
*
m_engine
;
GdbEngine
*
const
m_engine
;
};
}
// namespace Internal
...
...
src/plugins/debugger/gdb/gdb.pri
View file @
1d64e169
...
...
@@ -2,6 +2,7 @@ include(../../../shared/trk/trk.pri)
HEADERS += \
$$PWD/abstractgdbadapter.h \
$$PWD/plaingdbadapter.h \
$$PWD/gdbmi.h \
$$PWD/gdbengine.h \
$$PWD/gdboptionspage.h \
...
...
@@ -14,10 +15,11 @@ SOURCES += \
$$PWD/gdbmi.cpp \
$$PWD/gdbengine.cpp \
$$PWD/gdboptionspage.cpp \
$$PWD/
trk
gdbadapter.cpp \
$$PWD/
plain
gdbadapter.cpp \
$$PWD/trkoptions.cpp \
$$PWD/trkoptionswidget.cpp \
$$PWD/trkoptionspage.cpp
$$PWD/trkoptionspage.cpp \
$$PWD/trkgdbadapter.cpp
FORMS += $$PWD/gdboptionspage.ui \
$$PWD/trkoptionswidget.ui
...
...
src/plugins/debugger/gdb/gdbengine.cpp
View file @
1d64e169
This diff is collapsed.
Click to expand it.
src/plugins/debugger/gdb/gdbengine.h
View file @
1d64e169
...
...
@@ -33,11 +33,8 @@
#include "idebuggerengine.h"
#include "debuggermanager.h" // only for StartParameters
#include "gdbmi.h"
#include "abstractgdbadapter.h"
#include "outputcollector.h"
#include "watchutils.h"
#include <consoleprocess.h>
#include "outputcollector.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
...
...
@@ -45,6 +42,7 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QPoint>
#include <QtCore/QSet>
#include <QtCore/QTextCodec>
#include <QtCore/QTime>
#include <QtCore/QVariant>
...
...
@@ -58,7 +56,7 @@ QT_END_NAMESPACE
namespace
Debugger
{
namespace
Internal
{
class
AbstractGdbAdapter
;
class
DebuggerManager
;
class
IDebuggerManagerAccessForEngines
;
class
GdbResultRecord
;
...
...
@@ -75,52 +73,14 @@ enum DebuggingHelperState
DebuggingHelperUnavailable
,
};
class
PlainGdbAdapter
:
public
AbstractGdbAdapter
{
public:
PlainGdbAdapter
(
QObject
*
parent
=
0
)
:
AbstractGdbAdapter
(
parent
)
{
connect
(
&
m_proc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)));
connect
(
&
m_proc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_proc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_proc
,
SIGNAL
(
started
()),
this
,
SIGNAL
(
started
()));
connect
(
&
m_proc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)));
}
void
start
(
const
QString
&
program
,
const
QStringList
&
args
,
QIODevice
::
OpenMode
mode
)
{
m_proc
.
start
(
program
,
args
,
mode
);
}
void
kill
()
{
m_proc
.
kill
();
}
void
terminate
()
{
m_proc
.
terminate
();
}
bool
waitForStarted
(
int
msecs
)
{
return
m_proc
.
waitForStarted
(
msecs
);
}
bool
waitForFinished
(
int
msecs
)
{
return
m_proc
.
waitForFinished
(
msecs
);
}
QProcess
::
ProcessState
state
()
const
{
return
m_proc
.
state
();
}
QString
errorString
()
const
{
return
m_proc
.
errorString
();
}
QByteArray
readAllStandardError
()
{
return
m_proc
.
readAllStandardError
();
}
QByteArray
readAllStandardOutput
()
{
return
m_proc
.
readAllStandardOutput
();
}
qint64
write
(
const
char
*
data
)
{
return
m_proc
.
write
(
data
);
}
void
setWorkingDirectory
(
const
QString
&
dir
)
{
m_proc
.
setWorkingDirectory
(
dir
);
}
void
setEnvironment
(
const
QStringList
&
env
)
{
m_proc
.
setEnvironment
(
env
);
}
bool
isAdapter
()
const
{
return
false
;
}
void
attach
();
void
interruptInferior
();
private:
QProcess
m_proc
;
};
class
GdbEngine
:
public
IDebuggerEngine
{
Q_OBJECT
public:
GdbEngine
(
DebuggerManager
*
parent
,
AbstractGdbAdapter
*
gdbAdapter
);
explicit
GdbEngine
(
DebuggerManager
*
parent
);
~
GdbEngine
();
void
setGdbAdapter
(
AbstractGdbAdapter
*
adapter
);
signals:
void
gdbInputAvailable
(
int
channel
,
const
QString
&
msg
);
...
...
@@ -145,7 +105,6 @@ private:
void
shutdown
();
void
setToolTipExpression
(
const
QPoint
&
mousePos
,
TextEditor
::
ITextEditor
*
editor
,
int
cursorPos
);
void
startDebugger
(
const
DebuggerStartParametersPtr
&
sp
);
Q_SLOT
void
startDebugger2
();
void
exitDebugger
();
void
exitDebugger2
();
void
detachDebugger
();
...
...
@@ -217,14 +176,20 @@ public: // otherwise the Qt flag macros are unhappy
private:
typedef
void
(
GdbEngine
::*
GdbCommandCallback
)(
const
GdbResultRecord
&
record
,
const
QVariant
&
cookie
);
typedef
void
(
GdbEngine
::*
GdbCommandCallback
)
(
const
GdbResultRecord
&
record
,
const
QVariant
&
cookie
);
typedef
void
(
AbstractGdbAdapter
::*
AdapterCallback
)
(
const
GdbResultRecord
&
record
,
const
QVariant
&
cookie
);
struct
GdbCommand
{
GdbCommand
()
:
flags
(
0
),
callback
(
0
),
callbackName
(
0
)
{}
GdbCommand
()
:
flags
(
0
),
callback
(
0
),
adapterCallback
(
0
),
callbackName
(
0
)
{}
int
flags
;
GdbCommandCallback
callback
;
AdapterCallback
adapterCallback
;
const
char
*
callbackName
;
QString
command
;
QVariant
cookie
;
...
...
@@ -235,7 +200,7 @@ private:
// queue". resultNeeded == true increments m_pendingResults on
// send and decrements on receipt, effectively preventing
// watch model updates before everything is finished.
void
flushCommand
(
GdbCommand
&
cmd
);
void
flushCommand
(
const
GdbCommand
&
cmd
);
void
postCommand
(
const
QString
&
command
,
GdbCommandFlags
flags
,
GdbCommandCallback
callback
=
0
,
...
...
@@ -245,7 +210,11 @@ private:
GdbCommandCallback
callback
=
0
,
const
char
*
callbackName
=
0
,
const
QVariant
&
cookie
=
QVariant
());
void
postCommand
(
const
QString
&
command
,
AdapterCallback
callback
,
const
char
*
callbackName
,
const
QVariant
&
cookie
=
QVariant
());
void
postCommandHelper
(
const
GdbCommand
&
cmd
);
void
setTokenBarrier
();
void
updateLocals
();
...
...
@@ -257,25 +226,36 @@ private slots:
void
readUploadStandardOutput
();
void
readUploadStandardError
();
void
readDebugeeOutput
(
const
QByteArray
&
data
);
void
stubStarted
();
void
stubError
(
const
QString
&
msg
);
void
uploadProcError
(
QProcess
::
ProcessError
error
);
void
emitStartFailed
();
void
handleAdapterStarted
();
void
handleAdapterStartFailed
(
const
QString
&
msg
);
void
handleInferiorPrepared
();
void
handleInferiorPreparationFailed
(
const
QString
&
msg
);
void
handleInferiorStarted
();
void
handleInferiorStartFailed
(
const
QString
&
msg
);
void
handleInferiorShutDown
();
void
handleInferiorShutdownFailed
(
const
QString
&
msg
);
void
handleAdapterShutDown
();
void
handleAdapterShutdownFailed
(
const
QString
&
msg
);
private:
int
terminationIndex
(
const
QByteArray
&
buffer
,
int
&
length
);
void
handleResponse
(
const
QByteArray
&
buff
);
void
handleStart
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
void
handleAttach
(
const
GdbResultRecord
&
,
const
QVariant
&
);
void
handleStubAttached
(
const
GdbResultRecord
&
,
const
QVariant
&
);
void
handleAqcuiredInferior
();
void
handleAsyncOutput2
(
const
GdbResultRecord
&
,
const
QVariant
&
cookie
);
void
handleAsyncOutput2
(
const
GdbMi
&
data
);
void
handleAsyncOutput
(
const
GdbMi
&
data
);
void
handleStop1
(
const
GdbResultRecord
&
,
const
QVariant
&
cookie
);
void
handleStop2
(
const
GdbResultRecord
&
,
const
QVariant
&
cookie
);
void
handleStop2
(
const
GdbMi
&
data
);
void
handleResultRecord
(
const
GdbResultRecord
&
response
);
void
handleFileExecAndSymbols
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
void
handleExecContinue
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
void
handleExecRun
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
//
void handleExecRun(const GdbResultRecord &response, const QVariant &);
void
handleExecJumpToLine
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
void
handleExecRunToFunction
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
void
handleInfoShared
(
const
GdbResultRecord
&
response
,
const
QVariant
&
);
...
...
@@ -306,7 +286,6 @@ private:
QList
<
WatchData
>
*
insertions
);
const
bool
m_dumperInjectionLoad
;
OutputCollector
m_outputCollector
;
QTextCodec
*
m_outputCodec
;
QTextCodec
::
ConverterState
m_outputCodecState
;
...
...
@@ -315,8 +294,6 @@ private:
AbstractGdbAdapter
*
m_gdbAdapter
;
QProcess
m_uploadProc
;
Core
::
Utils
::
ConsoleProcess
m_stubProc
;
QHash
<
int
,
GdbCommand
>
m_cookieForToken
;
QHash
<
int
,
QByteArray
>
m_customOutputForToken
;
...
...
@@ -448,7 +425,11 @@ private:
QString
m_currentFrame
;
QMap
<
QString
,
QString
>
m_varToType
;
bool
m_autoContinue
;
typedef
void
(
GdbEngine
::*
Continuation
)();
// function called after all previous responses have been received
Continuation
m_continuationAfterDone
;
void
handleInitialBreakpointsSet
();
bool
m_waitingForFirstBreakpointToBeHit
;
bool
m_modulesListOutdated
;
...
...
@@ -458,6 +439,8 @@ private:
IDebuggerManagerAccessForEngines
*
const
qq
;
DebuggerStartParametersPtr
m_startParameters
;
// make sure to re-initialize new members in initializeVariables();
public:
OutputCollector
m_outputCollector
;
};
}
// namespace Internal
...
...
src/plugins/debugger/gdb/plaingdbadapter.cpp
0 → 100644
View file @
1d64e169
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** 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
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "plaingdbadapter.h"
#include "debuggeractions.h"
#include "gdbengine.h"
#include "procinterrupt.h"
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <QtCore/QFileInfo>
#include <QtGui/QMessageBox>
namespace
Debugger
{
namespace
Internal
{
#define STRINGIFY_INTERNAL(x) #x
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
#define CB(callback) \
static_cast<GdbEngine::AdapterCallback>(&PlainGdbAdapter::callback), \
STRINGIFY(callback)
///////////////////////////////////////////////////////////////////////
//
// PlainGdbAdapter
//
///////////////////////////////////////////////////////////////////////
PlainGdbAdapter
::
PlainGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
AbstractGdbAdapter
(
engine
,
parent
)
{
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SIGNAL
(
adapterStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleFinished
(
int
,
QProcess
::
ExitStatus
)));
m_stubProc
.
setMode
(
Core
::
Utils
::
ConsoleProcess
::
Debug
);
#ifdef Q_OS_UNIX
m_stubProc
.
setSettings
(
Core
::
ICore
::
instance
()
->
settings
());
#endif
connect
(
&
m_stubProc
,
SIGNAL
(
processError
(
QString
)),
this
,
SLOT
(
stubError
(
QString
)));
connect
(
&
m_stubProc
,
SIGNAL
(
processStarted
()),
this
,
SLOT
(
stubStarted
()));
// FIXME:
// connect(&m_stubProc, SIGNAL(wrapperStopped()),
// m_manager, SLOT(exitDebugger()));
}
void
PlainGdbAdapter
::
startAdapter
(
const
DebuggerStartParametersPtr
&
sp
)
{
debugMessage
(
_
(
"TRYING TO START ADAPTER"
));
m_startParameters
=
sp
;
QStringList
gdbArgs
;
gdbArgs
.
prepend
(
_
(
"mi"
));
gdbArgs
.
prepend
(
_
(
"-i"
));
if
(
m_startParameters
->
useTerminal
)
{
m_stubProc
.
stop
();
// We leave the console open, so recycle it now.
m_stubProc
.
setWorkingDirectory
(
m_startParameters
->
workingDir
);
m_stubProc
.
setEnvironment
(
m_startParameters
->
environment
);
if
(
!
m_stubProc
.
start
(
m_startParameters
->
executable
,
m_startParameters
->
processArgs
))
{
// Error message for user is delivered via a signal.
emitAdapterStartFailed
(
QString
());
return
;
}
}
else
{
if
(
!
m_engine
->
m_outputCollector
.
listen
())
{
emitAdapterStartFailed
(
tr
(
"Cannot set up communication with child process: %1"
)
.
arg
(
m_engine
->
m_outputCollector
.
errorString
()));
return
;
}
gdbArgs
.
prepend
(
_
(
"--tty="
)
+
m_engine
->
m_outputCollector
.
serverName
());
if
(
!
m_startParameters
->
workingDir
.
isEmpty
())
setWorkingDirectory
(
m_startParameters
->
workingDir
);
if
(
!
m_startParameters
->
environment
.
isEmpty
())
setEnvironment
(
m_startParameters
->
environment
);
}
QString
location
=
theDebuggerStringSetting
(
GdbLocation
);
//showStatusMessage(tr("Starting Debugger: ") + loc + _c(' ') + gdbArgs.join(_(" ")));
m_gdbProc
.
start
(
location
,
gdbArgs
);
}
void
PlainGdbAdapter
::
prepareInferior
()
{
if
(
!
m_startParameters
->
processArgs
.
isEmpty
())
m_engine
->
postCommand
(
_
(
"-exec-arguments "
)
+
m_startParameters
->
processArgs
.
join
(
_
(
" "
)));
QFileInfo
fi
(
m_engine
->
startParameters
().
executable
);
m_engine
->
postCommand
(
_
(
"-file-exec-and-symbols
\"
%1
\"
"
).
arg
(
fi
.
absoluteFilePath
()),
CB
(
handleFileExecAndSymbols
));
}
void
PlainGdbAdapter
::
handleFileExecAndSymbols
(
const
GdbResultRecord
&
response
,
const
QVariant
&
)
{
if
(
response
.
resultClass
==
GdbResultDone
)
{
//m_breakHandler->clearBreakMarkers();
emit
inferiorPrepared
();
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
QString
msg
=
tr
(
"Starting executable failed:
\n
"
)
+
__
(
response
.
data
.
findChild
(
"msg"
).
data
());
emit
inferiorPreparationFailed
(
msg
);
}
}
void
PlainGdbAdapter
::
startInferior
()
{
m_engine
->
postCommand
(
_
(
"-exec-run"
),
CB
(
handleExecRun
));
/*
#ifdef Q_OS_MAC
m_engine->postCommand(_("sharedlibrary apply-load-rules all"));
// On MacOS, breaking in at the entry point wreaks havoc.
m_engine->postCommand(_("tbreak main"));
m_waitingForFirstBreakpointToBeHit = true;
m_engine->postCommand(_("-exec-run"), CB(handleExecRun));
#else
// FIXME:
// if (!m_dumperInjectionLoad)
// m_engine->postCommand(_("set auto-solib-add off"));
m_engine->postCommand(_("info target"), CB(handleInfoTarget));
#endif
*/
}
void
PlainGdbAdapter
::
handleInfoTarget
(
const
GdbResultRecord
&
response
,
const
QVariant
&
)
{
#if defined(Q_OS_MAC)
Q_UNUSED
(
response
)
#else
if
(
response
.
resultClass
==
GdbResultDone
)
{
// [some leading stdout here]
// >&" Entry point: 0x80831f0 0x08048134 - 0x08048147 is .interp\n"
// [some trailing stdout here]
QString
msg
=
_
(
response
.
data
.
findChild
(
"consolestreamoutput"
).
data
());
QRegExp
needle
(
_
(
"
\\
bEntry point: (0x[0-9a-f]+)
\\
b"
));
if
(
needle
.
indexIn
(
msg
)
!=
-
1
)
{
//debugMessage(_("STREAM: ") + msg + " " + needle.cap(1));
m_engine
->
postCommand
(
_
(
"tbreak *"
)
+
needle
.
cap
(
1
));
// FIXME: m_waitingForFirstBreakpointToBeHit = true;
m_engine
->
postCommand
(
_
(
"-exec-run"
),
CB
(
handleExecRun
));
}
else
{
debugMessage
(
_
(
"PARSING START ADDRESS FAILED: "
)
+
msg
);
emit
inferiorStartFailed
(
_
(
"Parsing start address failed"
));
}
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
debugMessage
(
_
(
"FETCHING START ADDRESS FAILED: "
+
response
.
toString
()));
emit
inferiorStartFailed
(
_
(
"Fetching start address failed"
));
}
#endif
}
void
PlainGdbAdapter
::
handleExecRun
(
const
GdbResultRecord
&
response
,
const
QVariant
&
)
{
if
(
response
.
resultClass
==
GdbResultRunning
)
{
emit
inferiorStarted
();
}
else
{
QTC_ASSERT
(
response
.
resultClass
==
GdbResultError
,
/**/
);
const
QByteArray
&
msg
=
response
.
data
.
findChild
(
"msg"
).
data
();
//QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
//interruptInferior();
emit
inferiorStartFailed
(
msg
);
}
}
void
PlainGdbAdapter
::
interruptInferior
()
{
debugMessage
(
_
(
"TRYING TO INTERUPT INFERIOR"
));
if
(
m_engine
->
startMode
()
==
StartRemote
)
{
m_engine
->
postCommand
(
_
(
"-exec-interrupt"
));
return
;
}
const
qint64
attachedPID
=
m_engine
->
inferiorPid
();
if
(
attachedPID
<=
0
)
{
debugMessage
(
_
(
"TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED"
));
return
;
}
if
(
!
interruptProcess
(
attachedPID
))
debugMessage
(
_
(
"CANNOT INTERRUPT %1"
).
arg
(
attachedPID
));
}
void
PlainGdbAdapter
::
shutdownAdapter
()
{
m_engine
->
postCommand
(
_
(
"-gdb-exit"
),
CB
(
handleExit
));
// 20s can easily happen when loading webkit debug information
if
(
!
m_gdbProc
.
waitForFinished
(
20000
))
{
debugMessage
(
_
(
"FORCING TERMINATION: %1"
)
.
arg
(
state
()));
m_gdbProc
.
terminate
();
m_gdbProc
.
waitForFinished
(
20000
);
}
if
(
state
()
!=
QProcess
::
NotRunning
)
{
debugMessage
(
_
(
"PROBLEM STOPPING DEBUGGER: STATE %1"
)
.
arg
(
state
()));
m_gdbProc
.
kill
();
}
}
void
PlainGdbAdapter
::
handleExit
(
const
GdbResultRecord
&
response
,
const
QVariant
&
)
{
if
(
response
.
resultClass
==
GdbResultDone
)
{
emit
adapterShutDown
();
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
QString
msg
=
tr
(
"Gdb process could not be stopped:
\n
"
)
+
__
(
response
.
data
.
findChild
(
"msg"
).
data
());
emit
adapterShutdownFailed
(
msg
);
}
}
void
PlainGdbAdapter
::
handleFinished
(
int
,
QProcess
::
ExitStatus
)
{
debugMessage
(
_
(
"GDB PROESS FINISHED"
));
}
void
PlainGdbAdapter
::
shutdownInferior
()
{
m_engine
->
postCommand
(
_
(
"kill"
));
}
void
PlainGdbAdapter
::
stubStarted
()
{
const
qint64
attachedPID
=
m_stubProc
.
applicationPID
();
emit
inferiorPidChanged
(
attachedPID
);
m_engine
->
postCommand
(
_
(
"attach %1"
).
arg
(
attachedPID
),
CB
(
handleStubAttached
));
}
void
PlainGdbAdapter
::
handleStubAttached
(
const
GdbResultRecord
&
,
const
QVariant
&
)
{
qDebug
()
<<
"STUB ATTACHED, FIXME"
;
//qq->notifyInferiorStopped();
//handleAqcuiredInferior();
// FIXME: m_autoContinue = true;
}
void
PlainGdbAdapter
::
stubError
(
const
QString
&
msg
)
{
QMessageBox
::
critical
(
m_engine
->
mainWindow
(),
tr
(
"Debugger Error"
),
msg
);
}
void
PlainGdbAdapter
::
emitAdapterStartFailed
(
const
QString
&
msg
)
{
// QMessageBox::critical(mainWindow(), tr("Debugger Startup Failure"),
// tr("Cannot start debugger: %1").arg(m_gdbAdapter->errorString()));
m_stubProc
.
blockSignals
(
true
);
m_stubProc
.
stop
();
m_stubProc
.
blockSignals
(
false
);
emit
adapterStartFailed
(
msg
);
}
}
// namespace Internal
}
// namespace Debugger
src/plugins/debugger/gdb/plaingdbadapter.h
0 → 100644
View file @
1d64e169
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**