Misc: wire up and refactor trace logging

This commit is contained in:
Ty Lamontagne 2024-10-13 16:04:33 -04:00 committed by Ty
parent 0a599e7337
commit ab21d22514
22 changed files with 850 additions and 618 deletions

View File

@ -77,7 +77,6 @@ target_sources(common PRIVATE
Timer.h Timer.h
TextureDecompress.h TextureDecompress.h
Threading.h Threading.h
TraceLog.h
VectorIntrin.h VectorIntrin.h
WAVWriter.h WAVWriter.h
WindowInfo.h WindowInfo.h

View File

@ -364,6 +364,7 @@ bool Log::SetFileOutputLevel(LOGLEVEL level, std::string path)
} }
s_file_level = s_file_handle ? level : LOGLEVEL_NONE; s_file_level = s_file_handle ? level : LOGLEVEL_NONE;
UpdateMaxLevel();
return IsFileOutputEnabled(); return IsFileOutputEnabled();
} }

View File

@ -1,197 +0,0 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#pragma once
#include "common/Assertions.h"
#include "common/Console.h"
#include "common/StringUtil.h"
// --------------------------------------------------------------------------------------
// TraceLogDescriptor
// --------------------------------------------------------------------------------------
// Provides textual information for use by UIs; to give the end user a selection screen for
// enabling/disabling logs, and also for saving the log settings to INI.
//
struct TraceLogDescriptor
{
// short name, alphanumerics only: used for saving/loading options.
const char* ShortName;
// Standard UI name for this log source. Used in menus, options dialogs.
const char* Name;
// Length description for use as a tooltip or menu item description.
const char* Description;
const char* GetShortName() const
{
pxAssumeMsg(Name, "Tracelog descriptors require a valid name!");
return ShortName ? ShortName : Name;
}
};
// --------------------------------------------------------------------------------------
// BaseTraceLogSource
// --------------------------------------------------------------------------------------
// This class houses the base attributes for any trace log (to file or to console), which
// only includes the logfile's name, description, and enabled bit (for UIs and ini files),
// and an IsActive() method for determining if the log should be written or not.
//
// Derived classes then provide their own Write/DoWrite functions that format and write
// the log to the intended target(s).
//
// All individual calls to log write functions should be responsible for checking the
// status of the log via the IsActive() method manually (typically done via macro). This
// is done in favor of internal checks because most logs include detailed/formatted
// information, which itself can take a lot of cpu power to prepare. If the IsActive()
// check is done top-level, the parameters' calculations can be skipped. If the IsActive()
// check is done internally as part of the Write/Format calls, all parameters have to be
// resolved regardless of if the log is actually active.
//
class BaseTraceLogSource
{
protected:
const TraceLogDescriptor* m_Descriptor;
public:
// Indicates if the user has enabled this specific log. This boolean only represents
// the configured status of this log, and does *NOT* actually mean the log is active
// even when TRUE. Because many tracelogs have master enablers that act on a group
// of logs, logging checks should always use IsActive() instead to determine if a log
// should be processed or not.
bool Enabled;
protected:
BaseTraceLogSource()
: m_Descriptor(NULL)
, Enabled(false)
{
}
public:
BaseTraceLogSource(const TraceLogDescriptor* desc)
{
pxAssumeMsg(desc, "Trace logs must have a valid (non-NULL) descriptor.");
Enabled = false;
m_Descriptor = desc;
}
// Provides a categorical identifier, typically in "group.subgroup.subgroup" form.
// (use periods in favor of colons, since they do not require escape characters when
// written to ini/config files).
virtual std::string GetCategory() const { return std::string(); }
// This method should be used to determine if a log should be generated or not.
// See the class overview comments for details on how and why this method should
// be used.
virtual bool IsActive() const { return Enabled; }
virtual const char* GetShortName() const { return m_Descriptor->GetShortName(); }
virtual const char* GetName() const { return m_Descriptor->Name; }
virtual const char* GetDescription() const
{
return (m_Descriptor->Description != NULL) ? m_Descriptor->Description : "";
}
virtual bool HasDescription() const { return m_Descriptor->Description != NULL; }
};
// --------------------------------------------------------------------------------------
// TextFileTraceLog
// --------------------------------------------------------------------------------------
// This class is tailored for performance logging to file. It does not support console
// colors or wide/unicode text conversion.
//
class TextFileTraceLog : public BaseTraceLogSource
{
public:
TextFileTraceLog(const TraceLogDescriptor* desc)
: BaseTraceLogSource(desc)
{
}
bool Write(const char* fmt, ...) const
{
va_list list;
va_start(list, fmt);
WriteV(fmt, list);
va_end(list);
return false;
}
bool WriteV(const char* fmt, va_list list) const
{
std::string ascii;
ApplyPrefix(ascii);
ascii += StringUtil::StdStringFromFormatV(fmt, list);
DoWrite(ascii.c_str());
return false;
}
virtual void ApplyPrefix(std::string& ascii) const {}
virtual void DoWrite(const char* fmt) const = 0;
};
// --------------------------------------------------------------------------------------
// ConsoleLogSource
// --------------------------------------------------------------------------------------
// This class is tailored for logging to console. It applies default console color attributes
// to all writes, and supports both char and wxChar (Ascii and UF8/16) formatting.
//
class ConsoleLogSource : public BaseTraceLogSource
{
public:
ConsoleColors DefaultColor;
protected:
ConsoleLogSource()
: DefaultColor(Color_Gray)
{
}
public:
ConsoleLogSource(const TraceLogDescriptor* desc, ConsoleColors defaultColor = Color_Gray)
: BaseTraceLogSource(desc)
{
DefaultColor = defaultColor;
}
// Writes to the console using the source's default color. Note that the source's default
// color will always be used, thus ConsoleColorScope() will not be effectual unless the
// console's default color is Color_Default.
bool Write(const char* fmt, ...) const
{
va_list list;
va_start(list, fmt);
WriteV(fmt, list);
va_end(list);
return false;
}
// Writes to the console using the specified color. This overrides the default color setting
// for this log.
bool Write(ConsoleColors color, const char* fmt, ...) const
{
va_list list;
va_start(list, fmt);
WriteV(color, fmt, list);
va_end(list);
return false;
}
bool WriteV(const char* fmt, va_list list) const
{
Console.FormatV(fmt, list);
return false;
}
bool WriteV(ConsoleColors color, const char* fmt, va_list list) const
{
Console.FormatV(color, fmt, list);
return false;
}
};

View File

@ -58,6 +58,88 @@ DebugSettingsWidget::DebugSettingsWidget(SettingsWindow* dialog, QWidget* parent
connect(m_ui.dumpGSDraws, &QCheckBox::checkStateChanged, this, &DebugSettingsWidget::onDrawDumpingChanged); connect(m_ui.dumpGSDraws, &QCheckBox::checkStateChanged, this, &DebugSettingsWidget::onDrawDumpingChanged);
onDrawDumpingChanged(); onDrawDumpingChanged();
#ifdef PCSX2_DEVBUILD
//////////////////////////////////////////////////////////////////////////
// Trace Logging Settings
//////////////////////////////////////////////////////////////////////////
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEnable, "EmuCore/TraceLog", "Enabled", false);
dialog->registerWidgetHelp(m_ui.chkEnable, tr("Enable Trace Logging"), tr("Unchecked"), tr("Globally enable / disable trace logging."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEBIOS, "EmuCore/TraceLog", "EE.bios", false);
dialog->registerWidgetHelp(m_ui.chkEEBIOS, tr("EE BIOS"), tr("Unchecked"), tr("Log SYSCALL and DECI2 activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEMemory, "EmuCore/TraceLog", "EE.memory", false);
dialog->registerWidgetHelp(m_ui.chkEEMemory, tr("EE Memory"), tr("Unchecked"), tr("Log memory access to unknown or unmapped EE memory."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEER5900, "EmuCore/TraceLog", "EE.r5900", false);
dialog->registerWidgetHelp(m_ui.chkEER5900, tr("EE R5900"), tr("Unchecked"), tr("Log R5900 core instructions (excluding COPs). Requires modifying the PCSX2 source and enabling the interpreter."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEECOP0, "EmuCore/TraceLog", "EE.cop0", false);
dialog->registerWidgetHelp(m_ui.chkEECOP0, tr("EE COP0"), tr("Unchecked"), tr("Log COP0 (MMU, CPU status, etc) instructions."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEECOP1, "EmuCore/TraceLog", "EE.cop1", false);
dialog->registerWidgetHelp(m_ui.chkEECOP1, tr("EE COP1"), tr("Unchecked"), tr("Log COP1 (FPU) instructions."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEECOP2, "EmuCore/TraceLog", "EE.cop2", false);
dialog->registerWidgetHelp(m_ui.chkEECOP2, tr("EE COP2"), tr("Unchecked"), tr("Log COP2 (VU0 Macro mode) instructions."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEECache, "EmuCore/TraceLog", "EE.cache", false);
dialog->registerWidgetHelp(m_ui.chkEECache, tr("EE Cache"), tr("Unchecked"), tr("Log EE cache activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEMMIO, "EmuCore/TraceLog", "EE.knownhw", false);
dialog->registerWidgetHelp(m_ui.chkEEMMIO, tr("EE Known MMIO"), tr("Unchecked"), tr("Log known MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEUNKNWNMMIO, "EmuCore/TraceLog", "EE.unknownhw", false);
dialog->registerWidgetHelp(m_ui.chkEEUNKNWNMMIO, tr("EE Unknown MMIO"), tr("Unchecked"), tr("Log unknown or unimplemented MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEDMARegs, "EmuCore/TraceLog", "EE.dmahw", false);
dialog->registerWidgetHelp(m_ui.chkEEDMARegs, tr("EE DMA Registers"), tr("Unchecked"), tr("Log DMA-related MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEIPU, "EmuCore/TraceLog", "EE.ipu", false);
dialog->registerWidgetHelp(m_ui.chkEEIPU, tr("EE IPU"), tr("Unchecked"), tr("Log IPU activity; MMIO, decoding operations, DMA status, etc."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEGIFTags, "EmuCore/TraceLog", "EE.giftag", false);
dialog->registerWidgetHelp(m_ui.chkEEGIFTags, tr("EE GIF Tags"), tr("Unchecked"), tr("Log GIFtag parsing activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEVIFCodes, "EmuCore/TraceLog", "EE.vifcode", false);
dialog->registerWidgetHelp(m_ui.chkEEVIFCodes, tr("EE VIF Codes"), tr("Unchecked"), tr("Log VIFcode processing; command, tag style, interrupts."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEMSKPATH3, "EmuCore/TraceLog", "EE.mskpath3", false);
dialog->registerWidgetHelp(m_ui.chkEEMSKPATH3, tr("EE MSKPATH3"), tr("Unchecked"), tr("Log Path3 Masking processing."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEMFIFO, "EmuCore/TraceLog", "EE.spr", false);
dialog->registerWidgetHelp(m_ui.chkEEMFIFO, tr("EE MFIFO"), tr("Unchecked"), tr("Log Scratchpad MFIFO activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEDMACTRL, "EmuCore/TraceLog", "EE.dmac", false);
dialog->registerWidgetHelp(m_ui.chkEEDMACTRL, tr("EE DMA Controller"), tr("Unchecked"), tr("Log DMA transfer activity. Stalls, bus right arbitration, etc."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEECounters, "EmuCore/TraceLog", "EE.counters", false);
dialog->registerWidgetHelp(m_ui.chkEECounters, tr("EE Counters"), tr("Unchecked"), tr("Log all EE counters events and some counter register activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEVIF, "EmuCore/TraceLog", "EE.vif", false);
dialog->registerWidgetHelp(m_ui.chkEEVIF, tr("EE VIF"), tr("Unchecked"), tr("Log various VIF and VIFcode processing data."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEEGIF, "EmuCore/TraceLog", "EE.gif", false);
dialog->registerWidgetHelp(m_ui.chkEEGIF, tr("EE GIF"), tr("Unchecked"), tr("Log various GIF and GIFtag parsing data."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPBIOS, "EmuCore/TraceLog", "IOP.Bios", false);
dialog->registerWidgetHelp(m_ui.chkIOPBIOS, tr("IOP BIOS"), tr("Unchecked"), tr("Log SYSCALL and IRX activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPMemcards, "EmuCore/TraceLog", "IOP.memcards", false);
dialog->registerWidgetHelp(m_ui.chkIOPMemcards, tr("IOP Memcards"), tr("Unchecked"), tr("Log memory card activity. Reads, Writes, erases, etc."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPR3000A, "EmuCore/TraceLog", "IOP.r3000a", false);
dialog->registerWidgetHelp(m_ui.chkIOPR3000A, tr("IOP R3000A"), tr("Unchecked"), tr("Log R3000A core instructions (excluding COPs)."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPCOP2, "EmuCore/TraceLog", "IOP.cop2", false);
dialog->registerWidgetHelp(m_ui.chkIOPCOP2, tr("IOP COP2"), tr("Unchecked"), tr("Log IOP GPU co-processor instructions."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPMMIO, "EmuCore/TraceLog", "IOP.knownhw", false);
dialog->registerWidgetHelp(m_ui.chkIOPMMIO, tr("IOP Known MMIO"), tr("Unchecked"), tr("Log known MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPUNKNWNMMIO, "EmuCore/TraceLog", "IOP.unknownhw", false);
dialog->registerWidgetHelp(m_ui.chkIOPUNKNWNMMIO, tr("IOP Unknown MMIO"), tr("Unchecked"), tr("Log unknown or unimplemented MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPDMARegs, "EmuCore/TraceLog", "IOP.dmahw", false);
dialog->registerWidgetHelp(m_ui.chkIOPDMARegs, tr("IOP DMA Registers"), tr("Unchecked"), tr("Log DMA-related MMIO accesses."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPPad, "EmuCore/TraceLog", "IOP.pad", false);
dialog->registerWidgetHelp(m_ui.chkIOPPad, tr("IOP PAD"), tr("Unchecked"), tr("Log PAD activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPDMACTRL, "EmuCore/TraceLog", "IOP.dmac", false);
dialog->registerWidgetHelp(m_ui.chkIOPDMACTRL, tr("IOP DMA Controller"), tr("Unchecked"), tr("Log DMA transfer activity. Stalls, bus right arbitration, etc."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPCounters, "EmuCore/TraceLog", "IOP.counters", false);
dialog->registerWidgetHelp(m_ui.chkIOPCounters, tr("IOP Counters"), tr("Unchecked"), tr("Log all IOP counters events and some counter register activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPCDVD, "EmuCore/TraceLog", "IOP.cdvd", false);
dialog->registerWidgetHelp(m_ui.chkIOPCDVD, tr("IOP CDVD"), tr("Unchecked"), tr("Log CDVD hardware activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkIOPMDEC, "EmuCore/TraceLog", "IOP.mdec", false);
dialog->registerWidgetHelp(m_ui.chkIOPMDEC, tr("IOP MDEC"), tr("Unchecked"), tr("Log Motion (FMV) Decoder hardware unit activity."));
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.chkEESIF, "EmuCore/TraceLog", "MDEC.sif", false);
dialog->registerWidgetHelp(m_ui.chkEESIF, tr("EE SIF"), tr("Unchecked"), tr("Log SIF (EE <-> IOP) activity."));
connect(m_ui.chkEnable, &QCheckBox::checkStateChanged, this, &DebugSettingsWidget::onLoggingEnableChanged);
onLoggingEnableChanged();
#else
m_ui.debugTabs->removeTab(m_ui.debugTabs->indexOf(m_ui.traceLogTabWidget));
#endif
} }
DebugSettingsWidget::~DebugSettingsWidget() = default; DebugSettingsWidget::~DebugSettingsWidget() = default;
@ -70,3 +152,47 @@ void DebugSettingsWidget::onDrawDumpingChanged()
m_ui.saveTexture->setEnabled(enabled); m_ui.saveTexture->setEnabled(enabled);
m_ui.saveDepth->setEnabled(enabled); m_ui.saveDepth->setEnabled(enabled);
} }
#ifdef PCSX2_DEVBUILD
void DebugSettingsWidget::onLoggingEnableChanged()
{
const bool enabled = m_dialog->getEffectiveBoolValue("EmuCore/TraceLog", "Enabled", false);
m_ui.chkEEBIOS->setEnabled(enabled);
m_ui.chkEEMemory->setEnabled(enabled);
m_ui.chkEER5900->setEnabled(enabled);
m_ui.chkEECOP0->setEnabled(enabled);
m_ui.chkEECOP1->setEnabled(enabled);
m_ui.chkEECOP2->setEnabled(enabled);
m_ui.chkEECache->setEnabled(enabled);
m_ui.chkEEMMIO->setEnabled(enabled);
m_ui.chkEEUNKNWNMMIO->setEnabled(enabled);
m_ui.chkEEDMARegs->setEnabled(enabled);
m_ui.chkEEIPU->setEnabled(enabled);
m_ui.chkEEGIFTags->setEnabled(enabled);
m_ui.chkEEVIFCodes->setEnabled(enabled);
m_ui.chkEEMSKPATH3->setEnabled(enabled);
m_ui.chkEEMFIFO->setEnabled(enabled);
m_ui.chkEEDMACTRL->setEnabled(enabled);
m_ui.chkEECounters->setEnabled(enabled);
m_ui.chkEEVIF->setEnabled(enabled);
m_ui.chkEEGIF->setEnabled(enabled);
m_ui.chkEESIF->setEnabled(enabled);
m_ui.chkIOPBIOS->setEnabled(enabled);
m_ui.chkIOPMemcards->setEnabled(enabled);
m_ui.chkIOPR3000A->setEnabled(enabled);
m_ui.chkIOPCOP2->setEnabled(enabled);
m_ui.chkIOPMMIO->setEnabled(enabled);
m_ui.chkIOPUNKNWNMMIO->setEnabled(enabled);
m_ui.chkIOPDMARegs->setEnabled(enabled);
m_ui.chkIOPMemcards->setEnabled(enabled);
m_ui.chkIOPPad->setEnabled(enabled);
m_ui.chkIOPDMACTRL->setEnabled(enabled);
m_ui.chkIOPCounters->setEnabled(enabled);
m_ui.chkIOPCDVD->setEnabled(enabled);
m_ui.chkIOPMDEC->setEnabled(enabled);
g_emu_thread->applySettings();
}
#endif

View File

@ -20,6 +20,9 @@ public:
private Q_SLOTS: private Q_SLOTS:
void onDrawDumpingChanged(); void onDrawDumpingChanged();
#ifdef PCSX2_DEVBUILD
void onLoggingEnableChanged();
#endif
private: private:
SettingsWindow* m_dialog; SettingsWindow* m_dialog;

View File

@ -24,7 +24,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTabWidget" name="tabs"> <widget class="QTabWidget" name="debugTabs">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
@ -35,7 +35,7 @@
<attribute name="title"> <attribute name="title">
<string>Analysis</string> <string>Analysis</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -289,6 +289,300 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="traceLogTabWidget">
<attribute name="title">
<string>Trace Logging</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="chkEnable">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="traceLogHorizontalLayout">
<item>
<widget class="QGroupBox" name="grpEELogging">
<property name="title">
<string>EE</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="grpEELoggingGrid">
<item row="4" column="1">
<widget class="QCheckBox" name="chkEEDMACTRL">
<property name="text">
<string>DMA Control</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="chkEEMFIFO">
<property name="text">
<string>SPR / MFIFO</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="chkEEVIF">
<property name="text">
<string>VIF</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="chkEECOP1">
<property name="text">
<string>COP1 (FPU)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="chkEEMSKPATH3">
<property name="text">
<string>MSKPATH3</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkEECache">
<property name="text">
<string>Cache</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="chkEEGIF">
<property name="text">
<string>GIF</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkEER5900">
<property name="text">
<string>R5900</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkEECOP0">
<property name="text">
<string>COP0</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkEEMMIO">
<property name="text">
<string>HW Regs (MMIO)</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="chkEECounters">
<property name="text">
<string>Counters</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="chkEESIF">
<property name="text">
<string>SIF</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkEECOP2">
<property name="text">
<string>COP2 (VU0 Macro)</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="chkEEVIFCodes">
<property name="text">
<string>VIFCodes</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkEEMemory">
<property name="text">
<string>Memory</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkEEUNKNWNMMIO">
<property name="text">
<string>Unknown MMIO</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="chkEEIPU">
<property name="text">
<string>IPU</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="chkEEBIOS">
<property name="text">
<string>BIOS</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkEEDMARegs">
<property name="text">
<string>DMA Registers</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="chkEEGIFTags">
<property name="text">
<string>GIFTags</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="eeLoggingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpIOPLogging">
<property name="title">
<string>IOP</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="grpIOPLoggingGrid">
<item row="4" column="0">
<widget class="QCheckBox" name="chkIOPCounters">
<property name="text">
<string>Counters</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkIOPUNKNWNMMIO">
<property name="text">
<string>Unknown MMIO</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkIOPMMIO">
<property name="text">
<string>HW Regs (MMIO)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkIOPCDVD">
<property name="text">
<string>CDVD</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="chkIOPR3000A">
<property name="text">
<string>R3000A</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkIOPMemcards">
<property name="text">
<string>Memcards</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkIOPDMARegs">
<property name="text">
<string>DMA Registers</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkIOPPad">
<property name="text">
<string>Pad</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chkIOPBIOS">
<property name="text">
<string>BIOS</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="chkIOPMDEC">
<property name="text">
<string>MDEC</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkIOPDMACTRL">
<property name="text">
<string>DMA Control</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkIOPCOP2">
<property name="text">
<string>COP2 (GPU)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="iopLoggingSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -450,41 +450,82 @@ enum class GSNativeScaling : u8
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// TraceFiltersEE // TraceLogsEE
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
struct TraceFiltersEE struct TraceLogsEE
{ {
// EE
BITFIELD32() BITFIELD32()
bool bool
m_EnableAll : 1, // Master Enable switch (if false, no logs at all) bios : 1,
m_EnableDisasm : 1, memory : 1,
m_EnableRegisters : 1, giftag : 1,
m_EnableEvents : 1; // Enables logging of event-driven activity -- counters, DMAs, etc. vifcode : 1,
mskpath3 : 1,
r5900 : 1,
cop0 : 1,
cop1 : 1,
cop2 : 1,
cache : 1,
knownhw : 1,
unknownhw : 1,
dmahw : 1,
ipu : 1,
dmac : 1,
counters : 1,
spr : 1,
vif : 1,
gif : 1;
BITFIELD_END BITFIELD_END
TraceFiltersEE(); TraceLogsEE();
bool operator==(const TraceFiltersEE& right) const; bool operator==(const TraceLogsEE& right) const;
bool operator!=(const TraceFiltersEE& right) const; bool operator!=(const TraceLogsEE& right) const;
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// TraceFiltersIOP // TraceLogsIOP
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
struct TraceFiltersIOP struct TraceLogsIOP
{ {
BITFIELD32() BITFIELD32()
bool bool
m_EnableAll : 1, // Master Enable switch (if false, no logs at all) bios : 1,
m_EnableDisasm : 1, memcards : 1,
m_EnableRegisters : 1, pad : 1,
m_EnableEvents : 1; // Enables logging of event-driven activity -- counters, DMAs, etc. r3000a : 1,
cop2 : 1,
memory : 1,
knownhw : 1,
unknownhw : 1,
dmahw : 1,
dmac : 1,
counters : 1,
cdvd : 1,
mdec : 1;
BITFIELD_END BITFIELD_END
TraceFiltersIOP(); TraceLogsIOP();
bool operator==(const TraceFiltersIOP& right) const; bool operator==(const TraceLogsIOP& right) const;
bool operator!=(const TraceFiltersIOP& right) const; bool operator!=(const TraceLogsIOP& right) const;
};
// --------------------------------------------------------------------------------------
// TraceLogsMISC
// --------------------------------------------------------------------------------------
struct TraceLogsMISC
{
BITFIELD32()
bool
sif : 1;
BITFIELD_END
TraceLogsMISC();
bool operator==(const TraceLogsMISC& right) const;
bool operator!=(const TraceLogsMISC& right) const;
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
@ -492,21 +533,18 @@ struct TraceFiltersIOP
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
struct TraceLogFilters struct TraceLogFilters
{ {
// Enabled - global toggle for high volume logging. This is effectively the equivalent to
// (EE.Enabled() || IOP.Enabled() || SIF) -- it's cached so that we can use the macros
// below to inline the conditional check. This is desirable because these logs are
// *very* high volume, and debug builds get noticably slower if they have to invoke
// methods/accessors to test the log enable bits. Debug builds are slow enough already,
// so I prefer this to help keep them usable.
bool Enabled; bool Enabled;
TraceFiltersEE EE; TraceLogsEE EE;
TraceFiltersIOP IOP; TraceLogsIOP IOP;
TraceLogsMISC MISC;
TraceLogFilters(); TraceLogFilters();
void LoadSave(SettingsWrapper& ini); void LoadSave(SettingsWrapper& ini);
// When logging, the tracelogpack is checked, not was in the config.
// Call this to sync the tracelogpack values with the config values.
void SyncToConfig() const;
bool operator==(const TraceLogFilters& right) const; bool operator==(const TraceLogFilters& right) const;
bool operator!=(const TraceLogFilters& right) const; bool operator!=(const TraceLogFilters& right) const;
}; };

View File

@ -499,8 +499,7 @@ static __fi void VSyncStart(u32 sCycle)
// Poll input after MTGS frame push, just in case it has to stall to catch up. // Poll input after MTGS frame push, just in case it has to stall to catch up.
VMManager::Internal::PollInputOnCPUThread(); VMManager::Internal::PollInputOnCPUThread();
if (EmuConfig.Trace.Enabled && EmuConfig.Trace.EE.m_EnableAll) EECNT_LOG(" ================ EE COUNTER VSYNC START (frame: %d) ================", g_FrameCount);
SysTrace.EE.Counters.Write(" ================ EE COUNTER VSYNC START (frame: %d) ================", g_FrameCount);
// Memcard auto ejection - Uses a tick system timed off of real time, decrementing one tick per frame. // Memcard auto ejection - Uses a tick system timed off of real time, decrementing one tick per frame.
AutoEject::CountDownTicks(); AutoEject::CountDownTicks();
@ -564,8 +563,7 @@ static __fi void GSVSync()
static __fi void VSyncEnd(u32 sCycle) static __fi void VSyncEnd(u32 sCycle)
{ {
if (EmuConfig.Trace.Enabled && EmuConfig.Trace.EE.m_EnableAll) EECNT_LOG(" ================ EE COUNTER VSYNC END (frame: %d) ================", g_FrameCount);
SysTrace.EE.Counters.Write(" ================ EE COUNTER VSYNC END (frame: %d) ================", g_FrameCount);
g_FrameCount++; g_FrameCount++;
if (!GSSMODE1reg.SINT) if (!GSSMODE1reg.SINT)

View File

@ -3,15 +3,12 @@
#pragma once #pragma once
#include "common/TraceLog.h" #include "common/Console.h"
#include "Config.h" #include "Config.h"
#include "Memory.h" #include "Memory.h"
#include <string> #include <string>
// TODO: Purge emuLog and all this other nonsense, just go through Log with LOGLEVEL_TRACE.
extern FILE *emuLog;
extern char* disVU0MicroUF(u32 code, u32 pc); extern char* disVU0MicroUF(u32 code, u32 pc);
extern char* disVU0MicroLF(u32 code, u32 pc); extern char* disVU0MicroLF(u32 code, u32 pc);
extern char* disVU1MicroUF(u32 code, u32 pc); extern char* disVU1MicroUF(u32 code, u32 pc);
@ -19,16 +16,16 @@ extern char* disVU1MicroLF(u32 code, u32 pc);
namespace R5900 namespace R5900
{ {
void disR5900Fasm( std::string& output, u32 code, u32 pc, bool simplify = false); void disR5900Fasm(std::string& output, u32 code, u32 pc, bool simplify = false);
extern const char * const GPR_REG[32]; extern const char* const GPR_REG[32];
extern const char * const COP0_REG[32]; extern const char* const COP0_REG[32];
extern const char * const COP1_REG_FP[32]; extern const char* const COP1_REG_FP[32];
extern const char * const COP1_REG_FCR[32]; extern const char* const COP1_REG_FCR[32];
extern const char * const COP2_REG_FP[32]; extern const char* const COP2_REG_FP[32];
extern const char * const COP2_REG_CTL[32]; extern const char* const COP2_REG_CTL[32];
extern const char * const COP2_VFnames[4]; extern const char* const COP2_VFnames[4];
extern const char * const GS_REG_PRIV[19]; extern const char* const GS_REG_PRIV[19];
extern const u32 GS_REG_PRIV_ADDR[19]; extern const u32 GS_REG_PRIV_ADDR[19];
} }
@ -40,163 +37,50 @@ namespace R3000A
extern char* disR3000AF(u32 code, u32 pc); extern char* disR3000AF(u32 code, u32 pc);
} }
// this structure uses old fashioned C-style "polymorphism". The base struct TraceLogDescriptor struct LogDescriptor
// must always be the first member in the struct.
struct SysTraceLogDescriptor
{ {
TraceLogDescriptor base; std::string Prefix;
const char* Prefix; std::string Name;
std::string Description;
};
struct LogBase
{
const LogDescriptor& Descriptor;
ConsoleColors Color;
bool Enabled = false;
LogBase(const LogDescriptor& descriptor, ConsoleColors color = Color_Gray)
: Descriptor(descriptor)
, Color(color) {};
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// SysTraceLog // TraceLog
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// Default trace log for high volume VM/System logging. struct TraceLog : public LogBase
// This log dumps to emuLog.txt directly and has no ability to pipe output
// to the console (due to the console's inability to handle extremely high
// logging volume).
class SysTraceLog : public TextFileTraceLog
{ {
public: TraceLog(const LogDescriptor& descriptor, ConsoleColors color = Color_Gray)
// Pass me a NULL and you *will* suffer! Muahahaha. : LogBase(descriptor, color) {};
SysTraceLog( const SysTraceLogDescriptor* desc )
: TextFileTraceLog( &desc->base ) {}
void DoWrite( const char *fmt ) const override; bool Write(const char* fmt, ...) const;
bool IsActive() const override bool Write(ConsoleColors color, const char* fmt, ...) const;
bool IsActive() const
{ {
return EmuConfig.Trace.Enabled && Enabled; return EmuConfig.Trace.Enabled && Enabled;
} }
}; };
class SysTraceLog_EE : public SysTraceLog struct ConsoleLog : public LogBase
{ {
typedef SysTraceLog _parent; ConsoleLog(const LogDescriptor& descriptor, ConsoleColors color = Color_Gray)
: LogBase(descriptor, color) {};
public: bool Write(const char* fmt, ...) const;
SysTraceLog_EE( const SysTraceLogDescriptor* desc ) : _parent( desc ) {} bool Write(ConsoleColors color, const char* fmt, ...) const;
bool IsActive() const
void ApplyPrefix( std::string& ascii ) const override;
bool IsActive() const override
{ {
return SysTraceLog::IsActive() && EmuConfig.Trace.EE.m_EnableAll; return Enabled;
} }
std::string GetCategory() const override { return "EE"; }
};
class SysTraceLog_VIFcode : public SysTraceLog_EE
{
typedef SysTraceLog_EE _parent;
public:
SysTraceLog_VIFcode( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
void ApplyPrefix(std::string& ascii ) const override;
};
class SysTraceLog_EE_Disasm : public SysTraceLog_EE
{
typedef SysTraceLog_EE _parent;
public:
SysTraceLog_EE_Disasm( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableDisasm;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Disasm"; }
};
class SysTraceLog_EE_Registers : public SysTraceLog_EE
{
typedef SysTraceLog_EE _parent;
public:
SysTraceLog_EE_Registers( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableRegisters;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Registers"; }
};
class SysTraceLog_EE_Events : public SysTraceLog_EE
{
typedef SysTraceLog_EE _parent;
public:
SysTraceLog_EE_Events( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableEvents;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Events"; }
};
class SysTraceLog_IOP : public SysTraceLog
{
typedef SysTraceLog _parent;
public:
SysTraceLog_IOP( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
void ApplyPrefix( std::string& ascii ) const override;
bool IsActive() const override
{
return SysTraceLog::IsActive() && EmuConfig.Trace.IOP.m_EnableAll;
}
std::string GetCategory() const override { return "IOP"; }
};
class SysTraceLog_IOP_Disasm : public SysTraceLog_IOP
{
typedef SysTraceLog_IOP _parent;
public:
SysTraceLog_IOP_Disasm( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableDisasm;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Disasm"; }
};
class SysTraceLog_IOP_Registers : public SysTraceLog_IOP
{
typedef SysTraceLog_IOP _parent;
public:
SysTraceLog_IOP_Registers( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableRegisters;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Registers"; }
};
class SysTraceLog_IOP_Events : public SysTraceLog_IOP
{
typedef SysTraceLog_IOP _parent;
public:
SysTraceLog_IOP_Events( const SysTraceLogDescriptor* desc ) : _parent( desc ) {}
bool IsActive() const override
{
return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableEvents;
}
std::string GetCategory() const override { return _parent::GetCategory() + ".Events"; }
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
@ -209,12 +93,10 @@ public:
// string data. (otherwise %'s would get mis-interpreted). // string data. (otherwise %'s would get mis-interpreted).
// //
template< ConsoleColors conColor > template< ConsoleColors conColor >
class ConsoleLogFromVM : public BaseTraceLogSource class ConsoleLogFromVM : public LogBase
{ {
typedef BaseTraceLogSource _parent;
public: public:
ConsoleLogFromVM( const TraceLogDescriptor* desc ) : _parent( desc ) {} ConsoleLogFromVM(const LogDescriptor& descriptor) : LogBase(descriptor, conColor) {};
bool Write(std::string_view msg) bool Write(std::string_view msg)
{ {
@ -242,82 +124,85 @@ public:
return false; return false;
} }
bool IsActive()
{
return Enabled;
}
private: private:
std::string m_buffer; std::string m_buffer;
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// SysTraceLogPack // TraceLogPack
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
struct SysTraceLogPack struct TraceLogPack
{ {
// TODO : Sif has special logging needs.. ? TraceLog SIF;
SysTraceLog SIF;
struct EE_PACK struct EE_PACK
{ {
SysTraceLog_EE Bios; TraceLog Bios;
SysTraceLog_EE Memory; TraceLog Memory;
SysTraceLog_EE GIFtag; TraceLog GIFtag;
SysTraceLog_VIFcode VIFcode; TraceLog VIFcode;
SysTraceLog_EE MSKPATH3; TraceLog MSKPATH3;
SysTraceLog_EE_Disasm R5900; TraceLog R5900;
SysTraceLog_EE_Disasm COP0; TraceLog COP0;
SysTraceLog_EE_Disasm COP1; TraceLog COP1;
SysTraceLog_EE_Disasm COP2; TraceLog COP2;
SysTraceLog_EE_Disasm Cache; TraceLog Cache;
SysTraceLog_EE_Registers KnownHw; TraceLog KnownHw;
SysTraceLog_EE_Registers UnknownHw; TraceLog UnknownHw;
SysTraceLog_EE_Registers DMAhw; TraceLog DMAhw;
SysTraceLog_EE_Registers IPU; TraceLog IPU;
SysTraceLog_EE_Events DMAC; TraceLog DMAC;
SysTraceLog_EE_Events Counters; TraceLog Counters;
SysTraceLog_EE_Events SPR; TraceLog SPR;
SysTraceLog_EE_Events VIF; TraceLog VIF;
SysTraceLog_EE_Events GIF; TraceLog GIF;
EE_PACK(); EE_PACK();
} EE; } EE;
struct IOP_PACK struct IOP_PACK
{ {
SysTraceLog_IOP Bios; TraceLog Bios;
SysTraceLog_IOP Memcards; TraceLog Memcards;
SysTraceLog_IOP PAD; TraceLog PAD;
SysTraceLog_IOP_Disasm R3000A; TraceLog R3000A;
SysTraceLog_IOP_Disasm COP2; TraceLog COP2;
SysTraceLog_IOP_Disasm Memory; TraceLog Memory;
SysTraceLog_IOP_Registers KnownHw; TraceLog KnownHw;
SysTraceLog_IOP_Registers UnknownHw; TraceLog UnknownHw;
SysTraceLog_IOP_Registers DMAhw; TraceLog DMAhw;
// TODO items to be added, or removed? I can't remember which! --air // TODO items to be added, or removed? I can't remember which! --air
//SysTraceLog_IOP_Registers SPU2; //TraceLog_IOP_Registers SPU2;
//SysTraceLog_IOP_Registers USB; //TraceLog_IOP_Registers USB;
//SysTraceLog_IOP_Registers FW; //TraceLog_IOP_Registers FW;
SysTraceLog_IOP_Events DMAC; TraceLog DMAC;
SysTraceLog_IOP_Events Counters; TraceLog Counters;
SysTraceLog_IOP_Events CDVD; TraceLog CDVD;
SysTraceLog_IOP_Events MDEC; TraceLog MDEC;
IOP_PACK(); IOP_PACK();
} IOP; } IOP;
SysTraceLogPack(); TraceLogPack();
}; };
struct SysConsoleLogPack struct ConsoleLogPack
{ {
ConsoleLogSource ELF; ConsoleLog ELF;
ConsoleLogSource eeRecPerf; ConsoleLog eeRecPerf;
ConsoleLogSource pgifLog; ConsoleLog pgifLog;
ConsoleLogFromVM<Color_Cyan> eeConsole; ConsoleLogFromVM<Color_Cyan> eeConsole;
ConsoleLogFromVM<Color_Yellow> iopConsole; ConsoleLogFromVM<Color_Yellow> iopConsole;
@ -325,26 +210,24 @@ struct SysConsoleLogPack
ConsoleLogFromVM<Color_StrongMagenta> recordingConsole; ConsoleLogFromVM<Color_StrongMagenta> recordingConsole;
ConsoleLogFromVM<Color_Red> controlInfo; ConsoleLogFromVM<Color_Red> controlInfo;
SysConsoleLogPack(); ConsoleLogPack();
}; };
extern SysTraceLogPack SysTrace; extern TraceLogPack TraceLogging;
extern SysConsoleLogPack SysConsole; extern ConsoleLogPack ConsoleLogging;
extern void __Log( const char* fmt, ... );
// Helper macro for cut&paste. Note that we intentionally use a top-level *inline* bitcheck // Helper macro for cut&paste. Note that we intentionally use a top-level *inline* bitcheck
// against Trace.Enabled, to avoid extra overhead in Debug builds when logging is disabled. // against Trace.Enabled, to avoid extra overhead in Debug builds when logging is disabled.
// (specifically this allows debug builds to skip havingto resolve all the parameters being // (specifically this allows debug builds to skip havingto resolve all the parameters being
// passed into the function) // passed into the function)
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
# define SysTraceActive(trace) SysTrace.trace.IsActive() # define TraceActive(trace) TraceLogging.trace.IsActive()
#else #else
# define SysTraceActive(trace) (false) # define TraceActive(trace) (false)
#endif #endif
#define macTrace(trace) SysTraceActive(trace) && SysTrace.trace.Write #define macTrace(trace) TraceActive(trace) && TraceLogging.trace.Write
#define SIF_LOG macTrace(SIF) #define SIF_LOG macTrace(SIF)
@ -381,11 +264,11 @@ extern void __Log( const char* fmt, ... );
#define MDEC_LOG macTrace(IOP.MDEC) #define MDEC_LOG macTrace(IOP.MDEC)
#define ELF_LOG SysConsole.ELF.IsActive() && SysConsole.ELF.Write #define ELF_LOG ConsoleLogging.ELF.IsActive() && ConsoleLogging.ELF.Write
#define eeRecPerfLog SysConsole.eeRecPerf.IsActive() && SysConsole.eeRecPerf #define eeRecPerfLog ConsoleLogging.eeRecPerf.IsActive() && ConsoleLogging.eeRecPerf
#define eeConLog SysConsole.eeConsole.IsActive() && SysConsole.eeConsole.Write #define eeConLog ConsoleLogging.eeConsole.IsActive() && ConsoleLogging.eeConsole.Write
#define eeDeci2Log SysConsole.deci2.IsActive() && SysConsole.deci2.Write #define eeDeci2Log ConsoleLogging.deci2.IsActive() && ConsoleLogging.deci2.Write
#define iopConLog SysConsole.iopConsole.IsActive() && SysConsole.iopConsole.Write #define iopConLog ConsoleLogging.iopConsole.IsActive() && ConsoleLogging.iopConsole.Write
#define pgifConLog SysConsole.pgifLog.IsActive() && SysConsole.pgifLog.Write #define pgifConLog ConsoleLogging.pgifLog.IsActive() && ConsoleLogging.pgifLog.Write
#define recordingConLog SysConsole.recordingConsole.IsActive() && SysConsole.recordingConsole.Write #define recordingConLog ConsoleLogging.recordingConsole.IsActive() && ConsoleLogging.recordingConsole.Write
#define controlLog SysConsole.controlInfo.IsActive() && SysConsole.controlInfo.Write #define controlLog ConsoleLogging.controlInfo.IsActive() && ConsoleLogging.controlInfo.Write

View File

@ -7,7 +7,7 @@
#include "DisassemblyManager.h" #include "DisassemblyManager.h"
#include "Memory.h" #include "Memory.h"
#include "Debug.h" #include "common/StringUtil.h"
#include "MIPSAnalyst.h" #include "MIPSAnalyst.h"
int DisassemblyManager::maxParamChars = 29; int DisassemblyManager::maxParamChars = 29;

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0+ // SPDX-License-Identifier: GPL-3.0+
#include "MIPSAnalyst.h" #include "MIPSAnalyst.h"
#include "common/StringUtil.h"
#include "Debug.h" #include "Debug.h"
#include "DebugInterface.h" #include "DebugInterface.h"
#include "DebugInterface.h" #include "DebugInterface.h"

View File

@ -936,7 +936,7 @@ namespace R3000A
// printf-style formatting processing. This part can be skipped if the user has the // printf-style formatting processing. This part can be skipped if the user has the
// console disabled. // console disabled.
if (!SysConsole.iopConsole.IsActive()) if (!ConsoleLogging.iopConsole.IsActive())
return 1; return 1;
char tmp[1024], tmp2[1024]; char tmp[1024], tmp2[1024];

View File

@ -173,32 +173,47 @@ namespace EmuFolders
static std::string GetPortableModePath(); static std::string GetPortableModePath();
} // namespace EmuFolders } // namespace EmuFolders
TraceFiltersEE::TraceFiltersEE() TraceLogsEE::TraceLogsEE()
{ {
bitset = 0; bitset = 0;
} }
bool TraceFiltersEE::operator==(const TraceFiltersEE& right) const bool TraceLogsEE::operator==(const TraceLogsEE& right) const
{ {
return OpEqu(bitset); return OpEqu(bitset);
} }
bool TraceFiltersEE::operator!=(const TraceFiltersEE& right) const bool TraceLogsEE::operator!=(const TraceLogsEE& right) const
{ {
return !this->operator==(right); return !this->operator==(right);
} }
TraceFiltersIOP::TraceFiltersIOP() TraceLogsIOP::TraceLogsIOP()
{ {
bitset = 0; bitset = 0;
} }
bool TraceFiltersIOP::operator==(const TraceFiltersIOP& right) const bool TraceLogsIOP::operator==(const TraceLogsIOP& right) const
{ {
return OpEqu(bitset); return OpEqu(bitset);
} }
bool TraceFiltersIOP::operator!=(const TraceFiltersIOP& right) const bool TraceLogsIOP::operator!=(const TraceLogsIOP& right) const
{
return !this->operator==(right);
}
TraceLogsMISC::TraceLogsMISC()
{
bitset = 0;
}
bool TraceLogsMISC::operator==(const TraceLogsMISC& right) const
{
return OpEqu(bitset);
}
bool TraceLogsMISC::operator!=(const TraceLogsMISC& right) const
{ {
return !this->operator==(right); return !this->operator==(right);
} }
@ -214,16 +229,88 @@ void TraceLogFilters::LoadSave(SettingsWrapper& wrap)
SettingsWrapEntry(Enabled); SettingsWrapEntry(Enabled);
// Retaining backwards compat of the trace log enablers isn't really important, and SettingsWrapBitBool(EE.bios);
// doing each one by hand would be murder. So let's cheat and just save it as an int: SettingsWrapBitBool(EE.memory);
SettingsWrapBitBool(EE.giftag);
SettingsWrapBitBool(EE.vifcode);
SettingsWrapBitBool(EE.mskpath3);
SettingsWrapBitBool(EE.r5900);
SettingsWrapBitBool(EE.cop0);
SettingsWrapBitBool(EE.cop1);
SettingsWrapBitBool(EE.cop2);
SettingsWrapBitBool(EE.cache);
SettingsWrapBitBool(EE.knownhw);
SettingsWrapBitBool(EE.unknownhw);
SettingsWrapBitBool(EE.dmahw);
SettingsWrapBitBool(EE.ipu);
SettingsWrapBitBool(EE.dmac);
SettingsWrapBitBool(EE.counters);
SettingsWrapBitBool(EE.spr);
SettingsWrapBitBool(EE.vif);
SettingsWrapBitBool(EE.gif);
SettingsWrapEntry(EE.bitset); SettingsWrapBitBool(IOP.bios);
SettingsWrapEntry(IOP.bitset); SettingsWrapBitBool(IOP.memcards);
SettingsWrapBitBool(IOP.pad);
SettingsWrapBitBool(IOP.r3000a);
SettingsWrapBitBool(IOP.cop2);
SettingsWrapBitBool(IOP.memory);
SettingsWrapBitBool(IOP.knownhw);
SettingsWrapBitBool(IOP.unknownhw);
SettingsWrapBitBool(IOP.dmahw);
SettingsWrapBitBool(IOP.dmac);
SettingsWrapBitBool(IOP.counters);
SettingsWrapBitBool(IOP.cdvd);
SettingsWrapBitBool(IOP.mdec);
SettingsWrapBitBool(MISC.sif);
}
void TraceLogFilters::SyncToConfig() const
{
auto& ee = TraceLogging.EE;
ee.Bios.Enabled = EE.bios;
ee.Memory.Enabled = EE.memory;
ee.GIFtag.Enabled = EE.giftag;
ee.VIFcode.Enabled = EE.vifcode;
ee.MSKPATH3.Enabled = EE.mskpath3;
ee.R5900.Enabled = EE.r5900;
ee.COP0.Enabled = EE.cop0;
ee.COP1.Enabled = EE.cop1;
ee.COP2.Enabled = EE.cop2;
ee.KnownHw.Enabled = EE.knownhw;
ee.UnknownHw.Enabled = EE.unknownhw;
ee.DMAhw.Enabled = EE.dmahw;
ee.IPU.Enabled = EE.ipu;
ee.DMAC.Enabled = EE.dmac;
ee.Counters.Enabled = EE.counters;
ee.SPR.Enabled = EE.spr;
ee.VIF.Enabled = EE.vif;
ee.GIF.Enabled = EE.gif;
auto& iop = TraceLogging.IOP;
iop.Bios.Enabled = IOP.bios;
iop.Memcards.Enabled = IOP.memcards;
iop.PAD.Enabled = IOP.pad;
iop.R3000A.Enabled = IOP.r3000a;
iop.COP2.Enabled = IOP.cop2;
iop.Memory.Enabled = IOP.memory;
iop.KnownHw.Enabled = IOP.knownhw;
iop.UnknownHw.Enabled = IOP.unknownhw;
iop.DMAhw.Enabled = IOP.dmahw;
iop.DMAC.Enabled = IOP.dmac;
iop.Counters.Enabled = IOP.counters;
iop.CDVD.Enabled = IOP.cdvd;
iop.MDEC.Enabled = IOP.mdec;
TraceLogging.SIF.Enabled = MISC.sif;
EmuConfig.Trace.Enabled = Enabled;
} }
bool TraceLogFilters::operator==(const TraceLogFilters& right) const bool TraceLogFilters::operator==(const TraceLogFilters& right) const
{ {
return OpEqu(Enabled) && OpEqu(EE) && OpEqu(IOP); return OpEqu(Enabled) && OpEqu(EE) && OpEqu(IOP) && OpEqu(MISC);
} }
bool TraceLogFilters::operator!=(const TraceLogFilters& right) const bool TraceLogFilters::operator!=(const TraceLogFilters& right) const

View File

@ -1066,7 +1066,7 @@ void SYSCALL()
break; break;
case Syscall::sceSifSetDma: case Syscall::sceSifSetDma:
// The only thing this code is used for is the one log message, so don't execute it if we aren't logging bios messages. // The only thing this code is used for is the one log message, so don't execute it if we aren't logging bios messages.
if (SysTraceActive(EE.Bios)) if (TraceActive(EE.Bios))
{ {
//struct t_sif_cmd_header *hdr; //struct t_sif_cmd_header *hdr;
//struct t_sif_rpc_bind *bind; //struct t_sif_rpc_bind *bind;

View File

@ -6,6 +6,7 @@
#include "Utilities/InputRecordingLogger.h" #include "Utilities/InputRecordingLogger.h"
#include "common/FileSystem.h" #include "common/FileSystem.h"
#include "common/StringUtil.h"
#include "DebugTools/Debug.h" #include "DebugTools/Debug.h"
#include "MemoryTypes.h" #include "MemoryTypes.h"
#include "svnrev.h" #include "svnrev.h"

View File

@ -24,226 +24,217 @@
using namespace R5900; using namespace R5900;
FILE* emuLog; TraceLogPack TraceLogging;
ConsoleLogPack ConsoleLogging;
SysTraceLogPack SysTrace; bool TraceLog::Write(const char* fmt, ...) const
SysConsoleLogPack SysConsole;
// writes text directly to the logfile, no newlines appended.
void __Log(const char* fmt, ...)
{ {
va_list list; auto prefixed_str = fmt::format("{:<8}: {}", Descriptor.Prefix, fmt);
va_start(list, fmt); va_list args;
va_start(args, fmt);
Log::Writev(LOGLEVEL_TRACE, Color, prefixed_str.c_str(), args);
va_end(args);
if (emuLog != NULL) return false;
{
std::vfprintf(emuLog, fmt, list);
fputs("\n", emuLog);
fflush(emuLog);
}
va_end(list);
} }
void SysTraceLog::DoWrite(const char* msg) const bool TraceLog::Write(ConsoleColors color, const char* fmt, ...) const
{ {
if (emuLog == NULL) auto prefixed_str = fmt::format("{:<8}: {}", Descriptor.Prefix, fmt);
return; va_list args;
va_start(args, fmt);
Log::Writev(LOGLEVEL_TRACE, color, prefixed_str.c_str(), args);
va_end(args);
fputs(msg, emuLog); return false;
fputs("\n", emuLog);
fflush(emuLog);
} }
void SysTraceLog_EE::ApplyPrefix(std::string& ascii) const bool ConsoleLog::Write(const char* fmt, ...) const
{ {
fmt::format_to(std::back_inserter(ascii), "{:<4}({:08x} {:08x}): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, cpuRegs.pc, cpuRegs.cycle); auto prefixed_str = fmt::format("{:<8}: {}", Descriptor.Prefix, fmt);
va_list args;
va_start(args, fmt);
Console.WriteLn(Color, prefixed_str.c_str(), args);
va_end(args);
return false;
} }
void SysTraceLog_IOP::ApplyPrefix(std::string& ascii) const bool ConsoleLog::Write(ConsoleColors color, const char* fmt, ...) const
{ {
fmt::format_to(std::back_inserter(ascii), "{:<4}({:08x} {:08x}): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, psxRegs.pc, psxRegs.cycle); auto prefixed_str = fmt::format("{:<8}: {}", Descriptor.Prefix, fmt);
}
void SysTraceLog_VIFcode::ApplyPrefix(std::string& ascii) const va_list args;
{ va_start(args, fmt);
_parent::ApplyPrefix(ascii); Console.WriteLn(color, prefixed_str.c_str(), args);
ascii.append("vifCode_"); va_end(args);
return false;
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// SysConsoleLogPack (descriptions) // ConsoleLogPack (descriptions)
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
static const TraceLogDescriptor static const LogDescriptor
TLD_ELF = { LD_ELF = {
"ELF", "E&LF", "ELF", "E&LF",
"Dumps detailed information for PS2 executables (ELFs)."}, "Dumps detailed information for PS2 executables (ELFs)."},
TLD_eeRecPerf = {"EErecPerf", "EErec &Performance", "Logs manual protection, split blocks, and other things that might impact performance."}, LD_eeRecPerf = {"EErecPerf", "EErec &Performance", "Logs manual protection, split blocks, and other things that might impact performance."},
TLD_eeConsole = {"EEout", "EE C&onsole", "Shows the game developer's logging text (EE processor)."}, LD_eeConsole = {"EEout", "EE C&onsole", "Shows the game developer's logging text (EE processor)."},
TLD_iopConsole = {"IOPout", "&IOP Console", "Shows the game developer's logging text (IOP processor)."}, LD_iopConsole = {"IOPout", "&IOP Console", "Shows the game developer's logging text (IOP processor)."},
TLD_deci2 = {"DECI2", "DECI&2 Console", "Shows DECI2 debugging logs (EE processor)."}, LD_deci2 = {"DECI2", "DECI&2 Console", "Shows DECI2 debugging logs (EE processor)."},
TLD_Pgif = {"PGIFout", "&PGIF Console", "Shows output from pgif the emulated ps1 gpu"}, LD_Pgif = {"PGIFout", "&PGIF Console", "Shows output from pgif the emulated ps1 gpu"},
TLD_recordingConsole = {"Input Recording", "Input Recording Console", "Shows recording related logs and information."}, LD_recordingConsole = {"Input Recording", "Input Recording Console", "Shows recording related logs and information."},
TLD_controlInfo = {"Controller Info", "Controller Info", "Shows detailed controller input values for port 1, every frame."} LD_controlInfo = {"Controller Info", "Controller Info", "Shows detailed controller input values for port 1, every frame."};
; // End init of TraceLogDescriptors
SysConsoleLogPack::SysConsoleLogPack() ConsoleLogPack::ConsoleLogPack()
: ELF(&TLD_ELF, Color_Gray) : ELF(LD_ELF, Color_Gray)
, eeRecPerf(&TLD_eeRecPerf, Color_Gray) , eeRecPerf(LD_eeRecPerf, Color_Gray)
, pgifLog(&TLD_Pgif) , pgifLog(LD_Pgif)
, eeConsole(&TLD_eeConsole) , eeConsole(LD_eeConsole)
, iopConsole(&TLD_iopConsole) , iopConsole(LD_iopConsole)
, deci2(&TLD_deci2) , deci2(LD_deci2)
, recordingConsole(&TLD_recordingConsole) , recordingConsole(LD_recordingConsole)
, controlInfo(&TLD_controlInfo) , controlInfo(LD_controlInfo)
{ {
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// SysTraceLogPack (descriptions) // TraceLogPack (descriptions)
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
static const SysTraceLogDescriptor static const LogDescriptor
TLD_SIF = { LD_SIF = {"SIF", "SIF (EE <-> IOP)", ""};
{"SIF", "SIF (EE <-> IOP)",
""},
"SIF"};
// ---------------------------- // ----------------------------
// EmotionEngine (EE/R5900) // EmotionEngine (EE/R5900)
// ---------------------------- // ----------------------------
static const SysTraceLogDescriptor static const LogDescriptor
TLD_EE_Bios = { LD_EE_Bios = {"Bios", "Bios", "SYSCALL and DECI2 activity."},
{"Bios", "Bios",
"SYSCALL and DECI2 activity."},
"EE"},
TLD_EE_Memory = {{"Memory", "Memory", "Direct memory accesses to unknown or unmapped EE memory space."}, "eMem"}, LD_EE_Memory = {"Memory", "Memory", "Direct memory accesses to unknown or unmapped EE memory space."},
TLD_EE_R5900 = {{"R5900", "R5900 Core", "Disasm of executing core instructions (excluding COPs and CACHE)."}, "eDis"}, LD_EE_R5900 = {"R5900", "R5900 Core", "Disasm of executing core instructions (excluding COPs and CACHE)."},
TLD_EE_COP0 = {{"COP0", "COP0", "Disasm of COP0 instructions (MMU, cpu and dma status, etc)."}, "eDis"}, LD_EE_COP0 = {"COP0", "COP0", "Disasm of COP0 instructions (MMU, cpu and dma status, etc)."},
TLD_EE_COP1 = {{"FPU", "COP1/FPU", "Disasm of the EE's floating point unit (FPU) only."}, "eDis"}, LD_EE_COP1 = {"FPU", "COP1/FPU", "Disasm of the EE's floating point unit (FPU) only."},
TLD_EE_COP2 = {{"VUmacro", "COP2/VUmacro", "Disasm of the EE's VU0macro co-processor instructions."}, "eDis"}, LD_EE_COP2 = {"VUmacro", "COP2/VUmacro", "Disasm of the EE's VU0macro co-processor instructions."},
TLD_EE_Cache = {{"Cache", "Cache", "Execution of EE cache instructions."}, "eDis"}, LD_EE_Cache = {"Cache", "Cache", "Execution of EE cache instructions."},
TLD_EE_KnownHw = {{"HwRegs", "Hardware Regs", "All known hardware register accesses (very slow!); not including sub filter options below."}, "eReg"}, LD_EE_KnownHw = {"HwRegs", "Hardware Regs", "All known hardware register accesses (very slow!); not including sub filter options below."},
TLD_EE_UnknownHw = {{"UnknownRegs", "Unknown Regs", "Logs only unknown, unmapped, or unimplemented register accesses."}, "eReg"}, LD_EE_UnknownHw = {"UnknownRegs", "Unknown Regs", "Logs only unknown, unmapped, or unimplemented register accesses."},
TLD_EE_DMAhw = {{"DmaRegs", "DMA Regs", "Logs only DMA-related registers."}, "eReg"}, LD_EE_DMAhw = {"DmaRegs", "DMA Regs", "Logs only DMA-related registers."},
TLD_EE_IPU = {{"IPU", "IPU", "IPU activity: hardware registers, decoding operations, DMA status, etc."}, "IPU"}, LD_EE_IPU = {"IPU", "IPU", "IPU activity: hardware registers, decoding operations, DMA status, etc."},
TLD_EE_GIFtag = {{"GIFtags", "GIFtags", "All GIFtag parse activity; path index, tag type, etc."}, "GIF"}, LD_EE_GIFtag = {"GIFtags", "GIFtags", "All GIFtag parse activity; path index, tag type, etc."},
TLD_EE_VIFcode = {{"VIFcodes", "VIFcodes", "All VIFcode processing; command, tag style, interrupts."}, "VIF"}, LD_EE_VIFcode = {"VIFcodes", "VIFcodes", "All VIFcode processing; command, tag style, interrupts."},
TLD_EE_MSKPATH3 = {{"MSKPATH3", "MSKPATH3", "All processing involved in Path3 Masking."}, "MSKPATH3"}, LD_EE_MSKPATH3 = {"MSKPATH3", "MSKPATH3", "All processing involved in Path3 Masking."},
TLD_EE_SPR = {{"MFIFO", "Scratchpad MFIFO", "Scratchpad's MFIFO activity."}, "SPR"}, LD_EE_SPR = {"MFIFO", "Scratchpad MFIFO", "Scratchpad's MFIFO activity."},
TLD_EE_DMAC = {{"DmaCtrl", "DMA Controller", "Actual data transfer logs, bus right arbitration, stalls, etc."}, "eDmaC"}, LD_EE_DMAC = {"DmaCtrl", "DMA Controller", "Actual data transfer logs, bus right arbitration, stalls, etc."},
TLD_EE_Counters = {{"Counters", "Counters", "Tracks all EE counters events and some counter register activity."}, "eCnt"}, LD_EE_Counters = {"Counters", "Counters", "Tracks all EE counters events and some counter register activity."},
TLD_EE_VIF = {{"VIF", "VIF", "Dumps various VIF and VIFcode processing data."}, "VIF"}, LD_EE_VIF = {"VIF", "VIF", "Dumps various VIF and VIFcode processing data."},
TLD_EE_GIF = {{"GIF", "GIF", "Dumps various GIF and GIFtag parsing data."}, "GIF"}; LD_EE_GIF = {"GIF", "GIF", "Dumps various GIF and GIFtag parsing data."};
// ---------------------------------- // ----------------------------------
// IOP - Input / Output Processor // IOP - Input / Output Processor
// ---------------------------------- // ----------------------------------
static const SysTraceLogDescriptor static const LogDescriptor
TLD_IOP_Bios = { LD_IOP_Bios = {"Bios", "Bios", "SYSCALL and IRX activity."},
{"Bios", "Bios",
"SYSCALL and IRX activity."},
"IOP"},
TLD_IOP_Memory = {{"Memory", "Memory", "Direct memory accesses to unknown or unmapped IOP memory space."}, "iMem"}, LD_IOP_Memory = {"Memory", "Memory", "Direct memory accesses to unknown or unmapped IOP memory space."},
TLD_IOP_R3000A = {{"R3000A", "R3000A Core", "Disasm of executing core instructions (excluding COPs and CACHE)."}, "iDis"}, LD_IOP_R3000A = {"R3000A", "R3000A Core", "Disasm of executing core instructions (excluding COPs and CACHE)."},
TLD_IOP_COP2 = {{"COP2/GPU", "COP2", "Disasm of the IOP's GPU co-processor instructions."}, "iDis"}, LD_IOP_COP2 = {"COP2/GPU", "COP2", "Disasm of the IOP's GPU co-processor instructions."},
TLD_IOP_KnownHw = {{"HwRegs", "Hardware Regs", "All known hardware register accesses, not including the sub-filters below."}, "iReg"}, LD_IOP_KnownHw = {"HwRegs", "Hardware Regs", "All known hardware register accesses, not including the sub-filters below."},
TLD_IOP_UnknownHw = {{"UnknownRegs", "Unknown Regs", "Logs only unknown, unmapped, or unimplemented register accesses."}, "iReg"}, LD_IOP_UnknownHw = {"UnknownRegs", "Unknown Regs", "Logs only unknown, unmapped, or unimplemented register accesses."},
TLD_IOP_DMAhw = {{"DmaRegs", "DMA Regs", "Logs only DMA-related registers."}, "iReg"}, LD_IOP_DMAhw = {"DmaRegs", "DMA Regs", "Logs only DMA-related registers."},
TLD_IOP_Memcards = {{"Memorycards", "Memorycards", "Memorycard reads, writes, erases, terminators, and other processing."}, "Mcd"}, LD_IOP_Memcards = {"Memorycards", "Memorycards", "Memorycard reads, writes, erases, terminators, and other processing."},
TLD_IOP_PAD = {{"Pad", "Pad", "Gamepad activity on the SIO."}, "Pad"}, LD_IOP_PAD = {"Pad", "Pad", "Gamepad activity on the SIO."},
TLD_IOP_DMAC = {{"DmaCrl", "DMA Controller", "Actual DMA event processing and data transfer logs."}, "iDmaC"}, LD_IOP_DMAC = {"DmaCtrl", "DMA Controller", "Actual DMA event processing and data transfer logs."},
TLD_IOP_Counters = {{"Counters", "Counters", "Tracks all IOP counters events and some counter register activity."}, "iCnt"}, LD_IOP_Counters = {"Counters", "Counters", "Tracks all IOP counters events and some counter register activity."},
TLD_IOP_CDVD = {{"CDVD", "CDVD", "Detailed logging of CDVD hardware."}, "CDVD"}, LD_IOP_CDVD = {"CDVD", "CDVD", "Detailed logging of CDVD hardware."},
TLD_IOP_MDEC = {{"MDEC", "MDEC", "Detailed logging of the Motion (FMV) Decoder hardware unit."}, "MDEC"}; LD_IOP_MDEC = {"MDEC", "MDEC", "Detailed logging of the Motion (FMV) Decoder hardware unit."};
SysTraceLogPack::SysTraceLogPack() TraceLogPack::TraceLogPack()
: SIF(&TLD_SIF) : SIF(LD_SIF)
{ {
} }
SysTraceLogPack::EE_PACK::EE_PACK() TraceLogPack::EE_PACK::EE_PACK()
: Bios(&TLD_EE_Bios) : Bios(LD_EE_Bios)
, Memory(&TLD_EE_Memory) , Memory(LD_EE_Memory)
, GIFtag(&TLD_EE_GIFtag) , GIFtag(LD_EE_GIFtag)
, VIFcode(&TLD_EE_VIFcode) , VIFcode(LD_EE_VIFcode)
, MSKPATH3(&TLD_EE_MSKPATH3) , MSKPATH3(LD_EE_MSKPATH3)
, R5900(&TLD_EE_R5900) , R5900(LD_EE_R5900)
, COP0(&TLD_EE_COP0) , COP0(LD_EE_COP0)
, COP1(&TLD_EE_COP1) , COP1(LD_EE_COP1)
, COP2(&TLD_EE_COP2) , COP2(LD_EE_COP2)
, Cache(&TLD_EE_Cache) , Cache(LD_EE_Cache)
, KnownHw(&TLD_EE_KnownHw) , KnownHw(LD_EE_KnownHw)
, UnknownHw(&TLD_EE_UnknownHw) , UnknownHw(LD_EE_UnknownHw)
, DMAhw(&TLD_EE_DMAhw) , DMAhw(LD_EE_DMAhw)
, IPU(&TLD_EE_IPU) , IPU(LD_EE_IPU)
, DMAC(&TLD_EE_DMAC) , DMAC(LD_EE_DMAC)
, Counters(&TLD_EE_Counters) , Counters(LD_EE_Counters)
, SPR(&TLD_EE_SPR) , SPR(LD_EE_SPR)
, VIF(&TLD_EE_VIF) , VIF(LD_EE_VIF)
, GIF(&TLD_EE_GIF) , GIF(LD_EE_GIF)
{ {
} }
SysTraceLogPack::IOP_PACK::IOP_PACK() TraceLogPack::IOP_PACK::IOP_PACK()
: Bios(&TLD_IOP_Bios) : Bios(LD_IOP_Bios)
, Memcards(&TLD_IOP_Memcards) , Memcards(LD_IOP_Memcards)
, PAD(&TLD_IOP_PAD) , PAD(LD_IOP_PAD)
, R3000A(&TLD_IOP_R3000A) , R3000A(LD_IOP_R3000A)
, COP2(&TLD_IOP_COP2) , COP2(LD_IOP_COP2)
, Memory(&TLD_IOP_Memory) , Memory(LD_IOP_Memory)
, KnownHw(&TLD_IOP_KnownHw) , KnownHw(LD_IOP_KnownHw)
, UnknownHw(&TLD_IOP_UnknownHw) , UnknownHw(LD_IOP_UnknownHw)
, DMAhw(&TLD_IOP_DMAhw) , DMAhw(LD_IOP_DMAhw)
, DMAC(&TLD_IOP_DMAC) , DMAC(LD_IOP_DMAC)
, Counters(&TLD_IOP_Counters) , Counters(LD_IOP_Counters)
, CDVD(&TLD_IOP_CDVD) , CDVD(LD_IOP_CDVD)
, MDEC(&TLD_IOP_MDEC) , MDEC(LD_IOP_MDEC)
{ {
} }

View File

@ -453,7 +453,6 @@ void VMManager::Internal::CPUThreadShutdown()
void VMManager::Internal::SetFileLogPath(std::string path) void VMManager::Internal::SetFileLogPath(std::string path)
{ {
s_log_force_file_log = Log::SetFileOutputLevel(LOGLEVEL_DEBUG, std::move(path)); s_log_force_file_log = Log::SetFileOutputLevel(LOGLEVEL_DEBUG, std::move(path));
emuLog = Log::GetFileLogHandle();
} }
void VMManager::Internal::SetBlockSystemConsole(bool block) void VMManager::Internal::SetBlockSystemConsole(bool block)
@ -476,12 +475,6 @@ void VMManager::UpdateLoggingSettings(SettingsInterface& si)
if (system_console_enabled != Log::IsConsoleOutputEnabled()) if (system_console_enabled != Log::IsConsoleOutputEnabled())
Log::SetConsoleOutputLevel(system_console_enabled ? level : LOGLEVEL_NONE); Log::SetConsoleOutputLevel(system_console_enabled ? level : LOGLEVEL_NONE);
if (file_logging_enabled != Log::IsFileOutputEnabled())
{
std::string path = Path::Combine(EmuFolders::Logs, "emulog.txt");
Log::SetFileOutputLevel(file_logging_enabled ? level : LOGLEVEL_NONE, std::move(path));
}
// Debug console only exists on Windows. // Debug console only exists on Windows.
#ifdef _WIN32 #ifdef _WIN32
const bool debug_console_enabled = IsDebuggerPresent() && si.GetBoolValue("Logging", "EnableDebugConsole", false); const bool debug_console_enabled = IsDebuggerPresent() && si.GetBoolValue("Logging", "EnableDebugConsole", false);
@ -496,17 +489,26 @@ void VMManager::UpdateLoggingSettings(SettingsInterface& si)
const bool any_logging_sinks = system_console_enabled || log_window_enabled || file_logging_enabled || debug_console_enabled; const bool any_logging_sinks = system_console_enabled || log_window_enabled || file_logging_enabled || debug_console_enabled;
const bool ee_console_enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableEEConsole", false); const bool ee_console_enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableEEConsole", false);
SysConsole.eeConsole.Enabled = ee_console_enabled; ConsoleLogging.eeConsole.Enabled = ee_console_enabled;
SysConsole.iopConsole.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableIOPConsole", false); ConsoleLogging.iopConsole.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableIOPConsole", false);
SysTrace.IOP.R3000A.Enabled = true; TraceLogging.IOP.R3000A.Enabled = true;
SysTrace.IOP.COP2.Enabled = true; TraceLogging.IOP.COP2.Enabled = true;
SysTrace.IOP.Memory.Enabled = true; TraceLogging.IOP.Memory.Enabled = true;
SysTrace.SIF.Enabled = true; TraceLogging.SIF.Enabled = true;
// Input Recording Logs // Input Recording Logs
SysConsole.recordingConsole.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableInputRecordingLogs", true); ConsoleLogging.recordingConsole.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableInputRecordingLogs", true);
SysConsole.controlInfo.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableControllerLogs", false); ConsoleLogging.controlInfo.Enabled = any_logging_sinks && si.GetBoolValue("Logging", "EnableControllerLogs", false);
// Sync the trace settings with the config.
EmuConfig.Trace.SyncToConfig();
// Set the output level if file logging or trace logs have changed.
if (file_logging_enabled != Log::IsFileOutputEnabled() || (EmuConfig.Trace.Enabled && Log::GetMaxLevel() < LOGLEVEL_TRACE))
{
std::string path = Path::Combine(EmuFolders::Logs, "emulog.txt");
Log::SetFileOutputLevel(file_logging_enabled ? EmuConfig.Trace.Enabled ? LOGLEVEL_TRACE : level : LOGLEVEL_NONE, std::move(path));
}
} }
void VMManager::SetDefaultLoggingSettings(SettingsInterface& si) void VMManager::SetDefaultLoggingSettings(SettingsInterface& si)
@ -519,6 +521,11 @@ void VMManager::SetDefaultLoggingSettings(SettingsInterface& si)
si.SetBoolValue("Logging", "EnableIOPConsole", false); si.SetBoolValue("Logging", "EnableIOPConsole", false);
si.SetBoolValue("Logging", "EnableInputRecordingLogs", true); si.SetBoolValue("Logging", "EnableInputRecordingLogs", true);
si.SetBoolValue("Logging", "EnableControllerLogs", false); si.SetBoolValue("Logging", "EnableControllerLogs", false);
EmuConfig.Trace.Enabled = false;
EmuConfig.Trace.EE.bitset = 0;
EmuConfig.Trace.IOP.bitset = 0;
EmuConfig.Trace.MISC.bitset = 0;
} }
bool VMManager::Internal::CheckSettingsVersion() bool VMManager::Internal::CheckSettingsVersion()

View File

@ -37,7 +37,7 @@ _vifT void vifTransferLoop(u32* &data) {
VIF_LOG("New VifCMD %x tagsize %x irq %d", vifX.cmd, vifX.tag.size, vifX.irq); VIF_LOG("New VifCMD %x tagsize %x irq %d", vifX.cmd, vifX.tag.size, vifX.irq);
if (IsDevBuild && SysTrace.EE.VIFcode.IsActive()) { if (IsDevBuild && TraceLogging.EE.VIFcode.IsActive()) {
// Pass 2 means "log it" // Pass 2 means "log it"
vifCmdHandler[idx][vifX.cmd & 0x7f](2, data); vifCmdHandler[idx][vifX.cmd & 0x7f](2, data);
} }

View File

@ -128,7 +128,7 @@ void iopHwWrite8_Page3( u32 addr, mem8_t val )
// all addresses are assumed to be prefixed with 0x1f803xxx: // all addresses are assumed to be prefixed with 0x1f803xxx:
pxAssert( (addr >> 12) == 0x1f803 ); pxAssert( (addr >> 12) == 0x1f803 );
if( SysConsole.iopConsole.IsActive() && (addr == 0x1f80380c) ) // STDOUT if(ConsoleLogging.iopConsole.IsActive() && (addr == 0x1f80380c)) // STDOUT
{ {
static char pbuf[1024]; static char pbuf[1024];
static int pidx; static int pidx;

View File

@ -197,7 +197,7 @@ template< typename T>
static __ri void IopHwTraceLog( u32 addr, T val, bool mode ) static __ri void IopHwTraceLog( u32 addr, T val, bool mode )
{ {
if (!IsDevBuild) return; if (!IsDevBuild) return;
if (!EmuConfig.Trace.Enabled || !EmuConfig.Trace.IOP.m_EnableAll || !EmuConfig.Trace.IOP.m_EnableRegisters) return; if (!EmuConfig.Trace.Enabled) return;
std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8)); std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8));
std::string valStr; std::string valStr;

View File

@ -256,7 +256,7 @@ template< typename T>
static __ri void eeHwTraceLog( u32 addr, T val, bool mode ) static __ri void eeHwTraceLog( u32 addr, T val, bool mode )
{ {
if (!IsDevBuild) return; if (!IsDevBuild) return;
if (!EmuConfig.Trace.Enabled || !EmuConfig.Trace.EE.m_EnableAll || !EmuConfig.Trace.EE.m_EnableRegisters) return; if (!EmuConfig.Trace.Enabled) return;
if (!_eelog_enabled(addr)) return; if (!_eelog_enabled(addr)) return;
std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8)); std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8));

View File

@ -662,14 +662,14 @@ static void psxRecompileIrxImport()
const char* funcname = nullptr; const char* funcname = nullptr;
#endif #endif
if (!hle && !debug && (!SysTraceActive(IOP.Bios) || !funcname)) if (!hle && !debug && (!TraceActive(IOP.Bios) || !funcname))
return; return;
xMOV(ptr32[&psxRegs.code], psxRegs.code); xMOV(ptr32[&psxRegs.code], psxRegs.code);
xMOV(ptr32[&psxRegs.pc], psxpc); xMOV(ptr32[&psxRegs.pc], psxpc);
_psxFlushCall(FLUSH_NODESTROY); _psxFlushCall(FLUSH_NODESTROY);
if (SysTraceActive(IOP.Bios)) if (TraceActive(IOP.Bios))
{ {
xMOV64(arg3reg, (uptr)funcname); xMOV64(arg3reg, (uptr)funcname);