Compare commits

...

3 Commits

Author SHA1 Message Date
chaoticgd
bea471a0e3 Debugger: Fix loading symbols from ELF files other than the boot ELF 2024-11-06 16:58:07 -05:00
chaoticgd
4dafee17e0 Debugger: Refactor nocash symbol importer 2024-11-06 14:23:22 -05:00
PCSX2 Bot
af10be9036 [ci skip] Qt: Update Base Translation. 2024-11-05 19:06:39 -05:00
5 changed files with 2033 additions and 1988 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -126,6 +126,7 @@ void SymbolImporter::Reset()
m_guardian.ReadWrite([&](ccc::SymbolDatabase& database) {
database.clear();
m_builtin_types.clear();
ccc::Result<ccc::SymbolSourceHandle> source = database.get_symbol_source("Built-In");
if (!source.success())
@@ -145,6 +146,8 @@ void SymbolImporter::Reset()
type->size_bytes = ccc::ast::builtin_class_size(default_type.bclass);
type->bclass = default_type.bclass;
(*symbol)->set_type(std::move(type));
m_builtin_types.emplace(default_type.name, (*symbol)->handle());
}
});
}
@@ -193,12 +196,12 @@ void SymbolImporter::AnalyseElf(
ShutdownWorkerThread();
m_import_thread = std::thread([this, nocash_path, options, worker_symbol_file = std::move(symbol_file)]() {
m_import_thread = std::thread([this, nocash_path, options, worker_symbol_file = std::move(symbol_file), builtins = m_builtin_types]() {
Threading::SetNameOfCurrentThread("Symbol Worker");
ccc::SymbolDatabase temp_database;
ImportSymbols(temp_database, worker_symbol_file, nocash_path, options, &m_interrupt_import_thread);
ImportSymbols(temp_database, worker_symbol_file, nocash_path, options, builtins, &m_interrupt_import_thread);
if (m_interrupt_import_thread)
return;
@@ -270,6 +273,7 @@ void SymbolImporter::ImportSymbols(
const ccc::ElfSymbolFile& elf,
const std::string& nocash_path,
const Pcsx2Config::DebugAnalysisOptions& options,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types,
const std::atomic_bool* interrupt)
{
ccc::DemanglerFunctions demangler;
@@ -307,8 +311,12 @@ void SymbolImporter::ImportSymbols(
if (!nocash_path.empty() && options.ImportSymFileFromDefaultLocation)
{
if (!ImportNocashSymbols(database, nocash_path))
Console.Error("Failed to read symbol file from default location '%s'.", nocash_path.c_str());
ccc::Result<bool> nocash_result = ImportNocashSymbols(database, nocash_path, builtin_types);
if (!nocash_result.success())
{
Console.Error("Failed to import symbol file '%s': %s",
nocash_path.c_str(), nocash_result.error().message.c_str());
}
}
for (const DebugExtraSymbolFile& extra_symbol_file : options.ExtraSymbolFiles)
@@ -318,8 +326,16 @@ void SymbolImporter::ImportSymbols(
if (StringUtil::EndsWithNoCase(extra_symbol_file.Path, ".sym"))
{
if (!ImportNocashSymbols(database, extra_symbol_file.Path))
Console.Error("Failed to read extra symbol file '%s'.", extra_symbol_file.Path.c_str());
ccc::Result<bool> nocash_result = ImportNocashSymbols(database, extra_symbol_file.Path, builtin_types);
if (!nocash_result.success())
{
Console.Error("Failed to import symbol file '%s': %s",
extra_symbol_file.Path.c_str(), nocash_result.error().message.c_str());
}
if (!*nocash_result)
Console.Error("Cannot open symbol file '%s'.", extra_symbol_file.Path.c_str());
continue;
}
@@ -340,7 +356,7 @@ void SymbolImporter::ImportSymbols(
continue;
}
ccc::Result<std::vector<std::unique_ptr<ccc::SymbolTable>>> symbol_tables = elf.get_all_symbol_tables();
ccc::Result<std::vector<std::unique_ptr<ccc::SymbolTable>>> symbol_tables = (*symbol_file)->get_all_symbol_tables();
if (!symbol_tables.success())
{
ccc::report_error(symbol_tables.error());
@@ -361,20 +377,22 @@ void SymbolImporter::ImportSymbols(
return;
}
bool SymbolImporter::ImportNocashSymbols(ccc::SymbolDatabase& database, const std::string& file_path)
ccc::Result<bool> SymbolImporter::ImportNocashSymbols(
ccc::SymbolDatabase& database,
const std::string& file_path,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types)
{
FILE* f = FileSystem::OpenCFile(file_path.c_str(), "r");
if (!f)
auto file = FileSystem::OpenManagedCFile(file_path.c_str(), "r");
if (!file)
return false;
ccc::Result<ccc::SymbolSourceHandle> source = database.get_symbol_source("Nocash Symbols");
if (!source.success())
return false;
CCC_RETURN_IF_ERROR(source);
while (!feof(f))
while (!feof(file.get()))
{
char line[256], value[256] = {0};
char* p = fgets(line, 256, f);
char* p = fgets(line, 256, file.get());
if (p == NULL)
break;
@@ -399,49 +417,31 @@ bool SymbolImporter::ImportNocashSymbols(ccc::SymbolDatabase& database, const st
if (sscanf(s + 1, "%04x", &size) != 1)
continue;
std::unique_ptr<ccc::ast::BuiltIn> scalar_type = std::make_unique<ccc::ast::BuiltIn>();
std::unique_ptr<ccc::ast::Node> type;
if (StringUtil::Strcasecmp(value, ".byt") == 0)
{
scalar_type->size_bytes = 1;
scalar_type->bclass = ccc::ast::BuiltInClass::UNSIGNED_8;
}
type = GetBuiltInType("u8", ccc::ast::BuiltInClass::UNSIGNED_8, builtin_types);
else if (StringUtil::Strcasecmp(value, ".wrd") == 0)
{
scalar_type->size_bytes = 2;
scalar_type->bclass = ccc::ast::BuiltInClass::UNSIGNED_16;
}
type = GetBuiltInType("u16", ccc::ast::BuiltInClass::UNSIGNED_16, builtin_types);
else if (StringUtil::Strcasecmp(value, ".dbl") == 0)
{
scalar_type->size_bytes = 4;
scalar_type->bclass = ccc::ast::BuiltInClass::UNSIGNED_32;
}
type = GetBuiltInType("u32", ccc::ast::BuiltInClass::UNSIGNED_32, builtin_types);
else if (StringUtil::Strcasecmp(value, ".asc") == 0)
{
scalar_type->size_bytes = 1;
scalar_type->bclass = ccc::ast::BuiltInClass::UNQUALIFIED_8;
}
type = GetBuiltInType("char", ccc::ast::BuiltInClass::UNQUALIFIED_8, builtin_types);
else
{
continue;
}
ccc::Result<ccc::GlobalVariable*> global_variable = database.global_variables.create_symbol(
line, address, *source, nullptr);
if (!global_variable.success())
{
fclose(f);
return false;
}
CCC_RETURN_IF_ERROR(global_variable);
if (scalar_type->size_bytes == (s32)size)
if (type->size_bytes == (s32)size)
{
(*global_variable)->set_type(std::move(scalar_type));
(*global_variable)->set_type(std::move(type));
}
else
{
std::unique_ptr<ccc::ast::Array> array = std::make_unique<ccc::ast::Array>();
array->size_bytes = (s32)size;
array->element_type = std::move(scalar_type);
array->element_type = std::move(type);
array->element_count = size / array->element_type->size_bytes;
(*global_variable)->set_type(std::move(array));
}
@@ -460,30 +460,41 @@ bool SymbolImporter::ImportNocashSymbols(ccc::SymbolDatabase& database, const st
if (size != 1)
{
ccc::Result<ccc::Function*> function = database.functions.create_symbol(value, address, *source, nullptr);
if (!function.success())
{
fclose(f);
return false;
}
CCC_RETURN_IF_ERROR(function);
(*function)->set_size(size);
}
else
{
ccc::Result<ccc::Label*> label = database.labels.create_symbol(value, address, *source, nullptr);
if (!label.success())
{
fclose(f);
return false;
}
CCC_RETURN_IF_ERROR(label);
}
}
}
fclose(f);
return true;
}
std::unique_ptr<ccc::ast::Node> SymbolImporter::GetBuiltInType(
const std::string& name,
ccc::ast::BuiltInClass bclass,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types)
{
auto type = builtin_types.find(name);
if (type != builtin_types.end())
{
std::unique_ptr<ccc::ast::TypeName> type_name = std::make_unique<ccc::ast::TypeName>();
type_name->size_bytes = ccc::ast::builtin_class_size(bclass);
type_name->data_type_handle = type->second;
return type_name;
}
std::unique_ptr<ccc::ast::BuiltIn> built_in = std::make_unique<ccc::ast::BuiltIn>();
built_in->size_bytes = ccc::ast::builtin_class_size(bclass);
built_in->bclass = bclass;
return built_in;
}
void SymbolImporter::ScanForFunctions(
ccc::SymbolDatabase& database, const ccc::ElfSymbolFile& elf, const Pcsx2Config::DebugAnalysisOptions& options)
{

View File

@@ -43,8 +43,18 @@ public:
const ccc::ElfSymbolFile& elf,
const std::string& nocash_path,
const Pcsx2Config::DebugAnalysisOptions& options,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types,
const std::atomic_bool* interrupt);
static bool ImportNocashSymbols(ccc::SymbolDatabase& database, const std::string& file_path);
static ccc::Result<bool> ImportNocashSymbols(
ccc::SymbolDatabase& database,
const std::string& file_path,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types);
static std::unique_ptr<ccc::ast::Node> GetBuiltInType(
const std::string& name,
ccc::ast::BuiltInClass bclass,
const std::map<std::string, ccc::DataTypeHandle>& builtin_types);
static void ScanForFunctions(
ccc::SymbolDatabase& database, const ccc::ElfSymbolFile& elf, const Pcsx2Config::DebugAnalysisOptions& options);
@@ -57,6 +67,8 @@ protected:
std::thread m_import_thread;
std::atomic_bool m_interrupt_import_thread = false;
std::map<std::string, ccc::DataTypeHandle> m_builtin_types;
};
extern SymbolImporter R5900SymbolImporter;

View File

@@ -6975,6 +6975,7 @@ TRANSLATE_NOOP("FullscreenUI", "Pauses the emulator when you open the quick menu
TRANSLATE_NOOP("FullscreenUI", "Determines whether a prompt will be displayed to confirm shutting down the emulator/game when the hotkey is pressed.");
TRANSLATE_NOOP("FullscreenUI", "Automatically saves the emulator state when powering down or exiting. You can then resume directly from where you left off next time.");
TRANSLATE_NOOP("FullscreenUI", "Creates a backup copy of a save state if it already exists when the save is created. The backup copy has a .backup suffix");
TRANSLATE_NOOP("FullscreenUI", "Show a save state selector UI when switching slots instead of showing a notification bubble.");
TRANSLATE_NOOP("FullscreenUI", "Uses a light coloured theme instead of the default dark theme.");
TRANSLATE_NOOP("FullscreenUI", "Game Display");
TRANSLATE_NOOP("FullscreenUI", "Automatically switches to fullscreen mode when a game is started.");
@@ -7637,6 +7638,7 @@ TRANSLATE_NOOP("FullscreenUI", "Pause On Menu");
TRANSLATE_NOOP("FullscreenUI", "Confirm Shutdown");
TRANSLATE_NOOP("FullscreenUI", "Save State On Shutdown");
TRANSLATE_NOOP("FullscreenUI", "Create Save State Backups");
TRANSLATE_NOOP("FullscreenUI", "Use Save State Selector");
TRANSLATE_NOOP("FullscreenUI", "Use Light Theme");
TRANSLATE_NOOP("FullscreenUI", "Start Fullscreen");
TRANSLATE_NOOP("FullscreenUI", "Double-Click Toggles Fullscreen");

View File

@@ -490,7 +490,7 @@ ImFont* ImGuiManager::AddFixedFont(float size)
bool ImGuiManager::AddIconFonts(float size)
{
// clang-format off
static constexpr ImWchar range_fa[] = { 0xe06f,0xe06f,0xf002,0xf002,0xf005,0xf005,0xf007,0xf007,0xf00c,0xf00e,0xf011,0xf011,0xf013,0xf013,0xf017,0xf017,0xf019,0xf019,0xf021,0xf023,0xf025,0xf028,0xf02b,0xf02b,0xf02e,0xf02e,0xf030,0xf030,0xf03a,0xf03a,0xf03d,0xf03e,0xf04b,0xf04c,0xf04e,0xf04e,0xf050,0xf050,0xf052,0xf052,0xf05e,0xf05e,0xf063,0xf063,0xf067,0xf067,0xf06a,0xf06a,0xf06e,0xf06e,0xf071,0xf071,0xf077,0xf078,0xf07b,0xf07c,0xf084,0xf084,0xf091,0xf091,0xf0ac,0xf0ad,0xf0b0,0xf0b0,0xf0c5,0xf0c5,0xf0c7,0xf0c8,0xf0cb,0xf0cb,0xf0d0,0xf0d0,0xf0dc,0xf0dc,0xf0e2,0xf0e2,0xf0eb,0xf0eb,0xf0f3,0xf0f3,0xf0fe,0xf0fe,0xf11b,0xf11c,0xf120,0xf121,0xf129,0xf12a,0xf140,0xf140,0xf14a,0xf14a,0xf15b,0xf15b,0xf15d,0xf15d,0xf187,0xf188,0xf191,0xf192,0xf1b3,0xf1b3,0xf1de,0xf1de,0xf1e6,0xf1e6,0xf1ea,0xf1eb,0xf1f8,0xf1f8,0xf1fc,0xf1fc,0xf21e,0xf21e,0xf245,0xf245,0xf26c,0xf26c,0xf279,0xf279,0xf2bd,0xf2bd,0xf2db,0xf2db,0xf2f2,0xf2f2,0xf302,0xf302,0xf3c1,0xf3c1,0xf3fd,0xf3fd,0xf410,0xf410,0xf462,0xf462,0xf466,0xf466,0xf4e2,0xf4e2,0xf51f,0xf51f,0xf545,0xf545,0xf54c,0xf54c,0xf553,0xf553,0xf56d,0xf56d,0xf5a2,0xf5a2,0xf65d,0xf65e,0xf6a9,0xf6a9,0xf70e,0xf70e,0xf756,0xf756,0xf780,0xf780,0xf794,0xf794,0xf815,0xf815,0xf84c,0xf84c,0xf8cc,0xf8cc,0x0,0x0 };
static constexpr ImWchar range_fa[] = { 0xe06f,0xe06f,0xf002,0xf002,0xf005,0xf005,0xf007,0xf007,0xf00c,0xf00e,0xf011,0xf011,0xf013,0xf013,0xf017,0xf017,0xf019,0xf019,0xf021,0xf023,0xf025,0xf028,0xf02b,0xf02b,0xf02e,0xf02e,0xf030,0xf030,0xf03a,0xf03a,0xf03d,0xf03e,0xf04b,0xf04c,0xf04e,0xf04e,0xf050,0xf050,0xf052,0xf052,0xf05a,0xf05a,0xf05e,0xf05e,0xf063,0xf063,0xf067,0xf067,0xf06a,0xf06a,0xf06e,0xf06e,0xf071,0xf071,0xf077,0xf078,0xf07b,0xf07c,0xf084,0xf084,0xf091,0xf091,0xf0ac,0xf0ad,0xf0b0,0xf0b0,0xf0c5,0xf0c5,0xf0c7,0xf0c8,0xf0cb,0xf0cb,0xf0d0,0xf0d0,0xf0dc,0xf0dc,0xf0e2,0xf0e2,0xf0eb,0xf0eb,0xf0f3,0xf0f3,0xf0fe,0xf0fe,0xf11b,0xf11c,0xf120,0xf121,0xf129,0xf12a,0xf140,0xf140,0xf14a,0xf14a,0xf15b,0xf15b,0xf15d,0xf15d,0xf187,0xf188,0xf191,0xf192,0xf1b3,0xf1b3,0xf1de,0xf1de,0xf1e6,0xf1e6,0xf1ea,0xf1eb,0xf1f8,0xf1f8,0xf1fc,0xf1fc,0xf21e,0xf21e,0xf245,0xf245,0xf26c,0xf26c,0xf279,0xf279,0xf2bd,0xf2bd,0xf2db,0xf2db,0xf2f2,0xf2f2,0xf302,0xf302,0xf3c1,0xf3c1,0xf3fd,0xf3fd,0xf410,0xf410,0xf462,0xf462,0xf466,0xf466,0xf4e2,0xf4e2,0xf51f,0xf51f,0xf545,0xf545,0xf54c,0xf54c,0xf553,0xf553,0xf56d,0xf56d,0xf5a2,0xf5a2,0xf65d,0xf65e,0xf6a9,0xf6a9,0xf70e,0xf70e,0xf756,0xf756,0xf780,0xf780,0xf794,0xf794,0xf815,0xf815,0xf84c,0xf84c,0xf8cc,0xf8cc,0x0,0x0 };
static constexpr ImWchar range_pf[] = { 0x2198,0x2199,0x219e,0x21a3,0x21b0,0x21b3,0x21ba,0x21c3,0x21ce,0x21ce,0x21d0,0x21d4,0x21dc,0x21dd,0x21e0,0x21e3,0x21f3,0x21f3,0x21f7,0x21f8,0x21fa,0x21fb,0x221a,0x221a,0x227a,0x227d,0x22bf,0x22c8,0x2349,0x2349,0x235a,0x235e,0x2360,0x2361,0x2364,0x2367,0x237a,0x237b,0x237d,0x237d,0x237f,0x237f,0x23b2,0x23b5,0x23cc,0x23cc,0x23f4,0x23f7,0x2427,0x243a,0x243d,0x243d,0x2443,0x2443,0x2460,0x246b,0x248f,0x248f,0x24f5,0x24fd,0x24ff,0x24ff,0x2605,0x2605,0x2699,0x2699,0x278a,0x278e,0xe001,0xe001,0xff21,0xff3a,0x0,0x0 };
// clang-format on