upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
authorRaulOrtizSanchez <122691427+rrrarrra9@users.noreply.github.com>2026-11-23 16:50:42 +0100
committerGitHub <noreply@github.com>2026-11-23 09:50:42 -0600
commit1d7350424229b0d34e7c1836f4507936a1a41cb8 (patch)
treeb8c147206a6beec49267be2ccfb8c7edf10c6490 /runtime/src/main.cpp
parent2693dc59e44701a137c6b825a4f88cd83533de31 (diff)
runtime: retain import report when initialization fails (#6835)
Squash-merged after diff review of PR #6835 - RT-486: Retain the import binding report when initialization fails
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index b75baf15f..71a5b44e1 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -20,6 +20,7 @@
20 20
21#include <cstdio> 21#include <cstdio>
22#include <cstdlib> 22#include <cstdlib>
23#include <exception>
23#include <filesystem> 24#include <filesystem>
24#include <map> 25#include <map>
25#include <string> 26#include <string>
@@ -179,9 +180,15 @@ int wmain(int argc, wchar_t** argv) {
179 r.error); 180 r.error);
180 } 181 }
181 if (run) rt::process::set_command_line(image.filename().wstring(), game_args); 182 if (run) rt::process::set_command_line(image.filename().wstring(), game_args);
183 std::exception_ptr init_failure;
182 if (init || run) { 184 if (init || run) {
183 loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs 185 try {
184 std::printf("%zu module(s) initialised\n", loader.modules().size()); 186 loader.initialise(); // TLS callbacks, then DllMain(DLL_PROCESS_ATTACH) for DLLs
187 std::printf("%zu module(s) initialised\n", loader.modules().size());
188 } catch (const std::exception&) {
189 // Keep the mapped modules available for the binding report on an attach failure.
190 init_failure = std::current_exception();
191 }
185 } 192 }
186 int unimplemented = 0, unimplemented_hresult = 0; 193 int unimplemented = 0, unimplemented_hresult = 0;
187 for (auto* m : loader.modules()) { 194 for (auto* m : loader.modules()) {
@@ -205,6 +212,10 @@ int wmain(int argc, wchar_t** argv) {
205 std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); 212 std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented);
206 std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult, 213 std::printf("unimplemented by return policy: hresult=%d other=%d\n", unimplemented_hresult,
207 unimplemented - unimplemented_hresult); 214 unimplemented - unimplemented_hresult);
215 if (init_failure) {
216 std::fflush(stdout);
217 std::rethrow_exception(init_failure);
218 }
208 if (!run) { 219 if (!run) {
209 rt::startup_trace::event("exit", "\"code\":0"); 220 rt::startup_trace::event("exit", "\"code\":0");
210 return 0; 221 return 0;