Commit 7ec95338 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

more reliable startup breakpoint handling

instead of picking "random" known entry point symbols, ask the debugger
for the actual entry point.
this also removes the "one instruction after the first one" hack, as it
seems fairly pointless.
NOTE: this does *not* work with the 2005 version of apple gdb.

Conflicts:

	src/plugins/debugger/gdbengine.cpp
parent 4a5137e0
...@@ -234,20 +234,6 @@ static bool isLeavableFunction(const QString &funcName, const QString &fileName) ...@@ -234,20 +234,6 @@ static bool isLeavableFunction(const QString &funcName, const QString &fileName)
return false; return false;
} }
static QString startSymbolName()
{
#ifdef Q_OS_WIN
return "WinMainCRTStartup";
#endif
#ifdef Q_OS_MAC
return "main";
return "_start";
#endif
#ifdef Q_OS_LINUX
return "_start";
#endif
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
...@@ -1679,7 +1665,7 @@ bool GdbEngine::startDebugger() ...@@ -1679,7 +1665,7 @@ bool GdbEngine::startDebugger()
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
sendCommand("set auto-solib-add off"); sendCommand("set auto-solib-add off");
#endif #endif
sendCommand("x/2i " + startSymbolName(), GdbStart); sendCommand("info target", GdbStart);
} }
// set all to "pending" // set all to "pending"
...@@ -1702,19 +1688,14 @@ void GdbEngine::continueInferior() ...@@ -1702,19 +1688,14 @@ void GdbEngine::continueInferior()
void GdbEngine::handleStart(const GdbResultRecord &response) void GdbEngine::handleStart(const GdbResultRecord &response)
{ {
if (response.resultClass == GdbResultDone) { if (response.resultClass == GdbResultDone) {
// stdout:&"x/2i _start\n" // [some leading stdout here]
// stdout:~"0x404540 <_start>:\txor %ebp,%ebp\n" // stdout:&" Entry point: 0x80831f0 0x08048134 - 0x08048147 is .interp\n"
// stdout:~"0x404542 <_start+2>:\tmov %rdx,%r9\n" // [some trailing stdout here]
QString msg = response.data.findChild("consolestreamoutput").data(); QString msg = response.data.findChild("consolestreamoutput").data();
#ifdef Q_OS_MAC QRegExp needle("\\bEntry point: (0x[0-9a-f]+)\\b");
// this ends up in 'gettimeoftheday' or such on MacOS 10.4 if (needle.indexIn(msg) != -1) {
QRegExp needle("0x([0-9a-f]+) <.*\\+.*>:");
#else
QRegExp needle("0x([0-9a-f]+) <" + startSymbolName() + "\\+.*>:");
#endif
if (needle.lastIndexIn(msg) != -1) {
//debugMessage("STREAM: " + msg + " " + needle.cap(1)); //debugMessage("STREAM: " + msg + " " + needle.cap(1));
sendCommand("tbreak *0x" + needle.cap(1)); sendCommand("tbreak *" + needle.cap(1));
m_waitingForFirstBreakpointToBeHit = true; m_waitingForFirstBreakpointToBeHit = true;
qq->notifyInferiorRunningRequested(); qq->notifyInferiorRunningRequested();
sendCommand("-exec-run"); sendCommand("-exec-run");
...@@ -1722,7 +1703,7 @@ void GdbEngine::handleStart(const GdbResultRecord &response) ...@@ -1722,7 +1703,7 @@ void GdbEngine::handleStart(const GdbResultRecord &response)
debugMessage("PARSING START ADDRESS FAILED: " + msg); debugMessage("PARSING START ADDRESS FAILED: " + msg);
} }
} else if (response.resultClass == GdbResultError) { } else if (response.resultClass == GdbResultError) {
debugMessage("PARSING START ADDRESS FAILED: " + response.toString()); debugMessage("FETCHING START ADDRESS FAILED: " + response.toString());
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment