Commit a33bf92b authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

GDB: Set OsAbi also when the executable is ELF and the toolchain is not

If the toolchain is misconfigured, it's still possible to save GDB from
crashing by reading the binary format from the executable.

Change-Id: I8f8db163e1dd6aef31fed23b1306e714e563646a
Reviewed-by: default avatarhjk <>
parent 25f5710d
......@@ -1879,7 +1879,17 @@ void GdbEngine::handleGdbExit(const DebuggerResponse &response)
void GdbEngine::setLinuxOsAbi()
// In case GDB has multiple supported targets, the default osabi can be Cygwin.
if (HostOsInfo::isWindowsHost() && runParameters().toolChainAbi.binaryFormat() == Abi::ElfFormat)
if (!HostOsInfo::isWindowsHost())
const DebuggerRunParameters &rp = runParameters();
bool isElf = (rp.toolChainAbi.binaryFormat() == Abi::ElfFormat);
if (!isElf && !rp.inferior.executable.isEmpty()) {
isElf = Utils::anyOf(Abi::abisOfBinary(FileName::fromString(rp.inferior.executable)),
[](const Abi &abi) {
return abi.binaryFormat() == Abi::ElfFormat;
if (isElf)
runCommand({"set osabi GNU/Linux"});
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