PPCSymbolDB: Use ranges in SaveSymbolMap
This commit is contained in:
parent
9b3b6bea9d
commit
5c151c11ac
|
@ -6,11 +6,11 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ranges>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
@ -466,42 +466,38 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::vector<const Common::Symbol*> function_symbols;
|
|
||||||
std::vector<const Common::Symbol*> data_symbols;
|
|
||||||
|
|
||||||
for (const auto& function : m_functions)
|
|
||||||
{
|
|
||||||
const Common::Symbol& symbol = function.second;
|
|
||||||
if (symbol.type == Common::Symbol::Type::Function)
|
|
||||||
function_symbols.push_back(&symbol);
|
|
||||||
else
|
|
||||||
data_symbols.push_back(&symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write .text section
|
// Write .text section
|
||||||
|
auto function_symbols =
|
||||||
|
m_functions |
|
||||||
|
std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Function; }) |
|
||||||
|
std::views::transform([](auto f) { return f.second; });
|
||||||
f.WriteString(".text section layout\n");
|
f.WriteString(".text section layout\n");
|
||||||
for (const auto& symbol : function_symbols)
|
for (const auto& symbol : function_symbols)
|
||||||
{
|
{
|
||||||
// Write symbol address, size, virtual address, alignment, name
|
// Write symbol address, size, virtual address, alignment, name
|
||||||
std::string line = fmt::format("{0:08x} {1:06x} {2:08x} {3} {4}", symbol->address, symbol->size,
|
std::string line = fmt::format("{:08x} {:06x} {:08x} {} {}", symbol.address, symbol.size,
|
||||||
symbol->address, 0, symbol->name);
|
symbol.address, 0, symbol.name);
|
||||||
// Also write the object name if it exists
|
// Also write the object name if it exists
|
||||||
if (!symbol->object_name.empty())
|
if (!symbol.object_name.empty())
|
||||||
line += fmt::format(" \t{0}", symbol->object_name);
|
line += fmt::format(" \t{0}", symbol.object_name);
|
||||||
line += "\n";
|
line += "\n";
|
||||||
f.WriteString(line);
|
f.WriteString(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write .data section
|
// Write .data section
|
||||||
|
auto data_symbols =
|
||||||
|
m_functions |
|
||||||
|
std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Data; }) |
|
||||||
|
std::views::transform([](auto f) { return f.second; });
|
||||||
f.WriteString("\n.data section layout\n");
|
f.WriteString("\n.data section layout\n");
|
||||||
for (const auto& symbol : data_symbols)
|
for (const auto& symbol : data_symbols)
|
||||||
{
|
{
|
||||||
// Write symbol address, size, virtual address, alignment, name
|
// Write symbol address, size, virtual address, alignment, name
|
||||||
std::string line = fmt::format("{0:08x} {1:06x} {2:08x} {3} {4}", symbol->address, symbol->size,
|
std::string line = fmt::format("{:08x} {:06x} {:08x} {} {}", symbol.address, symbol.size,
|
||||||
symbol->address, 0, symbol->name);
|
symbol.address, 0, symbol.name);
|
||||||
// Also write the object name if it exists
|
// Also write the object name if it exists
|
||||||
if (!symbol->object_name.empty())
|
if (!symbol.object_name.empty())
|
||||||
line += fmt::format(" \t{0}", symbol->object_name);
|
line += fmt::format(" \t{0}", symbol.object_name);
|
||||||
line += "\n";
|
line += "\n";
|
||||||
f.WriteString(line);
|
f.WriteString(line);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue