mirror of
https://github.com/ksherlock/mpw.git
synced 2024-09-28 01:54:33 +00:00
EnvMap -> Variable
This commit is contained in:
parent
810b521a11
commit
b7b6d8656b
@ -73,7 +73,7 @@ namespace {
|
|||||||
AddressMap wbrkMap; // write breaks.
|
AddressMap wbrkMap; // write breaks.
|
||||||
ToolMap tbrkMap; // tool breaks.
|
ToolMap tbrkMap; // tool breaks.
|
||||||
|
|
||||||
std::unordered_map<std::string, uint32_t> envMap;
|
std::unordered_map<std::string, uint32_t> SymbolTable;
|
||||||
|
|
||||||
|
|
||||||
void hexdump(const uint8_t *data, ssize_t size, uint32_t address = 0)
|
void hexdump(const uint8_t *data, ssize_t size, uint32_t address = 0)
|
||||||
@ -827,14 +827,17 @@ void SetXRegister(unsigned reg, uint32_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t EnvLookup(const std::string &s)
|
uint32_t VariableGet(const std::string &s)
|
||||||
{
|
{
|
||||||
auto iter = envMap.find(s);
|
auto iter = SymbolTable.find(s);
|
||||||
if (iter == envMap.end()) return 0;
|
if (iter == SymbolTable.end()) return 0;
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VariableSet(const std::string &key, uint32_t value)
|
||||||
|
{
|
||||||
|
SymbolTable.emplace(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO -- RUN command - reload, re-initialize, re-execute
|
// TODO -- RUN command - reload, re-initialize, re-execute
|
||||||
// TODO -- parser calls commands directly (except trace/step/run/etc)
|
// TODO -- parser calls commands directly (except trace/step/run/etc)
|
||||||
@ -845,14 +848,14 @@ void Shell()
|
|||||||
add_history("!Andy, it still has history!");
|
add_history("!Andy, it still has history!");
|
||||||
|
|
||||||
|
|
||||||
Loader::Native::LoadDebugNames(envMap);
|
Loader::Native::LoadDebugNames(SymbolTable);
|
||||||
|
|
||||||
//for (const auto &kv : envMap)
|
//for (const auto &kv : SymbolTable)
|
||||||
//{
|
//{
|
||||||
// printf("%06x: %s\n", kv.second, kv.first.c_str());
|
// printf("%06x: %s\n", kv.second, kv.first.c_str());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
envMap = LoadTrapFile(MPW::RootDirPathForFile("Traps.text"));
|
//SymbolTable = LoadTrapFile(MPW::RootDirPathForFile("Traps.text"));
|
||||||
|
|
||||||
// start it up
|
// start it up
|
||||||
printf("MPW Debugger shell\n\n");
|
printf("MPW Debugger shell\n\n");
|
||||||
|
@ -25,13 +25,70 @@ struct Command {
|
|||||||
uint32_t argv[10];
|
uint32_t argv[10];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Token {
|
||||||
|
// constructor is not allowable because
|
||||||
|
// this is a union in the parser.
|
||||||
|
#if 0
|
||||||
|
Token():
|
||||||
|
intValue(0), stringValue(0), subtype(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Token(uint32_t i) :
|
||||||
|
intValue(i), subtype(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Token(std::string *s, unsigned st = 0) :
|
||||||
|
intValue(0), stringValue(s), subtype(st)
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static Token Make()
|
||||||
|
{
|
||||||
|
Token t = {0, 0, 0};
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Token Make(uint32_t i)
|
||||||
|
{
|
||||||
|
Token t = { i, 0, 0};
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Token Make(std::string *s, uint32_t st)
|
||||||
|
{
|
||||||
|
Token t = { 0, s, st};
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t intValue;
|
||||||
|
std::string *stringValue;
|
||||||
|
unsigned subtype;
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
Token& operator=(uint32_t rhs)
|
||||||
|
{
|
||||||
|
intValue = rhs;
|
||||||
|
stringValue = 0;
|
||||||
|
subtype = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
operator uint32_t() const
|
||||||
|
{
|
||||||
|
return intValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ParseLine(const char *iter, Command *command);
|
bool ParseLine(const char *iter, Command *command);
|
||||||
|
|
||||||
std::unordered_map<std::string, uint32_t> LoadTrapFile(const std::string &path);
|
std::unordered_map<std::string, uint32_t> LoadTrapFile(const std::string &path);
|
||||||
|
|
||||||
uint32_t EnvLookup(const std::string &);
|
uint32_t VariableGet(const std::string &);
|
||||||
|
void VariableSet(const std::string &name, uint32_t value);
|
||||||
|
|
||||||
void Shell();
|
void Shell();
|
||||||
void Help();
|
void Help();
|
||||||
|
Loading…
Reference in New Issue
Block a user