WARNING emu.h recompile!

debugger: Show save state items in alphabetical order in the debugger view. [Curt Coder]
This commit is contained in:
Curt Coder 2018-05-18 13:08:54 +03:00
parent af1b9542ce
commit 4d3566cfa7
3 changed files with 44 additions and 8 deletions

View File

@ -153,22 +153,35 @@ void debug_view_memory::enumerate_sources()
m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), *region.second.get()))); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), *region.second.get())));
} }
// finally add all global array symbols // finally add all global array symbols in alphabetical order
for (int itemnum = 0; itemnum < 10000; itemnum++) std::vector<std::string> itemnames;
itemnames.resize(machine().save().registration_count());
for (int itemnum = 0; itemnum < machine().save().registration_count(); itemnum++)
{ {
// stop when we run out of items
u32 valsize, valcount; u32 valsize, valcount;
void *base; void *base;
const char *itemname = machine().save().indexed_item(itemnum, base, valsize, valcount); std::string name_string(machine().save().indexed_item(itemnum, base, valsize, valcount));
if (itemname == nullptr)
break; itemnames[itemnum] = name_string;
}
std::sort(itemnames.begin(), itemnames.end());
for (int itemnum = 0; itemnum < machine().save().registration_count(); itemnum++)
{
name = itemnames[itemnum];
const char *itemname = name.c_str();
// add pretty much anything that's not a timer (we may wish to cull other items later) // add pretty much anything that's not a timer (we may wish to cull other items later)
// also, don't trim the front of the name, it's important to know which VIA6522 we're looking at, e.g. // also, don't trim the front of the name, it's important to know which VIA6522 we're looking at, e.g.
if (strncmp(itemname, "timer/", 6)) if (strncmp(itemname, "timer/", 6))
{ {
name.assign(itemname); u32 valsize, valcount;
m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), base, valsize, valcount))); void *base;
machine().save().named_item(name, base, valsize, valcount);
m_source_list.append(*global_alloc(debug_view_memory_source(itemname, base, valsize, valcount)));
} }
} }

View File

@ -107,6 +107,28 @@ const char *save_manager::indexed_item(int index, void *&base, u32 &valsize, u32
} }
//-------------------------------------------------
// named_item - return an item with the given
// name
//-------------------------------------------------
void save_manager::named_item(std::string name, void *&base, u32 &valsize, u32 &valcount) const
{
for (auto it = m_entry_list.begin(); it != m_entry_list.end(); ++it)
{
if (it->get()->m_name.compare(name) == 0)
{
state_entry *entry = it->get();
base = entry->m_data;
valsize = entry->m_typesize;
valcount = entry->m_typecount;
break;
}
}
}
//------------------------------------------------- //-------------------------------------------------
// register_presave - register a pre-save // register_presave - register a pre-save
// function callback // function callback

View File

@ -106,6 +106,7 @@ public:
// registration control // registration control
void allow_registration(bool allowed = true); void allow_registration(bool allowed = true);
const char *indexed_item(int index, void *&base, u32 &valsize, u32 &valcount) const; const char *indexed_item(int index, void *&base, u32 &valsize, u32 &valcount) const;
void named_item(std::string name, void *&base, u32 &valsize, u32 &valcount) const;
// function registration // function registration
void register_presave(save_prepost_delegate func); void register_presave(save_prepost_delegate func);