Skip to content

Commit

Permalink
Merge pull request #258 from chaoticgd/demangler_const_ref
Browse files Browse the repository at this point in the history
Make a bunch of demangler parameters const references
  • Loading branch information
chaoticgd authored Oct 23, 2024
2 parents 912aae7 + 51c15af commit 114fd55
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/ccc/elf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Result<ElfFile> ElfFile::parse(std::vector<u8> image)
}

Result<void> ElfFile::import_section_headers(
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const
{
for (const ElfSection& section : sections) {
Address address = Address::non_zero(section.header.addr);
Expand All @@ -89,7 +89,7 @@ Result<void> ElfFile::import_section_headers(
}

Result<void> ElfFile::import_symbol_sections(
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const
{
// Parse sections generated as a result of passing -ffunction-sections and
// -fdata-sections to gcc. For example for a function "MyFunc" in the .text
Expand Down Expand Up @@ -143,7 +143,7 @@ Result<void> ElfFile::import_symbol_sections(
}

Result<void> ElfFile::import_link_once_sections(
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const
{
// Parse .gnu.linkonce.* section names. These are be generated as part of
// vague linking e.g. for template instantiations, and can be left in the
Expand Down
6 changes: 3 additions & 3 deletions src/ccc/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ struct ElfFile {
static Result<ElfFile> parse(std::vector<u8> image);

Result<void> import_section_headers(
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const;
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const;
Result<void> import_symbol_sections(
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const;
Result<void> import_link_once_sections(SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, DemanglerFunctions demangler) const;
SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const;
Result<void> import_link_once_sections(SymbolDatabase& database, const SymbolGroup& group, u32 importer_flags, const DemanglerFunctions& demangler) const;
static std::optional<ElfLinkOnceSection> parse_link_once_section_name(const std::string& section_name);

const ElfSection* lookup_section(const char* name) const;
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/elf_symtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Result<void> import_symbols(
std::span<const u8> symtab,
std::span<const u8> strtab,
u32 importer_flags,
DemanglerFunctions demangler)
const DemanglerFunctions& demangler)
{
for (u32 i = 0; i < symtab.size() / sizeof(Symbol); i++) {
const Symbol* symbol = get_packed<Symbol>(symtab, i * sizeof(Symbol));
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/elf_symtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Result<void> import_symbols(
std::span<const u8> symtab,
std::span<const u8> strtab,
u32 importer_flags,
DemanglerFunctions demangler);
const DemanglerFunctions& demangler);

Result<void> print_symbol_table(FILE* out, std::span<const u8> symtab, std::span<const u8> strtab);

Expand Down
2 changes: 1 addition & 1 deletion src/ccc/sndll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Result<void> import_sndll_symbols(
const SNDLLFile& sndll,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler)
const DemanglerFunctions& demangler)
{
for (const SNDLLSymbol& symbol : sndll.symbols) {
if (symbol.value == 0 || symbol.string.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/sndll.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Result<void> import_sndll_symbols(
const SNDLLFile& sndll,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler);
const DemanglerFunctions& demangler);

void print_sndll_symbols(FILE* out, const SNDLLFile& sndll);

Expand Down
2 changes: 1 addition & 1 deletion src/ccc/symbol_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Result<SymbolType*> SymbolList<SymbolType>::create_symbol(

template <typename SymbolType>
Result<SymbolType*> SymbolList<SymbolType>::create_symbol(
std::string name, SymbolSourceHandle source, const Module* module_symbol, Address address, u32 importer_flags, DemanglerFunctions demangler)
std::string name, SymbolSourceHandle source, const Module* module_symbol, Address address, u32 importer_flags, const DemanglerFunctions& demangler)
{
static const int DMGL_PARAMS = 1 << 0;
static const int DMGL_RET_POSTFIX = 1 << 5;
Expand Down
2 changes: 1 addition & 1 deletion src/ccc/symbol_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SymbolList {
const Module* module_symbol,
Address address,
u32 importer_flags,
DemanglerFunctions demangler);
const DemanglerFunctions& demangler);

// Update the address of a symbol without changing its handle.
bool move_symbol(SymbolHandle<SymbolType> handle, Address new_address);
Expand Down
10 changes: 5 additions & 5 deletions src/ccc/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Result<ModuleHandle> import_symbol_tables(
std::string module_name,
const std::vector<std::unique_ptr<SymbolTable>>& symbol_tables,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt)
{
Result<SymbolSourceHandle> module_source = database.get_symbol_source("Symbol Table Importer");
Expand Down Expand Up @@ -153,7 +153,7 @@ Result<void> MdebugSymbolTable::import(
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const
{
return mdebug::import_symbol_table(
Expand Down Expand Up @@ -199,7 +199,7 @@ Result<void> SymtabSymbolTable::import(
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const
{
return elf::import_symbols(database, group, m_symtab, m_strtab, importer_flags, demangler);
Expand Down Expand Up @@ -232,7 +232,7 @@ Result<void> SNDLLSymbolTable::import(
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const
{
return import_sndll_symbols(database, *m_sndll, group, importer_flags, demangler);
Expand Down Expand Up @@ -264,7 +264,7 @@ Result<void> ElfSectionHeadersSymbolTable::import(
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const
{
return m_elf.import_section_headers(database, group, importer_flags, demangler);
Expand Down
12 changes: 6 additions & 6 deletions src/ccc/symbol_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SymbolTable {
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const = 0;

// Print out all the field in the header structure if one exists.
Expand All @@ -74,7 +74,7 @@ Result<ModuleHandle> import_symbol_tables(
std::string module_name,
const std::vector<std::unique_ptr<SymbolTable>>& symbol_tables,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt);

class MdebugSymbolTable : public SymbolTable {
Expand All @@ -87,7 +87,7 @@ class MdebugSymbolTable : public SymbolTable {
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const override;

Result<void> print_headers(FILE* out) const override;
Expand All @@ -108,7 +108,7 @@ class SymtabSymbolTable : public SymbolTable {
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const override;

Result<void> print_headers(FILE* out) const override;
Expand All @@ -131,7 +131,7 @@ class SNDLLSymbolTable : public SymbolTable {
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const override;

Result<void> print_headers(FILE* out) const override;
Expand All @@ -151,7 +151,7 @@ class ElfSectionHeadersSymbolTable : public SymbolTable {
SymbolDatabase& database,
const SymbolGroup& group,
u32 importer_flags,
DemanglerFunctions demangler,
const DemanglerFunctions& demangler,
const std::atomic_bool* interrupt) const override;

Result<void> print_headers(FILE* out) const override;
Expand Down

0 comments on commit 114fd55

Please sign in to comment.