History

Change debugger options to enumeration. Alter how the debugger displays the registers. Adding a breakpoint that is already set is a no-op and simply returns the current cookie value. Fix bug in print for the Sys module - don't ignore format modifiers.

arr committed 10 years ago

Commit db76c0c1 parent f29cf0d6 files · +45 −41Browse files

Showing the changes to src/vm/tool_dispatch.cpp (1 of 6 files). Show all

Unified · Split

src/vm/tool_dispatch.cpp+8−2
@@ -245,8 +245,15 @@ cookie_t vm_tool_dispatch_t::set_breakpoint(std::shared_ptr<vm_module_t> module, · 244 unmodified lines
245 245
246 {246 {
247 std::lock_guard<std::mutex> lock{ _breakpoints.lock };247 std::lock_guard<std::mutex> lock{ _breakpoints.lock };
248 auto &pc_map = _breakpoints.original_opcodes[reinterpret_cast<std::uintptr_t>(module.get())];
249
250 // If the real opcode is already a breakpoint and it is known, return the current cookie.
248 if (real_opcode == opcode_t::brkpt)251 if (real_opcode == opcode_t::brkpt)
249 throw vm_system_exception{ "Breakpoint already set at PC" };252 {
253 auto iter = pc_map.find(pc);
254 if (iter != pc_map.cend())
255 return iter->second.second;
256 }
250 257
251 const auto cookie_id = _breakpoints.cookie_counter++;258 const auto cookie_id = _breakpoints.cookie_counter++;
252 259
@@ -254,7 +261,6 @@ cookie_t vm_tool_dispatch_t::set_breakpoint(std::shared_ptr<vm_module_t> module, · 1 unmodified line
254 _breakpoints.cookie_to_details[cookie_id] = { module, pc, real_opcode };261 _breakpoints.cookie_to_details[cookie_id] = { module, pc, real_opcode };
255 262
256 // Record the original opcode263 // Record the original opcode
257 auto &pc_map = _breakpoints.original_opcodes[reinterpret_cast<std::uintptr_t>(module.get())];
258 pc_map[pc] = std::make_pair(real_opcode, cookie_id);264 pc_map[pc] = std::make_pair(real_opcode, cookie_id);
259 265
260 // Replace the current opcode with breakpoint266 // Replace the current opcode with breakpoint