QT Debugger: The memory view chunk size radio now reports proper sizes.

Fixed "ignore" command reporting incorrect invalid CPUs.
             Fixed crazy code responsible for opcodes' crc32s in the comments system
             (what was I thinking back then?). [Andrew Gardner]
This commit is contained in:
Andrew Gardner 2013-04-02 03:33:43 +00:00
parent 8312271a56
commit de35bcf071
4 changed files with 57 additions and 25 deletions

View File

@ -554,16 +554,19 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev
}
/* if we got a valid one, return */
const UINT64 original_cpunum = cpunum;
execute_interface_iterator iter(machine.root_device());
for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
{
if (cpunum-- == 0)
{
*result = &exec->device();
return TRUE;
}
}
/* if out of range, complain */
debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)cpunum);
debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)original_cpunum);
return FALSE;
}

View File

@ -2767,33 +2767,27 @@ void device_debug::comment_dump(offs_t addr)
UINT32 device_debug::compute_opcode_crc32(offs_t address) const
{
// no memory interface, just fail
// no memory interface? just fail
if (m_memory == NULL)
return 0;
// no program interface, just fail
// get the crc bytes from program memory
address_space &space = m_memory->space(AS_PROGRAM);
// zero out the buffers
UINT8 opbuf[64], argbuf[64];
memset(opbuf, 0x00, sizeof(opbuf));
memset(argbuf, 0x00, sizeof(argbuf));
// fetch the bytes up to the maximum
// ask the interface how many bytes to get
int maxbytes = m_disasm->max_opcode_bytes();
// fetch the arg and op bytes & mash 'em into a single buffer
UINT8 buff[maxbytes*2];
memset(buff, 0x00, sizeof(buff));
for (int index = 0; index < maxbytes; index++)
{
opbuf[index] = debug_read_opcode(space, address + index, 1, false);
argbuf[index] = debug_read_opcode(space, address + index, 1, true);
buff[index] = debug_read_opcode(space, address + index, 1, false);
buff[index+maxbytes] = debug_read_opcode(space, address + index, 1, true);
}
// disassemble and then convert to bytes
char buff[256];
int numbytes = disassemble(buff, address & space.logaddrmask(), opbuf, argbuf) & DASMFLAG_LENGTHMASK;
numbytes = space.address_to_byte(numbytes);
// return a CRC of the resulting bytes
return crc32(0, argbuf, numbytes);
return crc32(0, buff, maxbytes*2);
}

View File

@ -38,12 +38,6 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
m_machine,
this);
// Populate the combo box
populateComboBox();
// Set to the current CPU's memory view
setToCurrentCpu();
// Layout
QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
subLayout->addWidget(m_inputEdit);
@ -65,8 +59,11 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
// Create a byte-chunk group
QActionGroup* chunkGroup = new QActionGroup(this);
QAction* chunkActOne = new QAction("1-byte chunks", this);
chunkActOne->setObjectName("chunkActOne");
QAction* chunkActTwo = new QAction("2-byte chunks", this);
chunkActTwo->setObjectName("chunkActTwo");
QAction* chunkActFour = new QAction("4-byte chunks", this);
chunkActFour->setObjectName("chunkActFour");
chunkActOne->setCheckable(true);
chunkActTwo->setCheckable(true);
chunkActFour->setCheckable(true);
@ -116,6 +113,15 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
optionsMenu->addSeparator();
optionsMenu->addAction(increaseBplAct);
optionsMenu->addAction(decreaseBplAct);
//
// Initialize
//
populateComboBox();
// Set to the current CPU's memory view
setToCurrentCpu();
}
@ -123,6 +129,16 @@ void MemoryWindow::memoryRegionChanged(int index)
{
m_memTable->view()->set_source(*m_memTable->view()->source_list().by_index(index));
m_memTable->viewport()->update();
// Update the chunk size radio buttons to the memory region's default
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view());
switch(memView->bytes_per_chunk())
{
case 1: chunkSizeMenuItem("chunkActOne")->setChecked(true); break;
case 2: chunkSizeMenuItem("chunkActTwo")->setChecked(true); break;
case 4: chunkSizeMenuItem("chunkActFour")->setChecked(true); break;
default: break;
}
}
@ -221,6 +237,24 @@ void MemoryWindow::setToCurrentCpu()
{
device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine);
const debug_view_source *source = m_memTable->view()->source_list().match_device(curCpu);
const int listIndex = m_memTable->view()->source_list().index(*source);
m_memoryComboBox->setCurrentIndex(listIndex);
const int listIndex = m_memTable->view()->source_list().index(*source);
m_memoryComboBox->setCurrentIndex(listIndex);
}
// I have a hard time storing QActions as class members. This is a substitute.
QAction* MemoryWindow::chunkSizeMenuItem(const QString& itemName)
{
QList<QMenu*> menus = menuBar()->findChildren<QMenu*>();
for (int i = 0; i < menus.length(); i++)
{
if (menus[i]->title() != "&Options") continue;
QList<QAction*> actions = menus[i]->actions();
for (int j = 0; j < actions.length(); j++)
{
if (actions[j]->objectName() == itemName)
return actions[j];
}
}
return NULL;
}

View File

@ -32,6 +32,7 @@ private slots:
private:
void populateComboBox();
void setToCurrentCpu();
QAction* chunkSizeMenuItem(const QString& itemName);
private: