From c7acd1d8e1577c68cd076a7a80a8df5ff263e455 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 21 Aug 2013 22:40:53 -0400 Subject: [PATCH] more info for ;info --- bin/debugger.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ bin/debugger.h | 2 ++ bin/parser.lemon | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bin/debugger.cpp b/bin/debugger.cpp index 7cff9a6..145e5e6 100644 --- a/bin/debugger.cpp +++ b/bin/debugger.cpp @@ -57,6 +57,7 @@ #include #include + #include namespace { @@ -840,6 +841,50 @@ void VariableSet(const std::string &key, uint32_t value) SymbolTable.emplace(key, value); } +void Info(uint32_t address) +{ + // print info on the value. + + Print(address); + + // 1. as a pointer. + MM::Native::MemoryInfo(address); + + // 2. (todo) - check SymbolTable for procedure address. + + // 2. as a tool trap. + if (address >= 0xa000 && address <= 0xafff) + { + const char *cp = TrapName(address); + if (cp) + printf("Tool: %s\n", cp); + } + + // 3. as a global + if (address <= 0xffff) + { + const char *cp = GlobalName(address); + if (cp) + printf("Global: %s\n", cp); + + } + +#if 0 + // 4 as an error + // almost all are negative 16-bit values, + // but may also be a positive 16-bit value. + uint16_t error = 0; + if (address <= 0xffff) error = address; + if ((address & 0xffff8000) == 0xffff8000) error = address; + if (error) + { + const char *cp = ErrorName(error); + if (cp) + printf("Error: %s\n", cp); + } +#endif +} + namespace { /* diff --git a/bin/debugger.h b/bin/debugger.h index 180ba55..6b01088 100644 --- a/bin/debugger.h +++ b/bin/debugger.h @@ -108,6 +108,8 @@ uint8_t ReadByte(uint32_t); void Print(uint32_t value); void PrintRegisters(); +void Info(uint32_t address); + void Dump(uint32_t address, int count = 256); void List(uint32_t address, int count = 20); void List(uint32_t pc, uint32_t endpc); diff --git a/bin/parser.lemon b/bin/parser.lemon index b723ea1..420e3d9 100644 --- a/bin/parser.lemon +++ b/bin/parser.lemon @@ -176,7 +176,7 @@ stmt ::= expr(a) AT expr(b) SEMI SEMIH EOL. stmt ::= expr(a) SEMI SEMII EOL. { - MM::Native::MemoryInfo(a.intValue); + Debug::Info(a.intValue); }