mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
add back fused gui log classes, this needs to be redone another way
also, add back wx requirement for strfmt
This commit is contained in:
parent
10e10de98d
commit
ed10ea7544
@ -54,23 +54,22 @@ std::string replace_all(std::string src, const std::string& from, const std::str
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef wxGUI
|
//TODO: move this wx Stuff somewhere else
|
||||||
////convert a wxString to a std::string encoded in utf8
|
//convert a wxString to a std::string encoded in utf8
|
||||||
////CAUTION, only use this to interface with wxWidgets classes
|
//CAUTION, only use this to interface with wxWidgets classes
|
||||||
//std::string fmt::ToUTF8(const wxString& right)
|
std::string fmt::ToUTF8(const wxString& right)
|
||||||
//{
|
{
|
||||||
// auto ret = std::string(((const char *) right.utf8_str()));
|
auto ret = std::string(((const char *)right.utf8_str()));
|
||||||
// return ret;
|
return ret;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
////convert a std::string encoded in utf8 to a wxString
|
//convert a std::string encoded in utf8 to a wxString
|
||||||
////CAUTION, only use this to interface with wxWidgets classes
|
//CAUTION, only use this to interface with wxWidgets classes
|
||||||
//wxString fmt::FromUTF8(const std::string& right)
|
wxString fmt::FromUTF8(const std::string& right)
|
||||||
//{
|
{
|
||||||
// auto ret = wxString::FromUTF8(right.c_str());
|
auto ret = wxString::FromUTF8(right.c_str());
|
||||||
// return ret;
|
return ret;
|
||||||
//}
|
}
|
||||||
//#endif
|
|
||||||
|
|
||||||
//TODO: remove this after every snippet that uses it is gone
|
//TODO: remove this after every snippet that uses it is gone
|
||||||
//WARNING: not fully compatible with CmpNoCase from wxString
|
//WARNING: not fully compatible with CmpNoCase from wxString
|
||||||
|
@ -4,91 +4,94 @@
|
|||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "DbgConsole.h"
|
#include "DbgConsole.h"
|
||||||
|
|
||||||
LogWriter ConLog;
|
BEGIN_EVENT_TABLE(DbgConsole, FrameBase)
|
||||||
class LogFrame;
|
EVT_CLOSE(DbgConsole::OnQuit)
|
||||||
extern LogFrame* ConLogFrame;
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
_LogBuffer LogBuffer;
|
DbgConsole::DbgConsole()
|
||||||
|
: FrameBase(nullptr, wxID_ANY, "Debug Console", "", wxDefaultSize, wxDefaultPosition, wxDEFAULT_FRAME_STYLE, true)
|
||||||
std::mutex g_cs_conlog;
|
, ThreadBase("DbgConsole thread")
|
||||||
|
, m_output(nullptr)
|
||||||
const uint max_item_count = 500;
|
|
||||||
const uint buffer_size = 1024 * 64;
|
|
||||||
|
|
||||||
static const std::string g_log_colors[] =
|
|
||||||
{
|
{
|
||||||
"Black", "Green", "White", "Yellow", "Red",
|
m_console = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
|
||||||
};
|
wxSize(500, 500), wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH2);
|
||||||
|
m_console->SetBackgroundColour(wxColor("Black"));
|
||||||
|
m_console->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
|
|
||||||
LogWriter::LogWriter()
|
m_color_white = new wxTextAttr(wxColour(255, 255, 255));
|
||||||
{
|
m_color_red = new wxTextAttr(wxColour(255, 0, 0));
|
||||||
if (!m_logfile.Open(_PRGNAME_ ".log", rFile::write))
|
|
||||||
{
|
if (Ini.HLESaveTTY.GetValue())
|
||||||
rMessageBox("Can't create log file! (" _PRGNAME_ ".log)", rMessageBoxCaptionStr, rICON_ERROR);
|
m_output = new wxFile("tty.log", wxFile::write);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/)
|
DbgConsole::~DbgConsole()
|
||||||
{
|
{
|
||||||
std::string new_prefix = prefix;
|
ThreadBase::Stop();
|
||||||
if (!prefix.empty())
|
m_dbg_buffer.Flush();
|
||||||
|
|
||||||
|
safe_delete(m_console);
|
||||||
|
safe_delete(m_color_white);
|
||||||
|
safe_delete(m_color_red);
|
||||||
|
safe_delete(m_output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbgConsole::Write(int ch, const std::string& text)
|
||||||
|
{
|
||||||
|
while (m_dbg_buffer.IsBusy())
|
||||||
{
|
{
|
||||||
if (NamedThreadBase* thr = GetCurrentNamedThread())
|
if (Emu.IsStopped())
|
||||||
{
|
{
|
||||||
new_prefix += " : " + thr->GetThreadName();
|
return;
|
||||||
}
|
}
|
||||||
|
Sleep(1);
|
||||||
}
|
}
|
||||||
|
m_dbg_buffer.Push(DbgPacket(ch, text));
|
||||||
|
|
||||||
if (m_logfile.IsOpened() && !new_prefix.empty())
|
if (!IsAlive()) Start();
|
||||||
m_logfile.Write("[" + new_prefix + "]: " + value + "\n");
|
}
|
||||||
|
|
||||||
if (!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
|
void DbgConsole::Clear()
|
||||||
return;
|
{
|
||||||
|
m_console->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(g_cs_conlog);
|
void DbgConsole::Task()
|
||||||
|
{
|
||||||
// TODO: Use ThreadBase instead, track main thread id
|
while (!TestDestroy())
|
||||||
if (rThread::IsMain())
|
|
||||||
{
|
{
|
||||||
while (LogBuffer.IsBusy())
|
if (!m_dbg_buffer.HasNewPacket())
|
||||||
{
|
|
||||||
// need extra break condition?
|
|
||||||
rYieldIfNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (LogBuffer.IsBusy())
|
|
||||||
{
|
{
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DbgPacket packet = m_dbg_buffer.Pop();
|
||||||
|
m_console->SetDefaultStyle(packet.m_ch == 1 ? *m_color_red : *m_color_white);
|
||||||
|
m_console->SetInsertionPointEnd();
|
||||||
|
m_console->WriteText(fmt::FromUTF8(packet.m_text));
|
||||||
|
|
||||||
|
if (m_output && Ini.HLESaveTTY.GetValue())
|
||||||
|
m_output->Write(fmt::FromUTF8(packet.m_text));
|
||||||
|
|
||||||
|
if (!DbgConsole::IsShown()) Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbgConsole::OnQuit(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
ThreadBase::Stop(false);
|
||||||
|
Hide();
|
||||||
|
|
||||||
|
if (m_output)
|
||||||
|
{
|
||||||
|
m_output->Close();
|
||||||
|
m_output = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();
|
//event.Skip();
|
||||||
|
|
||||||
LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LogWriter::SkipLn()
|
|
||||||
{
|
|
||||||
WriteToLog("", "", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgConsole::Close()
|
|
||||||
{
|
|
||||||
i = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgConsole::Clear()
|
|
||||||
{
|
|
||||||
i = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgConsole::Write(int ch, const std::string &msg)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,61 @@
|
|||||||
|
|
||||||
#include <cstring> //for memset
|
#include <cstring> //for memset
|
||||||
|
|
||||||
extern const uint max_item_count;
|
//struct _DbgBuffer : public MTPacketBuffer<DbgPacket>
|
||||||
extern const uint buffer_size;
|
//{
|
||||||
|
// _DbgBuffer() : MTPacketBuffer<DbgPacket>(1024)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void _push(const DbgPacket& data)
|
||||||
|
// {
|
||||||
|
// const u32 stext = data.m_text.length();
|
||||||
|
//
|
||||||
|
// m_buffer.resize(m_buffer.size() + sizeof(int) + sizeof(u32) + stext);
|
||||||
|
//
|
||||||
|
// u32 c_put = m_put;
|
||||||
|
//
|
||||||
|
// memcpy(&m_buffer[c_put], &data.m_ch, sizeof(int));
|
||||||
|
// c_put += sizeof(int);
|
||||||
|
//
|
||||||
|
// memcpy(&m_buffer[c_put], &stext, sizeof(u32));
|
||||||
|
// c_put += sizeof(u32);
|
||||||
|
// memcpy(&m_buffer[c_put], data.m_text.data(), stext);
|
||||||
|
// c_put += stext;
|
||||||
|
//
|
||||||
|
// m_put = c_put;
|
||||||
|
// CheckBusy();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// DbgPacket _pop()
|
||||||
|
// {
|
||||||
|
// DbgPacket ret;
|
||||||
|
//
|
||||||
|
// u32 c_get = m_get;
|
||||||
|
//
|
||||||
|
// ret.m_ch = *(int*)&m_buffer[c_get];
|
||||||
|
// c_get += sizeof(int);
|
||||||
|
//
|
||||||
|
// const u32& stext = *(u32*)&m_buffer[c_get];
|
||||||
|
// c_get += sizeof(u32);
|
||||||
|
// if (stext) ret.m_text = std::string(reinterpret_cast<const char*>(&m_buffer[c_get]), stext );
|
||||||
|
// c_get += stext;
|
||||||
|
//
|
||||||
|
// m_get = c_get;
|
||||||
|
// if(!HasNewPacket()) Flush();
|
||||||
|
//
|
||||||
|
// return ret;
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//struct DbgConsole
|
||||||
|
//{
|
||||||
|
// void *congui;
|
||||||
|
// DbgConsole();
|
||||||
|
// void Close();
|
||||||
|
// void Clear();
|
||||||
|
// void Write(int ch, const std::string &msg);
|
||||||
|
//};
|
||||||
|
|
||||||
struct DbgPacket
|
struct DbgPacket
|
||||||
{
|
{
|
||||||
@ -26,87 +79,6 @@ struct DbgPacket
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LogPacket
|
|
||||||
{
|
|
||||||
const std::string m_prefix;
|
|
||||||
const std::string m_text;
|
|
||||||
const std::string m_colour;
|
|
||||||
|
|
||||||
LogPacket(const std::string& prefix, const std::string& text, const std::string& colour)
|
|
||||||
: m_prefix(prefix)
|
|
||||||
, m_text(text)
|
|
||||||
, m_colour(colour)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _LogBuffer : public MTPacketBuffer<LogPacket>
|
|
||||||
{
|
|
||||||
_LogBuffer() : MTPacketBuffer<LogPacket>(buffer_size)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _push(const LogPacket& data)
|
|
||||||
{
|
|
||||||
const u32 sprefix = data.m_prefix.length();
|
|
||||||
const u32 stext = data.m_text.length();
|
|
||||||
const u32 scolour = data.m_colour.length();
|
|
||||||
|
|
||||||
m_buffer.resize(m_buffer.size() +
|
|
||||||
sizeof(u32) + sprefix +
|
|
||||||
sizeof(u32) + stext +
|
|
||||||
sizeof(u32) + scolour);
|
|
||||||
|
|
||||||
u32 c_put = m_put;
|
|
||||||
|
|
||||||
memcpy(&m_buffer[c_put], &sprefix, sizeof(u32));
|
|
||||||
c_put += sizeof(u32);
|
|
||||||
memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix);
|
|
||||||
c_put += sprefix;
|
|
||||||
|
|
||||||
memcpy(&m_buffer[c_put], &stext, sizeof(u32));
|
|
||||||
c_put += sizeof(u32);
|
|
||||||
memcpy(&m_buffer[c_put], data.m_text.c_str(), stext);
|
|
||||||
c_put += stext;
|
|
||||||
|
|
||||||
memcpy(&m_buffer[c_put], &scolour, sizeof(u32));
|
|
||||||
c_put += sizeof(u32);
|
|
||||||
memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour);
|
|
||||||
c_put += scolour;
|
|
||||||
|
|
||||||
m_put = c_put;
|
|
||||||
CheckBusy();
|
|
||||||
}
|
|
||||||
|
|
||||||
LogPacket _pop()
|
|
||||||
{
|
|
||||||
u32 c_get = m_get;
|
|
||||||
|
|
||||||
const u32& sprefix = *(u32*)&m_buffer[c_get];
|
|
||||||
c_get += sizeof(u32);
|
|
||||||
const std::string prefix((const char*)&m_buffer[c_get], sprefix);
|
|
||||||
c_get += sprefix;
|
|
||||||
|
|
||||||
const u32& stext = *(u32*)&m_buffer[c_get];
|
|
||||||
c_get += sizeof(u32);
|
|
||||||
const std::string text((const char*)&m_buffer[c_get], stext);
|
|
||||||
c_get += stext;
|
|
||||||
|
|
||||||
const u32& scolour = *(u32*)&m_buffer[c_get];
|
|
||||||
c_get += sizeof(u32);
|
|
||||||
const std::string colour((const char*)&m_buffer[c_get], scolour);
|
|
||||||
c_get += scolour;
|
|
||||||
|
|
||||||
m_get = c_get;
|
|
||||||
if (!HasNewPacket()) Flush();
|
|
||||||
|
|
||||||
return LogPacket(prefix, text, colour);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern _LogBuffer LogBuffer;
|
|
||||||
|
|
||||||
struct _DbgBuffer : public MTPacketBuffer<DbgPacket>
|
struct _DbgBuffer : public MTPacketBuffer<DbgPacket>
|
||||||
{
|
{
|
||||||
_DbgBuffer() : MTPacketBuffer<DbgPacket>(1024)
|
_DbgBuffer() : MTPacketBuffer<DbgPacket>(1024)
|
||||||
@ -144,20 +116,34 @@ struct _DbgBuffer : public MTPacketBuffer<DbgPacket>
|
|||||||
|
|
||||||
const u32& stext = *(u32*)&m_buffer[c_get];
|
const u32& stext = *(u32*)&m_buffer[c_get];
|
||||||
c_get += sizeof(u32);
|
c_get += sizeof(u32);
|
||||||
if (stext) ret.m_text = std::string(reinterpret_cast<const char*>(&m_buffer[c_get]), stext );
|
if (stext) ret.m_text = std::string(reinterpret_cast<const char*>(&m_buffer[c_get]), stext);
|
||||||
c_get += stext;
|
c_get += stext;
|
||||||
|
|
||||||
m_get = c_get;
|
m_get = c_get;
|
||||||
if(!HasNewPacket()) Flush();
|
if (!HasNewPacket()) Flush();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DbgConsole
|
class DbgConsole
|
||||||
|
: public FrameBase
|
||||||
|
, public ThreadBase
|
||||||
{
|
{
|
||||||
int i;
|
wxFile* m_output;
|
||||||
void Close();
|
wxTextCtrl* m_console;
|
||||||
|
wxTextAttr* m_color_white;
|
||||||
|
wxTextAttr* m_color_red;
|
||||||
|
_DbgBuffer m_dbg_buffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DbgConsole();
|
||||||
|
~DbgConsole();
|
||||||
|
void Write(int ch, const std::string& text);
|
||||||
void Clear();
|
void Clear();
|
||||||
void Write(int ch, const std::string &msg);
|
virtual void Task();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnQuit(wxCloseEvent& event);
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
@ -15,17 +15,171 @@
|
|||||||
#include "Emu/Memory/Memory.h"
|
#include "Emu/Memory/Memory.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
|
|
||||||
|
LogWriter ConLog;
|
||||||
|
class LogFrame;
|
||||||
|
extern LogFrame* ConLogFrame;
|
||||||
|
|
||||||
|
std::mutex g_cs_conlog;
|
||||||
|
|
||||||
|
const uint max_item_count = 500;
|
||||||
|
const uint buffer_size = 1024 * 64;
|
||||||
|
|
||||||
|
static const std::string g_log_colors[] =
|
||||||
|
{
|
||||||
|
"Black", "Green", "White", "Yellow", "Red",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct LogPacket
|
||||||
|
{
|
||||||
|
const std::string m_prefix;
|
||||||
|
const std::string m_text;
|
||||||
|
const std::string m_colour;
|
||||||
|
|
||||||
|
LogPacket(const std::string& prefix, const std::string& text, const std::string& colour)
|
||||||
|
: m_prefix(prefix)
|
||||||
|
, m_text(text)
|
||||||
|
, m_colour(colour)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _LogBuffer : public MTPacketBuffer<LogPacket>
|
||||||
|
{
|
||||||
|
_LogBuffer() : MTPacketBuffer<LogPacket>(buffer_size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void _push(const LogPacket& data)
|
||||||
|
{
|
||||||
|
const u32 sprefix = data.m_prefix.length();
|
||||||
|
const u32 stext = data.m_text.length();
|
||||||
|
const u32 scolour = data.m_colour.length();
|
||||||
|
|
||||||
|
m_buffer.resize(m_buffer.size() +
|
||||||
|
sizeof(u32) + sprefix +
|
||||||
|
sizeof(u32) + stext +
|
||||||
|
sizeof(u32) + scolour);
|
||||||
|
|
||||||
|
u32 c_put = m_put;
|
||||||
|
|
||||||
|
memcpy(&m_buffer[c_put], &sprefix, sizeof(u32));
|
||||||
|
c_put += sizeof(u32);
|
||||||
|
memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix);
|
||||||
|
c_put += sprefix;
|
||||||
|
|
||||||
|
memcpy(&m_buffer[c_put], &stext, sizeof(u32));
|
||||||
|
c_put += sizeof(u32);
|
||||||
|
memcpy(&m_buffer[c_put], data.m_text.c_str(), stext);
|
||||||
|
c_put += stext;
|
||||||
|
|
||||||
|
memcpy(&m_buffer[c_put], &scolour, sizeof(u32));
|
||||||
|
c_put += sizeof(u32);
|
||||||
|
memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour);
|
||||||
|
c_put += scolour;
|
||||||
|
|
||||||
|
m_put = c_put;
|
||||||
|
CheckBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogPacket _pop()
|
||||||
|
{
|
||||||
|
u32 c_get = m_get;
|
||||||
|
|
||||||
|
const u32& sprefix = *(u32*)&m_buffer[c_get];
|
||||||
|
c_get += sizeof(u32);
|
||||||
|
const std::string prefix((const char*)&m_buffer[c_get], sprefix);
|
||||||
|
c_get += sprefix;
|
||||||
|
|
||||||
|
const u32& stext = *(u32*)&m_buffer[c_get];
|
||||||
|
c_get += sizeof(u32);
|
||||||
|
const std::string text((const char*)&m_buffer[c_get], stext);
|
||||||
|
c_get += stext;
|
||||||
|
|
||||||
|
const u32& scolour = *(u32*)&m_buffer[c_get];
|
||||||
|
c_get += sizeof(u32);
|
||||||
|
const std::string colour((const char*)&m_buffer[c_get], scolour);
|
||||||
|
c_get += scolour;
|
||||||
|
|
||||||
|
m_get = c_get;
|
||||||
|
if (!HasNewPacket()) Flush();
|
||||||
|
|
||||||
|
return LogPacket(prefix, text, colour);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_LogBuffer LogBuffer;
|
||||||
|
|
||||||
|
LogWriter::LogWriter()
|
||||||
|
{
|
||||||
|
if (!m_logfile.Open(_PRGNAME_ ".log", rFile::write))
|
||||||
|
{
|
||||||
|
rMessageBox("Can't create log file! (" _PRGNAME_ ".log)", rMessageBoxCaptionStr, rICON_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/)
|
||||||
|
{
|
||||||
|
std::string new_prefix = prefix;
|
||||||
|
if (!prefix.empty())
|
||||||
|
{
|
||||||
|
if (NamedThreadBase* thr = GetCurrentNamedThread())
|
||||||
|
{
|
||||||
|
new_prefix += " : " + thr->GetThreadName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_logfile.IsOpened() && !new_prefix.empty())
|
||||||
|
m_logfile.Write("[" + new_prefix + "]: " + value + "\n");
|
||||||
|
|
||||||
|
if (!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(g_cs_conlog);
|
||||||
|
|
||||||
|
// TODO: Use ThreadBase instead, track main thread id
|
||||||
|
if (rThread::IsMain())
|
||||||
|
{
|
||||||
|
while (LogBuffer.IsBusy())
|
||||||
|
{
|
||||||
|
// need extra break condition?
|
||||||
|
rYieldIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (LogBuffer.IsBusy())
|
||||||
|
{
|
||||||
|
if (Emu.IsStopped())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();
|
||||||
|
|
||||||
|
LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LogWriter::SkipLn()
|
||||||
|
{
|
||||||
|
WriteToLog("", "", 0);
|
||||||
|
}
|
||||||
|
|
||||||
LogFrame* ConLogFrame;
|
LogFrame* ConLogFrame;
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(LogFrame, wxPanel)
|
BEGIN_EVENT_TABLE(LogFrame, wxPanel)
|
||||||
EVT_CLOSE(LogFrame::OnQuit)
|
EVT_CLOSE(LogFrame::OnQuit)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
LogFrame::LogFrame(wxWindow* parent)
|
LogFrame::LogFrame(wxWindow* parent)
|
||||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(600, 500))
|
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(600, 500))
|
||||||
, ThreadBase("LogThread")
|
, ThreadBase("LogThread")
|
||||||
, m_log(*new wxListView(this))
|
, m_log(*new wxListView(this))
|
||||||
{
|
{
|
||||||
m_log.InsertColumn(0, "Thread");
|
m_log.InsertColumn(0, "Thread");
|
||||||
m_log.InsertColumn(1, "Log");
|
m_log.InsertColumn(1, "Log");
|
||||||
@ -35,7 +189,7 @@ LogFrame::LogFrame(wxWindow* parent)
|
|||||||
s_main->Add(&m_log, 1, wxEXPAND);
|
s_main->Add(&m_log, 1, wxEXPAND);
|
||||||
SetSizer(s_main);
|
SetSizer(s_main);
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
ThreadBase::Start();
|
ThreadBase::Start();
|
||||||
}
|
}
|
||||||
@ -53,9 +207,9 @@ bool LogFrame::Close(bool force)
|
|||||||
|
|
||||||
void LogFrame::Task()
|
void LogFrame::Task()
|
||||||
{
|
{
|
||||||
while(!TestDestroy())
|
while (!TestDestroy())
|
||||||
{
|
{
|
||||||
if(!LogBuffer.HasNewPacket())
|
if (!LogBuffer.HasNewPacket())
|
||||||
{
|
{
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
continue;
|
continue;
|
||||||
@ -99,4 +253,4 @@ void LogFrame::OnQuit(wxCloseEvent& event)
|
|||||||
Stop(false);
|
Stop(false);
|
||||||
ConLogFrame = nullptr;
|
ConLogFrame = nullptr;
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
@ -1,94 +0,0 @@
|
|||||||
#include "stdafx.h"
|
|
||||||
#include "DbgFrame.h"
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(DbgFrame, FrameBase)
|
|
||||||
EVT_CLOSE(DbgFrame::OnQuit)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
DbgFrame::DbgFrame()
|
|
||||||
: FrameBase(nullptr, wxID_ANY, "DbgFrame", "", wxDefaultSize, wxDefaultPosition, wxDEFAULT_FRAME_STYLE, true)
|
|
||||||
, ThreadBase("DbgFrame thread")
|
|
||||||
, m_output(nullptr)
|
|
||||||
{
|
|
||||||
m_console = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
|
|
||||||
wxSize(500, 500), wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH2);
|
|
||||||
m_console->SetBackgroundColour(wxColor("Black"));
|
|
||||||
m_console->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
|
||||||
|
|
||||||
m_color_white = new wxTextAttr(wxColour(255, 255, 255));
|
|
||||||
m_color_red = new wxTextAttr(wxColour(255, 0, 0));
|
|
||||||
|
|
||||||
if (Ini.HLESaveTTY.GetValue())
|
|
||||||
m_output = new rFile("tty.log", rFile::write);
|
|
||||||
}
|
|
||||||
|
|
||||||
DbgFrame::~DbgFrame()
|
|
||||||
{
|
|
||||||
ThreadBase::Stop();
|
|
||||||
m_dbg_buffer.Flush();
|
|
||||||
|
|
||||||
safe_delete(m_console);
|
|
||||||
safe_delete(m_color_white);
|
|
||||||
safe_delete(m_color_red);
|
|
||||||
safe_delete(m_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgFrame::Write(int ch, const std::string& text)
|
|
||||||
{
|
|
||||||
while (m_dbg_buffer.IsBusy())
|
|
||||||
{
|
|
||||||
if (Emu.IsStopped())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Sleep(1);
|
|
||||||
}
|
|
||||||
m_dbg_buffer.Push(DbgPacket(ch, text));
|
|
||||||
|
|
||||||
if (!IsAlive()) Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgFrame::Clear()
|
|
||||||
{
|
|
||||||
m_console->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgFrame::Task()
|
|
||||||
{
|
|
||||||
while (!TestDestroy())
|
|
||||||
{
|
|
||||||
if (!m_dbg_buffer.HasNewPacket())
|
|
||||||
{
|
|
||||||
if (Emu.IsStopped())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DbgPacket packet = m_dbg_buffer.Pop();
|
|
||||||
m_console->SetDefaultStyle(packet.m_ch == 1 ? *m_color_red : *m_color_white);
|
|
||||||
m_console->SetInsertionPointEnd();
|
|
||||||
m_console->WriteText(fmt::FromUTF8(packet.m_text));
|
|
||||||
|
|
||||||
if (m_output && Ini.HLESaveTTY.GetValue())
|
|
||||||
m_output->Write(packet.m_text);
|
|
||||||
|
|
||||||
if (!DbgFrame::IsShown()) Show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbgFrame::OnQuit(wxCloseEvent& event)
|
|
||||||
{
|
|
||||||
ThreadBase::Stop(false);
|
|
||||||
Hide();
|
|
||||||
|
|
||||||
if (m_output)
|
|
||||||
{
|
|
||||||
m_output->Close();
|
|
||||||
m_output = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//event.Skip();
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class DbgFrame
|
|
||||||
: public FrameBase
|
|
||||||
, public ThreadBase
|
|
||||||
{
|
|
||||||
rFile* m_output;
|
|
||||||
wxTextCtrl* m_console;
|
|
||||||
wxTextAttr* m_color_white;
|
|
||||||
wxTextAttr* m_color_red;
|
|
||||||
_DbgBuffer m_dbg_buffer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DbgFrame();
|
|
||||||
~DbgFrame();
|
|
||||||
void Write(int ch, const std::string& text);
|
|
||||||
void Clear();
|
|
||||||
virtual void Task();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void OnQuit(wxCloseEvent& event);
|
|
||||||
DECLARE_EVENT_TABLE();
|
|
||||||
};
|
|
@ -60,7 +60,6 @@
|
|||||||
<ClCompile Include="Emu\Cell\SPUThread.cpp" />
|
<ClCompile Include="Emu\Cell\SPUThread.cpp" />
|
||||||
<ClCompile Include="Emu\CPU\CPUThread.cpp" />
|
<ClCompile Include="Emu\CPU\CPUThread.cpp" />
|
||||||
<ClCompile Include="Emu\CPU\CPUThreadManager.cpp" />
|
<ClCompile Include="Emu\CPU\CPUThreadManager.cpp" />
|
||||||
<ClCompile Include="Emu\DbgConsole.cpp" />
|
|
||||||
<ClCompile Include="Emu\Event.cpp" />
|
<ClCompile Include="Emu\Event.cpp" />
|
||||||
<ClCompile Include="Emu\FS\VFS.cpp" />
|
<ClCompile Include="Emu\FS\VFS.cpp" />
|
||||||
<ClCompile Include="Emu\FS\vfsDevice.cpp" />
|
<ClCompile Include="Emu\FS\vfsDevice.cpp" />
|
||||||
@ -268,7 +267,6 @@
|
|||||||
<ClInclude Include="Emu\CPU\CPUThread.h" />
|
<ClInclude Include="Emu\CPU\CPUThread.h" />
|
||||||
<ClInclude Include="Emu\CPU\CPUThreadManager.h" />
|
<ClInclude Include="Emu\CPU\CPUThreadManager.h" />
|
||||||
<ClInclude Include="Emu\DbgCommand.h" />
|
<ClInclude Include="Emu\DbgCommand.h" />
|
||||||
<ClInclude Include="Emu\DbgConsole.h" />
|
|
||||||
<ClInclude Include="Emu\FS\VFS.h" />
|
<ClInclude Include="Emu\FS\VFS.h" />
|
||||||
<ClInclude Include="Emu\FS\vfsDevice.h" />
|
<ClInclude Include="Emu\FS\vfsDevice.h" />
|
||||||
<ClInclude Include="Emu\FS\vfsDeviceLocalFile.h" />
|
<ClInclude Include="Emu\FS\vfsDeviceLocalFile.h" />
|
||||||
|
@ -107,9 +107,6 @@
|
|||||||
<ClCompile Include="Crypto\utils.cpp">
|
<ClCompile Include="Crypto\utils.cpp">
|
||||||
<Filter>Crypto</Filter>
|
<Filter>Crypto</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Emu\DbgConsole.cpp">
|
|
||||||
<Filter>Emu</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Emu\System.cpp">
|
<ClCompile Include="Emu\System.cpp">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -604,9 +601,6 @@
|
|||||||
<ClInclude Include="Crypto\utils.h">
|
<ClInclude Include="Crypto\utils.h">
|
||||||
<Filter>Crypto</Filter>
|
<Filter>Crypto</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Emu\DbgConsole.h">
|
|
||||||
<Filter>Emu</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Emu\GameInfo.h">
|
<ClInclude Include="Emu\GameInfo.h">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -86,21 +86,4 @@ CPUThread& GetCPU(const u8 core)
|
|||||||
return Emu.GetCPU().Get(core);
|
return Emu.GetCPU().Get(core);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//TODOB: remove this
|
|
||||||
//convert a wxString to a std::string encoded in utf8
|
|
||||||
//CAUTION, only use this to interface with wxWidgets classes
|
|
||||||
std::string fmt::ToUTF8(const wxString& right)
|
|
||||||
{
|
|
||||||
auto ret = std::string(((const char *)right.utf8_str()));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//convert a std::string encoded in utf8 to a wxString
|
|
||||||
//CAUTION, only use this to interface with wxWidgets classes
|
|
||||||
wxString fmt::FromUTF8(const std::string& right)
|
|
||||||
{
|
|
||||||
auto ret = wxString::FromUTF8(right.c_str());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameInfo CurGameInfo;
|
GameInfo CurGameInfo;
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||||
<TargetName>$(ProjectName)-$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)-$(PlatformShortName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
@ -163,9 +163,9 @@
|
|||||||
<ClCompile Include="..\Utilities\StrFmt.cpp" />
|
<ClCompile Include="..\Utilities\StrFmt.cpp" />
|
||||||
<ClCompile Include="..\Utilities\Thread.cpp" />
|
<ClCompile Include="..\Utilities\Thread.cpp" />
|
||||||
<ClCompile Include="Emu\DbgCommand.cpp" />
|
<ClCompile Include="Emu\DbgCommand.cpp" />
|
||||||
|
<ClCompile Include="Emu\DbgConsole.cpp" />
|
||||||
<ClCompile Include="Gui\CompilerELF.cpp" />
|
<ClCompile Include="Gui\CompilerELF.cpp" />
|
||||||
<ClCompile Include="Gui\ConLog.cpp" />
|
<ClCompile Include="Gui\ConLog.cpp" />
|
||||||
<ClCompile Include="Gui\DbgFrame.cpp" />
|
|
||||||
<ClCompile Include="Gui\Debugger.cpp" />
|
<ClCompile Include="Gui\Debugger.cpp" />
|
||||||
<ClCompile Include="Gui\DisAsmFrame.cpp" />
|
<ClCompile Include="Gui\DisAsmFrame.cpp" />
|
||||||
<ClCompile Include="Gui\GameViewer.cpp" />
|
<ClCompile Include="Gui\GameViewer.cpp" />
|
||||||
@ -208,10 +208,10 @@
|
|||||||
<ClInclude Include="..\Utilities\Thread.h" />
|
<ClInclude Include="..\Utilities\Thread.h" />
|
||||||
<ClInclude Include="..\Utilities\Timer.h" />
|
<ClInclude Include="..\Utilities\Timer.h" />
|
||||||
<ClInclude Include="Emu\ConLog.h" />
|
<ClInclude Include="Emu\ConLog.h" />
|
||||||
|
<ClInclude Include="Emu\DbgConsole.h" />
|
||||||
<ClInclude Include="Gui\AboutDialog.h" />
|
<ClInclude Include="Gui\AboutDialog.h" />
|
||||||
<ClInclude Include="Gui\CompilerELF.h" />
|
<ClInclude Include="Gui\CompilerELF.h" />
|
||||||
<ClInclude Include="Gui\ConLogFrame.h" />
|
<ClInclude Include="Gui\ConLogFrame.h" />
|
||||||
<ClInclude Include="Gui\DbgFrame.h" />
|
|
||||||
<ClInclude Include="Gui\Debugger.h" />
|
<ClInclude Include="Gui\Debugger.h" />
|
||||||
<ClInclude Include="Gui\DisAsmFrame.h" />
|
<ClInclude Include="Gui\DisAsmFrame.h" />
|
||||||
<ClInclude Include="Gui\FrameBase.h" />
|
<ClInclude Include="Gui\FrameBase.h" />
|
||||||
|
@ -99,12 +99,12 @@
|
|||||||
<ClCompile Include="Gui\GSFrame.cpp">
|
<ClCompile Include="Gui\GSFrame.cpp">
|
||||||
<Filter>Gui</Filter>
|
<Filter>Gui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Gui\DbgFrame.cpp">
|
|
||||||
<Filter>Gui</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Emu\DbgCommand.cpp">
|
<ClCompile Include="Emu\DbgCommand.cpp">
|
||||||
<Filter>Emu</Filter>
|
<Filter>Emu</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Emu\DbgConsole.cpp">
|
||||||
|
<Filter>Emu</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="rpcs3.rc" />
|
<ResourceCompile Include="rpcs3.rc" />
|
||||||
@ -218,11 +218,11 @@
|
|||||||
<ClInclude Include="Gui\GSFrame.h">
|
<ClInclude Include="Gui\GSFrame.h">
|
||||||
<Filter>Gui</Filter>
|
<Filter>Gui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Gui\DbgFrame.h">
|
|
||||||
<Filter>Gui</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Gui\ConLogFrame.h">
|
<ClInclude Include="Gui\ConLogFrame.h">
|
||||||
<Filter>Gui</Filter>
|
<Filter>Gui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Emu\DbgConsole.h">
|
||||||
|
<Filter>Emu</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -291,17 +291,16 @@ enum Status
|
|||||||
#include "Utilities/IdManager.h"
|
#include "Utilities/IdManager.h"
|
||||||
#include "Utilities/StrFmt.h"
|
#include "Utilities/StrFmt.h"
|
||||||
|
|
||||||
|
#include "rpcs3/Ini.h"
|
||||||
|
#include "Gui/FrameBase.h"
|
||||||
|
#include "Gui/ConLogFrame.h"
|
||||||
#include "Emu/ConLog.h"
|
#include "Emu/ConLog.h"
|
||||||
#include "Emu/DbgConsole.h"
|
#include "Emu/DbgConsole.h"
|
||||||
#include "rpcs3/Ini.h"
|
|
||||||
#include "Emu/Memory/Memory.h"
|
#include "Emu/Memory/Memory.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "Emu/SysCalls/Callback.h"
|
#include "Emu/SysCalls/Callback.h"
|
||||||
#include "Emu/DbgCommand.h"
|
#include "Emu/DbgCommand.h"
|
||||||
//#ifdef wxGUI
|
//#ifdef wxGUI
|
||||||
#include "Gui/FrameBase.h"
|
|
||||||
#include "Gui/DbgFrame.h"
|
|
||||||
#include "Gui/ConLogFrame.h"
|
|
||||||
//#endif
|
//#endif
|
||||||
#include "Emu/Cell/PPUThread.h"
|
#include "Emu/Cell/PPUThread.h"
|
||||||
#include "Emu/SysCalls/SC_FUNC.h"
|
#include "Emu/SysCalls/SC_FUNC.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user