Previous 199869 Revisions Next

r35161 Friday 20th February, 2015 at 19:46:01 UTC by Vasantha Crabb
(Break|Watch)points window for Windows debugger
[src/osd/modules/debugger]debugwin.c
[src/osd/modules/debugger/win]debugviewinfo.h debugwin.h debugwininfo.c debugwininfo.h disasmbasewininfo.c logwininfo.c logwininfo.h pointswininfo.c* pointswininfo.h*
[src/osd/windows]windows.mak

trunk/src/osd/modules/debugger/debugwin.c
r243672r243673
1818#include "win/disasmwininfo.h"
1919#include "win/logwininfo.h"
2020#include "win/memorywininfo.h"
21#include "win/pointswininfo.h"
2122#include "win/uimetrics.h"
2223
2324#include "emu.h"
r243672r243673
6364   virtual void create_memory_window() { create_window<memorywin_info>(); }
6465   virtual void create_disasm_window() { create_window<disasmwin_info>(); }
6566   virtual void create_log_window() { create_window<logwin_info>(); }
67   virtual void create_points_window() { create_window<pointswin_info>(); }
6668   virtual void remove_window(debugwin_info &info);
6769
6870   virtual void show_all();
trunk/src/osd/modules/debugger/win/debugviewinfo.h
r243672r243673
3737   void send_pagedown();
3838   void set_focus() { SetFocus(m_wnd); }
3939
40   debug_view_type type() const { return m_view->type(); }
4041   debug_view_xy total_size() const { return m_view->total_size(); }
4142   bool cursor_supported() const { return m_view->cursor_supported(); }
4243   bool cursor_visible() const { return m_view->cursor_visible(); }
trunk/src/osd/modules/debugger/win/debugwin.h
r243672r243673
4242   virtual void create_memory_window() = 0;
4343   virtual void create_disasm_window() = 0;
4444   virtual void create_log_window() = 0;
45   virtual void create_points_window() = 0;
4546   virtual void remove_window(debugwin_info &info) = 0;
4647
4748   virtual void show_all() = 0;
trunk/src/osd/modules/debugger/win/debugwininfo.c
r243672r243673
233233         return true;
234234      }
235235      break;
236
237   case 'B':
238      if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
239      {
240         SendMessage(m_wnd, WM_COMMAND, ID_NEW_POINTS_WND, 0);
241         return true;
242      }
243      break;
236244   }
237245
238246   return false;
239247}
240248
241249
250void debugwin_info::recompute_children()
251{
252   if (m_views[0] != NULL)
253   {
254      // compute a client rect
255      RECT bounds;
256      bounds.top = bounds.left = 0;
257      bounds.right = m_views[0]->prefwidth() + (2 * EDGE_WIDTH);
258      bounds.bottom = 200;
259      AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);
260
261      // clamp the min/max size
262      set_maxwidth(bounds.right - bounds.left);
263
264      // get the parent's dimensions
265      RECT parent;
266      GetClientRect(window(), &parent);
267
268      // view gets the remaining space
269      InflateRect(&parent, -EDGE_WIDTH, -EDGE_WIDTH);
270      m_views[0]->set_bounds(parent);
271   }
272}
273
274
242275bool debugwin_info::handle_command(WPARAM wparam, LPARAM lparam)
243276{
244277   if (HIWORD(wparam) == 0)
r243672r243673
257290         debugger().create_log_window();
258291         return true;
259292
293      case ID_NEW_POINTS_WND:
294         debugger().create_points_window();
295         return true;
296
260297      case ID_RUN_AND_HIDE:
261298         debugger().hide_all();
262299      case ID_RUN:
r243672r243673
484521   AppendMenu(debugmenu, MF_ENABLED, ID_NEW_MEMORY_WND, TEXT("New Memory Window\tCtrl+M"));
485522   AppendMenu(debugmenu, MF_ENABLED, ID_NEW_DISASM_WND, TEXT("New Disassembly Window\tCtrl+D"));
486523   AppendMenu(debugmenu, MF_ENABLED, ID_NEW_LOG_WND, TEXT("New Error Log Window\tCtrl+L"));
524   AppendMenu(debugmenu, MF_ENABLED, ID_NEW_POINTS_WND, TEXT("New (Break|Watch)points Window\tCtrl+B"));
487525   AppendMenu(debugmenu, MF_DISABLED | MF_SEPARATOR, 0, TEXT(""));
488526   AppendMenu(debugmenu, MF_ENABLED, ID_RUN, TEXT("Run\tF5"));
489527   AppendMenu(debugmenu, MF_ENABLED, ID_RUN_AND_HIDE, TEXT("Run and Hide Debugger\tF12"));
trunk/src/osd/modules/debugger/win/debugwininfo.h
r243672r243673
6565      ID_NEW_MEMORY_WND = 1,
6666      ID_NEW_DISASM_WND,
6767      ID_NEW_LOG_WND,
68      ID_NEW_POINTS_WND,
6869      ID_RUN,
6970      ID_RUN_AND_HIDE,
7071      ID_RUN_VBLANK,
r243672r243673
8788      ID_INCREASE_MEM_WIDTH,
8889      ID_DECREASE_MEM_WIDTH,
8990
91      ID_TOGGLE_BREAKPOINT,
92      ID_RUN_TO_CURSOR,
9093      ID_SHOW_RAW,
9194      ID_SHOW_ENCRYPTED,
9295      ID_SHOW_COMMENTS,
93      ID_RUN_TO_CURSOR,
94      ID_TOGGLE_BREAKPOINT,
9596
96      ID_DEVICE_OPTIONS   // keep this always at the end
97      ID_SHOW_BREAKPOINTS,
98      ID_SHOW_WATCHPOINTS,
99
100      ID_DEVICE_OPTIONS   // always keep this at the end
97101   };
98102
99103   HWND window() const { return m_wnd; }
r243672r243673
102106   void set_minwidth(UINT32 value) { m_minwidth = value; }
103107   void set_maxwidth(UINT32 value) { m_maxwidth = value; }
104108
105   virtual void recompute_children() = 0;
109   virtual void recompute_children();
106110   virtual void update_menu() { }
107111   virtual bool handle_command(WPARAM wparam, LPARAM lparam);
108112   virtual void draw_contents(HDC dc);
trunk/src/osd/modules/debugger/win/disasmbasewininfo.c
r243672r243673
6060      {
6161      case 'R':
6262         SendMessage(window(), WM_COMMAND, ID_SHOW_RAW, 0);
63         return 1;
63         return true;
6464
6565      case 'E':
6666         SendMessage(window(), WM_COMMAND, ID_SHOW_ENCRYPTED, 0);
67         return 1;
67         return true;
6868
6969      case 'N':
7070         SendMessage(window(), WM_COMMAND, ID_SHOW_COMMENTS, 0);
71         return 1;
71         return true;
7272      }
7373   }
7474
r243672r243673
7777   /* ajg - steals the F4 from the global key handler - but ALT+F4 didn't work anyways ;) */
7878   case VK_F4:
7979      SendMessage(window(), WM_COMMAND, ID_RUN_TO_CURSOR, 0);
80      return 1;
80      return true;
8181
8282   case VK_F9:
8383      SendMessage(window(), WM_COMMAND, ID_TOGGLE_BREAKPOINT, 0);
84      return 1;
84      return true;
8585
8686   case VK_RETURN:
8787      if (m_views[0]->cursor_visible())
8888      {
8989         SendMessage(window(), WM_COMMAND, ID_STEP, 0);
90         return 1;
90         return true;
9191      }
9292      break;
9393   }
r243672r243673
100100{
101101   editwin_info::update_menu();
102102
103   disasmview_info *const dasmview = downcast<disasmview_info *>(m_views[0].get());
103104   HMENU const menu = GetMenu(window());
104105
105   bool const disasm_cursor_visible = m_views[0]->cursor_visible();
106   bool const disasm_cursor_visible = dasmview->cursor_visible();
107   if (disasm_cursor_visible)
108   {
109      offs_t const address = dasmview->selected_address();
110      device_debug *const debug = dasmview->source_device()->debug();
111      INT32 bpindex = -1;
112
113      // first find an existing breakpoint at this address
114      for (device_debug::breakpoint *bp = debug->breakpoint_first(); bp != NULL; bp = bp->next())
115      {
116         if (address == bp->address())
117         {
118            bpindex = bp->index();
119            break;
120         }
121      }
122
123      if (bpindex == -1)
124         ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Set breakpoint at cursor\tF9"));
125      else
126         ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Clear breakpoint at cursor\tF9"));
127   }
128   else
129   {
130      ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Toggle breakpoint at cursor\tF9"));
131   }
106132   EnableMenuItem(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND | (disasm_cursor_visible ? MF_ENABLED : MF_GRAYED));
107133   EnableMenuItem(menu, ID_RUN_TO_CURSOR, MF_BYCOMMAND | (disasm_cursor_visible ? MF_ENABLED : MF_GRAYED));
108134
109   disasm_right_column const rightcol = downcast<disasmview_info *>(m_views[0].get())->right_column();
135   disasm_right_column const rightcol = dasmview->right_column();
110136   CheckMenuItem(menu, ID_SHOW_RAW, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_RAW ? MF_CHECKED : MF_UNCHECKED));
111137   CheckMenuItem(menu, ID_SHOW_ENCRYPTED, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_ENCRYPTED ? MF_CHECKED : MF_UNCHECKED));
112138   CheckMenuItem(menu, ID_SHOW_COMMENTS, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_COMMENTS ? MF_CHECKED : MF_UNCHECKED));
r243672r243673
123149   case 0:
124150      switch (LOWORD(wparam))
125151      {
126      case ID_SHOW_RAW:
127         dasmview->set_right_column(DASM_RIGHTCOL_RAW);
128         recompute_children();
129         return true;
130
131      case ID_SHOW_ENCRYPTED:
132         dasmview->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
133         recompute_children();
134         return true;
135
136      case ID_SHOW_COMMENTS:
137         dasmview->set_right_column(DASM_RIGHTCOL_COMMENTS);
138         recompute_children();
139         return true;
140
141      case ID_RUN_TO_CURSOR:
142         if (dasmview->cursor_visible())
143         {
144            offs_t const address = dasmview->selected_address();
145            if (dasmview->source_is_visible_cpu())
146            {
147               astring command;
148               command.printf("go 0x%X", address);
149               debug_console_execute_command(machine(), command, 1);
150            }
151            else
152            {
153               dasmview->source_device()->debug()->go(address);
154            }
155         }
156         return true;
157
158152      case ID_TOGGLE_BREAKPOINT:
159153         if (dasmview->cursor_visible())
160154         {
r243672r243673
162156            device_debug *const debug = dasmview->source_device()->debug();
163157            INT32 bpindex = -1;
164158
165            /* first find an existing breakpoint at this address */
159            // first find an existing breakpoint at this address
166160            for (device_debug::breakpoint *bp = debug->breakpoint_first(); bp != NULL; bp = bp->next())
167161            {
168162               if (address == bp->address())
r243672r243673
172166               }
173167            }
174168
175            /* if it doesn't exist, add a new one */
169            // if it doesn't exist, add a new one
176170            if (dasmview->source_is_visible_cpu())
177171            {
178172               astring command;
r243672r243673
199193            }
200194         }
201195         return true;
196
197      case ID_RUN_TO_CURSOR:
198         if (dasmview->cursor_visible())
199         {
200            offs_t const address = dasmview->selected_address();
201            if (dasmview->source_is_visible_cpu())
202            {
203               astring command;
204               command.printf("go 0x%X", address);
205               debug_console_execute_command(machine(), command, 1);
206            }
207            else
208            {
209               dasmview->source_device()->debug()->go(address);
210            }
211         }
212         return true;
213
214      case ID_SHOW_RAW:
215         dasmview->set_right_column(DASM_RIGHTCOL_RAW);
216         recompute_children();
217         return true;
218
219      case ID_SHOW_ENCRYPTED:
220         dasmview->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
221         recompute_children();
222         return true;
223
224      case ID_SHOW_COMMENTS:
225         dasmview->set_right_column(DASM_RIGHTCOL_COMMENTS);
226         recompute_children();
227         return true;
202228      }
203229      break;
204230   }
trunk/src/osd/modules/debugger/win/logwininfo.c
r243672r243673
2727   // compute a client rect
2828   RECT bounds;
2929   bounds.top = bounds.left = 0;
30   bounds.right = m_views[0]->prefwidth() + (2 * EDGE_WIDTH);
30   bounds.right = m_views[0]->maxwidth() + (2 * EDGE_WIDTH);
3131   bounds.bottom = 200;
3232   AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);
3333
r243672r243673
4545logwin_info::~logwin_info()
4646{
4747}
48
49
50void logwin_info::recompute_children()
51{
52   // compute a client rect
53   RECT bounds;
54   bounds.top = bounds.left = 0;
55   bounds.right = m_views[0]->maxwidth() + (2 * EDGE_WIDTH);
56   bounds.bottom = 200;
57   AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);
58
59   // clamp the min/max size
60   set_maxwidth(bounds.right - bounds.left);
61
62   // get the parent's dimensions
63   RECT parent;
64   GetClientRect(window(), &parent);
65
66   // view gets the remaining space
67   InflateRect(&parent, -EDGE_WIDTH, -EDGE_WIDTH);
68   m_views[0]->set_bounds(parent);
69}
trunk/src/osd/modules/debugger/win/logwininfo.h
r243672r243673
1919public:
2020   logwin_info(debugger_windows_interface &debugger);
2121   virtual ~logwin_info();
22
23private:
24   virtual void recompute_children();
2522};
2623
2724#endif
trunk/src/osd/modules/debugger/win/pointswininfo.c
r0r243673
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles, Vas Crabb
3//============================================================
4//
5//   pointswininfo.c - Win32 debug window handling
6//
7//============================================================
8
9#include "pointswininfo.h"
10
11#include "debugviewinfo.h"
12
13#include "winutf8.h"
14
15
16pointswin_info::pointswin_info(debugger_windows_interface &debugger) :
17   debugwin_info(debugger, false, astring("All Breakpoints"), NULL)
18{
19   if (!window())
20      return;
21
22   m_views[0].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_BREAK_POINTS)));
23   if ((m_views[0] == NULL) || !m_views[0]->is_valid())
24   {
25      m_views[0].reset();
26      return;
27   }
28
29   // create the options menu
30   HMENU const optionsmenu = CreatePopupMenu();
31   AppendMenu(optionsmenu, MF_ENABLED, ID_SHOW_BREAKPOINTS, TEXT("Breakpoints\tCtrl+1"));
32   AppendMenu(optionsmenu, MF_ENABLED, ID_SHOW_WATCHPOINTS, TEXT("Watchpoints\tCtrl+2"));
33   AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)optionsmenu, TEXT("Options"));
34
35   // compute a client rect
36   RECT bounds;
37   bounds.top = bounds.left = 0;
38   bounds.right = m_views[0]->maxwidth() + (2 * EDGE_WIDTH);
39   bounds.bottom = 200;
40   AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);
41
42   // clamp the min/max size
43   set_maxwidth(bounds.right - bounds.left);
44
45   // position the window at the bottom-right
46   SetWindowPos(window(), HWND_TOP, 100, 100, bounds.right - bounds.left, bounds.bottom - bounds.top, SWP_SHOWWINDOW);
47
48   // recompute the children
49   recompute_children();
50}
51
52
53pointswin_info::~pointswin_info()
54{
55}
56
57
58bool pointswin_info::handle_key(WPARAM wparam, LPARAM lparam)
59{
60   if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
61   {
62      switch (wparam)
63      {
64      case '1':
65         SendMessage(window(), WM_COMMAND, ID_SHOW_BREAKPOINTS, 0);
66         return true;
67
68      case '2':
69         SendMessage(window(), WM_COMMAND, ID_SHOW_WATCHPOINTS, 0);
70         return true;
71      }
72   }
73
74   return debugwin_info::handle_key(wparam, lparam);
75}
76
77
78void pointswin_info::update_menu()
79{
80   debugwin_info::update_menu();
81
82   HMENU const menu = GetMenu(window());
83   CheckMenuItem(menu, ID_SHOW_BREAKPOINTS, MF_BYCOMMAND | (m_views[0]->type() == DVT_BREAK_POINTS ? MF_CHECKED : MF_UNCHECKED));
84   CheckMenuItem(menu, ID_SHOW_WATCHPOINTS, MF_BYCOMMAND | (m_views[0]->type() == DVT_WATCH_POINTS ? MF_CHECKED : MF_UNCHECKED));
85}
86
87
88bool pointswin_info::handle_command(WPARAM wparam, LPARAM lparam)
89{
90   switch (HIWORD(wparam))
91   {
92   // menu selections
93   case 0:
94      switch (LOWORD(wparam))
95      {
96      case ID_SHOW_BREAKPOINTS:
97         m_views[0].reset();
98         m_views[0].reset(global_alloc(debugview_info(debugger(), *this, window(), DVT_BREAK_POINTS)));
99         if (!m_views[0]->is_valid())
100            m_views[0].reset();
101         win_set_window_text_utf8(window(), "All Breakpoints");
102         recompute_children();
103         return true;
104
105      case ID_SHOW_WATCHPOINTS:
106         m_views[0].reset();
107         m_views[0].reset(global_alloc(debugview_info(debugger(), *this, window(), DVT_WATCH_POINTS)));
108         if (!m_views[0]->is_valid())
109            m_views[0].reset();
110         win_set_window_text_utf8(window(), "All Watchpoints");
111         recompute_children();
112         return true;
113      }
114      break;
115   }
116   return debugwin_info::handle_command(wparam, lparam);
117}
trunk/src/osd/modules/debugger/win/pointswininfo.h
r0r243673
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles, Vas Crabb
3//============================================================
4//
5//   pointswininfo.h - Win32 debug window handling
6//
7//============================================================
8
9#ifndef __DEBUG_WIN_POINTS_WIN_INFO_H__
10#define __DEBUG_WIN_POINTS_WIN_INFO_H__
11
12#include "debugwin.h"
13
14#include "debugwininfo.h"
15
16
17class pointswin_info : public debugwin_info
18{
19public:
20   pointswin_info(debugger_windows_interface &debugger);
21   virtual ~pointswin_info();
22
23   virtual bool handle_key(WPARAM wparam, LPARAM lparam);
24
25protected:
26   virtual void update_menu();
27   virtual bool handle_command(WPARAM wparam, LPARAM lparam);
28};
29
30#endif
trunk/src/osd/windows/windows.mak
r243672r243673
423423   $(OSDOBJ)/modules/debugger/win/logwininfo.o \
424424   $(OSDOBJ)/modules/debugger/win/memoryviewinfo.o \
425425   $(OSDOBJ)/modules/debugger/win/memorywininfo.o \
426   $(OSDOBJ)/modules/debugger/win/pointswininfo.o \
426427   $(OSDOBJ)/modules/debugger/win/uimetrics.o \
427428   $(OSDOBJ)/modules/debugger/debugint.o \
428429   $(OSDOBJ)/modules/debugger/debugqt.o \


Previous 199869 Revisions Next


© 1997-2024 The MAME Team