Previous 199869 Revisions Next

r23646 Wednesday 12th June, 2013 at 06:22:35 UTC by Andrew Gardner
QT Debugger: Finished up the breakpoints window. [Andrew Gardner]


It now shows breakpoints for all CPUs and lets you sort by
each field.
[src/emu/debug]debugcpu.c debugcpu.h dvbpoints.c dvbpoints.h
[src/osd/sdl]debugqtbreakpointswindow.c

trunk/src/osd/sdl/debugqtbreakpointswindow.c
r23645r23646
1010BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) :
1111   WindowQt(machine, NULL)
1212{
13   setWindowTitle("Debug: Machine Breakpoints");
13   setWindowTitle("Debug: All Breakpoints");
1414
1515   if (parent != NULL)
1616   {
trunk/src/emu/debug/dvbpoints.c
r23645r23646
22
33    dvpoints.c
44
5    Breakpoint debugger view.
5   Breakpoint debugger view.
66
77****************************************************************************
88
r23645r23646
3838***************************************************************************/
3939
4040#include "emu.h"
41#include "debugvw.h"
4241#include "dvbpoints.h"
43#include "debugcpu.h"
4442
4543
4644
r23645r23646
5351//-------------------------------------------------
5452
5553debug_view_breakpoints::debug_view_breakpoints(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate)
56   : debug_view(machine, DVT_BREAK_POINTS, osdupdate, osdprivate)
54   : debug_view(machine, DVT_BREAK_POINTS, osdupdate, osdprivate),
55     m_sortType(SORT_INDEX_ASCENDING)
5756{
5857   // fail if no available sources
5958   enumerate_sources();
r23645r23646
6160      throw std::bad_alloc();
6261
6362   // configure the view
64   m_total.y = 50;             // TODO
65   m_supports_cursor = true;
63   m_total.y = 10;
64   m_supports_cursor = false;
6665}
6766
6867
r23645r23646
126125
127126void debug_view_breakpoints::view_click(const int button, const debug_view_xy& pos)
128127{
128   bool clickedTopRow = (m_topleft.y == pos.y);
129   
130   if (clickedTopRow)
131   {
132      if (pos.x < 5 && m_sortType == SORT_INDEX_ASCENDING)
133         m_sortType = SORT_INDEX_DESCENDING;
134      else if (pos.x < 5)
135         m_sortType = SORT_INDEX_ASCENDING;
136      else if (pos.x < 9 && m_sortType == SORT_ENABLED_ASCENDING)
137         m_sortType = SORT_ENABLED_DESCENDING;
138      else if (pos.x < 9)
139         m_sortType = SORT_ENABLED_ASCENDING;
140      else if (pos.x < 31 && m_sortType == SORT_CPU_ASCENDING)
141         m_sortType = SORT_CPU_DESCENDING;
142      else if (pos.x < 31)
143         m_sortType = SORT_CPU_ASCENDING;
144      else if (pos.x < 45 && m_sortType == SORT_ADDRESS_ASCENDING)
145         m_sortType = SORT_ADDRESS_DESCENDING;
146      else if (pos.x < 45)
147         m_sortType = SORT_ADDRESS_ASCENDING;
148      else if (pos.x < 63 && m_sortType == SORT_CONDITION_ASCENDING)
149         m_sortType = SORT_CONDITION_DESCENDING;
150      else if (pos.x < 63)
151         m_sortType = SORT_CONDITION_ASCENDING;
152      else if (pos.x < 80 && m_sortType == SORT_ACTION_ASCENDING)
153         m_sortType = SORT_ACTION_DESCENDING;
154      else if (pos.x < 80)
155         m_sortType = SORT_ACTION_ASCENDING;
156   }
157   else
158   {
159      // Gather a sorted list of all the breakpoints for all the CPUs
160      device_debug::breakpoint** bpList = NULL;
161      const int numBPs = breakpoints(SORT_NONE, bpList);
162
163      const int bpIndex = pos.y-1;
164      if (bpIndex > numBPs || bpIndex < 0)
165         return;
166     
167      // Enable / disable
168      if (bpList[bpIndex]->enabled())
169         bpList[bpIndex]->setEnabled(false);
170      else
171         bpList[bpIndex]->setEnabled(true);
172     
173      delete[] bpList;
174   }
175
176   view_update();
129177}
130178
131179
r23645r23646
142190   }
143191}
144192
145//-------------------------------------------------
146//  view_update - update the contents of the
147//  disassembly view
148//-------------------------------------------------
149193
150void debug_view_breakpoints::view_update()
194// Sorting functors for the qsort function
195int cIndexAscending(const void* a, const void* b)
151196{
152   const debug_view_source& source = *m_source;
153   const device_debug& debugInterface = *source.device()->debug();
154   debug_view_char *dest = m_viewdata;
197   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
198   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
199   return left->index() > right->index();
200}
155201
156   // Gather a list of all the breakpoints in reverse order
202int cIndexDescending(const void* a, const void* b)
203{
204   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
205   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
206   return left->index() < right->index();
207}
208
209int cEnabledAscending(const void* a, const void* b)
210{
211   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
212   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
213   return left->enabled() < right->enabled();
214}
215
216int cEnabledDescending(const void* a, const void* b)
217{
218   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
219   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
220   return left->enabled() > right->enabled();
221}
222
223int cCpuAscending(const void* a, const void* b)
224{
225   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
226   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
227   const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag());
228   return result >= 0;
229}
230
231int cCpuDescending(const void* a, const void* b)
232{
233   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
234   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
235   const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag());
236   return result < 0;
237}
238
239int cAddressAscending(const void* a, const void* b)
240{
241   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
242   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
243   return left->address() > right->address();
244}
245
246int cAddressDescending(const void* a, const void* b)
247{
248   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
249   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
250   return left->address() < right->address();
251}
252
253int cConditionAscending(const void* a, const void* b)
254{
255   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
256   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
257   const int result = strcmp(left->condition(), right->condition());
258   return result >= 0;
259}
260
261int cConditionDescending(const void* a, const void* b)
262{
263   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
264   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
265   const int result = strcmp(left->condition(), right->condition());
266   return result < 0;
267}
268
269int cActionAscending(const void* a, const void* b)
270{
271   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
272   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
273   const int result = strcmp(left->action(), right->action());
274   return result >= 0;
275}
276
277int cActionDescending(const void* a, const void* b)
278{
279   const device_debug::breakpoint* left = *(device_debug::breakpoint**)a;
280   const device_debug::breakpoint* right = *(device_debug::breakpoint**)b;
281   const int result = strcmp(left->action(), right->action());
282   return result < 0;
283}
284
285
286int debug_view_breakpoints::breakpoints(SortMode sort, device_debug::breakpoint**& bpList)
287{
157288   int numBPs = 0;
158   device_debug::breakpoint** bpList = NULL;
159   if (debugInterface.breakpoint_first() != NULL)
289   bpList = NULL;
290   for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
160291   {
161292      // Alloc
293      const device_debug& debugInterface = *source->device()->debug();
162294      for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next())
163295         numBPs++;
164296      bpList = new device_debug::breakpoint*[numBPs];
165
166      // Collect
167      int i = 1;
168      for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next())
297   }
298   
299   int bpAddIndex = 1;
300   for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
301   {
302      device_debug& debugInterface = *source->device()->debug();
303      if (debugInterface.breakpoint_first() != NULL)
169304      {
170         bpList[numBPs-i] = bp;
171         i++;
305         // Collect
306         for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next())
307         {
308            bpList[numBPs-bpAddIndex] = bp;
309            bpAddIndex++;
310         }
172311      }
173312   }
313   
314   // And now for the sort
315   switch (m_sortType)
316   {
317      case SORT_NONE:
318         break;
319      case SORT_INDEX_ASCENDING:
320         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cIndexAscending);
321         break;
322      case SORT_INDEX_DESCENDING:
323         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cIndexDescending);
324         break;
325      case SORT_ENABLED_ASCENDING:
326         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cEnabledAscending);
327         break;
328      case SORT_ENABLED_DESCENDING:
329         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cEnabledDescending);
330         break;
331      case SORT_CPU_ASCENDING:
332         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cCpuAscending);
333         break;
334      case SORT_CPU_DESCENDING:
335         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cCpuDescending);
336         break;
337      case SORT_ADDRESS_ASCENDING:
338         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cAddressAscending);
339         break;
340      case SORT_ADDRESS_DESCENDING:
341         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cAddressDescending);
342         break;
343      case SORT_CONDITION_ASCENDING:
344         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cConditionAscending);
345         break;
346      case SORT_CONDITION_DESCENDING:
347         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cConditionDescending);
348         break;
349      case SORT_ACTION_ASCENDING:
350         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cActionAscending);
351         break;
352      case SORT_ACTION_DESCENDING:
353         qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cActionDescending);
354         break;
355   }
356   
357   return numBPs;
358}
174359
360
361//-------------------------------------------------
362//  view_update - update the contents of the
363//  disassembly view
364//-------------------------------------------------
365
366void debug_view_breakpoints::view_update()
367{
368   // Gather a list of all the breakpoints for all the CPUs
369   device_debug::breakpoint** bpList = NULL;
370   const int numBPs = breakpoints(SORT_NONE, bpList);
371   
372   // Set the view region so the scroll bars update
373   m_total.y = numBPs+1;
374
175375   // Draw
376   debug_view_char *dest = m_viewdata;
176377   for (int row = 0; row < m_visible.y; row++)
177378   {
178379      UINT32 effrow = m_topleft.y + row;
179
380     
180381      // Header
181      if (effrow == 0)
382      if (row == 0)
182383      {
183         astring header = "ID   En  Address          Condition         Action";
384         astring header;
385         header.printf("ID");
386         if (m_sortType == SORT_INDEX_ASCENDING) header.catprintf("\\");
387         else if (m_sortType == SORT_INDEX_DESCENDING) header.catprintf("/");
388         pad_astring_to_length(header, 5);
389         header.catprintf("En");
390         if (m_sortType == SORT_ENABLED_ASCENDING) header.catprintf("\\");
391         else if (m_sortType == SORT_ENABLED_DESCENDING) header.catprintf("/");
392         pad_astring_to_length(header, 9);
393         header.catprintf("CPU");
394         if (m_sortType == SORT_CPU_ASCENDING) header.catprintf("\\");
395         else if (m_sortType == SORT_CPU_DESCENDING) header.catprintf("/");
396         pad_astring_to_length(header, 31);
397         header.catprintf("Address");
398         if (m_sortType == SORT_ADDRESS_ASCENDING) header.catprintf("\\");
399         else if (m_sortType == SORT_ADDRESS_DESCENDING) header.catprintf("/");
400         pad_astring_to_length(header, 45);
401         header.catprintf("Condition");
402         if (m_sortType == SORT_CONDITION_ASCENDING) header.catprintf("\\");
403         else if (m_sortType == SORT_CONDITION_DESCENDING) header.catprintf("/");
404         pad_astring_to_length(header, 63);
405         header.catprintf("Action");
406         if (m_sortType == SORT_ACTION_ASCENDING) header.catprintf("\\");
407         else if (m_sortType == SORT_ACTION_DESCENDING) header.catprintf("/");
408         pad_astring_to_length(header, 80);
409         
184410         for (int i = 0; i < m_visible.x; i++)
185411         {
186412            dest->byte = (i < header.len()) ? header[i] : ' ';
r23645r23646
195421      if (bpi < numBPs && bpi >= 0)
196422      {
197423         device_debug::breakpoint* bp = bpList[bpi];
198
199         astring buffer;
424         
425          astring buffer;
200426         buffer.printf("%x", bp->index());
201427         pad_astring_to_length(buffer, 5);
202428         buffer.catprintf("%c", bp->enabled() ? 'X' : 'O');
203429         pad_astring_to_length(buffer, 9);
204         buffer.catprintf("%s", core_i64_hex_format(bp->address(), debugInterface.logaddrchars()));
205         pad_astring_to_length(buffer, 26);
430         buffer.catprintf("%s", bp->debugInterface()->device().tag());
431         pad_astring_to_length(buffer, 31);
432         buffer.catprintf("%s", core_i64_hex_format(bp->address(), bp->debugInterface()->logaddrchars()));
433         pad_astring_to_length(buffer, 45);
206434         if (astring(bp->condition()) != astring("1"))
207435         {
208436            buffer.catprintf("%s", bp->condition());
209            pad_astring_to_length(buffer, 44);
437            pad_astring_to_length(buffer, 63);
210438         }
211439         if (astring(bp->action()) != astring(""))
212440         {
213441            buffer.catprintf("%s", bp->action());
214            pad_astring_to_length(buffer, 60);
442            pad_astring_to_length(buffer, 80);
215443         }
216
444         
217445         for (int i = 0; i < m_visible.x; i++)
218446         {
219447            dest->byte = (i < buffer.len()) ? buffer[i] : ' ';
220448            dest->attrib = DCA_NORMAL;
449           
450            // Color disabled breakpoints red
451            if (i == 5 && dest->byte == 'O')
452               dest->attrib = DCA_CHANGED;
453           
221454            dest++;
222455         }
223456         continue;
224457      }
225
458     
226459      // Fill the remaining vertical space
227460      for (int i = 0; i < m_visible.x; i++)
228461      {
r23645r23646
231464         dest++;
232465      }
233466   }
234
235   delete bpList;
467   
468   delete[] bpList;
236469}
trunk/src/emu/debug/dvbpoints.h
r23645r23646
22
33    dvpoints.h
44
5    Breakpoint debugger view.
5   Breakpoint debugger view.
66
77****************************************************************************
88
r23645r23646
4141#define __DVBPOINTS_H__
4242
4343#include "debugvw.h"
44#include "debugcpu.h"
4445
4546
4647//**************************************************************************
r23645r23646
6364   virtual ~debug_view_breakpoints();
6465
6566public:
67    enum SortMode
68    {
69        SORT_NONE,
70        SORT_INDEX_ASCENDING,
71        SORT_INDEX_DESCENDING,
72        SORT_ENABLED_ASCENDING,
73        SORT_ENABLED_DESCENDING,
74        SORT_CPU_ASCENDING,
75        SORT_CPU_DESCENDING,
76        SORT_ADDRESS_ASCENDING,
77        SORT_ADDRESS_DESCENDING,
78        SORT_CONDITION_ASCENDING,
79        SORT_CONDITION_DESCENDING,
80        SORT_ACTION_ASCENDING,
81        SORT_ACTION_DESCENDING
82    };
83   
6684   // getters
6785   // setters
6886
r23645r23646
7896   void enumerate_sources();
7997   bool recompute(offs_t pc, int startline, int lines);
8098   void pad_astring_to_length(astring& str, int len);
99   int breakpoints(SortMode sort, device_debug::breakpoint**& bpList);
81100
101
82102   // internal state
103    SortMode m_sortType;
83104};
84105
85106
trunk/src/emu/debug/debugcpu.c
r23645r23646
23032303int device_debug::breakpoint_set(offs_t address, const char *condition, const char *action)
23042304{
23052305   // allocate a new one
2306   breakpoint *bp = auto_alloc(m_device.machine(), breakpoint(m_symtable, m_device.machine().debugcpu_data->bpindex++, address, condition, action));
2306   breakpoint *bp = auto_alloc(m_device.machine(), breakpoint(this, m_symtable, m_device.machine().debugcpu_data->bpindex++, address, condition, action));
23072307
23082308   // hook it into our list
23092309   bp->m_next = m_bplist;
r23645r23646
32783278//  breakpoint - constructor
32793279//-------------------------------------------------
32803280
3281device_debug::breakpoint::breakpoint(symbol_table &symbols, int index, offs_t address, const char *condition, const char *action)
3282   : m_next(NULL),
3283      m_index(index),
3284      m_enabled(true),
3285      m_address(address),
3286      m_condition(&symbols, (condition != NULL) ? condition : "1"),
3287      m_action((action != NULL) ? action : "")
3281device_debug::breakpoint::breakpoint(device_debug* debugInterface,
3282                                     symbol_table &symbols,
3283                                     int index,
3284                                     offs_t address,
3285                                     const char *condition,
3286                                     const char *action)
3287   : m_debugInterface(debugInterface),
3288     m_next(NULL),
3289     m_index(index),
3290     m_enabled(true),
3291     m_address(address),
3292     m_condition(&symbols, (condition != NULL) ? condition : "1"),
3293     m_action((action != NULL) ? action : "")
32883294{
32893295}
32903296
trunk/src/emu/debug/debugcpu.h
r23645r23646
7979
8080   public:
8181      // construction/destruction
82      breakpoint(symbol_table &symbols, int index, offs_t address, const char *condition = NULL, const char *action = NULL);
82      breakpoint(device_debug* debugInterface,
83               symbol_table &symbols,
84               int index,
85               offs_t address,
86               const char *condition = NULL,
87               const char *action = NULL);
8388
8489      // getters
90      const device_debug *debugInterface() const { return m_debugInterface; }
8591      breakpoint *next() const { return m_next; }
8692      int index() const { return m_index; }
8793      bool enabled() const { return m_enabled; }
r23645r23646
8995      const char *condition() const { return m_condition.original_string(); }
9096      const char *action() const { return m_action; }
9197
98      // setters
99      void setEnabled(bool value) { m_enabled = value; }
100
92101   private:
93102      // internals
94103      bool hit(offs_t pc);
95104
96      breakpoint *        m_next;                     // next in the list
97      int                 m_index;                    // user reported index
98      UINT8               m_enabled;                  // enabled?
99      offs_t              m_address;                  // execution address
100      parsed_expression   m_condition;                // condition
101      astring             m_action;                   // action
105      const device_debug * m_debugInterface;           // the interface we were created from
106      breakpoint *         m_next;                     // next in the list
107      int                  m_index;                    // user reported index
108      UINT8                m_enabled;                  // enabled?
109      offs_t               m_address;                  // execution address
110      parsed_expression    m_condition;                // condition
111      astring              m_action;                   // action
102112   };
103113
104114   // watchpoint class
r23645r23646
108118
109119   public:
110120      // construction/destruction
111      watchpoint(symbol_table &symbols, int index, address_space &space, int type, offs_t address, offs_t length, const char *condition = NULL, const char *action = NULL);
121      watchpoint(symbol_table &symbols,
122               int index,
123               address_space &space,
124               int type,
125               offs_t address,
126               offs_t length,
127               const char *condition = NULL,
128               const char *action = NULL);
112129
113130      // getters
114131      watchpoint *next() const { return m_next; }
r23645r23646
176193   int logaddrchars(address_spacenum spacenum = AS_0) const { return (m_memory != NULL && m_memory->has_space(spacenum)) ? m_memory->space(spacenum).logaddrchars() : 8; }
177194   int min_opcode_bytes() const { return (m_disasm != NULL) ? m_disasm->max_opcode_bytes() : 1; }
178195   int max_opcode_bytes() const { return (m_disasm != NULL) ? m_disasm->max_opcode_bytes() : 1; }
196   device_t& device() const { return m_device; }
179197
198
180199   // hooks used by the rest of the system
181200   void start_hook(attotime endtime);
182201   void stop_hook();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team