From ce2c1efc41470764126e9a1a7f4e0cfec4213587 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 14 Jul 2019 09:42:36 -0700 Subject: . --- html/subx/039debug.cc.html | 118 +++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 52 deletions(-) (limited to 'html/subx/039debug.cc.html') diff --git a/html/subx/039debug.cc.html b/html/subx/039debug.cc.html index 60653e04..fa0901d6 100644 --- a/html/subx/039debug.cc.html +++ b/html/subx/039debug.cc.html @@ -3,8 +3,8 @@ Mu - subx/039debug.cc - - + + @@ -14,14 +14,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } .LineNr { } .Constant { color: #008787; } +.Comment { color: #005faf; } .Delimiter { color: #c000c0; } .Special { color: #d70000; } .Identifier { color: #af5f00; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } -.Comment { color: #005faf; } +.Todo { color: #000000; background-color: #ffff00; padding-bottom: 1px; } .SalientComment { color: #0000af; } --> @@ -39,7 +39,7 @@ function JumpToLine() if (lineNum.indexOf('L') == -1) { lineNum = 'L'+lineNum; } - lineElem = document.getElementById(lineNum); + var lineElem = document.getElementById(lineNum); /* Always jump to new location even if the line was hidden inside a fold, or * we corrected the raw number to a line ID. */ @@ -91,7 +91,7 @@ if ('onhashchange' in window) { 31 fin >> addr; 32 string line; 33 getline(fin, line); - 34 put(Source_line, addr, hacky_squeeze_out_whitespace(line)); + 34 put(Source_line, addr, hacky_squeeze_out_whitespace(line)); 35 } 36 } 37 @@ -99,17 +99,17 @@ if ('onhashchange' in window) { 39 if (contains_key(Symbol_name, EIP)) 40 trace(Callstack_depth, "run") << "== label " << get(Symbol_name, EIP) << end(); 41 if (contains_key(Source_line, EIP)) - 42 trace(Callstack_depth, "run") << "0x" << HEXWORD << EIP << ": " << get(Source_line, EIP) << end(); + 42 trace(Callstack_depth, "run") << "0x" << HEXWORD << EIP << ": " << get(Source_line, EIP) << end(); 43 else 44 // no source line info; do what you can - 45 trace(Callstack_depth, "run") << "0x" << HEXWORD << EIP << ": " << debug_info(EIP) << end(); + 45 trace(Callstack_depth, "run") << "0x" << HEXWORD << EIP << ": " << debug_info(EIP) << end(); 46 47 :(code) 48 string debug_info(uint32_t inst_address) { 49 uint8_t op = read_mem_u8(inst_address); 50 if (op != 0xe8) { 51 ostringstream out; - 52 out << HEXBYTE << NUM(op); + 52 out << HEXBYTE << NUM(op); 53 return out.str(); 54 } 55 int32_t offset = read_mem_i32(inst_address+/*skip op*/1); @@ -117,7 +117,7 @@ if ('onhashchange' in window) { 57 if (contains_key(Symbol_name, next_eip)) 58 return "e8/call "+get(Symbol_name, next_eip); 59 ostringstream out; - 60 out << "e8/call 0x" << HEXWORD << next_eip; + 60 out << "e8/call 0x" << HEXWORD << next_eip; 61 return out.str(); 62 } 63 @@ -134,9 +134,9 @@ if ('onhashchange' in window) { 74 :(code) 75 void dump_watch_points() { 76 if (Watch_points.empty()) return; - 77 dbg << "watch points:" << end(); + 77 trace(Callstack_depth, "dbg") << "watch points:" << end(); 78 for (map<string, uint32_t>::iterator p = Watch_points.begin(); p != Watch_points.end(); ++p) - 79 dbg << " " << p->first << ": " << HEXWORD << p->second << " -> " << HEXWORD << read_mem_u32(p->second) << end(); + 79 trace(Callstack_depth, "dbg") << " " << p->first << ": " << HEXWORD << p->second << " -> " << HEXWORD << read_mem_u32(p->second) << end(); 80 } 81 82 :(before "End Globals") @@ -147,50 +147,64 @@ if ('onhashchange' in window) { 87 Watch_this_effective_address = get(Symbol_name, EIP); 88 :(after "Found effective_address(addr)") 89 if (!Watch_this_effective_address.empty()) { - 90 dbg << "now watching " << HEXWORD << addr << " for " << Watch_this_effective_address << end(); + 90 dbg << "now watching " << HEXWORD << addr << " for " << Watch_this_effective_address << end(); 91 put(Watch_points, Watch_this_effective_address, addr); 92 } 93 - 94 //: helpers - 95 - 96 :(code) - 97 string hacky_squeeze_out_whitespace(const string& s) { - 98 // strip whitespace at start - 99 string::const_iterator first = s.begin(); -100 while (first != s.end() && isspace(*first)) -101 ++first; -102 if (first == s.end()) return ""; -103 -104 // strip whitespace at end -105 string::const_iterator last = --s.end(); -106 while (last != s.begin() && isspace(*last)) -107 --last; -108 ++last; + 94 //: Special label that dumps regions of memory. + 95 //: Not a general mechanism; by the time you get here you're willing to hack + 96 //: on the emulator. + 97 :(after "Run One Instruction") + 98 if (contains_key(Symbol_name, EIP) && get(Symbol_name, EIP) == "$dump-stream-at-EAX") + 99 dump_stream_at(Reg[EAX].u); +100 :(code) +101 void dump_stream_at(uint32_t stream_start) { +102 int32_t stream_length = read_mem_i32(stream_start + 8); +103 dbg << "stream length: " << std::dec << stream_length << end(); +104 for (int i = 0; i < stream_length + 12; ++i) +105 dbg << "0x" << HEXWORD << (stream_start+i) << ": " << HEXBYTE << NUM(read_mem_u8(stream_start+i)) << end(); +106 } +107 +108 //: helpers 109 -110 // replace runs of spaces/dots with single space until comment or string -111 // TODO: -112 // leave alone dots not surrounded by whitespace -113 // leave alone '#' within word -114 // leave alone '"' within word -115 // squeeze spaces after end of string -116 ostringstream out; -117 bool previous_was_space = false; -118 bool in_comment_or_string = false; -119 for (string::const_iterator curr = first; curr != last; ++curr) { -120 if (in_comment_or_string) -121 out << *curr; -122 else if (isspace(*curr) || *curr == '.') -123 previous_was_space = true; -124 else { -125 if (previous_was_space) -126 out << ' '; -127 out << *curr; -128 previous_was_space = false; -129 if (*curr == '#' || *curr == '"') in_comment_or_string = true; -130 } -131 } -132 return out.str(); -133 } +110 :(code) +111 string hacky_squeeze_out_whitespace(const string& s) { +112 // strip whitespace at start +113 string::const_iterator first = s.begin(); +114 while (first != s.end() && isspace(*first)) +115 ++first; +116 if (first == s.end()) return ""; +117 +118 // strip whitespace at end +119 string::const_iterator last = --s.end(); +120 while (last != s.begin() && isspace(*last)) +121 --last; +122 ++last; +123 +124 // replace runs of spaces/dots with single space until comment or string +125 // TODO: +126 // leave alone dots not surrounded by whitespace +127 // leave alone '#' within word +128 // leave alone '"' within word +129 // squeeze spaces after end of string +130 ostringstream out; +131 bool previous_was_space = false; +132 bool in_comment_or_string = false; +133 for (string::const_iterator curr = first; curr != last; ++curr) { +134 if (in_comment_or_string) +135 out << *curr; +136 else if (isspace(*curr) || *curr == '.') +137 previous_was_space = true; +138 else { +139 if (previous_was_space) +140 out << ' '; +141 out << *curr; +142 previous_was_space = false; +143 if (*curr == '#' || *curr == '"') in_comment_or_string = true; +144 } +145 } +146 return out.str(); +147 } -- cgit 1.4.1-2-gfad0