<<
path:
root/public/0x2lib.git/html/0x2_Crashed.jai
blob: 764d92cbe495340463f09e83027da83c11b43313
[raw]
[clear marker]
3/** Currently (26.07.2026) Jai's crash handler does not print location data.
4 This modification from Cephon @ solarium.technology fixes this.
7 There are two ways to use this:
9 1. Importing necessary modules and initializing it
10 2. Using a macro with defaults that you might not like
17 Debug :: #import "Debug";
24 Debug.crash_handler = crash_handler;
27 Importing the Debug module will enable the module parameter `USE_GRAPHICS=true`.
28 This opens a window whenever an assertion hits.
29 To turn off this behavior, you must add:
32 Debug.set_report_mode(interactive = false);
44 Which does the things described above.
47 You can test a crash with:
50 t: *s32 = cast(*s32, 0);
56opinionated_init :: () #expand {
57 using,only(init) Debug :: #import "Debug";
60 Debug.crash_handler = crash_handler;
61 Debug.set_report_mode(interactive = false);
64crash_handler :: (trace_symbols: []string) {
65 using _ :: #import "String";
66 using _ :: #import "Process";
67 using _ :: #import "System";
70 found, _, right := split_from_right(it, " ");
74 process_result, output_string, _, _ := run_command(
75 "addr2line", "-e", get_path_of_running_executable(), "-f", "-C", "-p", right,
76 working_directory="", capture_and_return_output=true, timeout_ms = -1
78 if !(process_result.type == .EXITED && process_result.exit_code == 0) continue;
79 log("%", output_string);
87using,only(log) Basic :: #import "Basic";
91------------------------------------------------------------------------------
92This software is available under 2 licenses -- choose whichever you prefer.
93------------------------------------------------------------------------------
94ALTERNATIVE A - MIT License
95Copyright (c) 2026 Adam Blazeowsky
96Permission is hereby granted, free of charge, to any person obtaining a copy of
97this software and associated documentation files (the "Software"), to deal in
98the Software without restriction, including without limitation the rights to
99use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
100of the Software, and to permit persons to whom the Software is furnished to do
101so, subject to the following conditions:
102The above copyright notice and this permission notice shall be included in all
103copies or substantial portions of the Software.
104THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
111------------------------------------------------------------------------------
112ALTERNATIVE B - Public Domain (www.unlicense.org)
113This is free and unencumbered software released into the public domain.
114Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
115software, either in source code form or as a compiled binary, for any purpose,
116commercial or non-commercial, and by any means.
117In jurisdictions that recognize copyright laws, the author or authors of this
118software dedicate any and all copyright interest in the software to the public
119domain. We make this dedication for the benefit of the public at large and to
120the detriment of our heirs and successors. We intend this dedication to be an
121overt act of relinquishment in perpetuity of all present and future rights to
122this software under copyright law.
123THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
125FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
126AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
127ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
128WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
129------------------------------------------------------------------------------