Merge pull request #6981 from lioncash/const

CodeWidget/CodeViewWidget: Make symbol pointers const where applicable
This commit is contained in:
Léo Lam 2018-05-27 10:20:38 +02:00 committed by GitHub
commit 8f003f995b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View File

@ -280,17 +280,17 @@ void CodeViewWidget::OnCopyFunction()
{
const u32 address = GetContextAddress();
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
if (!symbol)
return;
std::string text = symbol->name + "\r\n";
// we got a function
u32 start = symbol->address;
u32 end = start + symbol->size;
const u32 start = symbol->address;
const u32 end = start + symbol->size;
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";
}

View File

@ -201,10 +201,10 @@ void CodeWidget::OnSelectSymbol()
if (items.isEmpty())
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(),
CodeViewWidget::SetAddressUpdate::WithUpdate);
m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
UpdateCallstack();
UpdateFunctionCalls(symbol);
UpdateFunctionCallers(symbol);
@ -252,7 +252,7 @@ void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update
void CodeWidget::Update()
{
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
const Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
UpdateCallstack();
@ -321,14 +321,14 @@ void CodeWidget::UpdateSymbols()
m_symbols_list->sortItems();
}
void CodeWidget::UpdateFunctionCalls(Symbol* symbol)
void CodeWidget::UpdateFunctionCalls(const Symbol* symbol)
{
m_function_calls_list->clear();
for (const auto& call : symbol->calls)
{
u32 addr = call.function;
Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
const u32 addr = call.function;
const Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
if (call_symbol)
{
@ -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();
for (const auto& caller : symbol->callers)
{
u32 addr = caller.callAddress;
Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
const u32 addr = caller.callAddress;
const Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
if (caller_symbol)
{

View File

@ -45,8 +45,8 @@ private:
void CreateWidgets();
void ConnectWidgets();
void UpdateCallstack();
void UpdateFunctionCalls(Symbol* symbol);
void UpdateFunctionCallers(Symbol* symbol);
void UpdateFunctionCalls(const Symbol* symbol);
void UpdateFunctionCallers(const Symbol* symbol);
void OnSearchAddress();
void OnSearchSymbols();