GDB: Fix break on main for console applications on Windows

It relies on the user setting (which has a correct default, but can be
changed), but that's better than nothing.

Change-Id: Ib74b348a8932b3522074f122cf939fcb20ccefb8
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2017-04-03 10:33:57 +03:00
committed by Orgad Shaneh
parent 8a4b0aeabf
commit 1bc2610b0b

View File

@@ -146,6 +146,11 @@ static bool isMostlyHarmlessMessage(const QStringRef &msg)
"Invalid argument\\n"; "Invalid argument\\n";
} }
static QString mainFunction(const DebuggerRunParameters &rp)
{
return QLatin1String(rp.toolChainAbi.os() == Abi::WindowsOS && !rp.useTerminal ? "qMain" : "main");
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
// Debuginfo Taskhandler // Debuginfo Taskhandler
@@ -2371,10 +2376,8 @@ QString GdbEngine::breakpointLocation(const BreakpointParameters &data)
return QLatin1String("__cxa_throw"); return QLatin1String("__cxa_throw");
if (data.type == BreakpointAtCatch) if (data.type == BreakpointAtCatch)
return QLatin1String("__cxa_begin_catch"); return QLatin1String("__cxa_begin_catch");
if (data.type == BreakpointAtMain) { if (data.type == BreakpointAtMain)
const Abi abi = runParameters().toolChainAbi; return mainFunction(runParameters());
return QLatin1String(abi.os() == Abi::WindowsOS ? "qMain" : "main");
}
if (data.type == BreakpointByFunction) if (data.type == BreakpointByFunction)
return '"' + data.functionName + '"'; return '"' + data.functionName + '"';
if (data.type == BreakpointByAddress) if (data.type == BreakpointByAddress)
@@ -4150,11 +4153,8 @@ void GdbEngine::handleInferiorPrepared()
} }
//runCommand("set follow-exec-mode new"); //runCommand("set follow-exec-mode new");
if (rp.breakOnMain) { if (rp.breakOnMain)
QString cmd = "tbreak "; runCommand({"tbreak " + mainFunction(rp)});
cmd += QLatin1String(rp.toolChainAbi.os() == Abi::WindowsOS ? "qMain" : "main");
runCommand({cmd});
}
// Initial attempt to set breakpoints. // Initial attempt to set breakpoints.
if (rp.startMode != AttachCore) { if (rp.startMode != AttachCore) {