From 4ae63dd796e4e87f81d8dc6155bf5d220f41fd4a Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Sat, 1 Feb 2025 12:01:15 +0000 Subject: [PATCH] Continue 6424 --- far/changelog | 5 +++++ far/exception_handler.cpp | 20 ++++++++++++++------ far/exception_handler.hpp | 1 + far/interf.cpp | 17 ++++++++++------- far/interf.hpp | 1 + far/log.hpp | 2 ++ far/main.cpp | 2 ++ far/vbuild.m4 | 2 +- 8 files changed, 36 insertions(+), 14 deletions(-) diff --git a/far/changelog b/far/changelog index 0a4dc2983f..afab1b841a 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,8 @@ +-------------------------------------------------------------------------------- +drkns 2025-02-01 11:59:59+00:00 - build 6427 + +1. Continue 6424. + -------------------------------------------------------------------------------- drkns 2025-02-01 02:49:37+00:00 - build 6426 diff --git a/far/exception_handler.cpp b/far/exception_handler.cpp index 656ea5fe10..9d2ce4edbb 100644 --- a/far/exception_handler.cpp +++ b/far/exception_handler.cpp @@ -128,6 +128,14 @@ static bool HandleCppExceptions = true; static bool HandleSehExceptions = true; static bool ForceStderrExceptionUI = false; +static bool s_ReportToStdErr = false; + +// On CI we can't access the filesystem, so just drop everything to stderr. +void report_to_stderr() +{ + s_ReportToStdErr = true; +} + static wchar_t s_ReportLocation[MAX_PATH]; // We can crash in the cleanup phase when profile paths are already destroyed. @@ -1811,7 +1819,7 @@ static handler_result handle_generic_exception( SCOPED_ACTION(tracer_detail::tracer::with_symbols)(PluginModule? ModuleName : L""sv); - const auto ReportLocation = get_report_location(); + const auto ReportLocation = s_ReportToStdErr? L"below"s : get_report_location(); LOGERROR(L"Unhandled exception, see {} for details"sv, ReportLocation); @@ -1839,12 +1847,12 @@ static handler_result handle_generic_exception( MiniDumpIgnoreInaccessibleMemory ); - const auto MinidumpNormal = write_minidump(Context, path::join(ReportLocation, WIDE_SV(MINIDUMP_NAME)), MinidumpFlags); - const auto MinidumpFull = write_minidump(Context, path::join(ReportLocation, WIDE_SV(FULLDUMP_NAME)), FulldumpFlags); + const auto MinidumpNormal = !s_ReportToStdErr && write_minidump(Context, path::join(ReportLocation, WIDE_SV(MINIDUMP_NAME)), MinidumpFlags); + const auto MinidumpFull = !s_ReportToStdErr && write_minidump(Context, path::join(ReportLocation, WIDE_SV(FULLDUMP_NAME)), FulldumpFlags); const auto BugReport = collect_information(Context, Location, PluginInfo, ModuleName, Type, Message, ErrorState, NestedStack); - const auto ReportOnDisk = write_report(BugReport, path::join(ReportLocation, WIDE_SV(BUGREPORT_NAME))); - const auto ReportInClipboard = !ReportOnDisk && SetClipboardText(BugReport); - const auto ReadmeOnDisk = write_readme(path::join(ReportLocation, L"README.txt"sv)); + const auto ReportOnDisk = !s_ReportToStdErr && write_report(BugReport, path::join(ReportLocation, WIDE_SV(BUGREPORT_NAME))); + const auto ReportInClipboard = !s_ReportToStdErr && !ReportOnDisk && SetClipboardText(BugReport); + const auto ReadmeOnDisk = !s_ReportToStdErr && write_readme(path::join(ReportLocation, L"README.txt"sv)); const auto AnythingOnDisk = ReportOnDisk || MinidumpNormal || MinidumpFull || ReadmeOnDisk; if (AnythingOnDisk && os::is_interactive_user_session()) diff --git a/far/exception_handler.hpp b/far/exception_handler.hpp index b2a4a04807..6b14237fbd 100644 --- a/far/exception_handler.hpp +++ b/far/exception_handler.hpp @@ -48,6 +48,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //---------------------------------------------------------------------------- +void report_to_stderr(); void set_report_location(string_view Directory); void disable_exception_handling(); diff --git a/far/interf.cpp b/far/interf.cpp index 6e2cda6e0e..048ad33b00 100644 --- a/far/interf.cpp +++ b/far/interf.cpp @@ -1698,15 +1698,15 @@ point GetNonMaximisedBufferSize() return NonMaximisedBufferSize(); } -size_t ConsoleChoice(string_view const Message, string_view const Choices, size_t const Default, function_ref const MessagePrinter) +static bool s_SuppressConsoleConfirmations; + +void suppress_console_confirmations() { - { - // The output can be redirected - DWORD Mode; - if (!console.GetMode(console.GetOutputHandle(), Mode)) - return Default; - } + s_SuppressConsoleConfirmations = true; +} +size_t ConsoleChoice(string_view const Message, string_view const Choices, size_t const Default, function_ref const MessagePrinter) +{ if (InitialConsoleMode) { ChangeConsoleMode(console.GetInputHandle(), InitialConsoleMode->Input); @@ -1722,6 +1722,9 @@ size_t ConsoleChoice(string_view const Message, string_view const Choices, size_ { std::wcout << far::format(L"\n{} ({})? "sv, Message, join(L"/"sv, Choices)) << std::flush; + if (s_SuppressConsoleConfirmations) + return Default; + wchar_t Input; std::wcin.clear(); std::wcin.get(Input).ignore(std::numeric_limits::max(), L'\n'); diff --git a/far/interf.hpp b/far/interf.hpp index d14c2c4ce9..0cdbec128e 100644 --- a/far/interf.hpp +++ b/far/interf.hpp @@ -296,6 +296,7 @@ class consoleicons: public singleton icon m_Small{false}; }; +void suppress_console_confirmations(); size_t ConsoleChoice(string_view Message, string_view Choices, size_t Default, function_ref MessagePrinter); bool ConsoleYesNo(string_view Message, bool Default, function_ref MessagePrinter); diff --git a/far/log.hpp b/far/log.hpp index 86de87839c..4d5dc76cdf 100644 --- a/far/log.hpp +++ b/far/log.hpp @@ -33,6 +33,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Internal: +// console must outlive logger +#include "console.hpp" // Platform: diff --git a/far/main.cpp b/far/main.cpp index 50cda5b566..38e4f06f21 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -965,6 +965,8 @@ static void configure_exception_handling(std::span const A if (equal_icase(i + 1, L"service"sv)) { os::debug::crt_report_to_stderr(); + report_to_stderr(); + suppress_console_confirmations(); continue; } } diff --git a/far/vbuild.m4 b/far/vbuild.m4 index a330905a74..0923d63171 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -6426 +6427