X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/blobdiff_plain/0b02b508dea56eb938a4d05141c10b207c383d2c..aae93d8686c01e6f0dc755b04663b9144fcd6638:/src/debugger/m68kDasmWin.cpp 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); }