Set text conversion to Qt/HTML format
authorJean-Paul Mari <djipi.mari@gmail.com>
Tue, 18 Aug 2020 20:48:25 +0000 (16:48 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Tue, 18 Aug 2020 20:48:25 +0000 (16:48 -0400)
docs/vj_HistoryNotes.txt
src/debugger/DWARFManager.cpp
src/debugger/callstackbrowser.cpp
src/debugger/m68kDasmWin.cpp
src/debugger/m68kDasmWin.h

index 808e6fe..17acefe 100644 (file)
@@ -10,6 +10,7 @@ Release 5 (TBA)
 4) Added a source tab in the main window for step into tracing
 5) Added the step over for source level tracing
 6) Project has switched to libdwarf 20200114 library 64bits for VS 2017
+7) Set text conversion to Qt/HTML format for the M68K tracing window
 
 Release 4a (15th August 2019)
 -----------------------------
index b65227f..eaf956a 100644 (file)
@@ -15,7 +15,6 @@
 \r
 // To Do\r
 // To use pointers instead of arrays usage\r
-// To keep sources text file intact wihtout QT/HTML transformation\r
 // \r
 \r
 \r
@@ -29,7 +28,7 @@
 \r
 \r
 // Definitions for debugging\r
-//#define DEBUG_NumCU                  0x44                            // CU number to debug or undefine it\r
+//#define DEBUG_NumCU                  0x                            // CU number to debug or undefine it\r
 //#define DEBUG_VariableName   "sound_death"                           // Variable name to look for or undefine it\r
 //#define DEBUG_TypeName               "Cbuf_Execute"                  // Type name to look for or undefine it\r
 //#define DEBUG_TypeDef                        DW_TAG_typedef          // Type def to look for or undefine it (not supported)\r
@@ -147,10 +146,10 @@ typedef struct CUStruct
        VariablesStruct *PtrVariables;                                  // Pointer to the global variables list structure\r
        size_t NbFrames;                                                                // Frames number\r
        size_t NbUsedLinesSrc;                                                  // Number of used source lines\r
-       size_t LastNumUsedLinesSrc;                                             // Last used source number line\r
+       size_t LastNumUsedLinesSrc;                                             // Last number line used\r
        CUStruct_LineSrc *PtrUsedLinesSrc;                              // Pointer to the used source lines list structure\r
        char **PtrUsedLinesLoadSrc;                                             // Pointer lists to each used source line referenced by the CUStruct_LineSrc structure\r
-       size_t *PtrUsedNumLines;                                                // Pointer list to the number lines used\r
+       size_t *PtrUsedNumLines;                                                // List of the number lines used\r
 }S_CUStruct;\r
 \r
 \r
@@ -1052,7 +1051,7 @@ void DWARFManager_InitDMI(void)
                                        dwarf_dealloc(dbg, linebuf, DW_DLA_LIST);\r
                                }\r
 \r
-                               // Set the source code lines for QT html/text conformity\r
+                               // Set the source code lines\r
                                if (PtrCU[NbCU].NbLinesLoadSrc)\r
                                {\r
                                        if (PtrCU[NbCU].PtrLinesLoadSrc = (char **)calloc(PtrCU[NbCU].NbLinesLoadSrc, sizeof(char *)))\r
index 0d30213..108dfe4 100644 (file)
@@ -11,6 +11,7 @@
 // JPM  09/12/2018  Added a status bar and better status report
 // JPM  10/20/2018  Added the return address information in the call stack
 // JPM  08/09/2019  Prevent crash in case of call stack is out of range
+// JPM   Aug./2020  Added different layouts
 
 // STILL TO DO:
 // To set the information display at the right
@@ -114,7 +115,7 @@ void CallStackBrowserWindow::RefreshContents(void)
                                        model->insertRow(NbRaw);
                                        model->setItem(NbRaw, 0, new QStandardItem(QString("%1").arg((FuncName = DBGManager_GetFunctionName(ret)) ? FuncName : "(N/A)")));
                                        FunctionName = QString(FuncName = DBGManager_GetLineSrcFromAdr(ret, DBG_NO_TAG));
-                                       FunctionName.replace("&nbsp;", " ");
+                                       //FunctionName.replace("&nbsp;", " ");
                                        model->setItem(NbRaw, 1, new QStandardItem(QString("%1").arg(FuncName ? FunctionName : "(N/A)")));
                                        sprintf(msg, "0x%06X", ret);
                                        model->setItem(NbRaw++, 2, new QStandardItem(QString("%1").arg(msg)));
index ec36938..65542fd 100644 (file)
 // JPM  06/27/2016  Created this file\r
 // JPM  12/04/2016  Suport ELF debug information\r
 // JPM              Replacing the ELF support by the debugger information manager calls\r
+// JPM   Aug./2020  Display only the code related to the traced function, added different layouts, Qt/HTML text format support\r
 //\r
 \r
 // STILL TO DO:\r
 //\r
 \r
-#include       <stdlib.h>\r
+#include <stdlib.h>\r
 #include "debugger/m68kDasmWin.h"\r
 #include "m68000/m68kinterface.h"\r
 #include "dsp.h"\r
 \r
 // \r
 m68KDasmWindow::m68KDasmWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),\r
-       layout(new QVBoxLayout), text(new QTextBrowser),\r
-       memBase(0)\r
+layout(new QVBoxLayout),\r
+#ifdef MD_LAYOUTTEXTS\r
+text(new QTextBrowser),\r
+#endif\r
+memBase(0)\r
 {\r
+       // Set font\r
        QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
        fixedFont.setStyleHint(QFont::Monospace);   //TypeWriter\r
        fixedFont.setLetterSpacing(QFont::PercentageSpacing, 100);\r
-       text->setFont(fixedFont);\r
-       setLayout(layout);\r
 \r
+       // Set text in layout\r
+#ifdef MD_LAYOUTTEXTS\r
+       text->setFont(fixedFont);\r
        layout->addWidget(text);\r
+#endif\r
+\r
+       // Set layout\r
+       setLayout(layout);\r
 }\r
 \r
 \r
@@ -56,8 +66,13 @@ void m68KDasmWindow::RefreshContents(void)
        size_t NumLine; // , CurrentNumLine = 0;\r
        size_t CurrentNumLine;\r
        char singleCharString[2] = { 0, 0 };\r
+#if MD_LAYOUTFILE == 1\r
+       bool In = true;\r
+#else\r
+#define In     true\r
+#endif\r
 \r
-       for (i = 0; i < nbr; i++)\r
+       for (i = 0; (i < nbr) && In; i++)\r
        {\r
                oldpc = pc;\r
                adr = constant = equal = false;\r
@@ -65,141 +80,163 @@ void m68KDasmWindow::RefreshContents(void)
                // Display source filename based on the program address\r
                if (vjs.displayFullSourceFilename && (PtrFullSource = DBGManager_GetFullSourceFilenameFromAdr(oldpc, &Error)) && strcmp(CurrentPtrFullSource, PtrFullSource))\r
                {\r
-#if 0\r
-                       if (strcmp(OldPtrFullSource, PtrFullSource))\r
+#if defined(MD_LAYOUTFILE)\r
+                       if (i)\r
+#if MD_LAYOUTFILE != 1\r
+                       {\r
+                               // add an empty line for the display of the new filename\r
+                               nbr++;\r
+                               s += QString("<br>");\r
+                       }\r
+#else\r
+                       {\r
+                               In = false;\r
+                       }\r
+                       else\r
+#endif\r
 #endif\r
                        {\r
-                               if (i)\r
-                               {\r
-                                       nbr++;\r
-                                       s += QString("<br>");\r
-                               }\r
-\r
                                CurrentNumLine = DBGManager_GetNumLineFromAdr(pc, DBG_NO_TAG) - 1;\r
-                               nbr++;\r
                                CurrentPtrFullSource = (char *)realloc(CurrentPtrFullSource, strlen(PtrFullSource) + 1);\r
                                strcpy(CurrentPtrFullSource, PtrFullSource);\r
+#if defined(MD_LAYOUTFILE)\r
                                if (!Error)\r
                                {\r
+                                       // Referenced filename does exist\r
                                        sprintf(string, "<font color='#ff0000'><b>%s</b></font><br>", PtrFullSource);\r
                                }\r
                                else\r
                                {\r
+                                       // Referenced filename doesn't exist\r
                                        sprintf(string, "<font color='#00ff00'><b>%s</b></font><br>", PtrFullSource);\r
                                }\r
+                               nbr++;\r
                                s += QString(string);\r
+#endif\r
                        }\r
                }\r
-\r
-               // Display line number based on the program address\r
-               if ((NumLine = DBGManager_GetNumLineFromAdr(oldpc, DBG_NO_TAG)) && ((signed)NumLine > (signed)CurrentNumLine))\r
+               else\r
                {\r
-                       if ((signed)CurrentNumLine < 0)\r
+                       // Display line number based on the program address\r
+                       if ((NumLine = DBGManager_GetNumLineFromAdr(oldpc, DBG_NO_TAG)) && ((signed)NumLine > (signed)CurrentNumLine))\r
                        {\r
-                               CurrentNumLine = NumLine - 1;\r
+#if MD_LAYOUTFILE != 1\r
+                               if ((signed)CurrentNumLine < 0)\r
+                               {\r
+                                       CurrentNumLine = NumLine - 1;\r
+                               }\r
+#endif\r
+                               sprintf(string, "| <font color='#006400'>%5u</font> | ", (unsigned int)++CurrentNumLine);               // (CurrentNumLine = NumLine));\r
+                       }\r
+                       else\r
+                       {\r
+                               sprintf(string, "|      | ");\r
                        }\r
-                       sprintf(string, "| <font color='#006400'>%5u</font> | ", (unsigned int)++CurrentNumLine);               // (CurrentNumLine = NumLine));\r
-               }\r
-               else\r
-               {\r
-                       sprintf(string, "|      | ");\r
-               }\r
-               s += QString(string);\r
-\r
-               // Display line source based on the program address\r
-               if (((signed)CurrentNumLine > 0) && (LineSrc = DBGManager_GetLineSrcFromNumLineBaseAdr(oldpc, CurrentNumLine)) && (LineSrc != CurrentLineSrc))\r
-               {\r
-                       sprintf(string, "<font color='#006400'>%s</font><br>", (CurrentLineSrc = LineSrc));\r
                        s += QString(string);\r
-                       nbr++;\r
-               }\r
-               else\r
-               {\r
-                       // Display symbol, or line source, based on the program address\r
-                       if (!CurrentLineSrc && !Symbol && (Symbol = DBGManager_GetSymbolNameFromAdr(oldpc)))\r
+\r
+                       // Display line source based on the program address\r
+                       if (((signed)CurrentNumLine > 0) && (LineSrc = DBGManager_GetLineSrcFromNumLineBaseAdr(oldpc, CurrentNumLine)) && (LineSrc != CurrentLineSrc))\r
                        {\r
-                               sprintf(string, "%s:<br>", Symbol);\r
+#if 0\r
+                               // add a color on the line text\r
+                               sprintf(string, "<font color='#006400'>%s</font><br>", (CurrentLineSrc = LineSrc));\r
                                s += QString(string);\r
+#else\r
+                               // add a color on the line text with HTML encoding\r
+                               s += QString("<font color='#006400'>");\r
+                               s += QString(QString((CurrentLineSrc = LineSrc)).toHtmlEscaped());\r
+                               s += QString("</font><br>");\r
+#endif\r
                                nbr++;\r
                        }\r
-                       // Display the assembly line based on the current PC\r
                        else\r
                        {\r
-                               pc += m68k_disassemble(buffer, (unsigned int)pc, 0, vjs.disasmopcodes);\r
-\r
-                               if (m68kPC == oldpc)\r
+                               // Display symbol, or line source, based on the program address\r
+                               if (!CurrentLineSrc && !Symbol && (Symbol = DBGManager_GetSymbolNameFromAdr(oldpc)))\r
                                {\r
-                                       sprintf(string, "-> <u>%06X: %s</u><br>", (unsigned int)oldpc, buffer);\r
-                                       m68kPCShow = true;\r
-                                       m68KPCNbrDisasmLines = i;\r
+                                       sprintf(string, "%s:<br>", Symbol);\r
+                                       s += QString(string);\r
+                                       nbr++;\r
                                }\r
+                               // Display the assembly line based on the current PC\r
                                else\r
                                {\r
-                                       sprintf(string, "   %06X: %s<br>", (unsigned int)oldpc, buffer);\r
-                               }\r
-\r
-                               buffer[0] = 0;  // Clear string\r
+                                       pc += m68k_disassemble(buffer, (unsigned int)pc, 0, vjs.disasmopcodes);\r
 \r
-                               for (j = 0; j < strlen(string); j++)\r
-                               {\r
-                                       if (string[j] == ' ')\r
+                                       if (m68kPC == oldpc)\r
                                        {\r
-                                               strcat(buffer, "&nbsp;");\r
-                                               adr = constant = false;\r
+                                               sprintf(string, "-> <u>%06X: %s</u><br>", (unsigned int)oldpc, buffer);\r
+                                               m68kPCShow = true;\r
+                                               m68KPCNbrDisasmLines = i;\r
                                        }\r
                                        else\r
                                        {\r
-                                               switch (string[j])\r
-                                               {\r
-                                               case    '#':\r
-                                                       constant = true;\r
-                                                       break;\r
-\r
-                                               case    '$':\r
-                                                       adr = true;\r
-                                                       break;\r
+                                               sprintf(string, "   %06X: %s<br>", (unsigned int)oldpc, buffer);\r
+                                       }\r
 \r
-                                               case    ',':\r
-                                                       constant = adr = equal = false;\r
-                                                       break;\r
+                                       buffer[0] = 0;  // Clear string\r
 \r
-                                               case    '=':\r
-                                                       equal = true;\r
-                                                       break;\r
+                                       for (j = 0; j < strlen(string); j++)\r
+                                       {\r
+                                               if (string[j] == ' ')\r
+                                               {\r
+                                                       strcat(buffer, "&nbsp;");\r
+                                                       adr = constant = false;\r
                                                }\r
-\r
-                                               if (!constant && adr && !equal)\r
+                                               else\r
                                                {\r
-                                                       int l = 0;\r
-                                                       char *p;\r
-                                                       do\r
+                                                       switch (string[j])\r
                                                        {\r
-                                                               adresse[l++] = string[++j];\r
-                                                       } while ((string[(j + 1)] >= '0') && (string[(j + 1)] <= '9') || (string[(j + 1)] >= 'A') && (string[(j + 1)] <= 'F'));\r
-                                                       adresse[l] = 0;\r
+                                                       case    '#':\r
+                                                               constant = true;\r
+                                                               break;\r
+\r
+                                                       case    '$':\r
+                                                               adr = true;\r
+                                                               break;\r
+\r
+                                                       case    ',':\r
+                                                               constant = adr = equal = false;\r
+                                                               break;\r
+\r
+                                                       case    '=':\r
+                                                               equal = true;\r
+                                                               break;\r
+                                                       }\r
 \r
-                                                       if (Symbol = DBGManager_GetSymbolNameFromAdr(strtoul(adresse, &p, 16)))\r
+                                                       if (!constant && adr && !equal)\r
                                                        {\r
-                                                               strcat(buffer, Symbol);\r
+                                                               int l = 0;\r
+                                                               char *p;\r
+                                                               do\r
+                                                               {\r
+                                                                       adresse[l++] = string[++j];\r
+                                                               } while ((string[(j + 1)] >= '0') && (string[(j + 1)] <= '9') || (string[(j + 1)] >= 'A') && (string[(j + 1)] <= 'F'));\r
+                                                               adresse[l] = 0;\r
+\r
+                                                               if (Symbol = DBGManager_GetSymbolNameFromAdr(strtoul(adresse, &p, 16)))\r
+                                                               {\r
+                                                                       strcat(buffer, Symbol);\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       strcat(buffer, "$");\r
+                                                                       strcat(buffer, adresse);\r
+                                                               }\r
+\r
+                                                               adr = false;\r
                                                        }\r
                                                        else\r
                                                        {\r
-                                                               strcat(buffer, "$");\r
-                                                               strcat(buffer, adresse);\r
+                                                               singleCharString[0] = string[j];\r
+                                                               strcat(buffer, singleCharString);\r
                                                        }\r
-\r
-                                                       adr = false;\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       singleCharString[0] = string[j];\r
-                                                       strcat(buffer, singleCharString);\r
                                                }\r
                                        }\r
-                               }\r
 \r
-                               Symbol = NULL;\r
-                               s += QString(buffer);\r
+                                       Symbol = NULL;\r
+                                       s += QString(buffer);\r
+                               }\r
                        }\r
                }\r
        }\r
@@ -231,7 +268,7 @@ void m68KDasmWindow::RefreshContents(void)
 \r
 \r
 // Set mem base PC address using the 68K pc current address\r
-void   m68KDasmWindow::Use68KPCAddress(void)\r
+void m68KDasmWindow::Use68KPCAddress(void)\r
 {\r
        memBase = m68k_get_reg(NULL, M68K_REG_PC);\r
 }\r
index 7ac5da6..e10ba93 100644 (file)
@@ -6,11 +6,19 @@
 // Who  When        What\r
 // ---  ----------  -------------------------------------------------------------\r
 // JPM  06/27/2016  Created this file\r
+// JPM   Aug./2020  Added different layouts\r
 //\r
 \r
 #ifndef __M68KDASMWIN_H__\r
 #define __M68KDASMWIN_H__\r
 \r
+#define MD_LAYOUTTEXTS                                         // Use a layout with just texts otherwise the new layout is used\r
+#ifdef MD_LAYOUTTEXTS\r
+#define MD_LAYOUTFILE  1                                       // Display the filenames (1: display only the first filename)\r
+#else\r
+#define MD_LAYOUTFILE  1                                       // Must display only the first filename\r
+#endif\r
+\r
 #include <QtWidgets>\r
 #include <stdint.h>\r
 \r
@@ -30,7 +38,9 @@ class m68KDasmWindow: public QWidget
 \r
        private:\r
                QVBoxLayout *layout;\r
+#ifdef MD_LAYOUTTEXTS\r
                QTextBrowser *text;\r
+#endif\r
                size_t memBase;\r
 };\r
 \r