Handle number of M68K cycles used when tracing in debugger mode
authorJean-Paul Mari <djipi.mari@gmail.com>
Sun, 4 Apr 2021 16:26:09 +0000 (12:26 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Sun, 4 Apr 2021 16:26:09 +0000 (12:26 -0400)
docs/vj_HistoryNotes.txt
src/gui/emustatus.cpp
src/gui/emustatus.h
src/gui/mainwin.cpp
src/jaguar.cpp
src/jaguar.h

index 3bb478b..4a2a32e 100644 (file)
@@ -33,6 +33,8 @@ Release 5 (TBA)
 -- Added a specific breakpoint for the M68K bus error exception
 21) Project has switched to libdwarf 20210305 library 64bits for VS 2017
 22) Breakpoint list window is now refreshed after a new breakpoint is set
 -- Added a specific breakpoint for the M68K bus error exception
 21) Project has switched to libdwarf 20210305 library 64bits for VS 2017
 22) Breakpoint list window is now refreshed after a new breakpoint is set
+23) Handle number of M68K cycles used when tracing in debugger mode
+-- The cycles are displayed in the emulator status window
 
 Release 4a (15th August 2019)
 -----------------------------
 
 Release 4a (15th August 2019)
 -----------------------------
index 73f5b81..3a3cc12 100644 (file)
@@ -8,6 +8,7 @@
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JPM  02/02/2017  Created this file
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JPM  02/02/2017  Created this file
+// JPM   Apr./2021  Display number of M68K cycles used in tracing mode
 //
 
 // STILL TO DO:
 //
 
 // STILL TO DO:
 
 
 // 
 
 
 // 
-EmuStatusWindow::EmuStatusWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
-       layout(new QVBoxLayout),
-       text(new QLabel),
-       GPURunning(GPUIsRunning())
+EmuStatusWindow::EmuStatusWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
+layout(new QVBoxLayout),
+resetcycles(new QPushButton(tr("Reset cycles"))),
+text(new QLabel),
+M68K_totalcycles(0),
+M68K_opcodecycles(0),
+GPURunning(GPUIsRunning())
 {
        setWindowTitle(tr("Emulator status"));
 
 {
        setWindowTitle(tr("Emulator status"));
 
@@ -35,6 +39,31 @@ EmuStatusWindow::EmuStatusWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::D
        setLayout(layout);
 
        layout->addWidget(text);
        setLayout(layout);
 
        layout->addWidget(text);
+       layout->addWidget(resetcycles);
+
+       connect(resetcycles, SIGNAL(clicked()), this, SLOT(ResetCycles()));
+}
+
+
+//
+void EmuStatusWindow::ResetCycles(void)
+{
+       ResetM68KCycles();
+       RefreshContents();
+}
+
+
+//
+void EmuStatusWindow::ResetM68KCycles(void)
+{
+       M68K_totalcycles = M68K_opcodecycles = 0;
+}
+
+
+//
+void EmuStatusWindow::UpdateM68KCycles(size_t cycles)
+{
+       M68K_totalcycles += (M68K_opcodecycles = cycles);
 }
 
 
 }
 
 
@@ -56,7 +85,11 @@ void EmuStatusWindow::RefreshContents(void)
                emuStatusDump += QString(string);
                sprintf(string, "        M68K tracing | %s\n", (startM68KTracing ? "On" : "Off"));
                emuStatusDump += QString(string);
                emuStatusDump += QString(string);
                sprintf(string, "        M68K tracing | %s\n", (startM68KTracing ? "On" : "Off"));
                emuStatusDump += QString(string);
-               sprintf(string, "                DRAM | %i KB", (vjs.DRAM_size / 1024));
+               sprintf(string, "                DRAM | %zi KB\n", (vjs.DRAM_size / 1024));
+               emuStatusDump += QString(string);
+               sprintf(string, "        M68K tracing | %zi cycle%s\n", M68K_opcodecycles, (M68K_opcodecycles ? "s" : ""));
+               emuStatusDump += QString(string);
+               sprintf(string, "  M68K tracing total | %zi cycle%s", M68K_totalcycles, (M68K_totalcycles ? "s" : ""));
                emuStatusDump += QString(string);
 
                text->setText(emuStatusDump);
                emuStatusDump += QString(string);
 
                text->setText(emuStatusDump);
index 1c3d52a..22da650 100644 (file)
@@ -16,18 +16,24 @@ class EmuStatusWindow : public QWidget
 
        public:
                EmuStatusWindow(QWidget * parent = 0);
 
        public:
                EmuStatusWindow(QWidget * parent = 0);
-
-       public slots:
+               void UpdateM68KCycles(size_t cycles);
                void RefreshContents(void);
                void RefreshContents(void);
+               void ResetM68KCycles(void);
+
+       private slots:
+               void ResetCycles(void);
 
        protected:
                void keyPressEvent(QKeyEvent *);
 
        private:
                QVBoxLayout * layout;
 
        protected:
                void keyPressEvent(QKeyEvent *);
 
        private:
                QVBoxLayout * layout;
+               QPushButton * resetcycles;
                QLabel * text;
                QLabel * text;
-               bool    GPURunning;
-               bool    M68000DebugHaltStatus;
+               bool GPURunning;
+               bool M68000DebugHaltStatus;
+               size_t M68K_opcodecycles;
+               size_t M68K_totalcycles;
 };
 
 #endif // __EMUSTATUS_H__
 };
 
 #endif // __EMUSTATUS_H__
index f9ead48..0202537 100644 (file)
@@ -28,6 +28,7 @@
 // JPM   Aug./2019  Update texts descriptions, set cartridge view menu for debugger mode only, added a HW registers browser and source level tracing\r
 // JPM  Marc./2020  Added the step over for source level tracing\r
 //  RG   Jan./2021  Linux build fixes\r
 // JPM   Aug./2019  Update texts descriptions, set cartridge view menu for debugger mode only, added a HW registers browser and source level tracing\r
 // JPM  Marc./2020  Added the step over for source level tracing\r
 //  RG   Jan./2021  Linux build fixes\r
+// JPM   Apr./2021  Handle number of M68K cycles used in tracing mode\r
 //\r
 \r
 // FIXED:\r
 //\r
 \r
 // FIXED:\r
@@ -1353,6 +1354,7 @@ void MainWin::ToggleRunState(void)
                cpuBrowseWin->UnholdBPM();\r
        }\r
 \r
                cpuBrowseWin->UnholdBPM();\r
        }\r
 \r
+       emuStatusWin->ResetM68KCycles();\r
        // Pause/unpause any running/non-running threads...\r
        DACPauseAudioThread(!running);\r
 }\r
        // Pause/unpause any running/non-running threads...\r
        DACPauseAudioThread(!running);\r
 }\r
@@ -1591,12 +1593,12 @@ void MainWin::DebuggerTraceStepInto(void)
        {\r
                while (!SourcesWin->CheckChangeLine())\r
                {\r
        {\r
                while (!SourcesWin->CheckChangeLine())\r
                {\r
-                       JaguarStepInto();\r
+                       emuStatusWin->UpdateM68KCycles(JaguarStepInto());\r
                }\r
        }\r
        else\r
        {\r
                }\r
        }\r
        else\r
        {\r
-               JaguarStepInto();\r
+               emuStatusWin->UpdateM68KCycles(JaguarStepInto());\r
        }\r
 \r
        videoWidget->updateGL();\r
        }\r
 \r
        videoWidget->updateGL();\r
@@ -1621,6 +1623,7 @@ void MainWin::DebuggerRestart(void)
        dasmtabWidget->setCurrentIndex(1);              // set focus on the disasm M68K tab\r
        m68k_set_reg(M68K_REG_A6, 0);\r
        m68k_brk_hitcounts_reset();\r
        dasmtabWidget->setCurrentIndex(1);              // set focus on the disasm M68K tab\r
        m68k_set_reg(M68K_REG_A6, 0);\r
        m68k_brk_hitcounts_reset();\r
+       emuStatusWin->ResetM68KCycles();\r
        bpmHitCounts = 0;\r
        DebuggerResetWindows();\r
        CommonResetWindows();\r
        bpmHitCounts = 0;\r
        DebuggerResetWindows();\r
        CommonResetWindows();\r
@@ -1641,12 +1644,12 @@ void MainWin::DebuggerTraceStepOver(void)
        {\r
                while (!SourcesWin->CheckChangeLine())\r
                {\r
        {\r
                while (!SourcesWin->CheckChangeLine())\r
                {\r
-                       JaguarStepOver(0);\r
+                       emuStatusWin->UpdateM68KCycles(JaguarStepOver(0));\r
                }\r
        }\r
        else\r
        {\r
                }\r
        }\r
        else\r
        {\r
-               JaguarStepOver(0);\r
+               emuStatusWin->UpdateM68KCycles(JaguarStepOver(0));\r
        }\r
 \r
        videoWidget->updateGL();\r
        }\r
 \r
        videoWidget->updateGL();\r
index 4f7cb91..594495a 100644 (file)
@@ -18,6 +18,7 @@
 // JPM   Aug./2019  Fix specific breakpoint for ROM cartridge or unknown memory location writing; added a specific breakpoint for the M68K illegal & unimplemented instruction, unknown exceptions and address error exceptions
 // JPM   Aug./2019  Fix potential emulator freeze after an exception has occured
 // JPM   Feb./2021  Added a specific breakpoint for the M68K bus error exception, and a M68K exception catch detection
 // JPM   Aug./2019  Fix specific breakpoint for ROM cartridge or unknown memory location writing; added a specific breakpoint for the M68K illegal & unimplemented instruction, unknown exceptions and address error exceptions
 // JPM   Aug./2019  Fix potential emulator freeze after an exception has occured
 // JPM   Feb./2021  Added a specific breakpoint for the M68K bus error exception, and a M68K exception catch detection
+// JPM   Apr./2021  Keep number of M68K cycles used in tracing mode
 //
 
 
 //
 
 
@@ -2609,14 +2610,16 @@ void JaguarExecuteNew(void)
 
 
 // Step over function
 
 
 // Step over function
-void   JaguarStepOver(int depth)
+int JaguarStepOver(int depth)
 {
        bool exit;
 {
        bool exit;
+       int cycles;
        //bool case55 = false;
        //uint32_t m68kSR;
 
        if (!depth)
        {
        //bool case55 = false;
        //uint32_t m68kSR;
 
        if (!depth)
        {
+               cycles = 0;
                exit = true;
        }
        else
                exit = true;
        }
        else
@@ -2626,7 +2629,7 @@ void      JaguarStepOver(int depth)
 
        do
        {
 
        do
        {
-               JaguarStepInto();
+               cycles += JaguarStepInto();
 
                switch (M68KGetCurrentOpcodeFamily())
                {
 
                switch (M68KGetCurrentOpcodeFamily())
                {
@@ -2663,7 +2666,7 @@ void      JaguarStepOver(int depth)
                        // bsr & jsr
                case 54:
                case 52:
                        // bsr & jsr
                case 54:
                case 52:
-                       JaguarStepOver(depth+1);
+                       cycles += JaguarStepOver(depth+1);
                        //if (depth)
                        //{
                        //      exit = false;
                        //if (depth)
                        //{
                        //      exit = false;
@@ -2683,17 +2686,19 @@ void    JaguarStepOver(int depth)
 #ifdef _MSC_VER
 #pragma message("Warning: !!! Need to verify the Jaguar Step Over function !!!")
 #else
 #ifdef _MSC_VER
 #pragma message("Warning: !!! Need to verify the Jaguar Step Over function !!!")
 #else
-       #warning "!!! Need to verify the Jaguar Step Over function !!!"
+#warning "!!! Need to verify the Jaguar Step Over function !!!"
 #endif // _MSC_VER
 #endif // _MSC_VER
+       return cycles;
 }
 
 
 // Step into function
 }
 
 
 // Step into function
-void   JaguarStepInto(void)
+int    JaguarStepInto(void)
 {
 {
+       int cycles;
        //      double timeToNextEvent = GetTimeToNextEvent();
 
        //      double timeToNextEvent = GetTimeToNextEvent();
 
-       m68k_execute(USEC_TO_M68K_CYCLES(0));
+       cycles = m68k_execute(USEC_TO_M68K_CYCLES(0));
 //     m68k_execute(USEC_TO_M68K_CYCLES(timeToNextEvent));
 
        if (vjs.GPUEnabled)
 //     m68k_execute(USEC_TO_M68K_CYCLES(timeToNextEvent));
 
        if (vjs.GPUEnabled)
@@ -2705,6 +2710,7 @@ void      JaguarStepInto(void)
 #else
 #warning "!!! Need to verify the Jaguar Step Into function !!!"
 #endif // _MSC_VER
 #else
 #warning "!!! Need to verify the Jaguar Step Into function !!!"
 #endif // _MSC_VER
+               return cycles;
 }
 
 
 }
 
 
index 2669380..2b2cc33 100644 (file)
@@ -36,8 +36,8 @@ bool JaguarInterruptHandlerIsValid(uint32_t i);
 void JaguarDasm(uint32_t offset, uint32_t qt);
 
 void JaguarExecuteNew(void);
 void JaguarDasm(uint32_t offset, uint32_t qt);
 
 void JaguarExecuteNew(void);
-void   JaguarStepInto(void);
-void   JaguarStepOver(int depth);
+int JaguarStepInto(void);
+int JaguarStepOver(int depth);
 
 // Exports from JAGUAR.CPP
 
 
 // Exports from JAGUAR.CPP