From a78e812a644ff1fcd8aa08b0dba600250924ae94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 29 Nov 2018 21:02:56 +0100 Subject: [PATCH] Add `dereference` command to aid testing breakpad --- src/openrct2/interface/InteractiveConsole.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index f6f18a5d9c..3cf5381afc 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1341,6 +1341,18 @@ static int32_t cc_abort( return 0; } +static int32_t cc_dereference( + [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnull-dereference" + // Dereference a nullptr to induce a crash to be caught by crash handler, on supported platforms + uint8_t* myptr = nullptr; + *myptr = 42; + return 0; +#pragma GCC diagnostic pop +} + static int32_t cc_terminate( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc) { @@ -1413,6 +1425,7 @@ static constexpr const console_command console_command_table[] = { { "clear", cc_clear, "Clears the console.", "clear" }, { "close", cc_close, "Closes the console.", "close" }, { "date", cc_for_date, "Sets the date to a given date.", "Format [ [ ]]." }, + { "dereference", cc_dereference, "Dereferences a nullptr, for testing purposes only", "dereference" }, { "echo", cc_echo, "Echoes the text to the console.", "echo " }, { "exit", cc_close, "Closes the console.", "exit" }, { "get", cc_get, "Gets the value of the specified variable.", "get " },