Added a debug message output for warn of buffer overruns when logging to a file with the Qt trace logger.

This commit is contained in:
mjbudd77 2021-04-24 19:13:46 -04:00
parent e2716ae2c5
commit aa5ce14c06
2 changed files with 34 additions and 6 deletions

View File

@ -46,6 +46,7 @@
#include "common/os_utils.h"
#include "Qt/ConsoleWindow.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/TraceLogger.h"
#include "Qt/main.h"
@ -99,6 +100,7 @@ static int recBufMax = 0;
static int recBufHead = 0;
static int recBufTail = 0;
static FILE *logFile = NULL;
static bool overrunWarningArmed = true;
static TraceLoggerDialog_t *traceLogWindow = NULL;
static void pushMsgToLogBuffer(const char *msg);
//----------------------------------------------------
@ -378,6 +380,7 @@ void TraceLoggerDialog_t::updatePeriodic(void)
else
{
recBufTail = recBufHead;
overrunWarningArmed = true;
}
if (traceViewCounter > 20)
@ -442,6 +445,21 @@ void TraceLoggerDialog_t::toggleLoggingOnOff(void)
}
}
//----------------------------------------------------
void TraceLoggerDialog_t::showBufferWarning(void)
{
const char *msg = "\
Error: Trace Logger Circular Buffer Overrun has been detected!\n\n\
This means that some instructions have not been written to the log\
file and resulting log of instructions is incomplete.\n\n\
Recommend increasing buffer size (max lines) to at least 1,000,000 lines.\n\n\
This message won't show again until logging is stopped and started again.";
if ( consoleWindow )
{
consoleWindow->QueueErrorMsgWindow(msg);
}
}
//----------------------------------------------------
void TraceLoggerDialog_t::openLogFile(void)
{
const char *romFile;
@ -1004,15 +1022,24 @@ void openTraceLoggerWindow(QWidget *parent)
//----------------------------------------------------
static void pushToLogBuffer(traceRecord_t &rec)
{
recBuf[recBufHead] = rec;
recBufHead = (recBufHead + 1) % recBufMax;
if ( logging )
{ // Warning that an buffer overrun has occurred,
// This means that some instructions have not been written to the log.
if ( logFile != NULL )
{
if ( overrunWarningArmed )
{ // Don't spam with buffer overrun warning messages,
// we will print once if this happens.
if (recBufHead == recBufTail)
{
if ( traceLogWindow )
{
traceLogWindow->showBufferWarning();
}
printf("Trace Log Overrun!!!\n");
overrunWarningArmed = false;
}
}
}
}

View File

@ -139,6 +139,7 @@ public:
TraceLoggerDialog_t(QWidget *parent = 0);
~TraceLoggerDialog_t(void);
void showBufferWarning(void);
protected:
QTimer *updateTimer;
QCheckBox *logLastCbox;