Previous 199869 Revisions Next

r22725 Thursday 9th May, 2013 at 19:20:05 UTC by Andrew Gardner
Adds memory tracking to debugger.  This includes two new commands:  trackmem and
pcatmem(p|d|i).  [Andrew Gardner]

Fixes left-click selection bug in the memory window. [Andrew Gardner]


Explanation:
------------
Call trackmem to start tracking which PC writes to which address in memory and
pcatmem(p|d|i) to query a memory region for which PC wrote to it.  Users of
the QT debugger can also right click on a memory address in the memory window
to make a popup message appear with the results - right-clicking also
automatically copies the resultant PC onto the clipboard.  (I'll attach an
image of this behavior in a follow-up mail).
[src/emu/debug]debugcmd.c debugcpu.c debugcpu.h debughlp.c dvmemory.c dvmemory.h
[src/osd/sdl]debugqtdasmwindow.h debugqtlogwindow.h debugqtmainwindow.c debugqtmainwindow.h debugqtmemorywindow.c debugqtmemorywindow.h debugqtview.h debugqtwindow.h

trunk/src/osd/sdl/debugqtmemorywindow.c
r22724r22725
3535   connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int)));
3636
3737   // The main memory window
38   m_memTable = new DebuggerView(DVT_MEMORY,
39                           m_machine,
40                           this);
38   m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this);
4139
4240   // Layout
4341   QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
r22724r22725
265263
266264
267265//=========================================================================
266//  DebuggerMemView
267//=========================================================================
268void DebuggerMemView::mousePressEvent(QMouseEvent* event)
269{
270   const bool leftClick = event->button() == Qt::LeftButton;
271   const bool rightClick = event->button() == Qt::RightButton;
272
273   if (leftClick || rightClick)
274   {
275      QFontMetrics actualFont = fontMetrics();
276      const int fontWidth = MAX(1, actualFont.width('_'));
277      const int fontHeight = MAX(1, actualFont.height());
278
279      debug_view_xy topLeft = view()->visible_position();
280      debug_view_xy clickViewPosition;
281      clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
282      clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
283      if (leftClick)
284      {
285         view()->process_click(DCK_LEFT_CLICK, clickViewPosition);
286      }
287      else if (rightClick)
288      {
289         // Display the last known PC to write to this memory location & copy it onto the clipboard
290         debug_view_memory* memView = downcast<debug_view_memory*>(view());
291         const offs_t address = memView->addressAtCursorPosition(clickViewPosition);
292         const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source());
293         address_space* addressSpace = source->space();
294         const int nativeDataWidth = addressSpace->data_width() / 8;
295         const UINT64 memValue = debug_read_memory(*addressSpace,
296                                         addressSpace->address_to_byte(address),
297                                         nativeDataWidth,
298                                         true);
299         const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(),
300                                                                       address,
301                                                                       memValue);
302         if (pc != (offs_t)(-1))
303         {
304            // TODO: You can specify a box that the tooltip stays alive within - might be good?
305            const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16);
306            QToolTip::showText(QCursor::pos(), addressAndPc, NULL);
307           
308            // Copy the PC into the clipboard as well
309            QClipboard *clipboard = QApplication::clipboard();
310            clipboard->setText(QString("%1").arg(pc, 2, 16));
311         }
312         else
313         {
314            QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL);
315         }
316      }
317
318      viewport()->update();
319      update();
320   }
321}
322
323
324//=========================================================================
268325//  MemoryWindowQtConfig
269326//=========================================================================
270327void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget)
trunk/src/osd/sdl/debugqtmemorywindow.h
r22724r22725
66#include "debugqtview.h"
77#include "debugqtwindow.h"
88
9class DebuggerMemView;
910
11
1012//============================================================
1113//  The Memory Window.
1214//============================================================
r22724r22725
3941   // Widgets
4042   QLineEdit* m_inputEdit;
4143   QComboBox* m_memoryComboBox;
42   DebuggerView* m_memTable;
44   DebuggerMemView* m_memTable;
4345};
4446
4547
4648//=========================================================================
49//  The mem window gets its own debugger view to handle right click pop-ups
50//=========================================================================
51class DebuggerMemView : public DebuggerView
52{
53public:
54   DebuggerMemView(const debug_view_type& type,
55               running_machine* machine,
56               QWidget* parent=NULL)
57      : DebuggerView(type, machine, parent)
58   {}
59   virtual ~DebuggerMemView() {}
60   
61protected:
62   void mousePressEvent(QMouseEvent* event);
63};
64
65
66//=========================================================================
4767//  A way to store the configuration of a window long enough to read/write.
4868//=========================================================================
4969class MemoryWindowQtConfig : public WindowQtConfig
r22724r22725
5979   }
6080
6181   ~MemoryWindowQtConfig() {}
62
82   
6383   // Settings
6484   int m_reverse;
6585   int m_addressMode;
6686   int m_chunkSize;
6787   int m_memoryRegion;
68
88   
6989   void buildFromQWidget(QWidget* widget);
7090   void applyToQWidget(QWidget* widget);
7191   void addToXmlDataNode(xml_data_node* node) const;
trunk/src/osd/sdl/debugqtmainwindow.c
r22724r22725
125125void MainWindow::closeEvent(QCloseEvent* event)
126126{
127127   debugActQuit();
128
128   
129129   // Insure the window doesn't disappear before we get a chance to save its parameters
130130   event->ignore();
131131}
trunk/src/osd/sdl/debugqtmainwindow.h
r22724r22725
171171      m_rightBar(0),
172172      m_windowState()
173173   {}
174
174   
175175   ~MainWindowQtConfig() {}
176
176   
177177   // Settings
178178   int m_rightBar;
179179   QByteArray m_windowState;
180
180   
181181   void buildFromQWidget(QWidget* widget);
182182   void applyToQWidget(QWidget* widget);
183183   void addToXmlDataNode(xml_data_node* node) const;
trunk/src/osd/sdl/debugqtwindow.h
r22724r22725
7777      m_next(NULL)
7878   {}
7979   virtual ~WindowQtConfig() {}
80
80   
8181   // Settings
8282   WindowType m_type;
8383   QPoint m_size;
8484   QPoint m_position;
85
85   
8686   // Dues for becoming a member of a simple_list
8787   WindowQtConfig* m_next;
8888   WindowQtConfig* next() const { return m_next; }
89
90
89   
90   
9191   virtual void buildFromQWidget(QWidget* widget);
9292   virtual void applyToQWidget(QWidget* widget);
9393   virtual void addToXmlDataNode(xml_data_node* node) const;
trunk/src/osd/sdl/debugqtlogwindow.h
r22724r22725
3535      WindowQtConfig(WIN_TYPE_LOG)
3636   {
3737   }
38
38   
3939   ~LogWindowQtConfig() {}
40
40   
4141   void buildFromQWidget(QWidget* widget);
4242   void applyToQWidget(QWidget* widget);
4343   void addToXmlDataNode(xml_data_node* node) const;
trunk/src/osd/sdl/debugqtview.h
r22724r22725
1212
1313public:
1414   DebuggerView(const debug_view_type& type,
15               running_machine* machine,
16               QWidget* parent=NULL);
15             running_machine* machine,
16             QWidget* parent=NULL);
1717   virtual ~DebuggerView();
1818
1919   void paintEvent(QPaintEvent* event);
trunk/src/osd/sdl/debugqtdasmwindow.h
r22724r22725
5252      m_rightBar(0)
5353   {
5454   }
55
55   
5656   ~DasmWindowQtConfig() {}
57
57   
5858   // Settings
5959   int m_cpu;
6060   int m_rightBar;
61
61   
6262   void buildFromQWidget(QWidget* widget);
6363   void applyToQWidget(QWidget* widget);
6464   void addToXmlDataNode(xml_data_node* node) const;
trunk/src/emu/debug/dvmemory.c
r22724r22725
204204   if (type == VIEW_NOTIFY_CURSOR_CHANGED)
205205   {
206206      // normalize the cursor
207      set_cursor_pos(get_cursor_pos());
207      set_cursor_pos(get_cursor_pos(m_cursor));
208208   }
209209   else if (type == VIEW_NOTIFY_SOURCE_CHANGED)
210210   {
r22724r22725
315315void debug_view_memory::view_char(int chval)
316316{
317317   // get the position
318   cursor_pos pos = get_cursor_pos();
318   cursor_pos pos = get_cursor_pos(m_cursor);
319319
320320   // handle the incoming key
321321   switch (chval)
r22724r22725
437437
438438   /* cursor popup|toggle */
439439   bool cursorVisible = true;
440   if (m_cursor.y == origcursor.y)
440   if (m_cursor.y == origcursor.y && m_cursor.x == origcursor.x)
441441   {
442442      cursorVisible = !m_cursor_visible;
443443   }
r22724r22725
461461   const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
462462
463463   // get the current cursor position
464   cursor_pos pos = get_cursor_pos();
464   cursor_pos pos = get_cursor_pos(m_cursor);
465465
466466   // determine the maximum address and address format string from the raw information
467467   int addrchars;
r22724r22725
565565//  an address and a shift value
566566//-------------------------------------------------
567567
568debug_view_memory::cursor_pos debug_view_memory::get_cursor_pos()
568debug_view_memory::cursor_pos debug_view_memory::get_cursor_pos(const debug_view_xy& cursor)
569569{
570570   // start with the base address for this row
571571   cursor_pos pos;
572   pos.m_address = m_byte_offset + m_cursor.y * m_bytes_per_chunk * m_chunks_per_row;
572   pos.m_address = m_byte_offset + cursor.y * m_bytes_per_chunk * m_chunks_per_row;
573573
574574   // determine the X position within the middle section, clamping as necessary
575575   const memory_view_pos &posdata = s_memory_pos_table[m_bytes_per_chunk];
576   int xposition = m_cursor.x - m_section[1].m_pos - 1;
576   int xposition = cursor.x - m_section[1].m_pos - 1;
577577   if (xposition < 0)
578578      xposition = 0;
579579   else if (xposition >= posdata.m_spacing * m_chunks_per_row)
trunk/src/emu/debug/debugcpu.h
r22724r22725
156156      // internals
157157      bool hit();
158158
159      registerpoint *    m_next;                     // next in the list
159      registerpoint *    m_next;                     // next in the list
160160      int                 m_index;                    // user reported index
161161      UINT8               m_enabled;                  // enabled?
162162      parsed_expression   m_condition;                // condition
r22724r22725
258258   void set_track_pc_visited(const offs_t& pc);
259259   void track_pc_data_clear() { m_track_pc_set.clear(); }
260260
261   // memory tracking
262   void set_track_mem(bool value) { m_track_mem = value; }
263   offs_t track_mem_pc_from_space_address_data(const address_spacenum& space,
264                                    const offs_t& address,
265                                    const UINT64& data) const;
266   void track_mem_data_clear() { m_track_mem_set.clear(); }
267
261268   // tracing
262269   void trace(FILE *file, bool trace_over, const char *action);
263270   void trace_printf(const char *fmt, ...);
r22724r22725
298305   device_disasm_interface *  m_disasm;                // disasm interface, if present
299306
300307   // global state
301   UINT32                  m_flags;                    // debugging flags for this CPU
302   symbol_table            m_symtable;                 // symbol table for expression evaluation
308   UINT32                      m_flags;                // debugging flags for this CPU
309   symbol_table                m_symtable;             // symbol table for expression evaluation
303310   debug_instruction_hook_func m_instrhook;            // per-instruction callback hook
304311
305312   // disassembly
r22724r22725
377384      bool operator < (const dasm_pc_tag& rhs) const
378385      {
379386         if (m_address == rhs.m_address)
380               return m_crc < rhs.m_crc;
387            return m_crc < rhs.m_crc;
381388         return (m_address < rhs.m_address);
382389      }
383390
384      offs_t m_address;
391      offs_t m_address;       // Stores [nothing] for a given address & crc32
385392      UINT32 m_crc;
386393   };
387394   simple_set<dasm_pc_tag> m_track_pc_set;
r22724r22725
393400   public:
394401      dasm_comment(offs_t address, UINT32 crc, const char *text, rgb_t color);
395402
396      astring  m_text;                     // comment text
397      rgb_t    m_color;                    // comment color
403      astring  m_text;        // Stores comment text & color for a given address & crc32
404      rgb_t    m_color;
398405   };
399406   simple_set<dasm_comment> m_comment_set;             // collection of comments
400407   UINT32                   m_comment_change;          // change counter for comments
401408
409   // memory tracking
410   class dasm_memory_access
411   {
412   public:
413      dasm_memory_access(const address_spacenum& address_space,
414                           const offs_t& address,
415                           const UINT64& data,
416                           const offs_t& pc);
417
418      // required to be included in a simple_set
419      bool operator < (const dasm_memory_access& rhs) const
420      {
421         if ((m_address == rhs.m_address) && (m_address_space == rhs.m_address_space))
422            return m_data < rhs.m_data;
423         return (m_address < rhs.m_address) && (m_address_space == rhs.m_address_space);
424      }
425
426      // Stores the PC for a given address, memory region, and data value
427      address_spacenum m_address_space;
428      offs_t           m_address;
429      UINT64           m_data;
430      offs_t           m_pc;
431   };
432   simple_set<dasm_memory_access> m_track_mem_set;
433   bool m_track_mem;
434
402435   // internal flag values
403436   static const UINT32 DEBUG_FLAG_OBSERVING        = 0x00000001;       // observing this CPU
404437   static const UINT32 DEBUG_FLAG_HISTORY          = 0x00000002;       // tracking this CPU's history
trunk/src/emu/debug/dvmemory.h
r22724r22725
8787   bool reverse() const { return m_reverse_view; }
8888   bool ascii() const { return m_ascii_view; }
8989   bool physical() const { return m_no_translation; }
90   offs_t addressAtCursorPosition(const debug_view_xy& pos) { return get_cursor_pos(pos).m_address; }
9091
9192   // setters
9293   void set_expression(const char *expression);
r22724r22725
117118   bool needs_recompute();
118119
119120   // cursor position management
120   cursor_pos get_cursor_pos();
121   cursor_pos get_cursor_pos(const debug_view_xy& cursor);
121122   void set_cursor_pos(cursor_pos pos);
122   cursor_pos begin_update_and_get_cursor_pos() { begin_update(); return get_cursor_pos(); }
123   cursor_pos begin_update_and_get_cursor_pos() { begin_update(); return get_cursor_pos(m_cursor); }
123124   void end_update_and_set_cursor_pos(cursor_pos pos) { set_cursor_pos(pos); end_update(); }
124125
125126   // memory access
trunk/src/emu/debug/debugcmd.c
r22724r22725
143143static void execute_traceflush(running_machine &machine, int ref, int params, const char **param);
144144static void execute_history(running_machine &machine, int ref, int params, const char **param);
145145static void execute_trackpc(running_machine &machine, int ref, int params, const char **param);
146static void execute_trackmem(running_machine &machine, int ref, int params, const char **param);
147static void execute_pcatmem(running_machine &machine, int ref, int params, const char **param);
146148static void execute_snap(running_machine &machine, int ref, int params, const char **param);
147149static void execute_source(running_machine &machine, int ref, int params, const char **param);
148150static void execute_map(running_machine &machine, int ref, int params, const char **param);
r22724r22725
292294   debug_console_register_command(machine, "ignore",    CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, execute_ignore);
293295   debug_console_register_command(machine, "observe",   CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, execute_observe);
294296
295   debug_console_register_command(machine, "comadd",   CMDFLAG_NONE, 0, 1, 2, execute_comment);
297   debug_console_register_command(machine, "comadd",    CMDFLAG_NONE, 0, 1, 2, execute_comment);
296298   debug_console_register_command(machine, "//",        CMDFLAG_NONE, 0, 1, 2, execute_comment);
297   debug_console_register_command(machine, "comdelete",    CMDFLAG_NONE, 0, 1, 1, execute_comment_del);
298   debug_console_register_command(machine, "comsave",  CMDFLAG_NONE, 0, 0, 0, execute_comment_save);
299   debug_console_register_command(machine, "comdelete", CMDFLAG_NONE, 0, 1, 1, execute_comment_del);
300   debug_console_register_command(machine, "comsave",   CMDFLAG_NONE, 0, 0, 0, execute_comment_save);
299301
300302   debug_console_register_command(machine, "bpset",     CMDFLAG_NONE, 0, 1, 3, execute_bpset);
301303   debug_console_register_command(machine, "bp",        CMDFLAG_NONE, 0, 1, 3, execute_bpset);
r22724r22725
369371   debug_console_register_command(machine, "history",   CMDFLAG_NONE, 0, 0, 2, execute_history);
370372   debug_console_register_command(machine, "trackpc",   CMDFLAG_NONE, 0, 0, 3, execute_trackpc);
371373
374   debug_console_register_command(machine, "trackmem",  CMDFLAG_NONE, 0, 0, 3, execute_trackmem);
375   debug_console_register_command(machine, "pcatmemp",  CMDFLAG_NONE, AS_PROGRAM, 1, 2, execute_pcatmem);
376   debug_console_register_command(machine, "pcatmemd",  CMDFLAG_NONE, AS_DATA,    1, 2, execute_pcatmem);
377   debug_console_register_command(machine, "pcatmemi",  CMDFLAG_NONE, AS_IO,      1, 2, execute_pcatmem);
378
372379   debug_console_register_command(machine, "snap",      CMDFLAG_NONE, 0, 0, 1, execute_snap);
373380
374381   debug_console_register_command(machine, "source",    CMDFLAG_NONE, 0, 1, 1, execute_source);
r22724r22725
26952702
26962703
26972704/*-------------------------------------------------
2705    execute_trackmem - execute the trackmem command
2706-------------------------------------------------*/
2707
2708static void execute_trackmem(running_machine &machine, int ref, int params, const char *param[])
2709{
2710   // Gather the on/off switch (if present)
2711   UINT64 turnOn = true;
2712   if (!debug_command_parameter_number(machine, param[0], &turnOn))
2713      return;
2714
2715   // Gather the cpu id (if present)
2716   device_t *cpu = NULL;
2717   if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu))
2718      return;
2719
2720   // Should we clear the existing data?
2721   UINT64 clear = false;
2722   if (!debug_command_parameter_number(machine, param[2], &clear))
2723      return;
2724
2725   // Get the address space for the given cpu
2726   address_space *space;
2727   if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : NULL, AS_PROGRAM, space))
2728      return;
2729
2730   // Inform the CPU it's time to start tracking memory writes
2731   cpu->debug()->set_track_mem(turnOn);
2732
2733   // Use the watchpoint system to catch memory writes
2734   space->enable_write_watchpoints(true);
2735
2736   // Clear out the existing data if requested
2737   if (clear)
2738      space->device().debug()->track_mem_data_clear();
2739}
2740
2741
2742/*-------------------------------------------------
2743    execute_pcatmem - execute the pcatmem command
2744-------------------------------------------------*/
2745
2746static void execute_pcatmem(running_machine &machine, int ref, int params, const char *param[])
2747{
2748   // Gather the required address parameter
2749   UINT64 address;
2750   if (!debug_command_parameter_number(machine, param[0], &address))
2751      return;
2752
2753   // Gather the cpu id (if present)
2754   device_t *cpu = NULL;
2755   if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : NULL, &cpu))
2756      return;
2757
2758   // Get the address space for the given cpu
2759   address_space *space;
2760   if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : NULL, ref, space))
2761      return;
2762
2763   // Get the value of memory at the address
2764   const int nativeDataWidth = space->data_width() / 8;
2765   const UINT64 data = debug_read_memory(*space,
2766                                space->address_to_byte(address),
2767                                nativeDataWidth,
2768                                true);
2769
2770   // Recover the pc & print
2771   const address_spacenum spaceNum = (address_spacenum)ref;
2772   const offs_t result = space->device().debug()->track_mem_pc_from_space_address_data(spaceNum, address, data);
2773   if (result != (offs_t)(-1))
2774      debug_console_printf(machine, "%02x\n", result);
2775   else
2776      debug_console_printf(machine, "UNKNOWN PC\n");
2777}
2778
2779
2780/*-------------------------------------------------
26982781    execute_snap - execute the snapshot command
26992782-------------------------------------------------*/
27002783
trunk/src/emu/debug/debughlp.c
r22724r22725
8888      "  logerror <format>[,<item>[,...]] -- outputs one or more <item>s to the error.log\n"
8989      "  tracelog <format>[,<item>[,...]] -- outputs one or more <item>s to the trace file using <format>\n"
9090      "  history [<cpu>,<length>] -- outputs a brief history of visited opcodes.\n"
91      "  trackpc [<bool>,<cpu>,<bool>] -- toggle to visually track visited opcodes [for the given cpu [& clear]].\n"
91      "  trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear].\n"
92      "  trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear].\n"
93      "  pcatmemp <address>[,<cpu>] -- query which PC wrote to a given program memory address for the current CPU.\n"
94      "  pcatmemd <address>[,<cpu>] -- query which PC wrote to a given data memory address for the current CPU.\n"
95      "  pcatmemi <address>[,<cpu>] -- query which PC wrote to a given I/O memory address for the current CPU.\n"
96      "                                (Note: you can also query this info by right clicking in a memory window.\n"
9297      "  snap [<filename>] -- save a screen snapshot\n"
9398      "  source <filename> -- reads commands from <filename> and executes them one by one\n"
9499      "  quit -- exits MAME and the debugger\n"
r22724r22725
391396      "trackpc 1\n"
392397      "  Begin tracking the current cpu's pc.\n"
393398      "\n"
394      "trackpc 1, 0, 0\n"
399      "trackpc 1, 0, 1\n"
395400      "  Continue tracking pc on cpu 0, but clear existing track info.\n"
396401   },
397402   {
403      "trackmem",
404      "\n"
405      "  trackmem [<bool>,<cpu>,<bool>]\n"
406      "\n"
407      "The trackmem command logs the PC at each time a memory address is written to.  "
408      "The first boolean argument toggles the process on and off.  The second argument is a cpu "
409      "selector; if no cpu is specified, the current cpu is automatically selected. The third argument "
410      " is a boolean denoting if the existing data should be cleared or not.  Please refer to the "
411      "pcatmem command for information on how to retrieve this data.  Also, right clicking in "
412      "a memory window will display the logged PC for the given address.\n"
413      "\n"
414      "Examples:\n"
415      "\n"
416      "trackmem\n"
417      "  Begin tracking the current CPU's pc.\n"
418      "\n"
419      "trackmem 1, 0, 1\n"
420      "  Continue tracking memory writes on cpu 0, but clear existing track info.\n"
421   },
422   {
423      "pcatmem",
424      "\n"
425      "  pcatmem(p/d/i) <address>[,<cpu>]\n"
426      "\n"
427      "The pcatmem command returns which PC wrote to a given memory address for the current CPU. "
428      "The first argument is the requested address.  The second argument is a cpu selector; if no "
429      "cpu is specified, the current cpu is automatically selected.  Right clicking in a memory window "
430      "will also display the logged PC for the given address.\n"
431      "\n"
432      "Examples:\n"
433      "\n"
434      "pcatmem 400000\n"
435      "  Print which PC wrote this CPU's memory location 0x400000.\n"
436   },
437   {
398438      "snap",
399439      "\n"
400440      "  snap [[<filename>], <scrnum>]\n"
trunk/src/emu/debug/debugcpu.c
r22724r22725
16631663      m_track_pc_set(),
16641664      m_track_pc(false),
16651665      m_comment_set(),
1666      m_comment_change(0)
1666      m_comment_change(0),
1667      m_track_mem_set(),
1668      m_track_mem(false)
16671669{
16681670   memset(m_pc_history, 0, sizeof(m_pc_history));
16691671   memset(m_wplist, 0, sizeof(m_wplist));
r22724r22725
20232025
20242026void device_debug::memory_write_hook(address_space &space, offs_t address, UINT64 data, UINT64 mem_mask)
20252027{
2028   if (m_track_mem)
2029   {
2030      dasm_memory_access newAccess(space.spacenum(), address, data, history_pc(0));
2031      if (!m_track_mem_set.insert(newAccess))
2032      {
2033         m_track_mem_set.remove(newAccess);
2034         m_track_mem_set.insert(newAccess);
2035      }
2036   }
20262037   watchpoint_check(space, WATCHPOINT_WRITE, address, data, mem_mask);
20272038}
20282039
r22724r22725
26312642
26322643
26332644//-------------------------------------------------
2645//  track_mem_pc_from_address_data - returns the pc that
2646//  wrote the data to this address or (offs_t)(-1) for
2647//  'not available'.
2648//-------------------------------------------------
2649
2650offs_t device_debug::track_mem_pc_from_space_address_data(const address_spacenum& space,
2651                                                          const offs_t& address,
2652                                                          const UINT64& data) const
2653{
2654   const offs_t missing = (offs_t)(-1);
2655   if (m_track_mem_set.empty())
2656      return missing;
2657   dasm_memory_access* mem_access = m_track_mem_set.find(dasm_memory_access(space, address, data, 0));
2658   if (mem_access == NULL) return missing;
2659   return mem_access->m_pc;
2660}
2661
2662
2663//-------------------------------------------------
26342664//  comment_add - adds a comment to the list at
26352665//  the given address
26362666//-------------------------------------------------
r22724r22725
26722702
26732703const char *device_debug::comment_text(offs_t addr) const
26742704{
2675   const UINT32 crc = compute_opcode_crc32(addr);
2705   const UINT32 crc = compute_opcode_crc32(addr);
26762706   dasm_comment* comment = m_comment_set.find(dasm_comment(addr, crc, "", 0));
26772707   if (comment == NULL) return NULL;
26782708   return comment->m_text;
r22724r22725
35233553
35243554device_debug::dasm_pc_tag::dasm_pc_tag(const offs_t& address, const UINT32& crc)
35253555   : m_address(address),
3526      m_crc(crc)
3556     m_crc(crc)
35273557{
35283558}
35293559
35303560//-------------------------------------------------
3561//  dasm_memory_access - constructor
3562//-------------------------------------------------
3563
3564device_debug::dasm_memory_access::dasm_memory_access(const address_spacenum& address_space,
3565                                        const offs_t& address,
3566                                        const UINT64& data,
3567                                        const offs_t& pc)
3568   : m_address_space(address_space),
3569     m_address(address),
3570     m_data(data),
3571     m_pc(pc)
3572{
3573}
3574
3575//-------------------------------------------------
35313576//  dasm_comment - constructor
35323577//-------------------------------------------------
35333578
35343579device_debug::dasm_comment::dasm_comment(offs_t address, UINT32 crc, const char *text, rgb_t color)
35353580   : dasm_pc_tag(address, crc),
3536      m_text(text),
3537      m_color(color)
3581     m_text(text),
3582     m_color(color)
35383583{
35393584}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team