Commit 0f623d54 authored by Peifeng Yu's avatar Peifeng Yu

Reapply some patches to 5.0 that are lost when merging into master

Test Plan: it compiles, and passes all gdb unit tests on my box.

Reviewers: kfunk

Reviewed By: kfunk

Subscribers: kdevelop-devel

Differential Revision: https://phabricator.kde.org/D2292
parent 7c976602
......@@ -26,6 +26,8 @@
#include <KLocalizedString>
#include <algorithm>
using namespace KDevelop;
using namespace KDevMI;
using namespace KDevMI::MI;
......@@ -74,25 +76,26 @@ void MIFrameStackModel::handleThreadInfo(const ResultRecord& r)
{
const Value& threads = r["threads"];
// Traverse GDB threads in backward order -- since GDB
// reports them in backward order. We want UI to
// show thread IDs in the natural order.
// FIXME: at least GDB 7.11 is reporting in the right order,
// consider sort the list afterwards.
QList<KDevelop::FrameStackModel::ThreadItem> threadsList;
int gidx = threads.size()-1;
for (; gidx >= 0; --gidx) {
KDevelop::FrameStackModel::ThreadItem i;
const Value & threadMI = threads[gidx];
i.nr = threadMI["id"].toInt();
QList<FrameStackModel::ThreadItem> threadsList;
for (int i = 0; i!= threads.size(); ++i) {
const auto &threadMI = threads[i];
FrameStackModel::ThreadItem threadItem;
threadItem.nr = threadMI["id"].toInt();
if (threadMI["state"].literal() == "stopped") {
i.name = getFunctionOrAddress(threads[gidx]["frame"]);
threadItem.name = getFunctionOrAddress(threadMI["frame"]);
} else {
i.name = i18n("(running)");
i18n("(running)");
}
threadsList << i;
threadsList << threadItem;
}
// Sort the list by id, some old version of GDB
// reports them in backward order. We want UI to
// show thread IDs in the natural order.
std::sort(threadsList.begin(), threadsList.end(),
[](const FrameStackModel::ThreadItem &a, const FrameStackModel::ThreadItem &b){
return a.nr < b.nr;
});
setThreads(threadsList);
if (r.hasField("current-thread-id")) {
int currentThreadId = r["current-thread-id"].toInt();
......
......@@ -58,6 +58,7 @@ DebugSession::DebugSession()
, m_breakpointController(nullptr)
, m_variableController(nullptr)
, m_frameStackModel(nullptr)
, m_autoDisableASLR(false)
{
m_breakpointController = new BreakpointController(this);
m_variableController = new VariableController(this);
......@@ -68,6 +69,11 @@ DebugSession::~DebugSession()
{
}
void DebugSession::setAutoDisableASLR(bool enable)
{
m_autoDisableASLR = enable;
}
BreakpointController *DebugSession::breakpointController() const
{
return m_breakpointController;
......@@ -120,6 +126,10 @@ void DebugSession::initializeDebugger()
addCommand(MI::NonMI, "source " + fileName);
}
// GDB can't disable ASLR on CI server.
addCommand(MI::GdbSet,
QStringLiteral("disable-randomization %1").arg(m_autoDisableASLR ? "on" : "off"));
qCDebug(DEBUGGERGDB) << "Initialized GDB";
}
......
......@@ -72,6 +72,11 @@ public:
VariableController * variableController() const override;
GdbFrameStackModel * frameStackModel() const override;
// FIXME: only used in unit test currently,
// potentially could be made a user configurable option
// Whether turn off auto-disable ASLR when starting inferiors
void setAutoDisableASLR(bool enable);
protected:
GdbDebugger *createDebugger() const override;
void initializeDebugger() override;
......@@ -89,6 +94,8 @@ private:
BreakpointController *m_breakpointController;
VariableController *m_variableController;
GdbFrameStackModel *m_frameStackModel;
bool m_autoDisableASLR;
};
} // end of namespace GDB
......
......@@ -35,11 +35,6 @@ public:
~GdbDebugger() override;
bool start(KConfigGroup& config, const QStringList& extraArguments = {}) override;
/** Reports debugger interal output, including stderr output from debugger
and the 'log' MI channel */
void debuggerInternalOutput(const QString& s);
};
} // end of namespace GDB
......
......@@ -21,8 +21,6 @@
*/
#include "gdbframestackmodel.h"
#include <algorithm>
#include "debugsession.h"
......
......@@ -57,7 +57,6 @@ using KDevelop::AutoTestShell;
namespace KDevMI { namespace GDB {
QUrl findExecutable(const QString& name)
{
QFileInfo info(qApp->applicationDirPath() + "/unittests/" + name);
Q_ASSERT(info.exists());
......@@ -182,6 +181,7 @@ public:
TestDebugSession() : DebugSession()
{
setSourceInitFile(false);
setAutoDisableASLR(false);
m_frameStackModel = new TestFrameStackModel(this);
KDevelop::ICore::self()->debugController()->addSession(this);
}
......
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