diff --git a/common/errormgmt.d b/common/errormgmt.d index 6ae4d06..bf75e51 100644 --- a/common/errormgmt.d +++ b/common/errormgmt.d @@ -32,8 +32,7 @@ void print_error(const(char) *message, int code, void print_error_adbg( const(char)* mod = __FILE__.ptr, int line = __LINE__) { debug printf("[%s@%d] ", mod, line); - const(adbg_error_t)* e = adbg_error_current(); - print_error(adbg_error_message(), e.code, null, e.func, e.line); + print_error(adbg_error_message(), adbg_error_code(), null, adbg_error_function(), adbg_error_line()); } void panic(int code, const(char)* message, @@ -45,8 +44,7 @@ void panic_crt(const(char)* prefix = null, const(char)* mod = __MODULE__.ptr, in panic(errno, strerror(errno), prefix, mod, line); } void panic_adbg(const(char)* prefix = null, const(char)* mod = __MODULE__.ptr) { - const(adbg_error_t)* e = adbg_error_current(); - panic(adbg_errno(), adbg_error_message(), prefix, e.func, e.line); + panic(adbg_errno(), adbg_error_message(), prefix, adbg_error_function(), adbg_error_line()); } void reset_error() { diff --git a/src/adbg/error.d b/src/adbg/error.d index 34b22a2..bf61c1d 100644 --- a/src/adbg/error.d +++ b/src/adbg/error.d @@ -107,6 +107,7 @@ enum AdbgError { libCapstone = 3002, /// Capstone } +// TODO: Make adbg_error_t struct private after removing adbg_error_current() /// Represents an error in alicedbg. struct adbg_error_t { int code; /// Error code @@ -117,6 +118,16 @@ struct adbg_error_t { /// Last error in alicedbg. private __gshared adbg_error_t error; +int adbg_error_code() { + return error.code; +} +int adbg_error_line() { + return error.line; +} +const(char)* adbg_error_function() { + return error.func; +} + //TODO: Strongly consider string, provides .ptr and .length private struct adbg_error_msg_t { int code; @@ -189,6 +200,7 @@ private immutable adbg_error_msg_t[] errors_msg = [ /// Returns: Pointer to the only error instance. //TODO: Deprecate as dangerous // Getting extra info such as source (string) and al. should be via functions +deprecated("Use adbg_error_function, adbg_error_line") const(adbg_error_t)* adbg_error_current() { return &error; }