From 2357717e375bc906050af3bd3a77fc244b0dbdf7 Mon Sep 17 00:00:00 2001 From: Stephen Hosom <0xhosom@gmail.com> Date: Wed, 19 Dec 2018 08:33:04 -0500 Subject: [PATCH 1/3] Add fatal_error_with_core bif This patch adds a bif for aborting and obtaining a core file from script land. --- src/reporter.bif | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/reporter.bif b/src/reporter.bif index 92088e5fc9..484b0ca007 100644 --- a/src/reporter.bif +++ b/src/reporter.bif @@ -72,6 +72,20 @@ function Reporter::fatal%(msg: string%): bool return new Val(1, TYPE_BOOL); %} +## Generates a fatal error on stderr and terminates program execution +## after dumping a core file +## +## msg: The error message to report. +## +## Returns: Always true. +function Reporter::fatal_error_with_core%(msg: string%): bool + %{ + reporter-PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->FatalError("%s", msg->CheckString()); + reporter->PopLocation(); + return new Val(1, TYPE_BOOL); + %} + ## Generates a "net" weird. ## ## name: the name of the weird. From 96999f5687e31e6feee84f0fc59b15880a42b897 Mon Sep 17 00:00:00 2001 From: Stephen Hosom <0xhosom@gmail.com> Date: Wed, 19 Dec 2018 08:58:41 -0500 Subject: [PATCH 2/3] Fix syntax error --- src/reporter.bif | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reporter.bif b/src/reporter.bif index 484b0ca007..1af50dd2d0 100644 --- a/src/reporter.bif +++ b/src/reporter.bif @@ -80,7 +80,7 @@ function Reporter::fatal%(msg: string%): bool ## Returns: Always true. function Reporter::fatal_error_with_core%(msg: string%): bool %{ - reporter-PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCall()->GetLocationInfo()); reporter->FatalError("%s", msg->CheckString()); reporter->PopLocation(); return new Val(1, TYPE_BOOL); From 6be5151291215b63068c50a813a343f27ccd1bfb Mon Sep 17 00:00:00 2001 From: Stephen Hosom <0xhosom@gmail.com> Date: Wed, 19 Dec 2018 10:33:41 -0500 Subject: [PATCH 3/3] Call FatalErrorWithCore instead of FatalError Previously, this bif didn't reference the correct function. --- src/reporter.bif | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reporter.bif b/src/reporter.bif index 1af50dd2d0..56eef4651a 100644 --- a/src/reporter.bif +++ b/src/reporter.bif @@ -81,7 +81,7 @@ function Reporter::fatal%(msg: string%): bool function Reporter::fatal_error_with_core%(msg: string%): bool %{ reporter->PushLocation(frame->GetCall()->GetLocationInfo()); - reporter->FatalError("%s", msg->CheckString()); + reporter->FatalErrorWithCore("%s", msg->CheckString()); reporter->PopLocation(); return new Val(1, TYPE_BOOL); %}