trunk/src/osd/modules/debugger/qt/dasmwindow.c
| r243690 | r243691 | |
| 37 | 37 | connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int))); |
| 38 | 38 | |
| 39 | 39 | // The main disasm window |
| 40 | | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, |
| 41 | | m_machine, |
| 42 | | this); |
| 40 | m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this); |
| 41 | connect(m_dasmView, SIGNAL(updated()), this, SLOT(dasmViewUpdated())); |
| 43 | 42 | |
| 44 | 43 | // Force a recompute of the disassembly region |
| 45 | 44 | downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); |
| r243690 | r243691 | |
| 69 | 68 | // |
| 70 | 69 | // Menu bars |
| 71 | 70 | // |
| 72 | | // Create two commands |
| 73 | | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 74 | | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 75 | | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 76 | | runToCursorAct->setShortcut(Qt::Key_F4); |
| 77 | | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 78 | | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 71 | // Create three commands |
| 72 | m_breakpointToggleAct = new QAction("Toggle Breakpoint at Cursor", this); |
| 73 | m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this); |
| 74 | m_runToCursorAct = new QAction("Run to Cursor", this); |
| 75 | m_breakpointToggleAct->setShortcut(Qt::Key_F9); |
| 76 | m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9); |
| 77 | m_runToCursorAct->setShortcut(Qt::Key_F4); |
| 78 | connect(m_breakpointToggleAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 79 | connect(m_breakpointEnableAct, SIGNAL(triggered(bool)), this, SLOT(enableBreakpointAtCursor(bool))); |
| 80 | connect(m_runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 79 | 81 | |
| 80 | 82 | // Right bar options |
| 81 | 83 | QActionGroup* rightBarGroup = new QActionGroup(this); |
| r243690 | r243691 | |
| 97 | 99 | |
| 98 | 100 | // Assemble the options menu |
| 99 | 101 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 100 | | optionsMenu->addAction(breakpointSetAct); |
| 101 | | optionsMenu->addAction(runToCursorAct); |
| 102 | optionsMenu->addAction(m_breakpointToggleAct); |
| 103 | optionsMenu->addAction(m_breakpointEnableAct); |
| 104 | optionsMenu->addAction(m_runToCursorAct); |
| 102 | 105 | optionsMenu->addSeparator(); |
| 103 | 106 | optionsMenu->addActions(rightBarGroup->actions()); |
| 104 | 107 | } |
| r243690 | r243691 | |
| 164 | 167 | } |
| 165 | 168 | |
| 166 | 169 | |
| 170 | void DasmWindow::enableBreakpointAtCursor(bool changedTo) |
| 171 | { |
| 172 | if (m_dasmView->view()->cursor_visible()) |
| 173 | { |
| 174 | offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address(); |
| 175 | device_t *const device = m_dasmView->view()->source()->device(); |
| 176 | device_debug *const cpuinfo = device->debug(); |
| 177 | |
| 178 | // Find an existing breakpoint at this address |
| 179 | device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 180 | while ((bp != NULL) && (bp->address() != address)) |
| 181 | bp = bp->next(); |
| 182 | |
| 183 | if (bp != NULL) |
| 184 | { |
| 185 | cpuinfo->breakpoint_enable(bp->index(), !bp->enabled()); |
| 186 | debug_console_printf(*m_machine, "Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled"); |
| 187 | m_machine->debug_view().update_all(); |
| 188 | debugger_refresh_display(*m_machine); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | refreshAll(); |
| 193 | } |
| 194 | |
| 195 | |
| 167 | 196 | void DasmWindow::runToCursor(bool changedTo) |
| 168 | 197 | { |
| 169 | 198 | if (m_dasmView->view()->cursor_visible()) |
| r243690 | r243691 | |
| 193 | 222 | } |
| 194 | 223 | |
| 195 | 224 | |
| 225 | void DasmWindow::dasmViewUpdated() |
| 226 | { |
| 227 | bool const haveCursor = m_dasmView->view()->cursor_visible(); |
| 228 | bool haveBreakpoint = false; |
| 229 | bool breakpointEnabled = false; |
| 230 | if (haveCursor) |
| 231 | { |
| 232 | offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address(); |
| 233 | device_t *const device = m_dasmView->view()->source()->device(); |
| 234 | device_debug *const cpuinfo = device->debug(); |
| 235 | |
| 236 | // Find an existing breakpoint at this address |
| 237 | device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 238 | while ((bp != NULL) && (bp->address() != address)) |
| 239 | bp = bp->next(); |
| 240 | |
| 241 | if (bp != NULL) |
| 242 | { |
| 243 | haveBreakpoint = true; |
| 244 | breakpointEnabled = bp->enabled(); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | m_breakpointToggleAct->setText(haveBreakpoint ? "Clear Breakpoint at Cursor" : haveCursor ? "Set Breakpoint at Cursor" : "Toggle Breakpoint at Cursor"); |
| 249 | m_breakpointEnableAct->setText((!haveBreakpoint || breakpointEnabled) ? "Disable Breakpoint at Cursor" : "Enable Breakpoint at Cursor"); |
| 250 | m_breakpointToggleAct->setEnabled(haveCursor); |
| 251 | m_breakpointEnableAct->setEnabled(haveBreakpoint); |
| 252 | m_runToCursorAct->setEnabled(haveCursor); |
| 253 | } |
| 254 | |
| 255 | |
| 196 | 256 | void DasmWindow::populateComboBox() |
| 197 | 257 | { |
| 198 | 258 | if (m_dasmView == NULL) |
trunk/src/osd/modules/debugger/qt/mainwindow.c
| r243690 | r243691 | |
| 43 | 43 | // |
| 44 | 44 | // Options Menu |
| 45 | 45 | // |
| 46 | | // Create two commands |
| 47 | | QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); |
| 48 | | QAction* runToCursorAct = new QAction("Run To Cursor", this); |
| 49 | | breakpointSetAct->setShortcut(Qt::Key_F9); |
| 50 | | runToCursorAct->setShortcut(Qt::Key_F4); |
| 51 | | connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 52 | | connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 46 | // Create three commands |
| 47 | m_breakpointToggleAct = new QAction("Toggle Breakpoint at Cursor", this); |
| 48 | m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this); |
| 49 | m_runToCursorAct = new QAction("Run to Cursor", this); |
| 50 | m_breakpointToggleAct->setShortcut(Qt::Key_F9); |
| 51 | m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9); |
| 52 | m_runToCursorAct->setShortcut(Qt::Key_F4); |
| 53 | connect(m_breakpointToggleAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); |
| 54 | connect(m_breakpointEnableAct, SIGNAL(triggered(bool)), this, SLOT(enableBreakpointAtCursor(bool))); |
| 55 | connect(m_runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); |
| 53 | 56 | |
| 54 | 57 | // Right bar options |
| 55 | 58 | QActionGroup* rightBarGroup = new QActionGroup(this); |
| r243690 | r243691 | |
| 71 | 74 | |
| 72 | 75 | // Assemble the options menu |
| 73 | 76 | QMenu* optionsMenu = menuBar()->addMenu("&Options"); |
| 74 | | optionsMenu->addAction(breakpointSetAct); |
| 75 | | optionsMenu->addAction(runToCursorAct); |
| 77 | optionsMenu->addAction(m_breakpointToggleAct); |
| 78 | optionsMenu->addAction(m_breakpointEnableAct); |
| 79 | optionsMenu->addAction(m_runToCursorAct); |
| 76 | 80 | optionsMenu->addSeparator(); |
| 77 | 81 | optionsMenu->addActions(rightBarGroup->actions()); |
| 78 | 82 | |
| r243690 | r243691 | |
| 109 | 113 | dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); |
| 110 | 114 | m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); |
| 111 | 115 | dasmDock->setWidget(m_dasmFrame); |
| 116 | connect(m_dasmFrame->view(), SIGNAL(updated()), this, SLOT(dasmViewUpdated())); |
| 112 | 117 | |
| 113 | 118 | addDockWidget(Qt::TopDockWidgetArea, dasmDock); |
| 114 | 119 | dockMenu->addAction(dasmDock->toggleViewAction()); |
| r243690 | r243691 | |
| 200 | 205 | |
| 201 | 206 | void MainWindow::toggleBreakpointAtCursor(bool changedTo) |
| 202 | 207 | { |
| 203 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 204 | | if (dasmView->cursor_visible()) |
| 208 | debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 209 | if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())) |
| 205 | 210 | { |
| 206 | | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 211 | offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address(); |
| 212 | device_debug *const cpuinfo = dasmView->source()->device()->debug(); |
| 213 | |
| 214 | // Find an existing breakpoint at this address |
| 215 | INT32 bpindex = -1; |
| 216 | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 217 | bp != NULL; |
| 218 | bp = bp->next()) |
| 207 | 219 | { |
| 208 | | offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address(); |
| 209 | | device_debug *cpuinfo = dasmView->source()->device()->debug(); |
| 210 | | |
| 211 | | // Find an existing breakpoint at this address |
| 212 | | INT32 bpindex = -1; |
| 213 | | for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 214 | | bp != NULL; |
| 215 | | bp = bp->next()) |
| 220 | if (address == bp->address()) |
| 216 | 221 | { |
| 217 | | if (address == bp->address()) |
| 218 | | { |
| 219 | | bpindex = bp->index(); |
| 220 | | break; |
| 221 | | } |
| 222 | bpindex = bp->index(); |
| 223 | break; |
| 222 | 224 | } |
| 225 | } |
| 223 | 226 | |
| 224 | | // If none exists, add a new one |
| 225 | | astring command; |
| 226 | | if (bpindex == -1) |
| 227 | | { |
| 228 | | command.printf("bpset 0x%X", address); |
| 229 | | } |
| 230 | | else |
| 231 | | { |
| 232 | | command.printf("bpclear 0x%X", bpindex); |
| 233 | | } |
| 234 | | debug_console_execute_command(*m_machine, command, 1); |
| 227 | // If none exists, add a new one |
| 228 | astring command; |
| 229 | if (bpindex == -1) |
| 230 | { |
| 231 | command.printf("bpset 0x%X", address); |
| 235 | 232 | } |
| 233 | else |
| 234 | { |
| 235 | command.printf("bpclear 0x%X", bpindex); |
| 236 | } |
| 237 | debug_console_execute_command(*m_machine, command, 1); |
| 236 | 238 | } |
| 237 | 239 | |
| 238 | 240 | refreshAll(); |
| 239 | 241 | } |
| 240 | 242 | |
| 241 | 243 | |
| 242 | | void MainWindow::runToCursor(bool changedTo) |
| 244 | void MainWindow::enableBreakpointAtCursor(bool changedTo) |
| 243 | 245 | { |
| 244 | | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 245 | | if (dasmView->cursor_visible()) |
| 246 | debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 247 | if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())) |
| 246 | 248 | { |
| 247 | | if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) |
| 249 | offs_t const address = dasmView->selected_address(); |
| 250 | device_debug *const cpuinfo = dasmView->source()->device()->debug(); |
| 251 | |
| 252 | // Find an existing breakpoint at this address |
| 253 | device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 254 | while ((bp != NULL) && (bp->address() != address)) |
| 255 | bp = bp->next(); |
| 256 | |
| 257 | if (bp != NULL) |
| 248 | 258 | { |
| 249 | | offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address(); |
| 259 | INT32 const bpindex = bp->index(); |
| 250 | 260 | astring command; |
| 251 | | command.printf("go 0x%X", address); |
| 261 | command.printf(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex); |
| 252 | 262 | debug_console_execute_command(*m_machine, command, 1); |
| 253 | 263 | } |
| 254 | 264 | } |
| 265 | |
| 266 | refreshAll(); |
| 255 | 267 | } |
| 256 | 268 | |
| 257 | 269 | |
| 270 | void MainWindow::runToCursor(bool changedTo) |
| 271 | { |
| 272 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 273 | if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())) |
| 274 | { |
| 275 | offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address(); |
| 276 | astring command; |
| 277 | command.printf("go 0x%X", address); |
| 278 | debug_console_execute_command(*m_machine, command, 1); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | |
| 258 | 283 | void MainWindow::rightBarChanged(QAction* changedTo) |
| 259 | 284 | { |
| 260 | 285 | debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| r243690 | r243691 | |
| 372 | 397 | } |
| 373 | 398 | |
| 374 | 399 | |
| 400 | void MainWindow::dasmViewUpdated() |
| 401 | { |
| 402 | debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); |
| 403 | bool const haveCursor = dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()); |
| 404 | bool haveBreakpoint = false; |
| 405 | bool breakpointEnabled = false; |
| 406 | if (haveCursor) |
| 407 | { |
| 408 | offs_t const address = dasmView->selected_address(); |
| 409 | device_t *const device = dasmView->source()->device(); |
| 410 | device_debug *const cpuinfo = device->debug(); |
| 411 | |
| 412 | // Find an existing breakpoint at this address |
| 413 | device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); |
| 414 | while ((bp != NULL) && (bp->address() != address)) |
| 415 | bp = bp->next(); |
| 416 | |
| 417 | if (bp != NULL) |
| 418 | { |
| 419 | haveBreakpoint = true; |
| 420 | breakpointEnabled = bp->enabled(); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | m_breakpointToggleAct->setText(haveBreakpoint ? "Clear Breakpoint at Cursor" : haveCursor ? "Set Breakpoint at Cursor" : "Toggle Breakpoint at Cursor"); |
| 425 | m_breakpointEnableAct->setText((!haveBreakpoint || breakpointEnabled) ? "Disable Breakpoint at Cursor" : "Enable Breakpoint at Cursor"); |
| 426 | m_breakpointToggleAct->setEnabled(haveCursor); |
| 427 | m_breakpointEnableAct->setEnabled(haveBreakpoint); |
| 428 | m_runToCursorAct->setEnabled(haveCursor); |
| 429 | } |
| 430 | |
| 431 | |
| 375 | 432 | void MainWindow::debugActClose() |
| 376 | 433 | { |
| 377 | 434 | m_machine->schedule_exit(); |