BreakPoints: Rename variables

Drops Hungarian notation where applicable.Drops Hungarian notation where
applicable.
This commit is contained in:
Lioncash 2017-01-11 08:27:45 -05:00
parent 274ab8a262
commit 0f8bcf412d
7 changed files with 190 additions and 186 deletions

View File

@ -140,13 +140,13 @@ void PPCDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool wri
{
// Add Memory Check
TMemCheck MemCheck;
MemCheck.StartAddress = address;
MemCheck.EndAddress = address;
MemCheck.OnRead = read;
MemCheck.OnWrite = write;
MemCheck.start_address = address;
MemCheck.end_address = address;
MemCheck.is_break_on_read = read;
MemCheck.is_break_on_write = write;
MemCheck.Log = log;
MemCheck.Break = true;
MemCheck.log_on_hit = log;
MemCheck.break_on_hit = true;
PowerPC::memchecks.Add(MemCheck);
}

View File

@ -15,8 +15,8 @@
bool BreakPoints::IsAddressBreakPoint(u32 address) const
{
for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == address)
for (const TBreakPoint& bp : m_breakpoints)
if (bp.address == address)
return true;
return false;
@ -24,8 +24,8 @@ bool BreakPoints::IsAddressBreakPoint(u32 address) const
bool BreakPoints::IsTempBreakPoint(u32 address) const
{
for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == address && bp.bTemporary)
for (const TBreakPoint& bp : m_breakpoints)
if (bp.address == address && bp.is_temporary)
return true;
return false;
@ -33,69 +33,69 @@ bool BreakPoints::IsTempBreakPoint(u32 address) const
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{
TBreakPointsStr bps;
for (const TBreakPoint& bp : m_BreakPoints)
TBreakPointsStr bp_strings;
for (const TBreakPoint& bp : m_breakpoints)
{
if (!bp.bTemporary)
if (!bp.is_temporary)
{
std::stringstream ss;
ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : "");
bps.push_back(ss.str());
ss << std::hex << bp.address << " " << (bp.is_enabled ? "n" : "");
bp_strings.push_back(ss.str());
}
}
return bps;
return bp_strings;
}
void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs)
void BreakPoints::AddFromStrings(const TBreakPointsStr& bp_strings)
{
for (const std::string& bpstr : bpstrs)
for (const std::string& bp_string : bp_strings)
{
TBreakPoint bp;
std::stringstream ss;
ss << std::hex << bpstr;
ss >> bp.iAddress;
bp.bOn = bpstr.find("n") != bpstr.npos;
bp.bTemporary = false;
ss << std::hex << bp_string;
ss >> bp.address;
bp.is_enabled = bp_string.find("n") != bp_string.npos;
bp.is_temporary = false;
Add(bp);
}
}
void BreakPoints::Add(const TBreakPoint& bp)
{
if (!IsAddressBreakPoint(bp.iAddress))
if (!IsAddressBreakPoint(bp.address))
{
m_BreakPoints.push_back(bp);
m_breakpoints.push_back(bp);
if (g_jit)
g_jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4, true);
g_jit->GetBlockCache()->InvalidateICache(bp.address, 4, true);
}
}
void BreakPoints::Add(u32 em_address, bool temp)
void BreakPoints::Add(u32 address, bool temp)
{
if (!IsAddressBreakPoint(em_address)) // only add new addresses
if (!IsAddressBreakPoint(address)) // only add new addresses
{
TBreakPoint pt; // breakpoint settings
pt.bOn = true;
pt.bTemporary = temp;
pt.iAddress = em_address;
TBreakPoint bp; // breakpoint settings
bp.is_enabled = true;
bp.is_temporary = temp;
bp.address = address;
m_BreakPoints.push_back(pt);
m_breakpoints.push_back(bp);
if (g_jit)
g_jit->GetBlockCache()->InvalidateICache(em_address, 4, true);
g_jit->GetBlockCache()->InvalidateICache(address, 4, true);
}
}
void BreakPoints::Remove(u32 em_address)
void BreakPoints::Remove(u32 address)
{
for (auto i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
for (auto i = m_breakpoints.begin(); i != m_breakpoints.end(); ++i)
{
if (i->iAddress == em_address)
if (i->address == address)
{
m_BreakPoints.erase(i);
m_breakpoints.erase(i);
if (g_jit)
g_jit->GetBlockCache()->InvalidateICache(em_address, 4, true);
g_jit->GetBlockCache()->InvalidateICache(address, 4, true);
return;
}
}
@ -105,25 +105,25 @@ void BreakPoints::Clear()
{
if (g_jit)
{
for (const TBreakPoint& bp : m_BreakPoints)
for (const TBreakPoint& bp : m_breakpoints)
{
g_jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4, true);
g_jit->GetBlockCache()->InvalidateICache(bp.address, 4, true);
}
}
m_BreakPoints.clear();
m_breakpoints.clear();
}
void BreakPoints::ClearAllTemporary()
{
auto bp = m_BreakPoints.begin();
while (bp != m_BreakPoints.end())
auto bp = m_breakpoints.begin();
while (bp != m_breakpoints.end())
{
if (bp->bTemporary)
if (bp->is_temporary)
{
if (g_jit)
g_jit->GetBlockCache()->InvalidateICache(bp->iAddress, 4, true);
bp = m_BreakPoints.erase(bp);
g_jit->GetBlockCache()->InvalidateICache(bp->address, 4, true);
bp = m_breakpoints.erase(bp);
}
else
{
@ -134,59 +134,60 @@ void BreakPoints::ClearAllTemporary()
MemChecks::TMemChecksStr MemChecks::GetStrings() const
{
TMemChecksStr mcs;
for (const TMemCheck& bp : m_MemChecks)
TMemChecksStr mc_strings;
for (const TMemCheck& mc : m_mem_checks)
{
std::stringstream mc;
mc << std::hex << bp.StartAddress;
mc << " " << (bp.bRange ? bp.EndAddress : bp.StartAddress) << " " << (bp.bRange ? "n" : "")
<< (bp.OnRead ? "r" : "") << (bp.OnWrite ? "w" : "") << (bp.Log ? "l" : "")
<< (bp.Break ? "p" : "");
mcs.push_back(mc.str());
std::stringstream ss;
ss << std::hex << mc.start_address;
ss << " " << (mc.is_ranged ? mc.end_address : mc.start_address) << " "
<< (mc.is_ranged ? "n" : "") << (mc.is_break_on_read ? "r" : "")
<< (mc.is_break_on_write ? "w" : "") << (mc.log_on_hit ? "l" : "")
<< (mc.break_on_hit ? "p" : "");
mc_strings.push_back(ss.str());
}
return mcs;
return mc_strings;
}
void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs)
void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
{
for (const std::string& mcstr : mcstrs)
for (const std::string& mc_string : mc_strings)
{
TMemCheck mc;
std::stringstream ss;
ss << std::hex << mcstr;
ss >> mc.StartAddress;
mc.bRange = mcstr.find("n") != mcstr.npos;
mc.OnRead = mcstr.find("r") != mcstr.npos;
mc.OnWrite = mcstr.find("w") != mcstr.npos;
mc.Log = mcstr.find("l") != mcstr.npos;
mc.Break = mcstr.find("p") != mcstr.npos;
if (mc.bRange)
ss >> mc.EndAddress;
ss << std::hex << mc_string;
ss >> mc.start_address;
mc.is_ranged = mc_string.find("n") != mc_string.npos;
mc.is_break_on_read = mc_string.find("r") != mc_string.npos;
mc.is_break_on_write = mc_string.find("w") != mc_string.npos;
mc.log_on_hit = mc_string.find("l") != mc_string.npos;
mc.break_on_hit = mc_string.find("p") != mc_string.npos;
if (mc.is_ranged)
ss >> mc.end_address;
else
mc.EndAddress = mc.StartAddress;
mc.end_address = mc.start_address;
Add(mc);
}
}
void MemChecks::Add(const TMemCheck& _rMemoryCheck)
void MemChecks::Add(const TMemCheck& memory_check)
{
bool had_any = HasAny();
if (GetMemCheck(_rMemoryCheck.StartAddress) == nullptr)
m_MemChecks.push_back(_rMemoryCheck);
if (GetMemCheck(memory_check.start_address) == nullptr)
m_mem_checks.push_back(memory_check);
// If this is the first one, clear the JIT cache so it can switch to
// watchpoint-compatible code.
if (!had_any && g_jit)
g_jit->GetBlockCache()->SchedulateClearCacheThreadSafe();
}
void MemChecks::Remove(u32 _Address)
void MemChecks::Remove(u32 address)
{
for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
for (auto i = m_mem_checks.begin(); i != m_mem_checks.end(); ++i)
{
if (i->StartAddress == _Address)
if (i->start_address == address)
{
m_MemChecks.erase(i);
m_mem_checks.erase(i);
if (!HasAny() && g_jit)
g_jit->GetBlockCache()->SchedulateClearCacheThreadSafe();
return;
@ -196,16 +197,16 @@ void MemChecks::Remove(u32 _Address)
TMemCheck* MemChecks::GetMemCheck(u32 address)
{
for (TMemCheck& bp : m_MemChecks)
for (TMemCheck& mc : m_mem_checks)
{
if (bp.bRange)
if (mc.is_ranged)
{
if (address >= bp.StartAddress && address <= bp.EndAddress)
return &(bp);
if (address >= mc.start_address && address <= mc.end_address)
return &mc;
}
else if (bp.StartAddress == address)
else if (mc.start_address == address)
{
return &(bp);
return &mc;
}
}
@ -213,27 +214,27 @@ TMemCheck* MemChecks::GetMemCheck(u32 address)
return nullptr;
}
bool TMemCheck::Action(DebugInterface* debug_interface, u32 iValue, u32 addr, bool write, int size,
bool TMemCheck::Action(DebugInterface* debug_interface, u32 value, u32 addr, bool write, int size,
u32 pc)
{
if ((write && OnWrite) || (!write && OnRead))
if ((write && is_break_on_write) || (!write && is_break_on_read))
{
if (Log)
if (log_on_hit)
{
NOTICE_LOG(MEMMAP, "MBP %08x (%s) %s%i %0*x at %08x (%s)", pc,
debug_interface->GetDescription(pc).c_str(), write ? "Write" : "Read", size * 8,
size * 2, iValue, addr, debug_interface->GetDescription(addr).c_str());
size * 2, value, addr, debug_interface->GetDescription(addr).c_str());
}
if (Break)
if (break_on_hit)
return true;
}
return false;
}
bool Watches::IsAddressWatch(u32 _iAddress) const
bool Watches::IsAddressWatch(u32 address) const
{
for (const TWatch& bp : m_Watches)
if (bp.iAddress == _iAddress)
for (const TWatch& watch : m_watches)
if (watch.address == address)
return true;
return false;
@ -241,68 +242,68 @@ bool Watches::IsAddressWatch(u32 _iAddress) const
Watches::TWatchesStr Watches::GetStrings() const
{
TWatchesStr bps;
for (const TWatch& bp : m_Watches)
TWatchesStr watch_strings;
for (const TWatch& watch : m_watches)
{
std::stringstream ss;
ss << std::hex << bp.iAddress << " " << bp.name;
bps.push_back(ss.str());
ss << std::hex << watch.address << " " << watch.name;
watch_strings.push_back(ss.str());
}
return bps;
return watch_strings;
}
void Watches::AddFromStrings(const TWatchesStr& bpstrs)
void Watches::AddFromStrings(const TWatchesStr& watch_strings)
{
for (const std::string& bpstr : bpstrs)
for (const std::string& watch_string : watch_strings)
{
TWatch bp;
TWatch watch;
std::stringstream ss;
ss << std::hex << bpstr;
ss >> bp.iAddress;
ss << std::hex << watch_string;
ss >> watch.address;
ss >> std::ws;
getline(ss, bp.name);
Add(bp);
std::getline(ss, watch.name);
Add(watch);
}
}
void Watches::Add(const TWatch& bp)
void Watches::Add(const TWatch& watch)
{
if (!IsAddressWatch(bp.iAddress))
if (!IsAddressWatch(watch.address))
{
m_Watches.push_back(bp);
m_watches.push_back(watch);
}
}
void Watches::Add(u32 em_address)
void Watches::Add(u32 address)
{
if (!IsAddressWatch(em_address)) // only add new addresses
if (!IsAddressWatch(address)) // only add new addresses
{
TWatch pt; // breakpoint settings
pt.bOn = true;
pt.iAddress = em_address;
TWatch watch; // watch settings
watch.is_enabled = true;
watch.address = address;
m_Watches.push_back(pt);
m_watches.push_back(watch);
}
}
void Watches::Update(int count, u32 em_address)
void Watches::Update(int count, u32 address)
{
m_Watches.at(count).iAddress = em_address;
m_watches.at(count).address = address;
}
void Watches::UpdateName(int count, const std::string name)
{
m_Watches.at(count).name = name;
m_watches.at(count).name = name;
}
void Watches::Remove(u32 em_address)
void Watches::Remove(u32 address)
{
for (auto i = m_Watches.begin(); i != m_Watches.end(); ++i)
for (auto i = m_watches.begin(); i != m_watches.end(); ++i)
{
if (i->iAddress == em_address)
if (i->address == address)
{
m_Watches.erase(i);
m_watches.erase(i);
return;
}
}
@ -310,5 +311,5 @@ void Watches::Remove(u32 em_address)
void Watches::Clear()
{
m_Watches.clear();
m_watches.clear();
}

View File

@ -13,35 +13,35 @@ class DebugInterface;
struct TBreakPoint
{
u32 iAddress = 0;
bool bOn = false;
bool bTemporary = false;
u32 address = 0;
bool is_enabled = false;
bool is_temporary = false;
};
struct TMemCheck
{
u32 StartAddress = 0;
u32 EndAddress = 0;
u32 start_address = 0;
u32 end_address = 0;
bool bRange = false;
bool is_ranged = false;
bool OnRead = false;
bool OnWrite = false;
bool is_break_on_read = false;
bool is_break_on_write = false;
bool Log = false;
bool Break = false;
bool log_on_hit = false;
bool break_on_hit = false;
u32 numHits = 0;
u32 num_hits = 0;
// returns whether to break
bool Action(DebugInterface* dbg_interface, u32 _iValue, u32 addr, bool write, int size, u32 pc);
bool Action(DebugInterface* dbg_interface, u32 value, u32 addr, bool write, int size, u32 pc);
};
struct TWatch
{
std::string name;
u32 iAddress = 0;
bool bOn = false;
u32 address = 0;
bool is_enabled = false;
};
// Code breakpoints.
@ -51,25 +51,25 @@ public:
using TBreakPoints = std::vector<TBreakPoint>;
using TBreakPointsStr = std::vector<std::string>;
const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
const TBreakPoints& GetBreakPoints() { return m_breakpoints; }
TBreakPointsStr GetStrings() const;
void AddFromStrings(const TBreakPointsStr& bps);
void AddFromStrings(const TBreakPointsStr& bp_strings);
// is address breakpoint
bool IsAddressBreakPoint(u32 address) const;
bool IsTempBreakPoint(u32 address) const;
// Add BreakPoint
void Add(u32 em_address, bool temp = false);
void Add(u32 address, bool temp = false);
void Add(const TBreakPoint& bp);
// Remove Breakpoint
void Remove(u32 _iAddress);
void Remove(u32 address);
void Clear();
void ClearAllTemporary();
private:
TBreakPoints m_BreakPoints;
TBreakPoints m_breakpoints;
};
// Memory breakpoints
@ -79,20 +79,20 @@ public:
using TMemChecks = std::vector<TMemCheck>;
using TMemChecksStr = std::vector<std::string>;
const TMemChecks& GetMemChecks() { return m_MemChecks; }
const TMemChecks& GetMemChecks() { return m_mem_checks; }
TMemChecksStr GetStrings() const;
void AddFromStrings(const TMemChecksStr& mcs);
void AddFromStrings(const TMemChecksStr& mc_strings);
void Add(const TMemCheck& _rMemoryCheck);
void Add(const TMemCheck& memory_check);
// memory breakpoint
TMemCheck* GetMemCheck(u32 address);
void Remove(u32 _Address);
void Remove(u32 address);
void Clear() { m_MemChecks.clear(); }
bool HasAny() const { return !m_MemChecks.empty(); }
void Clear() { m_mem_checks.clear(); }
bool HasAny() const { return !m_mem_checks.empty(); }
private:
TMemChecks m_MemChecks;
TMemChecks m_mem_checks;
};
class Watches
@ -101,23 +101,23 @@ public:
using TWatches = std::vector<TWatch>;
using TWatchesStr = std::vector<std::string>;
const TWatches& GetWatches() { return m_Watches; }
const TWatches& GetWatches() { return m_watches; }
TWatchesStr GetStrings() const;
void AddFromStrings(const TWatchesStr& bps);
void AddFromStrings(const TWatchesStr& watch_strings);
bool IsAddressWatch(u32 _iAddress) const;
bool IsAddressWatch(u32 address) const;
// Add BreakPoint
void Add(u32 em_address);
void Add(const TWatch& bp);
// Add watch
void Add(u32 address);
void Add(const TWatch& watch);
void Update(int count, u32 em_address);
void Update(int count, u32 address);
void UpdateName(int count, const std::string name);
// Remove Breakpoint
void Remove(u32 _iAddress);
// Remove watch
void Remove(u32 address);
void Clear();
private:
TWatches m_Watches;
TWatches m_watches;
};

View File

@ -424,7 +424,7 @@ static void Memcheck(u32 address, u32 var, bool write, int size)
// Disable when stepping so that resume works.
return;
}
mc->numHits++;
mc->num_hits++;
bool pause = mc->Action(&PowerPC::debug_interface, var, address, write, size, PC);
if (pause)
{

View File

@ -39,53 +39,54 @@ void CBreakPointView::Repopulate()
const BreakPoints::TBreakPoints& rBreakPoints = PowerPC::breakpoints.GetBreakPoints();
for (const auto& rBP : rBreakPoints)
{
if (!rBP.bTemporary)
if (!rBP.is_temporary)
{
wxString breakpoint_enabled_str = StrToWxStr(rBP.bOn ? "on" : " ");
wxString breakpoint_enabled_str = StrToWxStr(rBP.is_enabled ? "on" : " ");
int item = InsertItem(0, breakpoint_enabled_str);
SetItem(item, 1, StrToWxStr("BP"));
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress);
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rBP.address);
if (symbol)
{
wxString symbol_description = StrToWxStr(g_symbolDB.GetDescription(rBP.iAddress));
wxString symbol_description = StrToWxStr(g_symbolDB.GetDescription(rBP.address));
SetItem(item, 2, symbol_description);
}
std::string address = StringFromFormat("%08x", rBP.iAddress);
std::string address = StringFromFormat("%08x", rBP.address);
SetItem(item, 3, StrToWxStr(address));
SetItemData(item, rBP.iAddress);
SetItemData(item, rBP.address);
}
}
const MemChecks::TMemChecks& rMemChecks = PowerPC::memchecks.GetMemChecks();
for (const auto& rMemCheck : rMemChecks)
{
wxString memcheck_on_str = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " ");
const wxString memcheck_on_str =
StrToWxStr((rMemCheck.break_on_hit || rMemCheck.log_on_hit) ? "on" : " ");
int item = InsertItem(0, memcheck_on_str);
SetItem(item, 1, StrToWxStr("MBP"));
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress);
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.start_address);
if (symbol)
{
wxString memcheck_start_addr = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.StartAddress));
wxString memcheck_start_addr = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.start_address));
SetItem(item, 2, memcheck_start_addr);
}
std::string address_range_str =
StringFromFormat("%08x to %08x", rMemCheck.StartAddress, rMemCheck.EndAddress);
StringFromFormat("%08x to %08x", rMemCheck.start_address, rMemCheck.end_address);
SetItem(item, 3, StrToWxStr(address_range_str));
std::string mode;
if (rMemCheck.OnRead)
if (rMemCheck.is_break_on_read)
mode += 'r';
if (rMemCheck.OnWrite)
if (rMemCheck.is_break_on_write)
mode += 'w';
SetItem(item, 4, StrToWxStr(mode));
SetItemData(item, rMemCheck.StartAddress);
SetItemData(item, rMemCheck.start_address);
}
Refresh();

View File

@ -157,13 +157,13 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& event)
if (!EndAddressOK)
EndAddress = StartAddress;
MemCheck.StartAddress = StartAddress;
MemCheck.EndAddress = EndAddress;
MemCheck.bRange = StartAddress != EndAddress;
MemCheck.OnRead = OnRead;
MemCheck.OnWrite = OnWrite;
MemCheck.Log = Log;
MemCheck.Break = Break;
MemCheck.start_address = StartAddress;
MemCheck.end_address = EndAddress;
MemCheck.is_ranged = StartAddress != EndAddress;
MemCheck.is_break_on_read = OnRead;
MemCheck.is_break_on_write = OnWrite;
MemCheck.log_on_hit = Log;
MemCheck.break_on_hit = Break;
PowerPC::memchecks.Add(MemCheck);
EndModal(wxID_OK);

View File

@ -35,7 +35,7 @@ static std::string GetWatchName(int count)
static u32 GetWatchAddr(int count)
{
return PowerPC::watches.GetWatches().at(count - 1).iAddress;
return PowerPC::watches.GetWatches().at(count - 1).address;
}
static u32 GetWatchValue(int count)
@ -282,13 +282,11 @@ void CWatchView::OnPopupMenu(wxCommandEvent& event)
CMemoryWindow* memory_window = code_window->GetPanel<CMemoryWindow>();
CBreakPointWindow* breakpoint_window = code_window->GetPanel<CBreakPointWindow>();
wxString strNewVal;
TMemCheck MemCheck;
switch (event.GetId())
{
case IDM_DELETEWATCH:
strNewVal = GetValueByRowCol(m_selectedRow, 1);
{
wxString strNewVal = GetValueByRowCol(m_selectedRow, 1);
if (TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress))
{
PowerPC::watches.Remove(m_selectedAddress);
@ -297,20 +295,24 @@ void CWatchView::OnPopupMenu(wxCommandEvent& event)
Refresh();
}
break;
}
case IDM_ADDMEMCHECK:
MemCheck.StartAddress = m_selectedAddress;
MemCheck.EndAddress = m_selectedAddress;
MemCheck.bRange = false;
MemCheck.OnRead = true;
MemCheck.OnWrite = true;
MemCheck.Log = true;
MemCheck.Break = true;
{
TMemCheck MemCheck;
MemCheck.start_address = m_selectedAddress;
MemCheck.end_address = m_selectedAddress;
MemCheck.is_ranged = false;
MemCheck.is_break_on_read = true;
MemCheck.is_break_on_write = true;
MemCheck.log_on_hit = true;
MemCheck.break_on_hit = true;
PowerPC::memchecks.Add(MemCheck);
if (breakpoint_window)
breakpoint_window->NotifyUpdate();
Refresh();
break;
}
case IDM_VIEWMEMORY:
if (memory_window)
memory_window->JumpToAddress(m_selectedAddress);