summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/dvdisasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/debug/dvdisasm.cpp')
-rw-r--r--src/emu/debug/dvdisasm.cpp120
1 files changed, 64 insertions, 56 deletions
diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp
index 667542483a4..17cc766ef94 100644
--- a/src/emu/debug/dvdisasm.cpp
+++ b/src/emu/debug/dvdisasm.cpp
@@ -2,17 +2,18 @@
// copyright-holders:Aaron Giles, Olivier Galibert
/*********************************************************************
- dvdisasm.c
+ dvdisasm.cpp
Disassembly debugger view.
***************************************************************************/
#include "emu.h"
-#include "debugvw.h"
#include "dvdisasm.h"
+
+#include "debugbuf.h"
#include "debugcpu.h"
-#include "debugger.h"
+
//**************************************************************************
// DEBUG VIEW DISASM SOURCE
@@ -22,11 +23,15 @@
// debug_view_disasm_source - constructor
//-------------------------------------------------
-debug_view_disasm_source::debug_view_disasm_source(const char *name, device_t &device)
- : debug_view_source(name, &device),
+debug_view_disasm_source::debug_view_disasm_source(std::string &&name, device_t &device)
+ : debug_view_source(std::move(name), &device),
m_space(device.memory().space(AS_PROGRAM)),
- m_decrypted_space(device.memory().has_space(AS_OPCODES) ? device.memory().space(AS_OPCODES) : device.memory().space(AS_PROGRAM))
+ m_decrypted_space(device.memory().has_space(AS_OPCODES) ? device.memory().space(AS_OPCODES) : device.memory().space(AS_PROGRAM)),
+ m_pcbase(nullptr)
{
+ const device_state_interface *state;
+ if (device.interface(state))
+ m_pcbase = state->state_find_entry(STATE_GENPCBASE);
}
@@ -35,9 +40,6 @@ debug_view_disasm_source::debug_view_disasm_source(const char *name, device_t &d
// DEBUG VIEW DISASM
//**************************************************************************
-const int debug_view_disasm::DEFAULT_DASM_LINES, debug_view_disasm::DEFAULT_DASM_WIDTH, debug_view_disasm::DASM_MAX_BYTES;
-
-
//-------------------------------------------------
// debug_view_disasm - constructor
//-------------------------------------------------
@@ -52,16 +54,16 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up
{
// fail if no available sources
enumerate_sources();
- if(m_source_list.count() == 0)
+ if(m_source_list.empty())
throw std::bad_alloc();
// count the number of comments
- int total_comments = 0;
- for(const debug_view_source &source : m_source_list)
- {
- const debug_view_disasm_source &dasmsource = downcast<const debug_view_disasm_source &>(source);
- total_comments += dasmsource.device()->debug()->comment_count();
- }
+ //int total_comments = 0;
+ //for(auto &source : m_source_list)
+ //{
+ //const debug_view_disasm_source &dasmsource = downcast<const debug_view_disasm_source &>(*source);
+ //total_comments += dasmsource.device()->debug()->comment_count();
+ //}
// configure the view
m_total.y = DEFAULT_DASM_LINES;
@@ -86,19 +88,23 @@ debug_view_disasm::~debug_view_disasm()
void debug_view_disasm::enumerate_sources()
{
// start with an empty list
- m_source_list.reset();
+ m_source_list.clear();
// iterate over devices with disassembly interfaces
- std::string name;
- for(device_disasm_interface &dasm : disasm_interface_iterator(machine().root_device()))
+ for (device_disasm_interface &dasm : disasm_interface_enumerator(machine().root_device()))
{
- name = string_format("%s '%s'", dasm.device().name(), dasm.device().tag());
- if(dasm.device().memory().space_config(AS_PROGRAM)!=nullptr)
- m_source_list.append(*global_alloc(debug_view_disasm_source(name.c_str(), dasm.device())));
+ if (dasm.device().memory().space_config(AS_PROGRAM))
+ {
+ m_source_list.emplace_back(
+ std::make_unique<debug_view_disasm_source>(
+ util::string_format("%s '%s'", dasm.device().name(), dasm.device().tag()),
+ dasm.device()));
+ }
}
// reset the source to a known good entry
- set_source(*m_source_list.first());
+ if (!m_source_list.empty())
+ set_source(*m_source_list[0]);
}
@@ -113,7 +119,11 @@ void debug_view_disasm::view_notify(debug_view_notification type)
adjust_visible_y_for_cursor();
else if(type == VIEW_NOTIFY_SOURCE_CHANGED)
- m_expression.set_context(&downcast<const debug_view_disasm_source *>(m_source)->device()->debug()->symtable());
+ {
+ const debug_view_disasm_source &source = downcast<const debug_view_disasm_source &>(*m_source);
+ m_expression.set_context(&source.device()->debug()->symtable());
+ m_expression.set_default_base(source.space().is_octal() ? 8 : 16);
+ }
}
@@ -159,7 +169,7 @@ void debug_view_disasm::view_char(int chval)
case DCH_HOME: // set the active column to the PC
{
const debug_view_disasm_source &source = downcast<const debug_view_disasm_source &>(*m_source);
- offs_t pc = source.device()->state().pcbase() & source.m_space.logaddrmask();
+ offs_t pc = source.pcbase();
// figure out which row the pc is on
for(unsigned int curline = 0; curline < m_dasm.size(); curline++)
@@ -225,6 +235,7 @@ void debug_view_disasm::generate_from_address(debug_disasm_buffer &buffer, offs_
m_dasm.emplace_back(address, size, dasm);
address = next_address;
}
+ m_recompute = false;
}
bool debug_view_disasm::generate_with_pc(debug_disasm_buffer &buffer, offs_t pc)
@@ -242,6 +253,7 @@ bool debug_view_disasm::generate_with_pc(debug_disasm_buffer &buffer, offs_t pc)
backwards_offset = 64 << shift;
m_dasm.clear();
+ m_recompute = false;
offs_t address = (pc - m_backwards_steps*backwards_offset) & source.m_space.logaddrmask();
// Handle wrap at 0
if(address > pc)
@@ -316,7 +328,7 @@ void debug_view_disasm::generate_dasm(debug_disasm_buffer &buffer, offs_t pc)
return;
}
- if(address_position(pc) != -1) {
+ if(!m_recompute && address_position(pc) != -1) {
generate_from_address(buffer, m_dasm[0].m_address);
int pos = address_position(pc);
if(pos != -1) {
@@ -352,13 +364,7 @@ void debug_view_disasm::complete_information(const debug_view_disasm_source &sou
dasm.m_is_pc = adr == pc;
- dasm.m_is_bp = false;
- for(const device_debug::breakpoint &bp : source.device()->debug()->breakpoint_list())
- if(adr == (bp.address() & source.m_space.logaddrmask())) {
- dasm.m_is_bp = true;
- break;
- }
-
+ dasm.m_is_bp = source.device()->debug()->breakpoint_find(adr) != nullptr;
dasm.m_is_visited = source.device()->debug()->track_pc_visited(adr);
const char *comment = source.device()->debug()->comment_text(adr);
@@ -376,7 +382,7 @@ void debug_view_disasm::view_update()
{
const debug_view_disasm_source &source = downcast<const debug_view_disasm_source &>(*m_source);
debug_disasm_buffer buffer(*source.device());
- offs_t pc = source.device()->state().pcbase() & source.m_space.logaddrmask();
+ offs_t pc = source.pcbase();
generate_dasm(buffer, pc);
@@ -389,25 +395,25 @@ void debug_view_disasm::view_update()
// print - print a string in the disassembly view
//-------------------------------------------------
-void debug_view_disasm::print(int row, std::string text, int start, int end, u8 attrib)
+void debug_view_disasm::print(u32 row, std::string text, s32 start, s32 end, u8 attrib)
{
- int view_end = end - m_topleft.x;
+ s32 view_end = end - m_topleft.x;
if(view_end < 0)
return;
- int string_0 = start - m_topleft.x;
+ s32 string_0 = start - m_topleft.x;
if(string_0 >= m_visible.x)
return;
- int view_start = string_0 > 0 ? string_0 : 0;
+ s32 view_start = string_0 > 0 ? string_0 : 0;
debug_view_char *dest = &m_viewdata[row * m_visible.x + view_start];
if(view_end >= m_visible.x)
view_end = m_visible.x;
- for(int pos = view_start; pos < view_end; pos++) {
- int spos = pos - string_0;
- if(spos >= int(text.size()))
+ for(s32 pos = view_start; pos < view_end; pos++) {
+ s32 spos = pos - string_0;
+ if(spos >= s32(text.size()))
*dest++ = { ' ', attrib };
else
*dest++ = { u8(text[spos]), attrib };
@@ -422,13 +428,15 @@ void debug_view_disasm::print(int row, std::string text, int start, int end, u8
void debug_view_disasm::redraw()
{
// determine how many characters we need for an address and set the divider
- int m_divider1 = 1 + m_dasm[0].m_tadr.size() + 1;
+ s32 divider1 = 1 + m_dasm[0].m_tadr.size() + 1;
// assume a fixed number of characters for the disassembly
- int m_divider2 = m_divider1 + 1 + m_dasm_width + 1;
+ s32 divider2 = divider1 + 1 + m_dasm_width + 1;
// set the width of the third column to max comment length
- m_total.x = m_divider2 + 1 + 50; // DEBUG_COMMENT_MAX_LINE_LENGTH
+ m_total.x = divider2 + 1 + 50; // DEBUG_COMMENT_MAX_LINE_LENGTH
+
+ const s32 max_visible_col = m_topleft.x + m_visible.x;
// loop over visible rows
for(u32 row = 0; row < m_visible.y; row++)
@@ -455,22 +463,22 @@ void debug_view_disasm::redraw()
if(m_dasm[effrow].m_is_visited)
attrib |= DCA_VISITED;
- print(row, ' ' + m_dasm[effrow].m_tadr, 0, m_divider1, attrib | DCA_ANCILLARY);
- print(row, ' ' + m_dasm[effrow].m_dasm, m_divider1, m_divider2, attrib);
+ print(row, ' ' + m_dasm[effrow].m_tadr, 0, divider1, attrib | DCA_ANCILLARY);
+ print(row, ' ' + m_dasm[effrow].m_dasm, divider1, divider2, attrib);
if(m_right_column == DASM_RIGHTCOL_RAW || m_right_column == DASM_RIGHTCOL_ENCRYPTED) {
std::string text = ' ' +(m_right_column == DASM_RIGHTCOL_RAW ? m_dasm[effrow].m_topcodes : m_dasm[effrow].m_tparams);
- print(row, text, m_divider2, m_visible.x, attrib | DCA_ANCILLARY);
- if(int(text.size()) > m_visible.x - m_divider2) {
- int base = m_total.x - 3;
- if(base < m_divider2)
- base = m_divider2;
- print(row, "...", base, m_visible.x, attrib | DCA_ANCILLARY);
+ print(row, text, divider2, max_visible_col, attrib | DCA_ANCILLARY);
+ if(s32(text.size()) > max_visible_col - divider2) {
+ s32 base = max_visible_col - 3;
+ if(base < divider2)
+ base = divider2;
+ print(row, "...", base, max_visible_col, attrib | DCA_ANCILLARY);
}
} else if(!m_dasm[effrow].m_comment.empty())
- print(row, " // " + m_dasm[effrow].m_comment, m_divider2, m_visible.x, attrib | DCA_COMMENT | DCA_ANCILLARY);
+ print(row, " // " + m_dasm[effrow].m_comment, divider2, max_visible_col, attrib | DCA_COMMENT | DCA_ANCILLARY);
else
- print(row, "", m_divider2, m_visible.x, attrib | DCA_COMMENT | DCA_ANCILLARY);
+ print(row, "", divider2, max_visible_col, attrib | DCA_COMMENT | DCA_ANCILLARY);
}
}
}
@@ -511,7 +519,7 @@ void debug_view_disasm::set_right_column(disasm_right_column contents)
{
begin_update();
m_right_column = contents;
- m_recompute = m_update_pending = true;
+ m_update_pending = true;
end_update();
}
@@ -568,7 +576,7 @@ void debug_view_disasm::set_selected_address(offs_t address)
void debug_view_disasm::set_source(const debug_view_source &source)
{
if(&source != m_source) {
+ m_recompute = true;
debug_view::set_source(source);
- m_dasm.clear();
}
}