mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 18:38:51 +00:00
CutterCore: select the right RzReg based on debug/emulation status (#2977)
This commit is contained in:
parent
f99ffc3dbd
commit
8f7aebe7c7
@ -129,7 +129,10 @@ static QString fromOwnedCharPtr(char *str)
|
|||||||
|
|
||||||
static bool reg_sync(RzCore *core, RzRegisterType type, bool write)
|
static bool reg_sync(RzCore *core, RzRegisterType type, bool write)
|
||||||
{
|
{
|
||||||
return rz_debug_reg_sync(core->dbg, type, write);
|
if (rz_core_is_debug(core)) {
|
||||||
|
return rz_debug_reg_sync(core->dbg, type, write);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RzCoreLocked::RzCoreLocked(CutterCore *core) : core(core)
|
RzCoreLocked::RzCoreLocked(CutterCore *core) : core(core)
|
||||||
@ -1514,6 +1517,17 @@ RefDescription CutterCore::formatRefDesc(const QSharedPointer<AddrRefs> &refItem
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RzReg *CutterCore::getReg()
|
||||||
|
{
|
||||||
|
CORE_LOCK();
|
||||||
|
if (currentlyDebugging && currentlyEmulating) {
|
||||||
|
return core->analysis->reg;
|
||||||
|
} else if (currentlyDebugging) {
|
||||||
|
return core->dbg->reg;
|
||||||
|
}
|
||||||
|
return core->analysis->reg;
|
||||||
|
}
|
||||||
|
|
||||||
QList<RegisterRef> CutterCore::getRegisterRefs(int depth)
|
QList<RegisterRef> CutterCore::getRegisterRefs(int depth)
|
||||||
{
|
{
|
||||||
QList<RegisterRef> ret;
|
QList<RegisterRef> ret;
|
||||||
@ -1522,7 +1536,7 @@ QList<RegisterRef> CutterCore::getRegisterRefs(int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
RzList *ritems = rz_core_reg_filter_items_sync(core, core->dbg->reg, reg_sync, nullptr);
|
RzList *ritems = rz_core_reg_filter_items_sync(core, getReg(), reg_sync, nullptr);
|
||||||
if (!ritems) {
|
if (!ritems) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1530,7 +1544,7 @@ QList<RegisterRef> CutterCore::getRegisterRefs(int depth)
|
|||||||
RzRegItem *ri;
|
RzRegItem *ri;
|
||||||
CutterRzListForeach (ritems, it, RzRegItem, ri) {
|
CutterRzListForeach (ritems, it, RzRegItem, ri) {
|
||||||
RegisterRef reg;
|
RegisterRef reg;
|
||||||
reg.value = rz_reg_get_value(core->dbg->reg, ri);
|
reg.value = rz_reg_get_value(getReg(), ri);
|
||||||
reg.ref = getAddrRefs(reg.value, depth);
|
reg.ref = getAddrRefs(reg.value, depth);
|
||||||
reg.name = ri->name;
|
reg.name = ri->name;
|
||||||
ret.append(reg);
|
ret.append(reg);
|
||||||
@ -1547,7 +1561,7 @@ QList<AddrRefs> CutterCore::getStack(int size, int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
RVA addr = rz_debug_reg_get(core->dbg, "SP");
|
RVA addr = rz_core_reg_getv_by_role_or_name(core, "SP");
|
||||||
if (addr == RVA_INVALID) {
|
if (addr == RVA_INVALID) {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
@ -1596,7 +1610,7 @@ AddrRefs CutterCore::getAddrRefs(RVA addr, int depth)
|
|||||||
// Check if the address points to a register
|
// Check if the address points to a register
|
||||||
RzFlagItem *fi = rz_flag_get_i(core->flags, addr);
|
RzFlagItem *fi = rz_flag_get_i(core->flags, addr);
|
||||||
if (fi) {
|
if (fi) {
|
||||||
RzRegItem *r = rz_reg_get(core->dbg->reg, fi->name, -1);
|
RzRegItem *r = rz_reg_get(getReg(), fi->name, -1);
|
||||||
if (r) {
|
if (r) {
|
||||||
refs.reg = r->name;
|
refs.reg = r->name;
|
||||||
}
|
}
|
||||||
@ -1852,7 +1866,7 @@ QVector<RegisterRefValueDescription> CutterCore::getRegisterRefValues()
|
|||||||
{
|
{
|
||||||
QVector<RegisterRefValueDescription> result;
|
QVector<RegisterRefValueDescription> result;
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
RzList *ritems = rz_core_reg_filter_items_sync(core, core->dbg->reg, reg_sync, nullptr);
|
RzList *ritems = rz_core_reg_filter_items_sync(core, getReg(), reg_sync, nullptr);
|
||||||
if (!ritems) {
|
if (!ritems) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1861,8 +1875,8 @@ QVector<RegisterRefValueDescription> CutterCore::getRegisterRefValues()
|
|||||||
CutterRzListForeach (ritems, it, RzRegItem, ri) {
|
CutterRzListForeach (ritems, it, RzRegItem, ri) {
|
||||||
RegisterRefValueDescription desc;
|
RegisterRefValueDescription desc;
|
||||||
desc.name = ri->name;
|
desc.name = ri->name;
|
||||||
ut64 value = rz_reg_get_value(core->dbg->reg, ri);
|
ut64 value = rz_reg_get_value(getReg(), ri);
|
||||||
desc.value = QString::number(value);
|
desc.value = "0x" + QString::number(value, 16);
|
||||||
desc.ref = rz_core_analysis_hasrefs(core, value, true);
|
desc.ref = rz_core_analysis_hasrefs(core, value, true);
|
||||||
result.push_back(desc);
|
result.push_back(desc);
|
||||||
}
|
}
|
||||||
@ -1876,14 +1890,14 @@ QString CutterCore::getRegisterName(QString registerRole)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
return rz_reg_get_name_by_type(core->dbg->reg, registerRole.toUtf8().constData());
|
return rz_reg_get_name_by_type(getReg(), registerRole.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
RVA CutterCore::getProgramCounterValue()
|
RVA CutterCore::getProgramCounterValue()
|
||||||
{
|
{
|
||||||
if (currentlyDebugging) {
|
if (currentlyDebugging) {
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
return rz_debug_reg_get(core->dbg, "PC");
|
return rz_core_reg_getv_by_role_or_name(core, "PC");
|
||||||
}
|
}
|
||||||
return RVA_INVALID;
|
return RVA_INVALID;
|
||||||
}
|
}
|
||||||
@ -1895,7 +1909,7 @@ void CutterCore::setRegister(QString regName, QString regValue)
|
|||||||
}
|
}
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
ut64 val = rz_num_math(core->num, regValue.toUtf8().constData());
|
ut64 val = rz_num_math(core->num, regValue.toUtf8().constData());
|
||||||
rz_core_reg_assign_sync(core, core->dbg->reg, reg_sync, regName.toUtf8().constData(), val);
|
rz_core_reg_assign_sync(core, getReg(), reg_sync, regName.toUtf8().constData(), val);
|
||||||
emit registersChanged();
|
emit registersChanged();
|
||||||
emit refreshCodeViews();
|
emit refreshCodeViews();
|
||||||
}
|
}
|
||||||
@ -2900,7 +2914,7 @@ void CutterCore::getOpcodes()
|
|||||||
this->opcodes = cmdList("?O");
|
this->opcodes = cmdList("?O");
|
||||||
|
|
||||||
this->regs = {};
|
this->regs = {};
|
||||||
const RzList *rs = rz_reg_get_list(core->dbg->reg, RZ_REG_TYPE_ANY);
|
const RzList *rs = rz_reg_get_list(getReg(), RZ_REG_TYPE_ANY);
|
||||||
if (!rs) {
|
if (!rs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -662,6 +662,10 @@ public:
|
|||||||
QList<SearchDescription> getAllSearch(QString searchFor, QString space, QString in);
|
QList<SearchDescription> getAllSearch(QString searchFor, QString space, QString in);
|
||||||
QList<BreakpointDescription> getBreakpoints();
|
QList<BreakpointDescription> getBreakpoints();
|
||||||
QList<ProcessDescription> getAllProcesses();
|
QList<ProcessDescription> getAllProcesses();
|
||||||
|
/**
|
||||||
|
* @brief Get the right RzReg object based on the cutter state (debugging vs emulating)
|
||||||
|
*/
|
||||||
|
RzReg *getReg();
|
||||||
/**
|
/**
|
||||||
* @brief returns a list of reg values and their telescoped references
|
* @brief returns a list of reg values and their telescoped references
|
||||||
* @param depth telescoping depth
|
* @param depth telescoping depth
|
||||||
|
Loading…
Reference in New Issue
Block a user