Previous 199869 Revisions Next

r35179 Saturday 21st February, 2015 at 14:19:09 UTC by Vasantha Crabb
Qt debugger dynamically updates menu items controlling disassembly views
[src/osd/modules/debugger/qt]dasmwindow.c dasmwindow.h debuggerview.c debuggerview.h mainwindow.c mainwindow.h

trunk/src/osd/modules/debugger/qt/dasmwindow.c
r243690r243691
3737   connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int)));
3838
3939   // 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()));
4342
4443   // Force a recompute of the disassembly region
4544   downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
r243690r243691
6968   //
7069   // Menu bars
7170   //
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)));
7981
8082   // Right bar options
8183   QActionGroup* rightBarGroup = new QActionGroup(this);
r243690r243691
9799
98100   // Assemble the options menu
99101   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);
102105   optionsMenu->addSeparator();
103106   optionsMenu->addActions(rightBarGroup->actions());
104107}
r243690r243691
164167}
165168
166169
170void 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
167196void DasmWindow::runToCursor(bool changedTo)
168197{
169198   if (m_dasmView->view()->cursor_visible())
r243690r243691
193222}
194223
195224
225void 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
196256void DasmWindow::populateComboBox()
197257{
198258   if (m_dasmView == NULL)
trunk/src/osd/modules/debugger/qt/dasmwindow.h
r243690r243691
2424   void expressionSubmitted();
2525
2626   void toggleBreakpointAtCursor(bool changedTo);
27   void enableBreakpointAtCursor(bool changedTo);
2728   void runToCursor(bool changedTo);
2829   void rightBarChanged(QAction* changedTo);
2930
31   void dasmViewUpdated();
3032
33
3134private:
3235   void populateComboBox();
3336
3437
35private:
3638   // Widgets
3739   QLineEdit* m_inputEdit;
3840   QComboBox* m_cpuComboBox;
3941   DebuggerView* m_dasmView;
42
43   // Menu items
44   QAction* m_breakpointToggleAct;
45   QAction* m_breakpointEnableAct;
46   QAction* m_runToCursorAct;
4047};
4148
4249
trunk/src/osd/modules/debugger/qt/debuggerview.c
r243690r243691
379379   dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x);
380380   dView->viewport()->update();
381381   dView->update();
382   emit dView->updated();
382383}
trunk/src/osd/modules/debugger/qt/debuggerview.h
r243690r243691
1818
1919   void paintEvent(QPaintEvent* event);
2020
21   // Callback to allow MAME to refresh the view
22   static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate);
23
2421   // Setters and accessors
2522   void setPreferBottom(bool pb) { m_preferBottom = pb; }
2623   debug_view* view() { return m_view; }
2724
25signals:
26   void updated();
2827
2928protected:
3029   void keyPressEvent(QKeyEvent* event);
r243690r243691
3635
3736
3837private:
38   // Callback to allow MAME to refresh the view
39   static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate);
40
3941   bool m_preferBottom;
4042
4143   debug_view* m_view;
trunk/src/osd/modules/debugger/qt/mainwindow.c
r243690r243691
4343   //
4444   // Options Menu
4545   //
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)));
5356
5457   // Right bar options
5558   QActionGroup* rightBarGroup = new QActionGroup(this);
r243690r243691
7174
7275   // Assemble the options menu
7376   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);
7680   optionsMenu->addSeparator();
7781   optionsMenu->addActions(rightBarGroup->actions());
7882
r243690r243691
109113   dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
110114   m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
111115   dasmDock->setWidget(m_dasmFrame);
116   connect(m_dasmFrame->view(), SIGNAL(updated()), this, SLOT(dasmViewUpdated()));
112117
113118   addDockWidget(Qt::TopDockWidgetArea, dasmDock);
114119   dockMenu->addAction(dasmDock->toggleViewAction());
r243690r243691
200205
201206void MainWindow::toggleBreakpointAtCursor(bool changedTo)
202207{
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()))
205210   {
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())
207219      {
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())
216221         {
217            if (address == bp->address())
218            {
219               bpindex = bp->index();
220               break;
221            }
222            bpindex = bp->index();
223            break;
222224         }
225      }
223226
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);
235232      }
233      else
234      {
235         command.printf("bpclear 0x%X", bpindex);
236      }
237      debug_console_execute_command(*m_machine, command, 1);
236238   }
237239
238240   refreshAll();
239241}
240242
241243
242void MainWindow::runToCursor(bool changedTo)
244void MainWindow::enableBreakpointAtCursor(bool changedTo)
243245{
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()))
246248   {
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)
248258      {
249         offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
259         INT32 const bpindex = bp->index();
250260         astring command;
251         command.printf("go 0x%X", address);
261         command.printf(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
252262         debug_console_execute_command(*m_machine, command, 1);
253263      }
254264   }
265
266   refreshAll();
255267}
256268
257269
270void 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
258283void MainWindow::rightBarChanged(QAction* changedTo)
259284{
260285   debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
r243690r243691
372397}
373398
374399
400void 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
375432void MainWindow::debugActClose()
376433{
377434   m_machine->schedule_exit();
trunk/src/osd/modules/debugger/qt/mainwindow.h
r243690r243691
3737
3838private slots:
3939   void toggleBreakpointAtCursor(bool changedTo);
40   void enableBreakpointAtCursor(bool changedTo);
4041   void runToCursor(bool changedTo);
4142   void rightBarChanged(QAction* changedTo);
4243
r243690r243691
4546   void mountImage(bool changedTo);
4647   void unmountImage(bool changedTo);
4748
49   void dasmViewUpdated();
50
4851   // Closing the main window actually exits the program
4952   void debugActClose();
5053
5154
5255private:
56   void createImagesMenu();
57
5358   // Widgets and docks
5459   QLineEdit* m_inputEdit;
5560   DebuggerView* m_consoleView;
5661   ProcessorDockWidget* m_procFrame;
5762   DasmDockWidget* m_dasmFrame;
5863
64   // Menu items
65   QAction* m_breakpointToggleAct;
66   QAction* m_breakpointEnableAct;
67   QAction* m_runToCursorAct;
68
5969   // Terminal history
6070   int m_historyIndex;
6171   std::vector<QString> m_inputHistory;
6272   void addToHistory(const QString& command);
63
64   void createImagesMenu();
6573};
6674
6775


Previous 199869 Revisions Next


© 1997-2024 The MAME Team