mirror of
https://github.com/ksherlock/mpw.git
synced 2024-05-28 07:41:34 +00:00
store symbol table as a range
This commit is contained in:
parent
53cda5c7b7
commit
9c9decbe3b
|
@ -75,7 +75,8 @@ namespace {
|
||||||
AddressMap wbrkMap; // write breaks.
|
AddressMap wbrkMap; // write breaks.
|
||||||
ToolMap tbrkMap; // tool breaks.
|
ToolMap tbrkMap; // tool breaks.
|
||||||
|
|
||||||
std::map<std::string, uint32_t> SymbolTable;
|
Loader::DebugNameTable SymbolTable;
|
||||||
|
|
||||||
std::map<std::string, uint16_t> ErrorTable;
|
std::map<std::string, uint16_t> ErrorTable;
|
||||||
std::map<std::string, uint16_t> GlobalTable;
|
std::map<std::string, uint16_t> GlobalTable;
|
||||||
std::map<std::string, uint16_t> TrapTable;
|
std::map<std::string, uint16_t> TrapTable;
|
||||||
|
@ -831,16 +832,20 @@ void SetXRegister(unsigned reg, uint32_t value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// todo -- return a range
|
||||||
uint32_t VariableGet(const std::string &s)
|
uint32_t VariableGet(const std::string &s)
|
||||||
{
|
{
|
||||||
auto iter = SymbolTable.find(s);
|
auto iter = SymbolTable.find(s);
|
||||||
if (iter == SymbolTable.end()) return 0;
|
if (iter == SymbolTable.end()) return 0;
|
||||||
return iter->second;
|
return iter->second.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO -- take a Token and construct a pair, if it's a range.
|
||||||
|
// var = expr : expr or var = expr@count
|
||||||
|
|
||||||
void VariableSet(const std::string &key, uint32_t value)
|
void VariableSet(const std::string &key, uint32_t value)
|
||||||
{
|
{
|
||||||
SymbolTable.emplace(key, value);
|
SymbolTable.emplace(key, std::make_pair(value, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Info(uint32_t address)
|
void Info(uint32_t address)
|
||||||
|
@ -848,11 +853,30 @@ void Info(uint32_t address)
|
||||||
// print info on the value.
|
// print info on the value.
|
||||||
|
|
||||||
Print(address);
|
Print(address);
|
||||||
|
|
||||||
// 1. as a pointer.
|
// 1. as a pointer.
|
||||||
MM::Native::MemoryInfo(address);
|
MM::Native::MemoryInfo(address);
|
||||||
|
|
||||||
// 2. (todo) - check SymbolTable for procedure address.
|
// 2. (todo) - check SymbolTable for procedure address.
|
||||||
|
for (const auto &kv : SymbolTable)
|
||||||
|
{
|
||||||
|
const auto &name = kv.first;
|
||||||
|
auto range = kv.second;
|
||||||
|
|
||||||
|
//printf("%s: %x %x\n", name.c_str(), range.first, range.second);
|
||||||
|
|
||||||
|
// range end may be 0
|
||||||
|
if ((address == range.first) || (address >= range.first && address < range.second))
|
||||||
|
{
|
||||||
|
uint32_t offset = address - range.first;
|
||||||
|
if (offset)
|
||||||
|
printf("Routine: %s+$%x\n", name.c_str(), offset);
|
||||||
|
else
|
||||||
|
printf("Routine: %s\n", name.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 2. as a tool trap.
|
// 2. as a tool trap.
|
||||||
if (address >= 0xa000 && address <= 0xafff)
|
if (address >= 0xa000 && address <= 0xafff)
|
||||||
|
|
|
@ -23,7 +23,9 @@ enum {
|
||||||
// ; commands
|
// ; commands
|
||||||
kHexdump = 1,
|
kHexdump = 1,
|
||||||
kInfo,
|
kInfo,
|
||||||
kList
|
kList,
|
||||||
|
kBreak,
|
||||||
|
kTBreak
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Command {
|
struct Command {
|
||||||
|
@ -72,6 +74,9 @@ struct Token {
|
||||||
std::string *stringValue;
|
std::string *stringValue;
|
||||||
unsigned subtype;
|
unsigned subtype;
|
||||||
|
|
||||||
|
// unsigned range?
|
||||||
|
// unsigned modifier?
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
Token& operator=(uint32_t rhs)
|
Token& operator=(uint32_t rhs)
|
||||||
|
@ -82,7 +87,7 @@ struct Token {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
operator uint32_t() const
|
operator uint32_t() const
|
||||||
{
|
{
|
||||||
return intValue;
|
return intValue;
|
||||||
|
|
|
@ -363,7 +363,7 @@ namespace Loader {
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
void LoadDebugNames(std::map<std::string, uint32_t> &table)
|
void LoadDebugNames(DebugNameTable &table)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Segments.empty()) return;
|
if (Segments.empty()) return;
|
||||||
|
@ -493,7 +493,6 @@ namespace Loader {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.emplace(std::move(s), start + si.address);
|
|
||||||
|
|
||||||
|
|
||||||
// constant data
|
// constant data
|
||||||
|
@ -504,8 +503,13 @@ namespace Loader {
|
||||||
pc = (pc + length + 1) & ~1;
|
pc = (pc + length + 1) & ~1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO -- should this include the name and data?
|
||||||
|
table.emplace(std::move(s), std::make_pair(start + si.address, pc + si.address));
|
||||||
|
|
||||||
// in case no link instruction...
|
// in case no link instruction...
|
||||||
start = pc;
|
start = pc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::pair<uint32_t, uint32_t>> DebugNameTable;
|
||||||
namespace Native {
|
namespace Native {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,7 +22,7 @@ namespace Loader {
|
||||||
|
|
||||||
// scans segments for MacsBug debug names.
|
// scans segments for MacsBug debug names.
|
||||||
// associates them with the start of the segment.
|
// associates them with the start of the segment.
|
||||||
void LoadDebugNames(std::map<std::string, uint32_t> &table);
|
void LoadDebugNames(DebugNameTable &table);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user