Commit 1bc2610b authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

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