History

Addition of examine memory command to debugger. Re-design debugger command processing.

arr committed 10 years ago

Commit f2771671 parent e9ca2863 files · +255 −70Browse files

Showing the changes to src/include (2 of 3 files). Show all

Unified · Split

2 files
  1. src/include/runtime.h +1 −0
  2. src/include/vm_memory.h +26 −1
src/include/runtime.h+1−0
@@ -166,6 +166,7 @@ namespace disvm · 165 unmodified lines
166 // Returns this string.166 // Returns this string.
167 vm_string_t &append(const vm_string_t &other);167 vm_string_t &append(const vm_string_t &other);
168 168
169 // Returns the character length of the string.
169 word_t get_length() const;170 word_t get_length() const;
170 171
171 rune_t get_rune(word_t index) const;172 rune_t get_rune(word_t index) const;
src/include/vm_memory.h+26−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
9 9
10#include <cstdint>10#include <cstdint>
11#include <cassert>11#include <cassert>
12#include <limits>
12#include <mutex>13#include <mutex>
13#include <memory>14#include <memory>
14#include <bitset>15#include <bitset>
@@ -89,7 +90,7 @@ namespace disvm · 74 unmodified lines
89 {90 {
90 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };91 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };
91 92
92 // Enumerating the flags in reverse order so memory access is linear.93 // Enumerating the flags in reverse order so memory access is sequential.
93 if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]));94 if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]));
94 if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]));95 if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]));
95 if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]));96 if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]));
@@ -101,6 +102,30 @@ namespace disvm · 5 unmodified lines
101 }102 }
102 }103 }
103 }104 }
105
106 // Check if a specific pointer-sized offset in a type represents a pointer
107 inline bool is_offset_pointer(const type_descriptor_t &type_desc, std::size_t offset)
108 {
109 if (type_desc.size_in_bytes == 0)
110 return false;
111
112 assert(offset < static_cast<std::size_t>(std::numeric_limits<word_t>::max()));
113 const auto byte_offset = static_cast<word_t>(offset / 8);
114
115 // Highest order bit is the first field
116 const auto bit_offset = 7 - (offset % 8);
117 if (byte_offset < type_desc.map_in_bytes)
118 {
119 const auto words8 = type_desc.pointer_map[byte_offset];
120 if (words8 != 0)
121 {
122 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };
123 return flags[bit_offset];
124 }
125 }
126
127 return false;
128 }
104 }129 }
105}130}
106 131