Commit 8abf2d0c authored by Peifeng Yu's avatar Peifeng Yu
Browse files

Merge remote-tracking branch 'origin/master' into peifeng/lldb-plugin

parents c02581d9 db45e868
......@@ -20,6 +20,15 @@ set(debuggercommon_SRCS
stty.cpp
# tool views
widgets/debuggerconsoleview.cpp
widgets/disassemblewidget.cpp
# register
registers/registersview.cpp
registers/registercontroller.cpp
registers/registersmanager.cpp
registers/registercontroller_x86.cpp
registers/registercontroller_arm.cpp
registers/modelsmanager.cpp
registers/converters.cpp
)
if(KF5SysGuard_FOUND)
list(APPEND debuggercommon_SRCS
......@@ -30,6 +39,8 @@ endif()
ki18n_wrap_ui(debuggercommon_SRCS
dialogs/selectcoredialog.ui
widgets/debuggerconsoleview.ui
widgets/selectaddressdialog.ui
registers/registersview.ui
)
# Use old behavior (ignore the visibility properties for static libraries, object
......
......@@ -21,7 +21,7 @@
#include <KLocalizedString>
using namespace KDevMI::GDB;
using namespace KDevMI;
QString Converters::formatToString(Format format)
{
......
......@@ -22,10 +22,7 @@
#include "registercontroller.h"
namespace KDevMI
{
namespace GDB
{
namespace KDevMI {
class Converters
{
......@@ -37,6 +34,5 @@ public:
static QString modeToString(Mode mode);
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif // CONVERTERS_H
......@@ -26,7 +26,7 @@
#include <KSharedConfig>
namespace KDevMI { namespace GDB {
namespace KDevMI {
struct Model {
Model();
......@@ -61,10 +61,9 @@ private:
QVector<Model> m_models;
};
} // end of namespace GDB
} // end of namespace KDevMI
using namespace KDevMI::GDB;
using namespace KDevMI;
ModelsManager::ModelsManager(QObject* parent) : QObject(parent), m_models(new Models), m_controller(0), m_config(KSharedConfig::openConfig()->group("Register models")) {}
......
......@@ -36,8 +36,6 @@ class QStandardItem;
class QModelIndex;
namespace KDevMI {
namespace GDB
{
class Models;
class IRegisterController;
struct Register;
......@@ -99,6 +97,5 @@ private:
KConfigGroup m_config;
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif // MODELSMANAGER_H
......@@ -22,17 +22,17 @@
#include "converters.h"
#include "debuglog.h"
#include "midebugsession.h"
#include "mi/mi.h"
#include "mi/micommand.h"
#include "../debugsession.h"
#include <QRegExp>
#include <QtMath>
using namespace KDevMI::MI;
using namespace KDevMI::GDB;
using namespace KDevMI;
void IRegisterController::setSession(DebugSession* debugSession)
void IRegisterController::setSession(MIDebugSession* debugSession)
{
m_debugSession = debugSession;
}
......@@ -44,7 +44,7 @@ void IRegisterController::updateRegisters(const GroupsName& group)
}
if (m_pendingGroups.contains(group)) {
qCDebug(DEBUGGERGDB) << "Already updating " << group.name();
qCDebug(DEBUGGERCOMMON) << "Already updating " << group.name();
return;
}
......@@ -54,7 +54,7 @@ void IRegisterController::updateRegisters(const GroupsName& group)
}
return;
} else {
qCDebug(DEBUGGERGDB) << "Updating: " << group.name();
qCDebug(DEBUGGERCOMMON) << "Updating: " << group.name();
m_pendingGroups << group;
}
......@@ -100,7 +100,7 @@ void IRegisterController::updateRegisters(const GroupsName& group)
//Not initialized yet. They'll be updated afterwards.
if (registers.contains("-1")) {
qCDebug(DEBUGGERGDB) << "Will update later";
qCDebug(DEBUGGERCOMMON) << "Will update later";
m_pendingGroups.clear();
return;
}
......@@ -227,7 +227,7 @@ void IRegisterController::setFlagRegister(const Register& reg, const FlagRegiste
setGeneralRegister(Register(flag.registerName, QString("0x%1").arg(flagsValue, 0, 16)), flag.groupName);
} else {
updateRegisters(flag.groupName);
qCDebug(DEBUGGERGDB) << reg.name << ' ' << reg.value << "is incorrect flag name/value";
qCDebug(DEBUGGERCOMMON) << reg.name << ' ' << reg.value << "is incorrect flag name/value";
}
}
......@@ -238,13 +238,13 @@ void IRegisterController::setGeneralRegister(const Register& reg, const GroupsNa
}
const QString command = QString("set var $%1=%2").arg(reg.name).arg(reg.value);
qCDebug(DEBUGGERGDB) << "Setting register: " << command;
qCDebug(DEBUGGERCOMMON) << "Setting register: " << command;
m_debugSession->addCommand(NonMI, command);
updateRegisters(group);
}
IRegisterController::IRegisterController(DebugSession* debugSession, QObject* parent)
IRegisterController::IRegisterController(MIDebugSession* debugSession, QObject* parent)
: QObject(parent), m_debugSession(debugSession) {}
IRegisterController::~IRegisterController() {}
......
......@@ -33,10 +33,7 @@ namespace MI
struct ResultRecord;
}
namespace GDB
{
class DebugSession;
class MIDebugSession;
enum RegisterType {general, structured, flag, floatPoint};
......@@ -131,7 +128,7 @@ class IRegisterController : public QObject
public:
///Sets session @p debugSession to send commands to.
void setSession(DebugSession* debugSession);
void setSession(MIDebugSession* debugSession);
///There'll be at least 2 groups: "General" and "Flags", also "XMM", "FPU", "Segment" for x86, x86_64 architectures.
virtual QVector<GroupsName> namesOfRegisterGroups() const = 0;
......@@ -160,7 +157,7 @@ public slots:
virtual void setRegisterValue(const Register& reg);
protected:
IRegisterController(DebugSession* debugSession = 0, QObject* parent = 0);
IRegisterController(MIDebugSession* debugSession = 0, QObject* parent = 0);
///Returns registers from the @p group, or empty registers group if @p group is invalid.
virtual RegistersGroup registersFromGroup(const GroupsName& group) const = 0;
......@@ -236,16 +233,15 @@ protected:
QVector<FormatsModes > m_formatsModes;
///Current debug session;
DebugSession* m_debugSession;
MIDebugSession* m_debugSession;
};
} // end of namespace GDB
} // end of namespace KDevMI
Q_DECLARE_TYPEINFO(KDevMI::GDB::Register, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::GDB::RegistersGroup, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::GDB::FlagRegister, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::GDB::GroupsName, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::GDB::FormatsModes, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::Register, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::RegistersGroup, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::FlagRegister, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::GroupsName, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KDevMI::FormatsModes, Q_MOVABLE_TYPE);
#endif
......@@ -23,14 +23,14 @@
#include <KLocalizedString>
using namespace KDevMI::GDB;
using namespace KDevMI;
QVector<QStringList> RegisterController_Arm::m_registerNames;
FlagRegister RegisterController_Arm::m_cpsr;
void RegisterController_Arm::updateValuesForRegisters(RegistersGroup* registers) const
{
qCDebug(DEBUGGERGDB) << "Updating values for registers: " << registers->groupName.name();
qCDebug(DEBUGGERCOMMON) << "Updating values for registers: " << registers->groupName.name();
if (registers->groupName == enumToGroupName(Flags)) {
updateFlagValues(registers, m_cpsr);
} else {
......@@ -108,7 +108,7 @@ GroupsName RegisterController_Arm::enumToGroupName(ArmRegisterGroups group) cons
return groups[group];
}
RegisterController_Arm::RegisterController_Arm(DebugSession* debugSession, QObject* parent) : IRegisterController(debugSession, parent), m_registerNamesInitialized(false)
RegisterController_Arm::RegisterController_Arm(MIDebugSession* debugSession, QObject* parent) : IRegisterController(debugSession, parent), m_registerNamesInitialized(false)
{
if (m_registerNames.isEmpty()) {
for (int i = 0; i < static_cast<int>(LAST_REGISTER); i++) {
......
......@@ -25,16 +25,13 @@
#include "registercontroller.h"
namespace KDevMI {
namespace GDB
{
class DebugSession;
class MIDebugSession;
class RegisterController_Arm : public IRegisterController
{
public:
RegisterController_Arm(DebugSession* debugSession = 0, QObject* parent = 0);
RegisterController_Arm(MIDebugSession* debugSession = 0, QObject* parent = 0);
virtual QVector<GroupsName> namesOfRegisterGroups() const override;
......@@ -69,7 +66,6 @@ private:
bool m_registerNamesInitialized;
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif // REGISTERCONTROLLER_ARM_H
......@@ -23,14 +23,14 @@
#include <KLocalizedString>
using namespace KDevMI::GDB;
using namespace KDevMI;
QVector<QStringList> RegisterControllerGeneral_x86::m_registerNames;
FlagRegister RegisterControllerGeneral_x86::m_eflags;
void RegisterControllerGeneral_x86::updateValuesForRegisters(RegistersGroup* registers) const
{
qCDebug(DEBUGGERGDB) << "Updating values for registers: " << registers->groupName.name();
qCDebug(DEBUGGERCOMMON) << "Updating values for registers: " << registers->groupName.name();
if (registers->groupName == enumToGroupName(Flags)) {
updateFlagValues(registers, m_eflags);
} else {
......@@ -108,19 +108,19 @@ GroupsName RegisterControllerGeneral_x86::enumToGroupName(X86RegisterGroups grou
return groups[group];
}
RegisterController_x86::RegisterController_x86(DebugSession* debugSession, QObject* parent)
RegisterController_x86::RegisterController_x86(MIDebugSession* debugSession, QObject* parent)
: RegisterControllerGeneral_x86(debugSession, parent)
{
initRegisterNames();
}
RegisterController_x86_64::RegisterController_x86_64(DebugSession* debugSession, QObject* parent)
RegisterController_x86_64::RegisterController_x86_64(MIDebugSession* debugSession, QObject* parent)
: RegisterControllerGeneral_x86(debugSession, parent)
{
initRegisterNames();
}
RegisterControllerGeneral_x86::RegisterControllerGeneral_x86(DebugSession* debugSession, QObject* parent)
RegisterControllerGeneral_x86::RegisterControllerGeneral_x86(MIDebugSession* debugSession, QObject* parent)
: IRegisterController(debugSession, parent), m_registerNamesInitialized(false)
{
if (m_registerNames.isEmpty()) {
......
......@@ -25,10 +25,7 @@
namespace KDevMI
{
namespace GDB
{
class DebugSession;
class MIDebugSession;
class RegisterControllerGeneral_x86 : public IRegisterController
{
......@@ -39,7 +36,7 @@ public slots:
virtual void updateRegisters(const GroupsName& group = GroupsName()) override;
protected:
RegisterControllerGeneral_x86(DebugSession* debugSession = 0, QObject* parent = 0);
RegisterControllerGeneral_x86(MIDebugSession* debugSession = 0, QObject* parent = 0);
virtual RegistersGroup registersFromGroup(const GroupsName& group) const override;
......@@ -74,7 +71,7 @@ class RegisterController_x86 : public RegisterControllerGeneral_x86
{
public:
RegisterController_x86(DebugSession* debugSession = 0, QObject* parent = 0);
RegisterController_x86(MIDebugSession* debugSession = 0, QObject* parent = 0);
private:
void initRegisterNames();
......@@ -84,13 +81,12 @@ class RegisterController_x86_64 : public RegisterControllerGeneral_x86
{
public:
RegisterController_x86_64(DebugSession* debugSession = 0, QObject* parent = 0);
RegisterController_x86_64(MIDebugSession* debugSession = 0, QObject* parent = 0);
private:
void initRegisterNames();
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif // REGISTERCONTROLLER_X86_H
......@@ -24,13 +24,14 @@
#include "registercontroller_x86.h"
#include "registersview.h"
#include "dbgglobal.h"
#include "debuglog.h"
#include "midebugsession.h"
#include "mi/micommand.h"
#include "modelsmanager.h"
#include "../debugsession.h"
using namespace KDevMI::MI;
using namespace KDevMI::GDB;
using namespace KDevMI;
void ArchitectureParser::parseArchitecture()
{
......@@ -67,7 +68,7 @@ void ArchitectureParser::registerNamesHandler(const ResultRecord& r)
parseArchitecture();
}
void ArchitectureParser::determineArchitecture(DebugSession* debugSession)
void ArchitectureParser::determineArchitecture(MIDebugSession* debugSession)
{
if (!debugSession || debugSession->debuggerStateIsOn(s_dbgNotStarted | s_shuttingDown)) {
return;
......@@ -87,7 +88,7 @@ RegistersManager::RegistersManager(QWidget* parent)
void RegistersManager::architectureParsedSlot(Architecture arch)
{
qCDebug(DEBUGGERGDB) << " Current controller: " << m_registerController << "Current arch " << m_currentArchitecture;
qCDebug(DEBUGGERCOMMON) << " Current controller: " << m_registerController << "Current arch " << m_currentArchitecture;
if (m_registerController || m_currentArchitecture != undefined) {
return;
......@@ -96,15 +97,15 @@ void RegistersManager::architectureParsedSlot(Architecture arch)
switch (arch) {
case x86:
m_registerController.reset(new RegisterController_x86(m_debugSession)) ;
qCDebug(DEBUGGERGDB) << "Found x86 architecture";
qCDebug(DEBUGGERCOMMON) << "Found x86 architecture";
break;
case x86_64:
m_registerController.reset(new RegisterController_x86_64(m_debugSession));
qCDebug(DEBUGGERGDB) << "Found x86_64 architecture";
qCDebug(DEBUGGERCOMMON) << "Found x86_64 architecture";
break;
case arm:
m_registerController.reset(new RegisterController_Arm(m_debugSession));
qCDebug(DEBUGGERGDB) << "Found Arm architecture";
qCDebug(DEBUGGERCOMMON) << "Found Arm architecture";
break;
default:
m_registerController.reset();
......@@ -121,15 +122,15 @@ void RegistersManager::architectureParsedSlot(Architecture arch)
}
}
void RegistersManager::setSession(DebugSession* debugSession)
void RegistersManager::setSession(MIDebugSession* debugSession)
{
qCDebug(DEBUGGERGDB) << "Change session " << debugSession;
qCDebug(DEBUGGERCOMMON) << "Change session " << debugSession;
m_debugSession = debugSession;
if (m_registerController) {
m_registerController->setSession(debugSession);
}
if (!m_debugSession) {
qCDebug(DEBUGGERGDB) << "Will reparse arch";
qCDebug(DEBUGGERCOMMON) << "Will reparse arch";
m_needToCheckArch = true;
setController(0);
}
......@@ -141,7 +142,7 @@ void RegistersManager::updateRegisters()
return;
}
qCDebug(DEBUGGERGDB) << "Updating registers";
qCDebug(DEBUGGERCOMMON) << "Updating registers";
if (m_needToCheckArch) {
m_needToCheckArch = false;
m_currentArchitecture = undefined;
......@@ -154,7 +155,7 @@ void RegistersManager::updateRegisters()
if (m_registerController) {
m_registersView->updateRegisters();
} else {
qCDebug(DEBUGGERGDB) << "No registerController, yet?";
qCDebug(DEBUGGERCOMMON) << "No registerController, yet?";
}
}
......
......@@ -31,12 +31,10 @@ namespace MI
struct ResultRecord;
}
namespace GDB
{
class MIDebugSession;
class RegistersView;
class IRegisterController;
class DebugSession;
class ModelsManager;
enum Architecture {x86, x86_64, arm, other = 100, undefined};
......@@ -51,7 +49,7 @@ public:
ArchitectureParser(QObject* parent);
///Asynchronously determines current architecture. emits @p architectureParsed when ready.
void determineArchitecture(DebugSession* debugSession);
void determineArchitecture(MIDebugSession* debugSession);
Q_SIGNALS:
///Emits current CPU architecture. @sa determineArchitecture
......@@ -73,7 +71,7 @@ public:
RegistersManager(QWidget* parent);
public Q_SLOTS:
void setSession(DebugSession* debugSession);
void setSession(MIDebugSession* debugSession);
///Updates all registers.
void updateRegisters();
///@sa ArchitectureParser::determineArchitecture
......@@ -88,7 +86,7 @@ private:
ArchitectureParser* m_architectureParser;
DebugSession* m_debugSession;
MIDebugSession* m_debugSession;
ModelsManager* m_modelsManager;
......@@ -98,6 +96,5 @@ private:
bool m_needToCheckArch;
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif // REGISTERSMANAGER_H
......@@ -30,7 +30,7 @@
#include <KLocalizedString>
using namespace KDevMI::GDB;
using namespace KDevMI;
namespace
{
......@@ -181,7 +181,7 @@ void RegistersView::enable(bool enabled)
void RegistersView::setNameForTable(int idx, const QString& name)
{
qCDebug(DEBUGGERGDB) << name << " " << idx;
qCDebug(DEBUGGERCOMMON) << name << " " << idx;
const QString text = tabWidget->tabText(idx);
if (!text.contains(name)) {
tabWidget->setTabText(idx, text.isEmpty() ? name : text + '/' + name);
......
......@@ -29,8 +29,6 @@ class QMenu;
class QSignalMapper;
namespace KDevMI {
namespace GDB
{
class ModelsManager;
......@@ -90,7 +88,6 @@ private:
QVector<QAction*> m_actions;
};
} // end of namespace GDB
} // end of namespace KDevMI
#endif
......@@ -329,7 +329,7 @@ bool STTY::findExternalTTY(const QString& termApp)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
usleep(8000);
} else {
qCDebug(DEBUGGERGDB) << "Received terminal output(tty)";
qCDebug(DEBUGGERCOMMON) << "Received terminal output(tty)";
break;
}
}
......
......@@ -24,9 +24,9 @@
#include "disassemblewidget.h"
#include "debuggerplugin.h"
#include "midebuggerplugin.h"
#include "debuglog.h"
#include "debugsession.h"
#include "midebugsession.h"
#include "mi/micommand.h"
#include "registers/registersmanager.h"
......@@ -50,7 +50,7 @@
#include <QHeaderView>
#include <QFontDatabase>
using namespace KDevMI::GDB;
using namespace KDevMI;
using namespace KDevMI::MI;
......@@ -166,7 +166,7 @@ void DisassembleWindow::contextMenuEvent(QContextMenuEvent *e)
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
DisassembleWidget::DisassembleWidget(CppDebuggerPlugin* plugin, QWidget *parent)
DisassembleWidget::DisassembleWidget(MIDebuggerPlugin* plugin, QWidget *parent)
: QWidget(parent),
active_(false),
lower_(0),
......@@ -230,7 +230,7 @@ DisassembleWidget::DisassembleWidget(CppDebuggerPlugin* plugin, QWidget *parent)
&KDevelop::IDebugController::currentSessionChanged,
this, &DisassembleWidget::currentSessionChanged);
connect(plugin, &CppDebuggerPlugin::reset, this, &DisassembleWidget::slotDeactivate);
connect(plugin, &MIDebuggerPlugin::reset, this, &DisassembleWidget::slotDeactivate);
m_dlg = new SelectAddressDialog(this);
......@@ -244,7 +244,7 @@ DisassembleWidget::DisassembleWidget(CppDebuggerPlugin* plugin, QWidget *parent)
}
void DisassembleWidget::jumpToCursor() {
DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::
MIDebugSession *s = qobject_cast<MIDebugSession*>(KDevelop::ICore::
self()->debugController()->currentSession());
if (s && s->isRunning()) {
QString address = m_disassembleWindow->selectedItems().at(0)->text(Address);
......@@ -253,7 +253,7 @@ void DisassembleWidget::jumpToCursor() {
}
void DisassembleWidget::runToCursor(){
DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::
MIDebugSession *s = qobject_cast<MIDebugSession*>(KDevelop::ICore::
self()->debugController()->currentSession());
if (s && s->isRunning()) {
QString address = m_disassembleWindow->selectedItems().at(0)->text(Address);
......@@ -263,16 +263,16 @@ void DisassembleWidget::runToCursor(){
void DisassembleWidget::currentSessionChanged(KDevelop::IDebugSession* s)
{
DebugSession *session = qobject_cast<DebugSession*>(s);
MIDebugSession *session = qobject_cast<MIDebugSession*>(s);
enableControls( session != NULL ); // disable if session closed
m_registersManager->setSession(session);