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
166166 // Returns this string.
167167 vm_string_t &append(const vm_string_t &other);
168168
169+ // Returns the character length of the string.
169170 word_t get_length() const;
170171
171172 rune_t get_rune(word_t index) const;
src/include/vm_memory.h+26−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
99
1010 #include <cstdint>
1111 #include <cassert>
12+#include <limits>
1213 #include <mutex>
1314 #include <memory>
1415 #include <bitset>
@@ -89,7 +90,7 @@ namespace disvm · 74 unmodified lines
8990 {
9091 const auto flags = std::bitset<sizeof(words8) * 8>{ words8 };
9192
92− // Enumerating the flags in reverse order so memory access is linear.
93+ // Enumerating the flags in reverse order so memory access is sequential.
9394 if (flags[7] && (memory[0] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[0]));
9495 if (flags[6] && (memory[1] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[1]));
9596 if (flags[5] && (memory[2] != runtime_constants::nil)) callback(reinterpret_cast<pointer_t>(memory[2]));
@@ -101,6 +102,30 @@ namespace disvm · 5 unmodified lines
101102 }
102103 }
103104 }
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+ }
104129 }
105130 }
106131