Remove emulated stack trace.

This commit is contained in:
Christoffer Lerno
2023-11-17 01:19:37 +01:00
committed by Christoffer Lerno
parent ffb0021d04
commit 07c27f3292
13 changed files with 22 additions and 289 deletions

View File

@@ -68,25 +68,6 @@ macro anycast(any* v, $Type) @builtin
return ($Type*)v.ptr;
}
enum CallLocation : int(String name)
{
UNKNOWN("???"),
FUNCTION("function"),
METHOD("method"),
MACRO("macro"),
LAMBDA("lambda"),
TEST("test"),
}
struct CallstackElement
{
CallstackElement* prev;
String function;
String file;
CallLocation location;
uint line;
}
fn bool print_backtrace(String message, int backtraces_to_ignore) @if(env::NATIVE_STACKTRACE)
{
@pool()
@@ -132,27 +113,10 @@ fn void default_panic(String message, String file, String function, uint line) @
}
fn void default_panic(String message, String file, String function, uint line) @if(!env::NATIVE_STACKTRACE)
{
CallstackElement* stack = $$stacktrace();
$if $defined(io::stderr):
if (stack) stack = stack.prev;
if (stack)
{
io::eprint("\nERROR: '");
io::eprint(message);
io::eprintn("'");
}
else
{
io::eprint("\nERROR: '");
io::eprint(message);
io::eprintfn("', in %s (%s:%d)", function, file, line);
}
while (stack)
{
io::eprintfn(" in %s %s (%s:%d)", stack.location.name, stack.function, stack.file, stack.line);
if (stack == stack.prev) break;
stack = stack.prev;
}
io::eprint("\nERROR: '");
io::eprint(message);
io::eprintfn("', in %s (%s:%d)", function, file, line);
$endif
$$trap();
}

View File

@@ -4,14 +4,6 @@
module std::core::runtime;
import libc;
struct StackTrace
{
StackTrace* prev;
String file;
String function;
uint line;
}
struct AnyStruct
{
void* ptr;
@@ -223,8 +215,6 @@ fn bool run_tests(TestUnit[] tests)
name.appendf("Testing %s ", unit.name);
name.append_repeat('.', max_name - unit.name.len + 2);
io::printf("%s ", name.str_view());
CallstackElement* stack = $$stacktrace();
if (stack) stack.prev = null;
if (libc::setjmp(&context.buf) == 0)
{
if (catch err = unit.func())