Commit fad45991 authored by David Schulz's avatar David Schulz Committed by hjk
Browse files

added a detailed error description if ptrace is not permitted



Change-Id: I555fddcabdd2311e55907073c15d5627d3283a73
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 34933799
......@@ -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);
}
......
......@@ -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);
......
......@@ -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<QByteArray, Type> NameTypeMap;
......
......@@ -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:
......
Supports Markdown
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