From 1d4a9e7cb47178077e112f73bf6a60397f519497 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 25 Oct 2016 20:31:05 -0400 Subject: driver: struct mdso_error_info: extend and refactor. --- include/mdso/mdso.h | 15 +++++++++------ src/internal/mdso_errinfo_impl.c | 25 +++++++++++++------------ src/internal/mdso_errinfo_impl.h | 16 ++++++++-------- src/output/mdso_output_error.c | 24 ++++++++++++------------ 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/include/mdso/mdso.h b/include/mdso/mdso.h index 9efda11..1cceb7b 100644 --- a/include/mdso/mdso.h +++ b/include/mdso/mdso.h @@ -58,12 +58,15 @@ struct mdso_input { }; struct mdso_error_info { - int syserror; - int liberror; - const char * function; - int line; - unsigned flags; - void * ctx; + const struct mdso_driver_ctx * edctx; + const struct mdso_unit_ctx * euctx; + const char * eunit; + int esyscode; + int elibcode; + const char * efunction; + int eline; + unsigned eflags; + void * eany; }; struct mdso_common_ctx { diff --git a/src/internal/mdso_errinfo_impl.c b/src/internal/mdso_errinfo_impl.c index e106f47..fbd8433 100644 --- a/src/internal/mdso_errinfo_impl.c +++ b/src/internal/mdso_errinfo_impl.c @@ -10,12 +10,12 @@ int mdso_record_error( const struct mdso_driver_ctx * dctx, - int syserror, - int liberror, - const char * function, - int line, - unsigned flags, - void * ctx) + int esyscode, + int elibcode, + const char * efunction, + int eline, + unsigned eflags, + void * eany) { struct mdso_driver_ctx_impl * ictx; struct mdso_error_info * erri; @@ -28,12 +28,13 @@ int mdso_record_error( *ictx->errinfp = &ictx->erribuf[ictx->errinfp - ictx->erriptr]; erri = *ictx->errinfp; - erri->syserror = syserror; - erri->liberror = liberror; - erri->function = function; - erri->line = line; - erri->flags = flags; - erri->ctx = ctx; + erri->edctx = dctx; + erri->esyscode = esyscode; + erri->elibcode = elibcode; + erri->efunction = efunction; + erri->eline = eline; + erri->eflags = eflags; + erri->eany = eany; ictx->errinfp++; diff --git a/src/internal/mdso_errinfo_impl.h b/src/internal/mdso_errinfo_impl.h index 5a56e70..0e9b384 100644 --- a/src/internal/mdso_errinfo_impl.h +++ b/src/internal/mdso_errinfo_impl.h @@ -9,12 +9,12 @@ int mdso_record_error( const struct mdso_driver_ctx *, - int syserror, - int liberror, - const char * function, - int line, - unsigned flags, - void * ctx); + int esyscode, + int elibcode, + const char * efunction, + int eline, + unsigned eflags, + void * eany); #define MDSO_SYSTEM_ERROR(dctx) \ mdso_record_error( \ @@ -58,11 +58,11 @@ int mdso_record_error( MDSO_ERROR_TOP_LEVEL, \ 0) -#define MDSO_CUSTOM_ERROR(dctx,liberror) \ +#define MDSO_CUSTOM_ERROR(dctx,elibcode) \ mdso_record_error( \ dctx, \ 0, \ - liberror, \ + elibcode, \ __func__, \ __LINE__, \ MDSO_ERROR_TOP_LEVEL \ diff --git a/src/output/mdso_output_error.c b/src/output/mdso_output_error.c index 25817aa..59469b9 100644 --- a/src/output/mdso_output_error.c +++ b/src/output/mdso_output_error.c @@ -19,13 +19,13 @@ static const char aclr_magenta[] = "\x1b[35m"; static const char * mdso_output_error_header(const struct mdso_error_info * erri) { - if (erri->flags & MDSO_ERROR_CHILD) + if (erri->eflags & MDSO_ERROR_CHILD) return "exec error upon"; - else if (erri->flags & MDSO_ERROR_TOP_LEVEL) + else if (erri->eflags & MDSO_ERROR_TOP_LEVEL) return "error logged in"; - else if (erri->flags & MDSO_ERROR_NESTED) + else if (erri->eflags & MDSO_ERROR_NESTED) return "< returned to >"; else @@ -34,20 +34,20 @@ static const char * mdso_output_error_header(const struct mdso_error_info * erri static const char * mdso_output_strerror(const struct mdso_error_info * erri) { - if (erri->flags & MDSO_ERROR_CUSTOM) + if (erri->eflags & MDSO_ERROR_CUSTOM) return "flow error: unexpected condition or other"; - else if (erri->flags & MDSO_ERROR_NESTED) + else if (erri->eflags & MDSO_ERROR_NESTED) return ""; - else if (erri->flags & MDSO_ERROR_CHILD) + else if (erri->eflags & MDSO_ERROR_CHILD) return "(see child process error messages)"; - else if (erri->syserror == ENOBUFS) + else if (erri->esyscode == ENOBUFS) return "input error: string length exceeds buffer size."; else - return strerror(erri->syserror); + return strerror(erri->esyscode); } static int mdso_output_error_record_plain( @@ -59,8 +59,8 @@ static int mdso_output_error_record_plain( if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n", dctx->program, mdso_output_error_header(erri), - erri->function, - erri->line, + erri->efunction, + erri->eline, strlen(errdesc) ? ": " : "", errdesc) < 0) return -1; @@ -87,11 +87,11 @@ static int mdso_output_error_record_annotated( aclr_reset, aclr_bold,aclr_blue, - erri->function, + erri->efunction, aclr_reset, aclr_bold,aclr_green, - erri->line, + erri->eline, aclr_reset, strlen(errdesc) ? ": " : "", -- cgit v1.2.3