mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 12:12:50 +01:00
Log TTY output after emulation have been stopped
This commit is contained in:
parent
106f31db6a
commit
5d98f3866c
@ -2125,6 +2125,8 @@ void Emulator::Run(bool start_playtime)
|
||||
m_pause_start_time = 0;
|
||||
m_pause_amend_time = 0;
|
||||
|
||||
m_tty_file_init_pos = g_tty ? g_tty.pos() : usz{umax};
|
||||
|
||||
rpcs3::utils::configure_logs();
|
||||
|
||||
m_state = system_state::starting;
|
||||
@ -2957,6 +2959,30 @@ void Emulator::Kill(bool allow_autoexit, bool savestate)
|
||||
m_state = system_state::stopped;
|
||||
GetCallbacks().on_stop();
|
||||
|
||||
if (g_tty)
|
||||
{
|
||||
// Write merged TTY output after emulation has been safely stopped
|
||||
|
||||
if (usz attempted_read_size = utils::sub_saturate<usz>(g_tty.pos(), m_tty_file_init_pos))
|
||||
{
|
||||
if (fs::file tty_read_fd{fs::get_cache_dir() + "TTY.log"})
|
||||
{
|
||||
// Enfore an arbitrary limit for now to avoid OOM in case the guest code has bombarded TTY
|
||||
// 16MB, this should be enough
|
||||
constexpr usz c_max_tty_spill_size = 0x10'0000;
|
||||
|
||||
std::string tty_buffer(std::min<usz>(attempted_read_size, c_max_tty_spill_size), '\0');
|
||||
tty_buffer.resize(tty_read_fd.read_at(m_tty_file_init_pos, tty_buffer.data(), tty_buffer.size()));
|
||||
|
||||
if (!tty_buffer.empty())
|
||||
{
|
||||
// Mark start and end very clearly with RPCS3 put in it
|
||||
sys_log.notice("\nAccumulated RPCS3 TTY:\n\n\n%s\n\n\nEnd RPCS3 TTY Section.\n", tty_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Always Enable display sleep, not only if it was prevented.
|
||||
enable_display_sleep();
|
||||
|
||||
|
@ -139,6 +139,8 @@ class Emulator final
|
||||
|
||||
bool m_state_inspection_savestate = false;
|
||||
|
||||
usz m_tty_file_init_pos = umax;
|
||||
|
||||
std::vector<std::shared_ptr<atomic_t<u32>>> m_pause_msgs_refs;
|
||||
|
||||
std::vector<std::function<void()>> deferred_deserialization;
|
||||
|
Loading…
Reference in New Issue
Block a user