Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only log "always" messages in fatal_error_listener after Qt cli parsing #16247

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4790,7 +4790,7 @@ bool spu_thread::process_mfc_cmd()
getllar_spin_count = 0;
getllar_busy_waiting_switch = umax;

u64 ntime;
u64 ntime = 0;
rsx::reservation_lock rsx_lock(addr, 128);

for (u64 i = 0; i != umax; [&]()
Expand Down Expand Up @@ -4896,7 +4896,7 @@ bool spu_thread::process_mfc_cmd()
// Avoid logging useless commands if there is no reservation
const bool dump = g_cfg.core.mfc_debug && raddr;

const bool is_spurs_task_wait = pc == 0x11e4 && spurs_addr != -0x80u;
const bool is_spurs_task_wait = pc == 0x11e4 && spurs_addr != 0u - 0x80u;

if (!is_spurs_task_wait || spurs_addr != raddr || spurs_waited)
{
Expand Down Expand Up @@ -5570,6 +5570,8 @@ s64 spu_thread::get_ch_value(u32 ch)

thread_ctrl::wait_on(state, old);
}

fmt::throw_exception("Unreachable"); // Fix unannotated fallthrough warning
}

case MFC_RdTagStat:
Expand Down
28 changes: 24 additions & 4 deletions rpcs3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ LOG_CHANNEL(q_debug, "QDEBUG");

struct fatal_error_listener final : logs::listener
{
public:
~fatal_error_listener() override = default;

void log(u64 /*stamp*/, const logs::message& msg, const std::string& prefix, const std::string& text) override
{
if (msg <= logs::level::fatal)
if (msg == logs::level::fatal || (msg == logs::level::always && m_log_always))
{
std::string _msg = "RPCS3: ";

Expand All @@ -276,10 +277,17 @@ struct fatal_error_listener final : logs::listener
_msg += '\n';

// If launched from CMD
utils::attach_console(utils::console_stream::std_err, false);
utils::attach_console(msg == logs::level::fatal ? utils::console_stream::std_err : utils::console_stream::std_out, false);

// Output to error stream as is
utils::output_stderr(_msg);
if (msg == logs::level::fatal)
{
utils::output_stderr(_msg);
}
else
{
std::cout << _msg;
}

#ifdef _WIN32
if (IsDebuggerPresent())
Expand All @@ -295,6 +303,14 @@ struct fatal_error_listener final : logs::listener
}
}
}

void log_always(bool enabled)
{
m_log_always = enabled;
}

private:
bool m_log_always = false;
};

// Arguments that force a headless application (need to be checked in create_application)
Expand Down Expand Up @@ -572,7 +588,7 @@ int main(int argc, char** argv)
log_file = logs::make_file_listener(log_name, stats.avail_free / 4);
}

static std::unique_ptr<logs::listener> fatal_listener = std::make_unique<fatal_error_listener>();
static std::unique_ptr<fatal_error_listener> fatal_listener = std::make_unique<fatal_error_listener>();
logs::listener::add(fatal_listener.get());

{
Expand Down Expand Up @@ -1000,6 +1016,10 @@ int main(int argc, char** argv)
return 0;
}

// Enable console output of "always" log messages.
// Do this after parsing any Qt cli args that might open a window.
fatal_listener->log_always(true);

// Log unique ID
gui::utils::log_uuid();

Expand Down