Skip to content

Commit

Permalink
CodeWidget/CodeViewWidget: Make symbol pointers const where applicable
Browse files Browse the repository at this point in the history
These aren't used to modify the data they point to, so make that
explicit. Also while we're at it, add const to any nearby variables that
can be made so.
  • Loading branch information
lioncash committed May 27, 2018
1 parent f568e41 commit 880f787
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
Expand Up @@ -280,17 +280,17 @@ void CodeViewWidget::OnCopyFunction()
{ {
const u32 address = GetContextAddress(); const u32 address = GetContextAddress();


Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
if (!symbol) if (!symbol)
return; return;


std::string text = symbol->name + "\r\n"; std::string text = symbol->name + "\r\n";
// we got a function // we got a function
u32 start = symbol->address; const u32 start = symbol->address;
u32 end = start + symbol->size; const u32 end = start + symbol->size;
for (u32 addr = start; addr != end; addr += 4) for (u32 addr = start; addr != end; addr += 4)
{ {
std::string disasm = PowerPC::debug_interface.Disassemble(addr); const std::string disasm = PowerPC::debug_interface.Disassemble(addr);
text += StringFromFormat("%08x: ", addr) + disasm + "\r\n"; text += StringFromFormat("%08x: ", addr) + disasm + "\r\n";
} }


Expand Down
20 changes: 10 additions & 10 deletions Source/Core/DolphinQt2/Debugger/CodeWidget.cpp
Expand Up @@ -201,10 +201,10 @@ void CodeWidget::OnSelectSymbol()
if (items.isEmpty()) if (items.isEmpty())
return; return;


Symbol* symbol = g_symbolDB.GetSymbolFromAddr(items[0]->data(Qt::UserRole).toUInt()); const u32 address = items[0]->data(Qt::UserRole).toUInt();
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);


m_code_view->SetAddress(items[0]->data(Qt::UserRole).toUInt(), m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
CodeViewWidget::SetAddressUpdate::WithUpdate);
UpdateCallstack(); UpdateCallstack();
UpdateFunctionCalls(symbol); UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol); UpdateFunctionCallers(symbol);
Expand Down Expand Up @@ -252,7 +252,7 @@ void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update


void CodeWidget::Update() void CodeWidget::Update()
{ {
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress()); const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());


UpdateCallstack(); UpdateCallstack();


Expand Down Expand Up @@ -321,14 +321,14 @@ void CodeWidget::UpdateSymbols()
m_symbols_list->sortItems(); m_symbols_list->sortItems();
} }


void CodeWidget::UpdateFunctionCalls(Symbol* symbol) void CodeWidget::UpdateFunctionCalls(const Symbol* symbol)
{ {
m_function_calls_list->clear(); m_function_calls_list->clear();


for (const auto& call : symbol->calls) for (const auto& call : symbol->calls)
{ {
u32 addr = call.function; const u32 addr = call.function;
Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr); const Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);


if (call_symbol) if (call_symbol)
{ {
Expand All @@ -341,14 +341,14 @@ void CodeWidget::UpdateFunctionCalls(Symbol* symbol)
} }
} }


void CodeWidget::UpdateFunctionCallers(Symbol* symbol) void CodeWidget::UpdateFunctionCallers(const Symbol* symbol)
{ {
m_function_callers_list->clear(); m_function_callers_list->clear();


for (const auto& caller : symbol->callers) for (const auto& caller : symbol->callers)
{ {
u32 addr = caller.callAddress; const u32 addr = caller.callAddress;
Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr); const Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);


if (caller_symbol) if (caller_symbol)
{ {
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt2/Debugger/CodeWidget.h
Expand Up @@ -45,8 +45,8 @@ class CodeWidget : public QDockWidget
void CreateWidgets(); void CreateWidgets();
void ConnectWidgets(); void ConnectWidgets();
void UpdateCallstack(); void UpdateCallstack();
void UpdateFunctionCalls(Symbol* symbol); void UpdateFunctionCalls(const Symbol* symbol);
void UpdateFunctionCallers(Symbol* symbol); void UpdateFunctionCallers(const Symbol* symbol);


void OnSearchAddress(); void OnSearchAddress();
void OnSearchSymbols(); void OnSearchSymbols();
Expand Down

0 comments on commit 880f787

Please sign in to comment.