diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index 89dd2d5786a..2f0569cd8ee 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -166,8 +166,12 @@ void CoreGdbAdapter::setupInferior() QFileInfo fi(m_executable); const QByteArray sysroot = startParameters().sysroot.toLocal8Bit(); QByteArray path = fi.absoluteFilePath().toLocal8Bit(); - if (!sysroot.isEmpty()) + if (!sysroot.isEmpty()) { m_engine->postCommand("set sysroot " + sysroot); + // sysroot is not enough to correctly locate the sources, so explicitly + // relocate the most likely place for the debug source + m_engine->postCommand("set substitute-path /usr/src " + sysroot + "/usr/src"); + } m_engine->postCommand("-file-exec-and-symbols \"" + path + '"', CB(handleFileExecAndSymbols)); } diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index 174fbb90691..33fa272c1e1 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -180,8 +180,12 @@ void RemoteGdbServerAdapter::setupInferior() m_engine->postCommand("set architecture " + remoteArch); if (!gnuTarget.isEmpty()) m_engine->postCommand("set gnutarget " + gnuTarget); - if (!sysroot.isEmpty()) + if (!sysroot.isEmpty()) { m_engine->postCommand("set sysroot " + sysroot); + // sysroot is not enough to correctly locate the sources, so explicitly + // relocate the most likely place for the debug source + m_engine->postCommand("set substitute-path /usr/src " + sysroot + "/usr/src"); + } if (!searchPath.isEmpty()) m_engine->postCommand("set solib-search-path " + searchPath); if (!args.isEmpty())