Move some debug stuff to be in class scope

This commit is contained in:
Ilari Liusvaara 2014-05-23 18:11:06 +03:00
parent 16663f7786
commit 95d1b5130f
6 changed files with 180 additions and 167 deletions

View file

@ -6,59 +6,6 @@
#include <cstdint>
#include "library/dispatch.hpp"
enum debug_type
{
DEBUG_READ,
DEBUG_WRITE,
DEBUG_EXEC,
DEBUG_TRACE,
DEBUG_FRAME,
};
struct debug_callback_params_rwx
{
uint64_t addr; //Address.
uint64_t value; //Value/CPU.
};
struct debug_callback_params_trace
{
uint64_t cpu; //CPU number.
const char* decoded_insn; //Decoded instruction
bool true_insn; //True instruction flag.
};
struct debug_callback_params_frame
{
uint64_t frame; //Frame number.
bool loadstated; //Loadstate flag.
};
struct debug_callback_params
{
debug_type type;
union {
debug_callback_params_rwx rwx; //READ/WRITE/EXECUTE
debug_callback_params_trace trace; //TRACE.
debug_callback_params_frame frame; //FRAME.
};
};
struct debug_callback_base
{
/**
* Destructor.
*/
virtual ~debug_callback_base();
/**
* Do a callback.
*/
virtual void callback(const debug_callback_params& params) = 0;
/**
* Notify about killed callback.
*/
virtual void killed(uint64_t addr, debug_type type) = 0;
};
/**
* Debugging context.
@ -66,6 +13,72 @@ struct debug_callback_base
class debug_context
{
public:
/**
* Type of event.
*/
enum etype
{
DEBUG_READ,
DEBUG_WRITE,
DEBUG_EXEC,
DEBUG_TRACE,
DEBUG_FRAME,
};
/**
* Parameters for read/write/execute event.
*/
struct params_rwx
{
uint64_t addr; //Address.
uint64_t value; //Value/CPU.
};
/**
* Parameters for trace event.
*/
struct params_trace
{
uint64_t cpu; //CPU number.
const char* decoded_insn; //Decoded instruction
bool true_insn; //True instruction flag.
};
/**
* Parameters for frame event.
*/
struct params_frame
{
uint64_t frame; //Frame number.
bool loadstated; //Loadstate flag.
};
/**
* Parameters for debug callback.
*/
struct params
{
etype type;
union {
params_rwx rwx; //READ/WRITE/EXECUTE
params_trace trace; //TRACE.
params_frame frame; //FRAME.
};
};
/**
* Base class of debugging callbacks.
*/
struct callback_base
{
/**
* Destructor.
*/
virtual ~callback_base();
/**
* Do a callback.
*/
virtual void callback(const params& p) = 0;
/**
* Notify about killed callback.
*/
virtual void killed(uint64_t addr, etype type) = 0;
};
/**
* Placeholder for all addresses.
*/
@ -73,11 +86,11 @@ public:
/**
* Add a callback.
*/
void add_callback(uint64_t addr, debug_type type, debug_callback_base& cb);
void add_callback(uint64_t addr, etype type, callback_base& cb);
/**
* Remove a callback.
*/
void remove_callback(uint64_t addr, debug_type type, debug_callback_base& cb);
void remove_callback(uint64_t addr, etype type, callback_base& cb);
/**
* Fire a read callback.
*/
@ -131,7 +144,7 @@ public:
*/
void request_break();
//These are public only for some debugging stuff.
typedef std::list<debug_callback_base*> cb_list;
typedef std::list<callback_base*> cb_list;
std::map<uint64_t, cb_list> read_cb;
std::map<uint64_t, cb_list> write_cb;
std::map<uint64_t, cb_list> exec_cb;
@ -145,21 +158,21 @@ private:
bool corechange_r = false;
bool requesting_break = false;
struct tracelog_file : public debug_callback_base
struct tracelog_file : public callback_base
{
std::ofstream stream;
std::string full_filename;
unsigned refcnt;
tracelog_file(debug_context& parent);
~tracelog_file();
void callback(const debug_callback_params& p);
void killed(uint64_t addr, debug_type type);
void callback(const params& p);
void killed(uint64_t addr, etype type);
private:
debug_context& parent;
};
std::map<uint64_t, tracelog_file*> trace_outputs;
std::map<uint64_t, cb_list>& get_lists(debug_type type)
std::map<uint64_t, cb_list>& get_lists(etype type)
{
switch(type) {
case DEBUG_READ: return read_cb;

View file

@ -4,10 +4,10 @@
#include "internal.hpp"
#include "core/debug.hpp"
template<debug_type type>
template<debug_context::etype type>
void handle_registerX(lua::state& L, uint64_t addr, int lfn);
template<debug_type type>
template<debug_context::etype type>
void handle_unregisterX(lua::state& L, uint64_t addr, int lfn);
#endif

View file

@ -14,14 +14,14 @@
namespace
{
unsigned debug_flag(debug_type type)
unsigned debug_flag(debug_context::etype type)
{
switch(type) {
case DEBUG_READ: return 1;
case DEBUG_WRITE: return 2;
case DEBUG_EXEC: return 4;
case DEBUG_TRACE: return 8;
case DEBUG_FRAME: return 0;
case debug_context::DEBUG_READ: return 1;
case debug_context::DEBUG_WRITE: return 2;
case debug_context::DEBUG_EXEC: return 4;
case debug_context::DEBUG_TRACE: return 8;
case debug_context::DEBUG_FRAME: return 0;
default: throw std::runtime_error("Invalid debug callback type");
}
}
@ -29,7 +29,7 @@ namespace
namespace
{
template<class T> void kill_hooks(T& cblist, debug_type type)
template<class T> void kill_hooks(T& cblist, debug_context::etype type)
{
while(!cblist.empty()) {
if(cblist.begin()->second.empty()) {
@ -45,13 +45,13 @@ namespace
}
}
debug_callback_base::~debug_callback_base()
debug_context::callback_base::~callback_base()
{
}
const uint64_t debug_context::all_addresses = 0xFFFFFFFFFFFFFFFFULL;
void debug_context::add_callback(uint64_t addr, debug_type type, debug_callback_base& cb)
void debug_context::add_callback(uint64_t addr, debug_context::etype type, debug_context::callback_base& cb)
{
std::map<uint64_t, cb_list>& xcb = get_lists(type);
if(!corechange_r) {
@ -64,7 +64,7 @@ void debug_context::add_callback(uint64_t addr, debug_type type, debug_callback_
lst.push_back(&cb);
}
void debug_context::remove_callback(uint64_t addr, debug_type type, debug_callback_base& cb)
void debug_context::remove_callback(uint64_t addr, debug_context::etype type, debug_context::callback_base& cb)
{
std::map<uint64_t, cb_list>& xcb = get_lists(type);
if(type == DEBUG_FRAME) addr = 0;
@ -85,7 +85,7 @@ void debug_context::remove_callback(uint64_t addr, debug_type type, debug_callba
void debug_context::do_callback_read(uint64_t addr, uint64_t value)
{
debug_callback_params p;
params p;
p.type = DEBUG_READ;
p.rwx.addr = addr;
p.rwx.value = value;
@ -103,7 +103,7 @@ void debug_context::do_callback_read(uint64_t addr, uint64_t value)
void debug_context::do_callback_write(uint64_t addr, uint64_t value)
{
debug_callback_params p;
params p;
p.type = DEBUG_WRITE;
p.rwx.addr = addr;
p.rwx.value = value;
@ -121,7 +121,7 @@ void debug_context::do_callback_write(uint64_t addr, uint64_t value)
void debug_context::do_callback_exec(uint64_t addr, uint64_t cpu)
{
debug_callback_params p;
params p;
p.type = DEBUG_EXEC;
p.rwx.addr = addr;
p.rwx.value = cpu;
@ -140,7 +140,7 @@ void debug_context::do_callback_exec(uint64_t addr, uint64_t cpu)
void debug_context::do_callback_trace(uint64_t cpu, const char* str, bool true_insn)
{
debug_callback_params p;
params p;
p.type = DEBUG_TRACE;
p.trace.cpu = cpu;
p.trace.decoded_insn = str;
@ -156,7 +156,7 @@ void debug_context::do_callback_trace(uint64_t cpu, const char* str, bool true_i
void debug_context::do_callback_frame(uint64_t frame, bool loadstate)
{
debug_callback_params p;
params p;
p.type = DEBUG_FRAME;
p.frame.frame = frame;
p.frame.loadstated = loadstate;
@ -214,13 +214,13 @@ debug_context::tracelog_file::~tracelog_file()
{
}
void debug_context::tracelog_file::callback(const debug_callback_params& p)
void debug_context::tracelog_file::callback(const debug_context::params& p)
{
if(!parent.trace_outputs.count(p.trace.cpu)) return;
parent.trace_outputs[p.trace.cpu]->stream << p.trace.decoded_insn << std::endl;
}
void debug_context::tracelog_file::killed(uint64_t addr, debug_type type)
void debug_context::tracelog_file::killed(uint64_t addr, debug_context::etype type)
{
refcnt--;
if(!refcnt)

View file

@ -222,19 +222,19 @@ namespace
char lua_cb_list_key = 0;
struct lua_debug_callback2 : public debug_callback_base
struct lua_debug_callback2 : public debug_context::callback_base
{
lua::state* L;
uint64_t addr;
debug_type type;
debug_context::etype type;
bool dead;
const void* lua_fn;
~lua_debug_callback2();
void link_to_list();
void set_lua_fn(int slot);
void unregister();
void callback(const debug_callback_params& p);
void killed(uint64_t addr, debug_type type);
void callback(const debug_context::params& p);
void killed(uint64_t addr, debug_context::etype type);
static int on_lua_gc(lua_State* L);
lua_debug_callback2* prev;
lua_debug_callback2* next;
@ -243,7 +243,7 @@ namespace
struct lua_debug_callback_dict
{
~lua_debug_callback_dict();
std::map<std::pair<debug_type, uint64_t>, lua_debug_callback2*> cblist;
std::map<std::pair<debug_context::etype, uint64_t>, lua_debug_callback2*> cblist;
static int on_lua_gc(lua_State* L);
};
@ -254,7 +254,7 @@ namespace
L->rawget(LUA_REGISTRYINDEX);
if(!L->isnil(-1)) {
lua_debug_callback_dict* dc = (lua_debug_callback_dict*)L->touserdata(-1);
std::pair<debug_type, uint64_t> key = std::make_pair(type, addr);
std::pair<debug_context::etype, uint64_t> key = std::make_pair(type, addr);
if(dc->cblist.count(key)) {
dc->cblist[key] = next;
if(!next)
@ -292,7 +292,7 @@ namespace
L->rawget(LUA_REGISTRYINDEX);
lua_debug_callback2* was = NULL;
lua_debug_callback_dict* dc = (lua_debug_callback_dict*)L->touserdata(-1);
std::pair<debug_type, uint64_t> key = std::make_pair(type, addr);
std::pair<debug_context::etype, uint64_t> key = std::make_pair(type, addr);
if(dc->cblist.count(key))
was = dc->cblist[key];
dc->cblist[key] = this;
@ -327,25 +327,25 @@ namespace
L->rawset(LUA_REGISTRYINDEX);
}
void lua_debug_callback2::callback(const debug_callback_params& p)
void lua_debug_callback2::callback(const debug_context::params& p)
{
L->pushlightuserdata((char*)this + 1);
L->rawget(LUA_REGISTRYINDEX);
switch(p.type) {
case DEBUG_READ:
case DEBUG_WRITE:
case DEBUG_EXEC:
case debug_context::DEBUG_READ:
case debug_context::DEBUG_WRITE:
case debug_context::DEBUG_EXEC:
L->pushnumber(p.rwx.addr);
L->pushnumber(p.rwx.value);
do_lua_error(*L, L->pcall(2, 0, 0));
break;
case DEBUG_TRACE:
case debug_context::DEBUG_TRACE:
L->pushnumber(p.trace.cpu);
L->pushstring(p.trace.decoded_insn);
L->pushboolean(p.trace.true_insn);
do_lua_error(*L, L->pcall(3, 0, 0));
break;
case DEBUG_FRAME:
case debug_context::DEBUG_FRAME:
L->pushnumber(p.frame.frame);
L->pushboolean(p.frame.loadstated);
do_lua_error(*L, L->pcall(2, 0, 0));
@ -357,7 +357,7 @@ namespace
}
}
void lua_debug_callback2::killed(uint64_t addr, debug_type type)
void lua_debug_callback2::killed(uint64_t addr, debug_context::etype type)
{
//Assume this has been unregistered.
dead = true;
@ -398,7 +398,7 @@ namespace
}
}
template<debug_type type>
template<debug_context::etype type>
void handle_registerX(lua::state& L, uint64_t addr, int lfn)
{
//Put the context in userdata so it can be gc'd when Lua context is terminated.
@ -424,7 +424,7 @@ void handle_registerX(lua::state& L, uint64_t addr, int lfn)
CORE().dbg.add_callback(addr, type, *D);
}
template<debug_type type>
template<debug_context::etype type>
void handle_unregisterX(lua::state& L, uint64_t addr, int lfn)
{
lua_debug_callback_dict* Dx;
@ -453,25 +453,25 @@ void handle_unregisterX(lua::state& L, uint64_t addr, int lfn)
typedef void(*dummy1_t)(lua::state& L, uint64_t addr, int lfn);
dummy1_t dummy_628963286932869328692386963[] = {
handle_registerX<DEBUG_READ>,
handle_registerX<DEBUG_WRITE>,
handle_registerX<DEBUG_EXEC>,
handle_unregisterX<DEBUG_READ>,
handle_unregisterX<DEBUG_WRITE>,
handle_unregisterX<DEBUG_EXEC>,
handle_registerX<debug_context::DEBUG_READ>,
handle_registerX<debug_context::DEBUG_WRITE>,
handle_registerX<debug_context::DEBUG_EXEC>,
handle_unregisterX<debug_context::DEBUG_READ>,
handle_unregisterX<debug_context::DEBUG_WRITE>,
handle_unregisterX<debug_context::DEBUG_EXEC>,
};
namespace
{
template<debug_type type, bool reg>
template<debug_context::etype type, bool reg>
int lua_registerX(lua::state& L, lua::parameters& P)
{
uint64_t addr;
int lfn;
if(P.is_nil() && type != DEBUG_TRACE) {
if(P.is_nil() && type != debug_context::DEBUG_TRACE) {
addr = 0xFFFFFFFFFFFFFFFFULL;
P.skip();
} else if(type != DEBUG_TRACE)
} else if(type != debug_context::DEBUG_TRACE)
addr = lua_get_read_address(P);
else
P(addr);
@ -905,14 +905,14 @@ namespace
{"mapsqword", lua_mmap_memory<int64_t, &memory_space::read<int64_t>, &memory_space::write<int64_t>>},
{"mapfloat", lua_mmap_memory<float, &memory_space::read<float>, &memory_space::write<float>>},
{"mapdouble", lua_mmap_memory<double, &memory_space::read<double>, &memory_space::write<double>>},
{"registerread", lua_registerX<DEBUG_READ, true>},
{"unregisterread", lua_registerX<DEBUG_READ, false>},
{"registerwrite", lua_registerX<DEBUG_WRITE, true>},
{"unregisterwrite", lua_registerX<DEBUG_WRITE, false>},
{"registerexec", lua_registerX<DEBUG_EXEC, true>},
{"unregisterexec", lua_registerX<DEBUG_EXEC, false>},
{"registertrace", lua_registerX<DEBUG_TRACE, true>},
{"unregistertrace", lua_registerX<DEBUG_TRACE, false>},
{"registerread", lua_registerX<debug_context::DEBUG_READ, true>},
{"unregisterread", lua_registerX<debug_context::DEBUG_READ, false>},
{"registerwrite", lua_registerX<debug_context::DEBUG_WRITE, true>},
{"unregisterwrite", lua_registerX<debug_context::DEBUG_WRITE, false>},
{"registerexec", lua_registerX<debug_context::DEBUG_EXEC, true>},
{"unregisterexec", lua_registerX<debug_context::DEBUG_EXEC, false>},
{"registertrace", lua_registerX<debug_context::DEBUG_TRACE, true>},
{"unregistertrace", lua_registerX<debug_context::DEBUG_TRACE, false>},
});
lua::_class<lua_mmap_struct> class_mmap_struct(lua_class_memory, "MMAP_STRUCT", {

View file

@ -62,7 +62,7 @@ namespace
int readregion(lua::state& L, lua::parameters& P);
int writeregion(lua::state& L, lua::parameters& P);
int cheat(lua::state& L, lua::parameters& P);
template<debug_type type, bool reg> int registerX(lua::state& L, lua::parameters& P);
template<debug_context::etype type, bool reg> int registerX(lua::state& L, lua::parameters& P);
std::string print()
{
return vma;
@ -159,12 +159,12 @@ namespace
{"storecmp", &lua_vma::storecmp<true>},
{"readregion", &lua_vma::readregion},
{"writeregion", &lua_vma::writeregion},
{"registerread", &lua_vma::registerX<DEBUG_READ, true>},
{"unregisterread", &lua_vma::registerX<DEBUG_READ, false>},
{"registerwrite", &lua_vma::registerX<DEBUG_WRITE, true>},
{"unregisterwrite", &lua_vma::registerX<DEBUG_WRITE, false>},
{"registerexec", &lua_vma::registerX<DEBUG_EXEC, true>},
{"unregisterexec", &lua_vma::registerX<DEBUG_EXEC, false>},
{"registerread", &lua_vma::registerX<debug_context::DEBUG_READ, true>},
{"unregisterread", &lua_vma::registerX<debug_context::DEBUG_READ, false>},
{"registerwrite", &lua_vma::registerX<debug_context::DEBUG_WRITE, true>},
{"unregisterwrite", &lua_vma::registerX<debug_context::DEBUG_WRITE, false>},
{"registerexec", &lua_vma::registerX<debug_context::DEBUG_EXEC, true>},
{"unregisterexec", &lua_vma::registerX<debug_context::DEBUG_EXEC, false>},
}, &lua_vma::print);
lua::_class<lua_vma_list> class_vmalist(lua_class_memory, "VMALIST", {
@ -411,7 +411,7 @@ namespace
return cmp ? 1 : 0;
}
template<debug_type type, bool reg> int lua_vma::registerX(lua::state& L, lua::parameters& P)
template<debug_context::etype type, bool reg> int lua_vma::registerX(lua::state& L, lua::parameters& P)
{
uint64_t addr;
int lfn;

View file

@ -394,7 +394,7 @@ namespace
{
public:
dialog_breakpoint_add(wxWindow* parent, std::list<memory_region*> regions);
std::pair<uint64_t, debug_type> get_result();
std::pair<uint64_t, debug_context::etype> get_result();
void on_ok(wxCommandEvent& e) { EndModal(wxID_OK); }
void on_cancel(wxCommandEvent& e) { EndModal(wxID_CANCEL); }
void on_address_change(wxCommandEvent& e);
@ -457,7 +457,7 @@ namespace
}
}
std::pair<uint64_t, debug_type> dialog_breakpoint_add::get_result()
std::pair<uint64_t, debug_context::etype> dialog_breakpoint_add::get_result()
{
std::string vmaname = tostdstring(vmasel->GetStringSelection());
std::string addrtext = tostdstring(address->GetValue());
@ -473,13 +473,13 @@ namespace
} catch(std::exception& e) {
addr = base;
}
debug_type dtype = DEBUG_EXEC;
debug_context::etype dtype = debug_context::DEBUG_EXEC;
if(typesel->GetSelection() == 0)
dtype = DEBUG_READ;
dtype = debug_context::DEBUG_READ;
if(typesel->GetSelection() == 1)
dtype = DEBUG_WRITE;
dtype = debug_context::DEBUG_WRITE;
if(typesel->GetSelection() == 2)
dtype = DEBUG_EXEC;
dtype = debug_context::DEBUG_EXEC;
return std::make_pair(addr, dtype);
}
@ -493,8 +493,8 @@ namespace
void on_delete(wxCommandEvent& e);
void on_selchange(wxCommandEvent& e);
private:
std::string format_line(std::pair<uint64_t, debug_type> entry);
size_t get_insert_pos(std::pair<uint64_t, debug_type> entry);
std::string format_line(std::pair<uint64_t, debug_context::etype> entry);
size_t get_insert_pos(std::pair<uint64_t, debug_context::etype> entry);
void populate_breakpoints();
std::list<memory_region*> regions;
wxButton* ok;
@ -502,10 +502,10 @@ namespace
wxButton* delb;
wxListBox* brklist;
wxwin_tracelog* pwin;
std::vector<std::pair<uint64_t, debug_type>> listsyms;
std::vector<std::pair<uint64_t, debug_context::etype>> listsyms;
};
class wxwin_tracelog : public wxFrame, public debug_callback_base
class wxwin_tracelog : public wxFrame, public debug_context::callback_base
{
public:
wxwin_tracelog(wxWindow* parent, int _cpuid, const std::string& cpuname);
@ -517,9 +517,9 @@ namespace
void on_menu(wxCommandEvent& e);
void process_lines();
uint64_t get_find_line() { return find_active ? find_line : 0xFFFFFFFFFFFFFFFFULL; }
std::set<std::pair<uint64_t, debug_type>> get_breakpoints();
void add_breakpoint(uint64_t addr, debug_type dtype);
void remove_breakpoint(uint64_t addr, debug_type dtype);
std::set<std::pair<uint64_t, debug_context::etype>> get_breakpoints();
void add_breakpoint(uint64_t addr, debug_context::etype dtype);
void remove_breakpoint(uint64_t addr, debug_context::etype dtype);
private:
class _panel : public text_framebuffer_panel
{
@ -544,9 +544,9 @@ namespace
void scroll_pane(uint64_t line);
int cpuid;
volatile bool trace_active;
void callback(const debug_callback_params& params);
void killed(uint64_t addr, debug_type type);
void do_rwx_break(uint64_t addr, uint64_t value, debug_type type);
void callback(const debug_context::params& params);
void killed(uint64_t addr, debug_context::etype type);
void do_rwx_break(uint64_t addr, uint64_t value, debug_context::etype type);
void kill_debug_hooks();
scroll_bar* scroll;
_panel* panel;
@ -562,7 +562,7 @@ namespace
std::string find_string;
bool dirty;
bool singlestepping;
std::map<std::pair<uint64_t, debug_type>, bool> rwx_breakpoints;
std::map<std::pair<uint64_t, debug_context::etype>, bool> rwx_breakpoints;
wxMenuItem* m_singlestep;
};
@ -587,8 +587,8 @@ namespace
void wxwin_tracelog::kill_debug_hooks()
{
CORE().dbg.remove_callback(cpuid, DEBUG_TRACE, *this);
CORE().dbg.remove_callback(cpuid, DEBUG_FRAME, *this);
CORE().dbg.remove_callback(cpuid, debug_context::DEBUG_TRACE, *this);
CORE().dbg.remove_callback(cpuid, debug_context::DEBUG_FRAME, *this);
threads::alock h(buffer_mutex);
for(auto& i : rwx_breakpoints) {
if(!i.second)
@ -705,20 +705,20 @@ namespace
panel->request_paint();
}
void wxwin_tracelog::do_rwx_break(uint64_t addr, uint64_t value, debug_type type)
void wxwin_tracelog::do_rwx_break(uint64_t addr, uint64_t value, debug_context::etype type)
{
lsnes_instance.dbg.request_break();
}
void wxwin_tracelog::callback(const debug_callback_params& p)
void wxwin_tracelog::callback(const debug_context::params& p)
{
switch(p.type) {
case DEBUG_READ:
case DEBUG_WRITE:
case DEBUG_EXEC:
case debug_context::DEBUG_READ:
case debug_context::DEBUG_WRITE:
case debug_context::DEBUG_EXEC:
do_rwx_break(p.rwx.addr, p.rwx.value, p.type);
break;
case DEBUG_TRACE: {
case debug_context::DEBUG_TRACE: {
if(!trace_active)
return;
//Got tracelog line, send it.
@ -734,7 +734,7 @@ namespace
}
break;
}
case DEBUG_FRAME: {
case debug_context::DEBUG_FRAME: {
std::ostringstream xstr;
xstr << "------------ ";
xstr << "Frame " << p.frame.frame;
@ -752,12 +752,12 @@ namespace
}
}
void wxwin_tracelog::killed(uint64_t addr, debug_type type)
void wxwin_tracelog::killed(uint64_t addr, debug_context::etype type)
{
switch(type) {
case DEBUG_READ:
case DEBUG_WRITE:
case DEBUG_EXEC: {
case debug_context::DEBUG_READ:
case debug_context::DEBUG_WRITE:
case debug_context::DEBUG_EXEC: {
//We need to kill this hook if still active.
auto i2 = std::make_pair(addr, type);
auto& h = rwx_breakpoints[i2];
@ -766,7 +766,7 @@ namespace
h = false;
break;
}
case DEBUG_TRACE:
case debug_context::DEBUG_TRACE:
//Dtor!
if(!trace_active)
return;
@ -777,7 +777,7 @@ namespace
this->m_singlestep->Enable(false);
});
break;
case DEBUG_FRAME:
case debug_context::DEBUG_FRAME:
//Do nothing.
break;
}
@ -796,8 +796,8 @@ namespace
lsnes_instance.dbg.add_callback(i2.first, i2.second, *this);
i.second = true;
}
lsnes_instance.dbg.add_callback(cpuid, DEBUG_TRACE, *this);
lsnes_instance.dbg.add_callback(0, DEBUG_FRAME, *this);
lsnes_instance.dbg.add_callback(cpuid, debug_context::DEBUG_TRACE, *this);
lsnes_instance.dbg.add_callback(0, debug_context::DEBUG_FRAME, *this);
this->trace_active = true;
} else if(trace_active) {
this->trace_active = false;
@ -1055,9 +1055,9 @@ back:
return true;
}
std::set<std::pair<uint64_t, debug_type>> wxwin_tracelog::get_breakpoints()
std::set<std::pair<uint64_t, debug_context::etype>> wxwin_tracelog::get_breakpoints()
{
std::set<std::pair<uint64_t, debug_type>> ret;
std::set<std::pair<uint64_t, debug_context::etype>> ret;
lsnes_instance.run([this, &ret]() {
for(auto i : rwx_breakpoints)
ret.insert(i.first);
@ -1065,9 +1065,9 @@ back:
return ret;
}
void wxwin_tracelog::add_breakpoint(uint64_t addr, debug_type dtype)
void wxwin_tracelog::add_breakpoint(uint64_t addr, debug_context::etype dtype)
{
std::pair<uint64_t, debug_type> i2 = std::make_pair(addr, dtype);
std::pair<uint64_t, debug_context::etype> i2 = std::make_pair(addr, dtype);
if(!trace_active) {
//We'll register this later.
rwx_breakpoints[i2] = false;
@ -1077,9 +1077,9 @@ back:
rwx_breakpoints[i2] = true;
}
void wxwin_tracelog::remove_breakpoint(uint64_t addr, debug_type dtype)
void wxwin_tracelog::remove_breakpoint(uint64_t addr, debug_context::etype dtype)
{
std::pair<uint64_t, debug_type> i2 = std::make_pair(addr, dtype);
std::pair<uint64_t, debug_context::etype> i2 = std::make_pair(addr, dtype);
auto& h = rwx_breakpoints[i2];
if(h)
lsnes_instance.dbg.remove_callback(i2.first, i2.second, *this);
@ -1798,7 +1798,7 @@ back:
void dialog_breakpoints::on_add(wxCommandEvent& e)
{
uint64_t addr;
debug_type dtype;
debug_context::etype dtype;
dialog_breakpoint_add* d = new dialog_breakpoint_add(this, regions);
if(d->ShowModal() != wxID_OK) {
d->Destroy();
@ -1822,7 +1822,7 @@ back:
if(idx == wxNOT_FOUND)
return;
uint64_t addr;
debug_type dtype;
debug_context::etype dtype;
addr = listsyms[idx].first;
dtype = listsyms[idx].second;
lsnes_instance.run_async([this, addr, dtype]() {
@ -1832,7 +1832,7 @@ back:
listsyms.erase(listsyms.begin() + idx);
}
size_t dialog_breakpoints::get_insert_pos(std::pair<uint64_t, debug_type> entry)
size_t dialog_breakpoints::get_insert_pos(std::pair<uint64_t, debug_context::etype> entry)
{
size_t i = 0;
for(i = 0; i < listsyms.size(); i++)
@ -1841,7 +1841,7 @@ back:
return i;
}
std::string dialog_breakpoints::format_line(std::pair<uint64_t, debug_type> entry)
std::string dialog_breakpoints::format_line(std::pair<uint64_t, debug_context::etype> entry)
{
std::string base = "";
for(auto i : regions) {
@ -1852,11 +1852,11 @@ back:
}
if(base == "")
base = hex::to<uint64_t>(entry.first);
if(entry.second == DEBUG_READ)
if(entry.second == debug_context::DEBUG_READ)
return base + ": Read";
if(entry.second == DEBUG_WRITE)
if(entry.second == debug_context::DEBUG_WRITE)
return base + ": Write";
if(entry.second == DEBUG_EXEC)
if(entry.second == debug_context::DEBUG_EXEC)
return base + ": Execute";
return base + ": Unknown";
}