diff --git a/bin/debugger.cpp b/bin/debugger.cpp index 3fd50fc..8642898 100644 --- a/bin/debugger.cpp +++ b/bin/debugger.cpp @@ -73,7 +73,7 @@ namespace { AddressMap wbrkMap; // write breaks. ToolMap tbrkMap; // tool breaks. - std::unordered_map envMap; + std::unordered_map SymbolTable; 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); - if (iter == envMap.end()) return 0; + auto iter = SymbolTable.find(s); + if (iter == SymbolTable.end()) return 0; 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 -- parser calls commands directly (except trace/step/run/etc) @@ -845,14 +848,14 @@ void Shell() 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()); //} - envMap = LoadTrapFile(MPW::RootDirPathForFile("Traps.text")); + //SymbolTable = LoadTrapFile(MPW::RootDirPathForFile("Traps.text")); // start it up printf("MPW Debugger shell\n\n"); diff --git a/bin/debugger.h b/bin/debugger.h index 06e9528..2c82142 100644 --- a/bin/debugger.h +++ b/bin/debugger.h @@ -25,13 +25,70 @@ struct Command { 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); std::unordered_map 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 Help();