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
e4a9d85c
Commit
e4a9d85c
authored
Feb 16, 2009
by
hjk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes: debugger: work on shutdown
parent
137ba736
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
73 deletions
+62
-73
src/plugins/debugger/debuggermanager.cpp
src/plugins/debugger/debuggermanager.cpp
+7
-35
src/plugins/debugger/debuggermanager.h
src/plugins/debugger/debuggermanager.h
+0
-2
src/plugins/debugger/debuggerrunner.cpp
src/plugins/debugger/debuggerrunner.cpp
+7
-1
src/plugins/debugger/debuggerrunner.h
src/plugins/debugger/debuggerrunner.h
+3
-0
src/plugins/debugger/gdbengine.cpp
src/plugins/debugger/gdbengine.cpp
+44
-35
src/plugins/debugger/gdbengine.h
src/plugins/debugger/gdbengine.h
+1
-0
No files found.
src/plugins/debugger/debuggermanager.cpp
View file @
e4a9d85c
...
...
@@ -150,7 +150,6 @@ void DebuggerManager::init()
{
m_status
=
-
1
;
m_busy
=
false
;
m_shutdown
=
false
;
m_attachedPID
=
0
;
m_startMode
=
startInternal
;
...
...
@@ -578,7 +577,7 @@ void DebuggerManager::notifyInferiorExited()
void
DebuggerManager
::
notifyInferiorPidChanged
(
int
pid
)
{
//QMessageBox::warning(0, "PID", "PID: " + QString::number(pid));
qDebug
()
<<
"PID: "
<<
pid
;
//
qDebug() << "PID: " << pid;
emit
inferiorPidChanged
(
pid
);
}
...
...
@@ -590,9 +589,10 @@ void DebuggerManager::showApplicationOutput(const QString &str)
void
DebuggerManager
::
shutdown
()
{
//qDebug() << "DEBUGGER_MANAGER SHUTDOWN START";
m_shutdown
=
true
;
if
(
m_engine
)
if
(
m_engine
)
{
//qDebug() << "SHUTTING DOWN ENGINE" <<
m_engine
;
m_engine
->
shutdown
();
}
m_engine
=
0
;
delete
scriptEngine
;
...
...
@@ -835,10 +835,9 @@ void DebuggerManager::cleanupViews()
void
DebuggerManager
::
exitDebugger
()
{
if
(
m_shutdown
)
return
;
QTC_ASSERT
(
m_engine
,
return
);
m_engine
->
exitDebugger
();
//qDebug() << "DebuggerManager::exitDebugger";
if
(
m_engine
)
m_engine
->
exitDebugger
();
cleanupViews
();
setStatus
(
DebuggerProcessNotReady
);
setBusyCursor
(
false
);
...
...
@@ -960,33 +959,6 @@ void DebuggerManager::dumpLog()
ts
<<
m_outputWindow
->
combinedContents
();
}
#if 0
// call after m_gdbProc exited.
void GdbEngine::procFinished()
{
//qDebug() << "GDB PROCESS FINISHED";
setStatus(DebuggerProcessNotReady);
showStatusMessage(tr("Done"), 5000);
q->m_breakHandler->procFinished();
q->m_watchHandler->cleanup();
m_stackHandler->m_stackFrames.clear();
m_stackHandler->resetModel();
m_threadsHandler->resetModel();
if (q->m_modulesHandler)
q->m_modulesHandler->procFinished();
q->resetLocation();
setStatus(DebuggerProcessNotReady);
emit q->previousModeRequested();
emit q->debuggingFinished();
//exitDebugger();
//showStatusMessage("Gdb killed");
m_shortToFullName.clear();
m_fullToShortName.clear();
m_shared = 0;
q->m_busy = false;
}
#endif
void
DebuggerManager
::
addToWatchWindow
()
{
// requires a selection, but that's the only case we want...
...
...
src/plugins/debugger/debuggermanager.h
View file @
e4a9d85c
...
...
@@ -466,8 +466,6 @@ private:
IDebuggerEngine
*
engine
();
IDebuggerEngine
*
m_engine
;
DebuggerSettings
m_settings
;
// set during application shutdown
bool
m_shutdown
;
};
}
// namespace Internal
...
...
src/plugins/debugger/debuggerrunner.cpp
View file @
e4a9d85c
...
...
@@ -115,6 +115,8 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
connect
(
m_manager
,
SIGNAL
(
inferiorPidChanged
(
qint64
)),
this
,
SLOT
(
bringApplicationToForeground
(
qint64
)),
Qt
::
QueuedConnection
);
connect
(
this
,
SIGNAL
(
stopRequested
()),
m_manager
,
SLOT
(
exitDebugger
()));
}
void
DebuggerRunControl
::
start
()
...
...
@@ -148,17 +150,21 @@ void DebuggerRunControl::slotAddToOutputWindowInline(const QString &data)
void
DebuggerRunControl
::
stop
()
{
m_manager
->
exitDebugger
();
//qDebug() << "DebuggerRunControl::stop";
m_running
=
false
;
emit
stopRequested
();
}
void
DebuggerRunControl
::
debuggingFinished
()
{
m_running
=
false
;
//qDebug() << "DebuggerRunControl::finished";
//emit addToOutputWindow(this, tr("Debugging %1 finished").arg(m_executable));
emit
finished
();
}
bool
DebuggerRunControl
::
isRunning
()
const
{
//qDebug() << "DebuggerRunControl::isRunning" << m_running;
return
m_running
;
}
src/plugins/debugger/debuggerrunner.h
View file @
e4a9d85c
...
...
@@ -82,6 +82,9 @@ public:
virtual
void
stop
();
virtual
bool
isRunning
()
const
;
signals:
void
stopRequested
();
private
slots
:
void
debuggingFinished
();
void
slotAddToOutputWindowInline
(
const
QString
&
output
);
...
...
src/plugins/debugger/gdbengine.cpp
View file @
e4a9d85c
...
...
@@ -257,6 +257,8 @@ GdbEngine::GdbEngine(DebuggerManager *parent)
GdbEngine
::~
GdbEngine
()
{
// prevent sending error messages afterwards
m_gdbProc
.
disconnect
(
this
);
}
void
GdbEngine
::
initializeConnections
()
...
...
@@ -386,6 +388,11 @@ void GdbEngine::readDebugeeOutput(const QByteArray &data)
data
.
constData
(),
data
.
length
(),
&
m_outputCodecState
));
}
void
GdbEngine
::
debugMessage
(
const
QString
&
msg
)
{
emit
gdbOutputAvailable
(
"debug:"
,
msg
);
}
// called asyncronously as response to Gdb stdout output in
// gdbResponseAvailable()
void
GdbEngine
::
handleResponse
()
...
...
@@ -656,7 +663,7 @@ void GdbEngine::interruptInferior()
sendCommand
(
"-exec-interrupt"
,
GdbExecInterrupt
);
qq
->
notifyInferiorStopped
();
#else
qD
ebug
()
<<
"CANNOT STOP INFERIOR
"
<<
m_gdbProc
.
pid
();
d
ebug
Message
(
QString
(
"CANNOT STOP INFERIOR
%1"
).
arg
(
m_gdbProc
.
pid
()
))
;
if
(
interruptChildProcess
(
m_gdbProc
.
pid
()))
qq
->
notifyInferiorStopped
();
#endif
...
...
@@ -666,12 +673,12 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0)
{
int
pid
=
pid0
.
toInt
();
if
(
pid
==
0
)
{
qD
ebug
()
<<
"Cannot parse PID from
"
<<
pid0
;
d
ebug
Message
(
QString
(
"Cannot parse PID from
%1"
).
arg
(
pid0
))
;
return
;
}
if
(
pid
==
q
->
m_attachedPID
)
return
;
qD
ebug
()
<<
"FOUND PID
"
<<
pid
;
d
ebug
Message
(
QString
(
"FOUND PID
%1"
).
arg
(
pid
))
;
q
->
m_attachedPID
=
pid
;
qq
->
notifyInferiorPidChanged
(
pid
);
}
...
...
@@ -686,7 +693,7 @@ void GdbEngine::sendCommand(const QString &command, int type,
const
QVariant
&
cookie
,
bool
needStop
,
bool
synchronized
)
{
if
(
m_gdbProc
.
state
()
==
QProcess
::
NotRunning
)
{
//qDebug() <<
"NO GDB PROCESS RUNNING, CMD IGNORED:"
<<
command;
debugMessage
(
"NO GDB PROCESS RUNNING, CMD IGNORED:
"
+
command
)
;
return
;
}
...
...
@@ -718,9 +725,7 @@ void GdbEngine::sendCommand(const QString &command, int type,
m_cookieForToken
[
currentToken
()]
=
cmd
;
//qDebug() << "";
if
(
!
command
.
isEmpty
())
{
//qDebug() << qPrintable(currentTime()) << "RUNNING" << cmd.command;
m_gdbProc
.
write
(
cmd
.
command
.
toLatin1
()
+
"
\r\n
"
);
//emit gdbInputAvailable(QString(), " " + currentTime());
//emit gdbInputAvailable(QString(), "[" + currentTime() + "] " + cmd.command);
...
...
@@ -920,8 +925,8 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type,
break
;
default:
qD
ebug
()
<<
"FIXME: GdbEngine::handleResult: "
"should not happen
"
<<
type
;
d
ebug
Message
(
QString
(
"FIXME: GdbEngine::handleResult: "
"should not happen
%1"
).
arg
(
type
))
;
break
;
}
}
...
...
@@ -930,7 +935,7 @@ void GdbEngine::executeDebuggerCommand(const QString &command)
{
//createGdbProcessIfNeeded();
if
(
m_gdbProc
.
state
()
==
QProcess
::
NotRunning
)
{
qD
ebug
()
<<
"NO GDB PROCESS RUNNING, PLAIN CMD IGNORED: "
<<
command
;
d
ebug
Message
(
"NO GDB PROCESS RUNNING, PLAIN CMD IGNORED: "
+
command
)
;
return
;
}
...
...
@@ -938,11 +943,6 @@ void GdbEngine::executeDebuggerCommand(const QString &command)
cmd
.
command
=
command
;
cmd
.
type
=
-
1
;
//m_cookieForToken[currentToken()] = cmd;
//++currentToken();
//qDebug() << "";
//qDebug() << currentTime() << "Running command: " << cmd.command;
emit
gdbInputAvailable
(
QString
(),
cmd
.
command
);
m_gdbProc
.
write
(
cmd
.
command
.
toLatin1
()
+
"
\r\n
"
);
}
...
...
@@ -969,7 +969,7 @@ void GdbEngine::handleQueryPwd(const GdbResultRecord &record)
m_pwd
=
record
.
data
.
findChild
(
"consolestreamoutput"
).
data
();
m_pwd
=
m_pwd
.
trimmed
();
#endif
//qDebug() <<
"PWD RESULT:"
<<
m_pwd;
debugMessage
(
"PWD RESULT:
"
+
m_pwd
)
;
}
}
...
...
@@ -1146,8 +1146,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
QString
msg
=
data
.
findChild
(
"consolestreamoutput"
).
data
();
if
(
msg
.
contains
(
"Stopped due to shared library event"
)
||
reason
.
isEmpty
())
{
if
(
qq
->
wantsSelectedPluginBreakpoints
())
{
qD
ebug
()
<<
"SHARED LIBRARY EVENT "
<<
data
.
toString
();
qD
ebug
()
<<
"PATTERN
"
<<
qq
->
selectedPluginBreakpointsPattern
();
d
ebug
Message
(
"SHARED LIBRARY EVENT
:
"
+
data
.
toString
()
)
;
d
ebug
Message
(
"PATTERN
: "
+
qq
->
selectedPluginBreakpointsPattern
()
)
;
sendCommand
(
"sharedlibrary "
+
qq
->
selectedPluginBreakpointsPattern
());
continueInferior
();
q
->
showStatusMessage
(
tr
(
"Loading %1..."
).
arg
(
QString
(
data
.
toString
())));
...
...
@@ -1182,6 +1182,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
+
data
.
findChild
(
"signal-name"
).
toString
();
}
q
->
showStatusMessage
(
msg
);
// FIXME: shouldn't this use a statis change?
debugMessage
(
"CALLING PARENT EXITDEBUGGER"
);
q
->
exitDebugger
();
return
;
}
...
...
@@ -1193,21 +1195,21 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
if
(
qq
->
skipKnownFrames
())
{
if
(
reason
==
"end-stepping-range"
||
reason
==
"function-finished"
)
{
GdbMi
frame
=
data
.
findChild
(
"frame"
);
//
qD
ebug
() <<
frame.toString();
//
d
ebug
Message(
frame.toString()
)
;
m_currentFrame
=
frame
.
findChild
(
"addr"
).
data
()
+
'%'
+
frame
.
findChild
(
"func"
).
data
()
+
'%'
;
QString
funcName
=
frame
.
findChild
(
"func"
).
data
();
QString
fileName
=
frame
.
findChild
(
"file"
).
data
();
if
(
isLeavableFunction
(
funcName
,
fileName
))
{
//
qD
ebug
() <<
"LEAVING"
<<
funcName;
//
d
ebug
Message(
"LEAVING"
+
funcName
)
;
++
stepCounter
;
q
->
stepOutExec
();
//stepExec();
return
;
}
if
(
isSkippableFunction
(
funcName
,
fileName
))
{
//
qD
ebug
() <<
"SKIPPING"
<<
funcName;
//
d
ebug
Message(
"SKIPPING"
+
funcName
)
;
++
stepCounter
;
q
->
stepExec
();
return
;
...
...
@@ -1227,7 +1229,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
if
(
reason
==
"breakpoint-hit"
)
{
q
->
showStatusMessage
(
tr
(
"Stopped at breakpoint"
));
GdbMi
frame
=
data
.
findChild
(
"frame"
);
//
qD
ebug
() <<
"HIT BREAKPOINT: "
<<
frame.toString();
//
d
ebug
Message(
"HIT BREAKPOINT: "
+
frame.toString()
)
;
m_currentFrame
=
frame
.
findChild
(
"addr"
).
data
()
+
'%'
+
frame
.
findChild
(
"func"
).
data
()
+
'%'
;
...
...
@@ -1243,7 +1245,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
return
;
}
qD
ebug
()
<<
"STOPPED FOR UNKNOWN REASON
"
<<
data
.
toString
();
d
ebug
Message
(
"STOPPED FOR UNKNOWN REASON
: "
+
data
.
toString
()
)
;
// Ignore it. Will be handled with full response later in the
// JumpToLine or RunToFunction handlers
#if 1
...
...
@@ -1310,7 +1312,7 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response)
QString
msg
=
response
.
data
.
findChild
(
"consolestreamoutput"
).
data
();
QRegExp
supported
(
"GNU gdb(.*) (
\\
d+)
\\
.(
\\
d+)(
\\
.(
\\
d+))?"
);
if
(
supported
.
indexIn
(
msg
)
==
-
1
)
{
qD
ebug
()
<<
"UNSUPPORTED GDB VERSION "
<<
msg
;
d
ebug
Message
(
"UNSUPPORTED GDB VERSION "
+
msg
)
;
QStringList
list
=
msg
.
split
(
"
\n
"
);
while
(
list
.
size
()
>
2
)
list
.
removeLast
();
...
...
@@ -1331,7 +1333,7 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response)
m_gdbVersion
=
10000
*
supported
.
cap
(
2
).
toInt
()
+
100
*
supported
.
cap
(
3
).
toInt
()
+
1
*
supported
.
cap
(
5
).
toInt
();
//
qD
ebug
() <<
"GDB VERSION
" <<
m_gdbVersion;
//
d
ebug
Message(QString(
"GDB VERSION
: %1").arg(
m_gdbVersion
))
;
}
}
}
...
...
@@ -1387,7 +1389,7 @@ QString GdbEngine::fullName(const QString &fileName)
if
(
fileName
.
isEmpty
())
return
QString
();
QString
full
=
m_shortToFullName
.
value
(
fileName
,
QString
());
//
qD
ebug
() <<
"RESOLVING: "
<<
fileName
<<
full;
//
d
ebug
Message(
"RESOLVING: "
+
fileName
+ " " +
full
)
;
if
(
!
full
.
isEmpty
())
return
full
;
QFileInfo
fi
(
fileName
);
...
...
@@ -1397,7 +1399,7 @@ QString GdbEngine::fullName(const QString &fileName)
#ifdef Q_OS_WIN
full
=
QDir
::
cleanPath
(
full
);
#endif
//
qD
ebug
() <<
"STORING: "
<<
fileName
<<
full;
//
d
ebug
Message(
"STORING: "
+
fileName
+ " " +
full
)
;
m_shortToFullName
[
fileName
]
=
full
;
m_fullToShortName
[
full
]
=
fileName
;
return
full
;
...
...
@@ -1425,22 +1427,29 @@ void GdbEngine::shutdown()
void
GdbEngine
::
exitDebugger
()
{
//qDebug() << "EXITING: " << m_gdbProc.state();
if
(
m_gdbProc
.
state
()
==
QProcess
::
Starting
)
debugMessage
(
QString
(
"GDBENGINE EXITDEBUFFER: %1"
).
arg
(
m_gdbProc
.
state
()));
if
(
m_gdbProc
.
state
()
==
QProcess
::
Starting
)
{
debugMessage
(
QString
(
"WAITING FOR GDB STARTUP TO SHUTDOWN: %1"
)
.
arg
(
m_gdbProc
.
state
()));
m_gdbProc
.
waitForStarted
();
}
if
(
m_gdbProc
.
state
()
==
QProcess
::
Running
)
{
debugMessage
(
QString
(
"WAITING FOR RUNNING GDB TO SHUTDOWN: %1"
)
.
arg
(
m_gdbProc
.
state
()));
interruptInferior
();
sendCommand
(
"kill"
);
sendCommand
(
"-gdb-exit"
);
// 20s can easily happen when loading webkit debug information
m_gdbProc
.
waitForFinished
(
20000
);
if
(
m_gdbProc
.
state
()
!=
QProcess
::
Running
)
{
debugMessage
(
QString
(
"FORCING TERMINATION: %1"
)
.
arg
(
m_gdbProc
.
state
()));
m_gdbProc
.
terminate
();
m_gdbProc
.
waitForFinished
(
20000
);
}
}
if
(
m_gdbProc
.
state
()
!=
QProcess
::
NotRunning
)
qD
ebug
()
<<
"PROBLEM STOPPING DEBUGGER"
;
d
ebug
Message
(
"PROBLEM STOPPING DEBUGGER"
)
;
m_outputCollector
.
shutdown
();
initializeVariables
();
...
...
@@ -1462,7 +1471,7 @@ bool GdbEngine::startDebugger()
QString
fileName
=
'"'
+
fi
.
absoluteFilePath
()
+
'"'
;
if
(
m_gdbProc
.
state
()
!=
QProcess
::
NotRunning
)
{
qD
ebug
()
<<
"GDB IS ALREADY RUNNING!"
;
d
ebug
Message
(
"GDB IS ALREADY RUNNING!"
)
;
return
false
;
}
...
...
@@ -1636,16 +1645,16 @@ void GdbEngine::handleStart(const GdbResultRecord &response)
QString
msg
=
response
.
data
.
findChild
(
"consolestreamoutput"
).
data
();
QRegExp
needle
(
"0x([0-9a-f]+) <"
+
startSymbolName
()
+
"
\\
+.*>:"
);
if
(
needle
.
indexIn
(
msg
)
!=
-
1
)
{
//
qD
ebug
() <<
"STREAM: "
<<
msg
<<
needle.cap(1);
//
d
ebug
Message(
"STREAM: "
+
msg
+ " " +
needle.cap(1)
)
;
sendCommand
(
"tbreak *0x"
+
needle
.
cap
(
1
));
m_waitingForFirstBreakpointToBeHit
=
true
;
sendCommand
(
"-exec-run"
);
qq
->
notifyInferiorRunningRequested
();
}
else
{
qD
ebug
()
<<
"PARSING START ADDRESS FAILED
"
<<
msg
;
d
ebug
Message
(
"PARSING START ADDRESS FAILED
: "
+
msg
)
;
}
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
qDebug
()
<<
"PARSING START ADDRESS FAILED
"
<<
response
.
toString
();
debugMessage
(
"PARSING START ADDRESS FAILED
: "
+
response
.
toString
()
)
;
}
}
...
...
@@ -1740,12 +1749,12 @@ void GdbEngine::setTokenBarrier()
void
GdbEngine
::
setDebugDumpers
(
bool
on
)
{
if
(
on
)
{
qD
ebug
()
<<
"SWITCHING ON DUMPER DEBUGGING"
;
d
ebug
Message
(
"SWITCHING ON DUMPER DEBUGGING"
)
;
sendCommand
(
"set unwindonsignal off"
);
q
->
breakByFunction
(
"qDumpObjectData440"
);
//updateLocals();
}
else
{
qD
ebug
()
<<
"SWITCHING OFF DUMPER DEBUGGING"
;
d
ebug
Message
(
"SWITCHING OFF DUMPER DEBUGGING"
)
;
sendCommand
(
"set unwindonsignal on"
);
}
}
...
...
src/plugins/debugger/gdbengine.h
View file @
e4a9d85c
...
...
@@ -193,6 +193,7 @@ private:
void
handleShowVersion
(
const
GdbResultRecord
&
response
);
void
handleQueryPwd
(
const
GdbResultRecord
&
response
);
void
handleQuerySources
(
const
GdbResultRecord
&
response
);
void
debugMessage
(
const
QString
&
msg
);
OutputCollector
m_outputCollector
;
QTextCodec
*
m_outputCodec
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment