mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Remove emulated stack trace.
This commit is contained in:
committed by
Christoffer Lerno
parent
ffb0021d04
commit
07c27f3292
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user