From: Jean-Paul Mari Date: Tue, 18 Aug 2020 20:48:25 +0000 (-0400) Subject: Set text conversion to Qt/HTML format X-Git-Tag: v2.1.3-R5^2~36^2 X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/commitdiff_plain/cdeb91b063320e8eb9d9a193eb441ed7388a960a Set text conversion to Qt/HTML format --- diff --git a/docs/vj_HistoryNotes.txt b/docs/vj_HistoryNotes.txt index 808e6fe..17acefe 100644 --- a/docs/vj_HistoryNotes.txt +++ b/docs/vj_HistoryNotes.txt @@ -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) ----------------------------- diff --git a/src/debugger/DWARFManager.cpp b/src/debugger/DWARFManager.cpp index b65227f..eaf956a 100644 --- a/src/debugger/DWARFManager.cpp +++ b/src/debugger/DWARFManager.cpp @@ -15,7 +15,6 @@ // To Do // To use pointers instead of arrays usage -// To keep sources text file intact wihtout QT/HTML transformation // @@ -29,7 +28,7 @@ // Definitions for debugging -//#define DEBUG_NumCU 0x44 // CU number to debug or undefine it +//#define DEBUG_NumCU 0x3 // CU number to debug or undefine it //#define DEBUG_VariableName "sound_death" // Variable name to look for or undefine it //#define DEBUG_TypeName "Cbuf_Execute" // Type name to look for or undefine it //#define DEBUG_TypeDef DW_TAG_typedef // Type def to look for or undefine it (not supported) @@ -147,10 +146,10 @@ typedef struct CUStruct VariablesStruct *PtrVariables; // Pointer to the global variables list structure size_t NbFrames; // Frames number size_t NbUsedLinesSrc; // Number of used source lines - size_t LastNumUsedLinesSrc; // Last used source number line + size_t LastNumUsedLinesSrc; // Last number line used CUStruct_LineSrc *PtrUsedLinesSrc; // Pointer to the used source lines list structure char **PtrUsedLinesLoadSrc; // Pointer lists to each used source line referenced by the CUStruct_LineSrc structure - size_t *PtrUsedNumLines; // Pointer list to the number lines used + size_t *PtrUsedNumLines; // List of the number lines used }S_CUStruct; @@ -1052,7 +1051,7 @@ void DWARFManager_InitDMI(void) dwarf_dealloc(dbg, linebuf, DW_DLA_LIST); } - // Set the source code lines for QT html/text conformity + // Set the source code lines if (PtrCU[NbCU].NbLinesLoadSrc) { if (PtrCU[NbCU].PtrLinesLoadSrc = (char **)calloc(PtrCU[NbCU].NbLinesLoadSrc, sizeof(char *))) diff --git a/src/debugger/callstackbrowser.cpp b/src/debugger/callstackbrowser.cpp index 0d30213..108dfe4 100644 --- a/src/debugger/callstackbrowser.cpp +++ b/src/debugger/callstackbrowser.cpp @@ -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(" ", " "); + //FunctionName.replace(" ", " "); 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))); diff --git a/src/debugger/m68kDasmWin.cpp b/src/debugger/m68kDasmWin.cpp index ec36938..65542fd 100644 --- a/src/debugger/m68kDasmWin.cpp +++ b/src/debugger/m68kDasmWin.cpp @@ -10,12 +10,13 @@ // JPM 06/27/2016 Created this file // JPM 12/04/2016 Suport ELF debug information // JPM Replacing the ELF support by the debugger information manager calls +// JPM Aug./2020 Display only the code related to the traced function, added different layouts, Qt/HTML text format support // // STILL TO DO: // -#include +#include #include "debugger/m68kDasmWin.h" #include "m68000/m68kinterface.h" #include "dsp.h" @@ -26,16 +27,25 @@ // m68KDasmWindow::m68KDasmWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog), - layout(new QVBoxLayout), text(new QTextBrowser), - memBase(0) +layout(new QVBoxLayout), +#ifdef MD_LAYOUTTEXTS +text(new QTextBrowser), +#endif +memBase(0) { + // Set font QFont fixedFont("Lucida Console", 8, QFont::Normal); fixedFont.setStyleHint(QFont::Monospace); //TypeWriter fixedFont.setLetterSpacing(QFont::PercentageSpacing, 100); - text->setFont(fixedFont); - setLayout(layout); + // Set text in layout +#ifdef MD_LAYOUTTEXTS + text->setFont(fixedFont); layout->addWidget(text); +#endif + + // Set layout + setLayout(layout); } @@ -56,8 +66,13 @@ void m68KDasmWindow::RefreshContents(void) size_t NumLine; // , CurrentNumLine = 0; size_t CurrentNumLine; char singleCharString[2] = { 0, 0 }; +#if MD_LAYOUTFILE == 1 + bool In = true; +#else +#define In true +#endif - for (i = 0; i < nbr; i++) + for (i = 0; (i < nbr) && In; i++) { oldpc = pc; adr = constant = equal = false; @@ -65,141 +80,163 @@ void m68KDasmWindow::RefreshContents(void) // Display source filename based on the program address if (vjs.displayFullSourceFilename && (PtrFullSource = DBGManager_GetFullSourceFilenameFromAdr(oldpc, &Error)) && strcmp(CurrentPtrFullSource, PtrFullSource)) { -#if 0 - if (strcmp(OldPtrFullSource, PtrFullSource)) +#if defined(MD_LAYOUTFILE) + if (i) +#if MD_LAYOUTFILE != 1 + { + // add an empty line for the display of the new filename + nbr++; + s += QString("
"); + } +#else + { + In = false; + } + else +#endif #endif { - if (i) - { - nbr++; - s += QString("
"); - } - CurrentNumLine = DBGManager_GetNumLineFromAdr(pc, DBG_NO_TAG) - 1; - nbr++; CurrentPtrFullSource = (char *)realloc(CurrentPtrFullSource, strlen(PtrFullSource) + 1); strcpy(CurrentPtrFullSource, PtrFullSource); +#if defined(MD_LAYOUTFILE) if (!Error) { + // Referenced filename does exist sprintf(string, "%s
", PtrFullSource); } else { + // Referenced filename doesn't exist sprintf(string, "%s
", PtrFullSource); } + nbr++; s += QString(string); +#endif } } - - // Display line number based on the program address - if ((NumLine = DBGManager_GetNumLineFromAdr(oldpc, DBG_NO_TAG)) && ((signed)NumLine > (signed)CurrentNumLine)) + else { - if ((signed)CurrentNumLine < 0) + // Display line number based on the program address + if ((NumLine = DBGManager_GetNumLineFromAdr(oldpc, DBG_NO_TAG)) && ((signed)NumLine > (signed)CurrentNumLine)) { - CurrentNumLine = NumLine - 1; +#if MD_LAYOUTFILE != 1 + if ((signed)CurrentNumLine < 0) + { + CurrentNumLine = NumLine - 1; + } +#endif + sprintf(string, "| %5u | ", (unsigned int)++CurrentNumLine); // (CurrentNumLine = NumLine)); + } + else + { + sprintf(string, "| | "); } - sprintf(string, "| %5u | ", (unsigned int)++CurrentNumLine); // (CurrentNumLine = NumLine)); - } - else - { - sprintf(string, "| | "); - } - s += QString(string); - - // Display line source based on the program address - if (((signed)CurrentNumLine > 0) && (LineSrc = DBGManager_GetLineSrcFromNumLineBaseAdr(oldpc, CurrentNumLine)) && (LineSrc != CurrentLineSrc)) - { - sprintf(string, "%s
", (CurrentLineSrc = LineSrc)); s += QString(string); - nbr++; - } - else - { - // Display symbol, or line source, based on the program address - if (!CurrentLineSrc && !Symbol && (Symbol = DBGManager_GetSymbolNameFromAdr(oldpc))) + + // Display line source based on the program address + if (((signed)CurrentNumLine > 0) && (LineSrc = DBGManager_GetLineSrcFromNumLineBaseAdr(oldpc, CurrentNumLine)) && (LineSrc != CurrentLineSrc)) { - sprintf(string, "%s:
", Symbol); +#if 0 + // add a color on the line text + sprintf(string, "%s
", (CurrentLineSrc = LineSrc)); s += QString(string); +#else + // add a color on the line text with HTML encoding + s += QString(""); + s += QString(QString((CurrentLineSrc = LineSrc)).toHtmlEscaped()); + s += QString("
"); +#endif nbr++; } - // Display the assembly line based on the current PC else { - pc += m68k_disassemble(buffer, (unsigned int)pc, 0, vjs.disasmopcodes); - - if (m68kPC == oldpc) + // Display symbol, or line source, based on the program address + if (!CurrentLineSrc && !Symbol && (Symbol = DBGManager_GetSymbolNameFromAdr(oldpc))) { - sprintf(string, "-> %06X: %s
", (unsigned int)oldpc, buffer); - m68kPCShow = true; - m68KPCNbrDisasmLines = i; + sprintf(string, "%s:
", Symbol); + s += QString(string); + nbr++; } + // Display the assembly line based on the current PC else { - sprintf(string, " %06X: %s
", (unsigned int)oldpc, buffer); - } - - buffer[0] = 0; // Clear string + pc += m68k_disassemble(buffer, (unsigned int)pc, 0, vjs.disasmopcodes); - for (j = 0; j < strlen(string); j++) - { - if (string[j] == ' ') + if (m68kPC == oldpc) { - strcat(buffer, " "); - adr = constant = false; + sprintf(string, "-> %06X: %s
", (unsigned int)oldpc, buffer); + m68kPCShow = true; + m68KPCNbrDisasmLines = i; } else { - switch (string[j]) - { - case '#': - constant = true; - break; - - case '$': - adr = true; - break; + sprintf(string, " %06X: %s
", (unsigned int)oldpc, buffer); + } - case ',': - constant = adr = equal = false; - break; + buffer[0] = 0; // Clear string - case '=': - equal = true; - break; + for (j = 0; j < strlen(string); j++) + { + if (string[j] == ' ') + { + strcat(buffer, " "); + adr = constant = false; } - - if (!constant && adr && !equal) + else { - int l = 0; - char *p; - do + switch (string[j]) { - adresse[l++] = string[++j]; - } while ((string[(j + 1)] >= '0') && (string[(j + 1)] <= '9') || (string[(j + 1)] >= 'A') && (string[(j + 1)] <= 'F')); - adresse[l] = 0; + case '#': + constant = true; + break; + + case '$': + adr = true; + break; + + case ',': + constant = adr = equal = false; + break; + + case '=': + equal = true; + break; + } - if (Symbol = DBGManager_GetSymbolNameFromAdr(strtoul(adresse, &p, 16))) + if (!constant && adr && !equal) { - strcat(buffer, Symbol); + int l = 0; + char *p; + do + { + adresse[l++] = string[++j]; + } while ((string[(j + 1)] >= '0') && (string[(j + 1)] <= '9') || (string[(j + 1)] >= 'A') && (string[(j + 1)] <= 'F')); + adresse[l] = 0; + + if (Symbol = DBGManager_GetSymbolNameFromAdr(strtoul(adresse, &p, 16))) + { + strcat(buffer, Symbol); + } + else + { + strcat(buffer, "$"); + strcat(buffer, adresse); + } + + adr = false; } else { - strcat(buffer, "$"); - strcat(buffer, adresse); + singleCharString[0] = string[j]; + strcat(buffer, singleCharString); } - - adr = false; - } - else - { - singleCharString[0] = string[j]; - strcat(buffer, singleCharString); } } - } - Symbol = NULL; - s += QString(buffer); + Symbol = NULL; + s += QString(buffer); + } } } } @@ -231,7 +268,7 @@ void m68KDasmWindow::RefreshContents(void) // Set mem base PC address using the 68K pc current address -void m68KDasmWindow::Use68KPCAddress(void) +void m68KDasmWindow::Use68KPCAddress(void) { memBase = m68k_get_reg(NULL, M68K_REG_PC); } diff --git a/src/debugger/m68kDasmWin.h b/src/debugger/m68kDasmWin.h index 7ac5da6..e10ba93 100644 --- a/src/debugger/m68kDasmWin.h +++ b/src/debugger/m68kDasmWin.h @@ -6,11 +6,19 @@ // Who When What // --- ---------- ------------------------------------------------------------- // JPM 06/27/2016 Created this file +// JPM Aug./2020 Added different layouts // #ifndef __M68KDASMWIN_H__ #define __M68KDASMWIN_H__ +#define MD_LAYOUTTEXTS // Use a layout with just texts otherwise the new layout is used +#ifdef MD_LAYOUTTEXTS +#define MD_LAYOUTFILE 1 // Display the filenames (1: display only the first filename) +#else +#define MD_LAYOUTFILE 1 // Must display only the first filename +#endif + #include #include @@ -30,7 +38,9 @@ class m68KDasmWindow: public QWidget private: QVBoxLayout *layout; +#ifdef MD_LAYOUTTEXTS QTextBrowser *text; +#endif size_t memBase; };