Debugger: Use expressions for the function scanner address range

This commit is contained in:
chaoticgd 2024-11-14 22:53:55 +00:00 committed by Ty
parent cce0ae4369
commit 3b9b9a84cd
3 changed files with 28 additions and 8 deletions

View File

@ -37,8 +37,8 @@ DebugAnalysisSettingsWidget::DebugAnalysisSettingsWidget(QWidget* parent)
}
m_ui.customAddressRange->setChecked(Host::GetBoolSettingValue("Debugger/Analysis", "CustomFunctionScanRange", false));
m_ui.addressRangeStart->setText(QString::fromStdString(Host::GetStringSettingValue("Debugger/Analysis", "FunctionScanStartAddress", "0")));
m_ui.addressRangeEnd->setText(QString::fromStdString(Host::GetStringSettingValue("Debugger/Analysis", "FunctionScanEndAddress", "0")));
m_ui.addressRangeStart->setText(QString::fromStdString(Host::GetStringSettingValue("Debugger/Analysis", "FunctionScanStartAddress", "")));
m_ui.addressRangeEnd->setText(QString::fromStdString(Host::GetStringSettingValue("Debugger/Analysis", "FunctionScanEndAddress", "")));
m_ui.grayOutOverwrittenFunctions->setChecked(Host::GetBoolSettingValue("Debugger/Analysis", "GenerateFunctionHashes", true));

View File

@ -1105,8 +1105,8 @@ struct Pcsx2Config
DebugFunctionScanMode FunctionScanMode = DebugFunctionScanMode::SCAN_ELF;
bool CustomFunctionScanRange = false;
std::string FunctionScanStartAddress = "0";
std::string FunctionScanEndAddress = "0";
std::string FunctionScanStartAddress;
std::string FunctionScanEndAddress;
bool GenerateFunctionHashes = true;

View File

@ -351,7 +351,7 @@ void SymbolImporter::ImportExtraSymbols(
std::string error;
if (!parseExpression(extra_symbol_file.Condition.c_str(), &expression_functions, expression_result, error))
{
Console.Error("Failed to parse condition expression '%s' while importing extra symbol file '%s': %s.",
Console.Error("Failed to evaluate condition expression '%s' while importing extra symbol file '%s': %s",
extra_symbol_file.Condition.c_str(), path.c_str(), error.c_str());
}
@ -366,7 +366,7 @@ void SymbolImporter::ImportExtraSymbols(
std::string error;
if (!parseExpression(extra_symbol_file.BaseAddress.c_str(), &expression_functions, expression_result, error))
{
Console.Error("Failed to parse base address expression '%s' while importing extra symbol file '%s': %s.",
Console.Error("Failed to evaluate base address expression '%s' while importing extra symbol file '%s': %s",
extra_symbol_file.BaseAddress.c_str(), path.c_str(), error.c_str());
}
@ -548,12 +548,32 @@ std::unique_ptr<ccc::ast::Node> SymbolImporter::GetBuiltInType(
void SymbolImporter::ScanForFunctions(
ccc::SymbolDatabase& database, const ccc::ElfSymbolFile& elf, const Pcsx2Config::DebugAnalysisOptions& options)
{
MipsExpressionFunctions expression_functions(&r5900Debug, &database, true);
u32 start_address = 0;
u32 end_address = 0;
if (options.CustomFunctionScanRange)
{
start_address = static_cast<u32>(std::stoull(options.FunctionScanStartAddress.c_str(), nullptr, 16));
end_address = static_cast<u32>(std::stoull(options.FunctionScanEndAddress.c_str(), nullptr, 16));
u64 expression_result = 0;
std::string error;
if (!parseExpression(options.FunctionScanStartAddress.c_str(), &expression_functions, expression_result, error))
{
Console.Error("Failed to evaluate start address expression '%s' while scanning for functions: %s",
options.FunctionScanStartAddress.c_str(), error.c_str());
return;
}
start_address = static_cast<u32>(expression_result);
if (!parseExpression(options.FunctionScanEndAddress.c_str(), &expression_functions, expression_result, error))
{
Console.Error("Failed to evaluate end address expression '%s' while scanning for functions: %s",
options.FunctionScanEndAddress.c_str(), error.c_str());
return;
}
end_address = static_cast<u32>(expression_result);
}
else
{