void MainWindow::dasmViewUpdated() { debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); bool const haveCursor = dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()); bool haveBreakpoint = false; bool breakpointEnabled = false; if (haveCursor) { offs_t const address = dasmView->selected_address(); device_t *const device = dasmView->source()->device(); device_debug *const cpuinfo = device->debug(); // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); while ((bp != NULL) && (bp->address() != address)) bp = bp->next(); if (bp != NULL) { haveBreakpoint = true; breakpointEnabled = bp->enabled(); } } m_breakpointToggleAct->setText(haveBreakpoint ? "Clear Breakpoint at Cursor" : haveCursor ? "Set Breakpoint at Cursor" : "Toggle Breakpoint at Cursor"); m_breakpointEnableAct->setText((!haveBreakpoint || breakpointEnabled) ? "Disable Breakpoint at Cursor" : "Enable Breakpoint at Cursor"); m_breakpointToggleAct->setEnabled(haveCursor); m_breakpointEnableAct->setEnabled(haveBreakpoint); m_runToCursorAct->setEnabled(haveCursor); }
void MemoryWindow::setToCurrentCpu() { device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine); const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); const int listIndex = m_memTable->view()->source_list().indexof(*source); m_memoryComboBox->setCurrentIndex(listIndex); }
static void debugmain_process_string(win_i *win, const char *str) { if(!str[0]) debug_cpu_get_visible_cpu(*win->machine)->debug()->single_step(); else debug_console_execute_command(*win->machine, str, 1); }
void on_set_breakpoint_at_cursor_activate(GtkWidget *win) { win_i *info = get_win_i(win, WIN_TYPE_ALL); DView *disasm = get_view(info, DVT_DISASSEMBLY); astring command; if (disasm->view->cursor_visible()) { if (debug_cpu_get_visible_cpu(*info->machine) == disasm->view->source()->device()) { offs_t address = downcast<debug_view_disasm *>(disasm->view)->selected_address(); device_debug *cpuinfo = disasm->view->source()->device()->debug(); device_debug::breakpoint *bp; INT32 bpindex = -1; /* first find an existing breakpoint at this address */ for (bp = cpuinfo->breakpoint_first(); bp != NULL; bp = bp->next()) if (address == bp->address()) { bpindex = bp->index(); break; } /* if it doesn't exist, add a new one */ if (bpindex == -1) command.printf("bpset 0x%X", address); else command.printf("bpclear 0x%X", bpindex); debug_console_execute_command(*info->machine, command, 1); } } }
void MainWindow::executeCommand(bool withClear) { QString command = m_inputEdit->text(); // A blank command is a "silent step" if (command == "") { debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); return; } // Send along the command debug_console_execute_command(*m_machine, command.toLocal8Bit().data(), true); // Add history & set the index to be the top of the stack addToHistory(command); // Clear out the text and reset the history pointer only if asked if (withClear) { m_inputEdit->clear(); m_historyIndex = m_inputHistory.size(); } // Refresh m_consoleView->viewport()->update(); refreshAll(); }
bool debugview_info::set_source_for_visible_cpu() { device_t *const curcpu = debug_cpu_get_visible_cpu(machine()); if (curcpu != NULL) return set_source_for_device(*curcpu); else return false; }
bool debugview_info::source_is_visible_cpu() const { if (m_view != NULL) { const debug_view_source *const source = m_view->source(); return (source != NULL) && (debug_cpu_get_visible_cpu(machine()) == source->device()); } return false; }
void consolewin_info::process_string(char const *string) { if (string[0] == 0) // an empty string is a single step debug_cpu_get_visible_cpu(machine())->debug()->single_step(); else // otherwise, just process the command debug_console_execute_command(machine(), string, 1); // clear the edit text box set_editwnd_text(""); }
void MainWindow::runToCursor(bool changedTo) { debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())) { offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address(); std::string command = string_format("go 0x%X", address); debug_console_execute_command(*m_machine, command.c_str(), 1); } }
static void disasmwin_new(running_machine *machine) { disasmwin_i *dis; int item, cursel; const device_config *curcpu = debug_cpu_get_visible_cpu(machine); const disasm_subview_item *subview; char title[256]; dis = malloc(sizeof(*dis)); memset(dis, 0, sizeof(*dis)); dis->next = disasmwin_list; disasmwin_list = dis; dis->win = create_disasmwin(machine); dis->machine = machine; dis->disasm_w = DVIEW(lookup_widget(dis->win, "disasmview")); dview_set_debug_view(dis->disasm_w, machine, DVT_DISASSEMBLY, &dis->disasm); dis->cpu_w = GTK_COMBO_BOX(lookup_widget(dis->win, "cpu")); edit_init(machine, &dis->ed, lookup_widget(dis->win, "edit"), "curpc", 1, disasmwin_process_string, dis); debug_view_begin_update(dis->disasm); disasm_view_set_expression(dis->disasm, "curpc"); // debug_view_set_property_UINT32(dis->disasm, DVP_DASM_TRACK_LIVE, 1); debug_view_end_update(dis->disasm); // populate the combobox cursel = item = 0; for (subview = disasm_view_get_subview_list(dis->disasm); subview != NULL; subview = subview->next) { gtk_combo_box_append_text(dis->cpu_w, subview->name); if (cursel == 0 && subview->space->cpu == curcpu) cursel = item; item++; } gtk_combo_box_set_active(dis->cpu_w, cursel); disasm_view_set_subview(dis->disasm, cursel); subview = disasm_view_get_current_subview(dis->disasm); sprintf(title, "Disassembly: %s", subview->name); gtk_window_set_title(GTK_WINDOW(dis->win), title); g_signal_connect(dis->cpu_w, "changed", G_CALLBACK(disasmwin_cpu_changed), dis); g_signal_connect(lookup_widget(dis->win, "raw_opcodes"), "activate", G_CALLBACK(disasmwin_raw_opcodes_activate), dis); g_signal_connect(lookup_widget(dis->win, "enc_opcodes"), "activate", G_CALLBACK(disasmwin_enc_opcodes_activate), dis); g_signal_connect(lookup_widget(dis->win, "comments"), "activate", G_CALLBACK(disasmwin_comments_activate), dis); // g_signal_connect(dis->edit_w, "activate", G_CALLBACK(disasmwin_process_string), dis); g_signal_connect(dis->win, "destroy", G_CALLBACK(disasmwin_destroy), dis); gtk_widget_show_all(dis->win); }
static void memorywin_new(running_machine *machine) { memorywin_i *mem; int item, cursel; const device_config *curcpu = debug_cpu_get_visible_cpu(machine); const memory_subview_item *subview; mem = malloc(sizeof(*mem)); memset(mem, 0, sizeof(*mem)); mem->next = memorywin_list; memorywin_list = mem; mem->win = create_memorywin(machine); mem->machine = machine; mem->memory_w = DVIEW(lookup_widget(mem->win, "memoryview")); dview_set_debug_view(mem->memory_w, machine, DVT_MEMORY, &mem->memory); mem->zone_w = GTK_COMBO_BOX(lookup_widget(mem->win, "zone")); edit_init(machine, &mem->ed, lookup_widget(mem->win, "edit"), "0", 1, memorywin_process_string, mem); debug_view_begin_update(mem->memory); memory_view_set_expression(mem->memory, "0"); debug_view_end_update(mem->memory); // populate the combobox if (!memorycombo) { cursel = item = 0; for (subview = memory_view_get_subview_list(mem->memory); subview != NULL; subview = subview->next) { gtk_combo_box_append_text(mem->zone_w, subview->name); if (cursel == 0 && subview->space != NULL && subview->space->cpu == curcpu) cursel = item; item++; } memory_view_set_subview(mem->memory, cursel); gtk_combo_box_set_active(mem->zone_w, cursel); } g_signal_connect(mem->zone_w, "changed", G_CALLBACK(memorywin_zone_changed), mem); g_signal_connect(lookup_widget(mem->win, "chunks_1"), "activate", G_CALLBACK(on_chunks_1_activate), mem); g_signal_connect(lookup_widget(mem->win, "chunks_2"), "activate", G_CALLBACK(on_chunks_2_activate), mem); g_signal_connect(lookup_widget(mem->win, "chunks_4"), "activate", G_CALLBACK(on_chunks_4_activate), mem); g_signal_connect(lookup_widget(mem->win, "reverse"), "activate", G_CALLBACK(on_reverse_activate), mem); g_signal_connect(lookup_widget(mem->win, "ibpl"), "activate", G_CALLBACK(on_ibpl_activate), mem); g_signal_connect(lookup_widget(mem->win, "dbpl"), "activate", G_CALLBACK(on_dbpl_activate), mem); g_signal_connect(mem->win, "destroy", G_CALLBACK(memorywin_destroy), mem); gtk_widget_show_all(mem->win); }
void DasmWindow::runToCursor(bool changedTo) { if (m_dasmView->view()->cursor_visible()) { if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) { offs_t address = downcast<debug_view_disasm*>(m_dasmView->view())->selected_address(); astring command; command.printf("go 0x%X", address); debug_console_execute_command(*m_machine, command, 1); } } }
void on_run_to_cursor_activate(GtkWidget *win) { win_i *info = get_win_i(win, WIN_TYPE_ALL); DView *disasm = get_view(info, DVT_DISASSEMBLY); astring command; if (disasm->view->cursor_visible()) { if (debug_cpu_get_visible_cpu(*info->machine) == disasm->view->source()->device()) { offs_t address = downcast<debug_view_disasm *>(disasm->view)->selected_address(); command.printf("go 0x%X", address); debug_console_execute_command(*info->machine, command, 1); } } }
static void disasmwin_new(running_machine &machine) { win_i *dis; int item; //, cursel; device_t *curcpu = debug_cpu_get_visible_cpu(machine); GtkComboBox *cpu_w; astring title; dis = add_win_i(machine, WIN_TYPE_DISASM); dis->win = create_disasmwin(); dis->views[0] = DVIEW(lookup_widget(dis->win, "disasmview")); dview_set_debug_view(dis->views[0], machine, DVT_DISASSEMBLY); cpu_w = GTK_COMBO_BOX(lookup_widget(dis->win, "cpu")); edit_init(&dis->ed, lookup_widget(dis->win, "edit"), "curpc", 1, disasmwin_process_string, dis); downcast<debug_view_disasm *>(dis->views[0]->view)->set_expression("curpc"); // populate the combobox // cursel = 0; item = 0; for (const debug_view_source *source = dis->views[0]->view->source_list().head(); source != NULL; source = source->next()) { gtk_combo_box_append_text(cpu_w, source->name()); item++; } const debug_view_source *source = dis->views[0]->view->source_list().match_device(curcpu); gtk_combo_box_set_active(cpu_w, dis->views[0]->view->source_list().index(*source)); dis->views[0]->view->set_source(*source); title.printf("Disassembly: %s", source->name()); gtk_window_set_title(GTK_WINDOW(dis->win), title); g_signal_connect(cpu_w, "changed", G_CALLBACK(disasmwin_cpu_changed), dis); // g_signal_connect(dis->edit_w, "activate", G_CALLBACK(disasmwin_process_string), dis); g_signal_connect(dis->win, "destroy", G_CALLBACK(disasmwin_destroy), dis); gtk_widget_show_all(dis->win); }
void DasmWindow::toggleBreakpointAtCursor(bool changedTo) { if (m_dasmView->view()->cursor_visible()) { if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) { offs_t address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address(); device_debug *cpuinfo = m_dasmView->view()->source()->device()->debug(); // Find an existing breakpoint at this address INT32 bpindex = -1; for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); bp != NULL; bp = bp->next()) { if (address == bp->address()) { bpindex = bp->index(); break; } } // If none exists, add a new one astring command; if (bpindex == -1) { command.printf("bpset 0x%X", address); } else { command.printf("bpclear 0x%X", bpindex); } debug_console_execute_command(*m_machine, command, 1); } } refreshAll(); }
void MainWindow::enableBreakpointAtCursor(bool changedTo) { debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())) { offs_t const address = dasmView->selected_address(); device_debug *const cpuinfo = dasmView->source()->device()->debug(); // Find an existing breakpoint at this address device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); while ((bp != NULL) && (bp->address() != address)) bp = bp->next(); if (bp != NULL) { INT32 const bpindex = bp->index(); std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex); debug_console_execute_command(*m_machine, command.c_str(), 1); } } refreshAll(); }
static void memorywin_new(running_machine &machine) { win_i *mem; int item; //, cursel; device_t *curcpu = debug_cpu_get_visible_cpu(machine); GtkComboBox * zone_w; mem = add_win_i(machine, WIN_TYPE_MEMORY); mem->win = create_memorywin(); mem->views[0] = DVIEW(lookup_widget(mem->win, "memoryview")); dview_set_debug_view(mem->views[0], machine, DVT_MEMORY); zone_w = GTK_COMBO_BOX(lookup_widget(mem->win, "zone")); edit_init(&mem->ed, lookup_widget(mem->win, "edit"), "0", 1, memorywin_process_string, mem); downcast<debug_view_memory *>(mem->views[0]->view)->set_expression("0"); // populate the combobox // cursel = 0; item = 0; for (const debug_view_source *source = mem->views[0]->view->source_list().head(); source != NULL; source = source->next()) { gtk_combo_box_append_text(zone_w, source->name()); item++; } const debug_view_source *source = mem->views[0]->view->source_list().match_device(curcpu); gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().index(*source)); mem->views[0]->view->set_source(*source); g_signal_connect(zone_w, "changed", G_CALLBACK(memorywin_zone_changed), mem); g_signal_connect(mem->win, "destroy", G_CALLBACK(memorywin_destroy), mem); gtk_widget_show_all(mem->win); }
consolewin_info::consolewin_info(debugger_windows_interface &debugger) : disasmbasewin_info(debugger, true, "Debug", NULL), m_devices_menu(NULL) { if ((window() == NULL) || (m_views[0] == NULL)) goto cleanup; // create the views m_views[1].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_STATE))); if (!m_views[1]->is_valid()) goto cleanup; m_views[2].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_CONSOLE))); if (!m_views[2]->is_valid()) goto cleanup; { // Add image menu only if image devices exist image_interface_iterator iter(machine().root_device()); device_image_interface *img = iter.first(); if (img != NULL) { m_devices_menu = CreatePopupMenu(); for ( ; img != NULL; img = iter.next()) { astring temp; temp.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[no image]"); TCHAR *tc_buf = tstring_from_utf8(temp.c_str()); if (tc_buf != NULL) { AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf); osd_free(tc_buf); } } AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)m_devices_menu, TEXT("Images")); } // get the work bounds RECT work_bounds, bounds; SystemParametersInfo(SPI_GETWORKAREA, 0, &work_bounds, 0); // adjust the min/max sizes for the window style bounds.top = bounds.left = 0; bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + 100 + EDGE_WIDTH; AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); set_minwidth(bounds.right - bounds.left); bounds.top = bounds.left = 0; bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + MAX(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH; AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); set_maxwidth(bounds.right - bounds.left); // position the window at the bottom-right int const bestwidth = MIN(maxwidth(), work_bounds.right - work_bounds.left); int const bestheight = MIN(500, work_bounds.bottom - work_bounds.top); SetWindowPos(window(), HWND_TOP, work_bounds.right - bestwidth, work_bounds.bottom - bestheight, bestwidth, bestheight, SWP_SHOWWINDOW); } // recompute the children set_cpu(*debug_cpu_get_visible_cpu(machine())); // mark the edit box as the default focus and set it set_default_focus(); return; cleanup: m_views[2].reset(); m_views[1].reset(); m_views[0].reset(); }
void on_soft_reset_activate(GtkWidget *win) { get_running_machine(win)->schedule_soft_reset(); debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->go(); }
void on_step_out_activate(GtkWidget *win) { debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->single_step_out(); }
void on_run_vbl_activate(GtkWidget *win) { debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->go_vblank(); }
void debug_none::wait_for_debugger(device_t &device, bool firststop) { debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); }
void on_run_h_activate(GtkWidget *win) { debugwin_show(0); debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->go(); }
void on_run_cpu_activate(GtkWidget *win) { debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->go_next_device(); }
LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) { // handle a few messages switch (message) { // paint: draw bezels as necessary case WM_PAINT: { PAINTSTRUCT pstruct; HDC dc = BeginPaint(m_wnd, &pstruct); draw_contents(dc); EndPaint(m_wnd, &pstruct); break; } // keydown: handle debugger keys case WM_KEYDOWN: if (handle_key(wparam, lparam)) set_ignore_char_lparam(lparam); break; // char: ignore chars associated with keys we've handled case WM_CHAR: if (check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) return DefWindowProc(m_wnd, message, wparam, lparam); } break; // activate: set the focus case WM_ACTIVATE: if (wparam != WA_INACTIVE) set_default_focus(); break; // get min/max info: set the minimum window size case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = m_minwidth; minmax->ptMinTrackSize.y = m_minheight; minmax->ptMaxSize.x = minmax->ptMaxTrackSize.x = m_maxwidth; minmax->ptMaxSize.y = minmax->ptMaxTrackSize.y = m_maxheight; break; } // sizing: recompute child window locations case WM_SIZE: case WM_SIZING: recompute_children(); InvalidateRect(m_wnd, NULL, FALSE); break; // mouse wheel: forward to the first view case WM_MOUSEWHEEL: { static int units_carryover = 0; UINT lines_per_click; if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_click, 0)) lines_per_click = 3; int const units = GET_WHEEL_DELTA_WPARAM(wparam) + units_carryover; int const clicks = units / WHEEL_DELTA; units_carryover = units % WHEEL_DELTA; int const delta = clicks * lines_per_click; int viewnum = 0; POINT point; // figure out which view we are hovering over GetCursorPos(&point); ScreenToClient(m_wnd, &point); HWND const child = ChildWindowFromPoint(m_wnd, point); if (child) { for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++) { if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child)) break; } if (viewnum == MAX_VIEWS) break; } // send the appropriate message to this view's scrollbar if (m_views[viewnum] != NULL) m_views[viewnum]->send_vscroll(delta); break; } // activate: set the focus case WM_INITMENU: update_menu(); break; // command: handle a comment case WM_COMMAND: if (!handle_command(wparam, lparam)) return DefWindowProc(m_wnd, message, wparam, lparam); break; // close: close the window if it's not the main console case WM_CLOSE: if (m_is_main_console) { debugger().hide_all(); debug_cpu_get_visible_cpu(machine())->debug()->go(); } else { destroy(); } break; // destroy: close down the window case WM_NCDESTROY: m_wnd = NULL; debugger().remove_window(*this); break; // everything else: defaults default: return DefWindowProc(m_wnd, message, wparam, lparam); } return 0; }
bool debugwin_info::handle_command(WPARAM wparam, LPARAM lparam) { if (HIWORD(wparam) == 0) { switch (LOWORD(wparam)) { case ID_NEW_MEMORY_WND: debugger().create_memory_window(); return true; case ID_NEW_DISASM_WND: debugger().create_disasm_window(); return true; case ID_NEW_LOG_WND: debugger().create_log_window(); return true; case ID_NEW_POINTS_WND: debugger().create_points_window(); return true; case ID_RUN_AND_HIDE: debugger().hide_all(); case ID_RUN: debug_cpu_get_visible_cpu(machine())->debug()->go(); return true; case ID_NEXT_CPU: debug_cpu_get_visible_cpu(machine())->debug()->go_next_device(); return true; case ID_RUN_VBLANK: debug_cpu_get_visible_cpu(machine())->debug()->go_vblank(); return true; case ID_RUN_IRQ: debug_cpu_get_visible_cpu(machine())->debug()->go_interrupt(); return true; case ID_STEP: debug_cpu_get_visible_cpu(machine())->debug()->single_step(); return true; case ID_STEP_OVER: debug_cpu_get_visible_cpu(machine())->debug()->single_step_over(); return true; case ID_STEP_OUT: debug_cpu_get_visible_cpu(machine())->debug()->single_step_out(); return true; case ID_HARD_RESET: machine().schedule_hard_reset(); return true; case ID_SOFT_RESET: machine().schedule_soft_reset(); debug_cpu_get_visible_cpu(machine())->debug()->go(); return true; case ID_EXIT: set_default_focus(); machine().schedule_exit(); return true; } } return false; }
void on_run_irq_activate(GtkWidget *win) { debug_cpu_get_visible_cpu(*get_running_machine(win))->debug()->go_interrupt(); }