diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index a6c6390bd49..db1b5f8b3d6 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -92,12 +92,20 @@ void AttachGdbAdapter::runEngine() void AttachGdbAdapter::handleAttach(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); - if (response.resultClass == GdbResultDone || response.resultClass == GdbResultRunning) { + switch (response.resultClass) { + case GdbResultDone: + case GdbResultRunning: showMessage(_("INFERIOR ATTACHED")); showMessage(msgAttachedToStoppedInferior(), StatusBar); m_engine->handleInferiorPrepared(); - //m_engine->updateAll(); - } else { + break; + case GdbResultError: + if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { + m_engine->notifyInferiorSetupFailed(DumperHelper::msgPtraceErr(startParameters().startMode)); + break; + } + // if msg != "ptrace: ..." fall through + default: QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); m_engine->notifyInferiorSetupFailed(msg); } diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index adebbc6af17..b3ab4e6ef0d 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -113,6 +113,24 @@ QString DumperHelper::msgDumperOutdated(double requiredVersion, double currentVe arg(currentVersion).arg(requiredVersion); } +QString DumperHelper::msgPtraceError(DebuggerStartMode sm) +{ + if (sm == StartInternal) { + return QCoreApplication::translate("QtDumperHelper", + "ptrace: Operation not permitted.\n\n" + "Could not attach to the process. Check the settings of\n" + "/proc/sys/kernel/yama/ptrace_scope\n" + "For more details, see/etc/sysctl.d/10-ptrace.conf\n"); + } else { + return QCoreApplication::translate("QtDumperHelper", + "ptrace: Operation not permitted.\n\n" + "Could not attach to the process. If your uid matches the uid\n" + "of the target process, check the settings of\n" + "/proc/sys/kernel/yama/ptrace_scope\n" + "For more details, see/etc/sysctl.d/10-ptrace.conf\n"); + } +} + static inline void formatQtVersion(int v, QTextStream &str) { str << ((v >> 16) & 0xFF) << '.' << ((v >> 8) & 0xFF) << '.' << (v & 0xFF); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index a0a5870ba31..7467e1d21bc 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -167,6 +167,7 @@ public: QString toString(bool debug = false) const; static QString msgDumperOutdated(double requiredVersion, double currentVersion); + static QString msgPtraceErr(DebuggerStartMode sm); private: typedef QMap NameTypeMap; diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index a78f8dde2ba..4b18867b3ce 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -164,6 +164,10 @@ void TermGdbAdapter::handleStubAttached(const GdbResponse &response) m_engine->handleInferiorPrepared(); break; case GdbResultError: + if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { + m_engine->notifyInferiorSetupFailed(DumperHelper::msgPtraceErr(startParameters().startMode)); + break; + } m_engine->notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data.findChild("msg").data())); break; default: