libyasm
|
YASM error and warning reporting interface. More...
Go to the source code of this file.
Macros | |
#define | YASM_LIB_DECL |
#define | yasm_internal_error(message) yasm_internal_error_(__FILE__, __LINE__, message) |
Easily-callable version of yasm_internal_error_(). More... | |
Typedefs | |
typedef enum yasm_warn_class | yasm_warn_class |
Warning classes (that may be enabled/disabled). More... | |
typedef enum yasm_error_class | yasm_error_class |
Error classes. More... | |
typedef void(* | yasm_print_error_func )(const char *fn, unsigned long line, const char *msg, const char *xref_fn, unsigned long xref_line, const char *xref_msg) |
Print out an error. More... | |
typedef void(* | yasm_print_warning_func )(const char *fn, unsigned long line, const char *msg) |
Print out a warning. More... | |
Enumerations | |
enum | yasm_warn_class { YASM_WARN_NONE = 0, YASM_WARN_GENERAL, YASM_WARN_UNREC_CHAR, YASM_WARN_PREPROC, YASM_WARN_ORPHAN_LABEL, YASM_WARN_UNINIT_CONTENTS, YASM_WARN_SIZE_OVERRIDE, YASM_WARN_IMPLICIT_SIZE_OVERRIDE } |
Warning classes (that may be enabled/disabled). More... | |
enum | yasm_error_class { YASM_ERROR_NONE = 0x0000, YASM_ERROR_GENERAL = 0xFFFF, YASM_ERROR_ARITHMETIC = 0x0001, YASM_ERROR_OVERFLOW = 0x8001, YASM_ERROR_FLOATING_POINT = 0x4001, YASM_ERROR_ZERO_DIVISION = 0x2001, YASM_ERROR_ASSERTION = 0x0002, YASM_ERROR_VALUE = 0x0004, YASM_ERROR_NOT_ABSOLUTE = 0x8004, YASM_ERROR_TOO_COMPLEX = 0x4004, YASM_ERROR_NOT_CONSTANT = 0x2004, YASM_ERROR_IO = 0x0008, YASM_ERROR_NOT_IMPLEMENTED = 0x0010, YASM_ERROR_TYPE = 0x0020, YASM_ERROR_SYNTAX = 0x0040, YASM_ERROR_PARSE = 0x8040 } |
Error classes. More... | |
Functions | |
YASM_LIB_DECL void | yasm_errwarn_initialize (void) |
Initialize any internal data structures. More... | |
YASM_LIB_DECL void | yasm_errwarn_cleanup (void) |
Clean up any memory allocated by yasm_errwarn_initialize() or other functions. | |
YASM_LIB_DECL void | yasm__fatal (const char *message,...) |
Reporting point of fatal errors, with variable arguments (internal only). More... | |
YASM_LIB_DECL void | yasm_error_clear (void) |
Unconditionally clear the error indicator, freeing any associated data. More... | |
yasm_error_class | yasm_error_occurred (void) |
Get the error indicator. More... | |
YASM_LIB_DECL int | yasm_error_matches (yasm_error_class eclass) |
Check the error indicator against an error class. More... | |
YASM_LIB_DECL void | yasm_error_set_va (yasm_error_class eclass, const char *format, va_list va) |
Set the error indicator (va_list version). More... | |
YASM_LIB_DECL void | yasm_error_set (yasm_error_class eclass, const char *format,...) |
Set the error indicator. More... | |
YASM_LIB_DECL void | yasm_error_set_xref_va (unsigned long xrefline, const char *format, va_list va) |
Set a cross-reference for a new error (va_list version). More... | |
YASM_LIB_DECL void | yasm_error_set_xref (unsigned long xrefline, const char *format,...) |
Set a cross-reference for a new error. More... | |
YASM_LIB_DECL void | yasm_error_fetch (yasm_error_class *eclass, char **str, unsigned long *xrefline, char **xrefstr) |
Fetch the error indicator and all associated data. More... | |
YASM_LIB_DECL void | yasm_warn_clear (void) |
Unconditionally clear all warning indicators, freeing any associated data. More... | |
YASM_LIB_DECL yasm_warn_class | yasm_warn_occurred (void) |
Get the first warning indicator. More... | |
YASM_LIB_DECL void | yasm_warn_set_va (yasm_warn_class wclass, const char *format, va_list va) |
Add a warning indicator (va_list version). More... | |
YASM_LIB_DECL void | yasm_warn_set (yasm_warn_class wclass, const char *format,...) |
Add a warning indicator. More... | |
YASM_LIB_DECL void | yasm_warn_fetch (yasm_warn_class *wclass, char **str) |
Fetch the first warning indicator and all associated data. More... | |
YASM_LIB_DECL void | yasm_warn_enable (yasm_warn_class wclass) |
Enable a class of warnings. More... | |
YASM_LIB_DECL void | yasm_warn_disable (yasm_warn_class wclass) |
Disable a class of warnings. More... | |
YASM_LIB_DECL void | yasm_warn_disable_all (void) |
Disable all classes of warnings. More... | |
YASM_LIB_DECL yasm_errwarns * | yasm_errwarns_create (void) |
Create an error/warning set for collection of multiple error/warnings. More... | |
YASM_LIB_DECL void | yasm_errwarns_destroy (yasm_errwarns *errwarns) |
Destroy an error/warning set. More... | |
YASM_LIB_DECL void | yasm_errwarn_propagate (yasm_errwarns *errwarns, unsigned long line) |
Propagate error indicator and warning indicator(s) to an error/warning set. More... | |
YASM_LIB_DECL unsigned int | yasm_errwarns_num_errors (yasm_errwarns *errwarns, int warning_as_error) |
Get total number of errors logged. More... | |
YASM_LIB_DECL void | yasm_errwarns_output_all (yasm_errwarns *errwarns, yasm_linemap *lm, int warning_as_error, yasm_print_error_func print_error, yasm_print_warning_func print_warning) |
Outputs error/warning set in sorted order (sorted by virtual line number). More... | |
YASM_LIB_DECL char * | yasm__conv_unprint (int ch) |
Convert a possibly unprintable character into a printable string. More... | |
Variables | |
YASM_LIB_DECL void(* | yasm_internal_error_ )(const char *file, unsigned int line, const char *message) |
Reporting point of internal errors. More... | |
YASM_LIB_DECL void(* | yasm_fatal )(const char *message, va_list va) |
Reporting point of fatal errors. More... | |
YASM_LIB_DECL const char *(* | yasm_gettext_hook )(const char *msgid) |
Hook for library users to map to gettext() if GNU gettext is being used. More... | |
YASM error and warning reporting interface.
Definition in file errwarn.h.
#define yasm_internal_error | ( | message | ) | yasm_internal_error_(__FILE__, __LINE__, message) |
Easily-callable version of yasm_internal_error_().
Automatically uses FILE and LINE as the file and line.
message | internal error message |
typedef enum yasm_error_class yasm_error_class |
Error classes.
Bitmask-based to support limited subclassing.
typedef void(* yasm_print_error_func)(const char *fn, unsigned long line, const char *msg,const char *xref_fn, unsigned long xref_line,const char *xref_msg) |
typedef void(* yasm_print_warning_func)(const char *fn, unsigned long line, const char *msg) |
typedef enum yasm_warn_class yasm_warn_class |
Warning classes (that may be enabled/disabled).
enum yasm_error_class |
Error classes.
Bitmask-based to support limited subclassing.
enum yasm_warn_class |
Warning classes (that may be enabled/disabled).
YASM_LIB_DECL char* yasm__conv_unprint | ( | int | ch | ) |
Convert a possibly unprintable character into a printable string.
ch | possibly unprintable character |
YASM_LIB_DECL void yasm__fatal | ( | const char * | message, |
... | |||
) |
Reporting point of fatal errors, with variable arguments (internal only).
message | fatal error message |
... | argument list for message |
YASM_LIB_DECL void yasm_error_clear | ( | void | ) |
Unconditionally clear the error indicator, freeing any associated data.
Has no effect if the error indicator is not set.
YASM_LIB_DECL void yasm_error_fetch | ( | yasm_error_class * | eclass, |
char ** | str, | ||
unsigned long * | xrefline, | ||
char ** | xrefstr | ||
) |
Fetch the error indicator and all associated data.
If the error indicator is set, the output pointers are set to the current error indicator values, and the error indicator is cleared. The code using this function is then responsible for yasm_xfree()'ing str and xrefstr (if non-NULL). If the error indicator is not set, all output values are set to 0 (including eclass, which is set to YASM_ERROR_NONE).
eclass | error class (output) |
str | error message |
xrefline | virtual line used for cross-referencing (0 if no xref) |
xrefstr | cross-reference error message (NULL if no xref) |
YASM_LIB_DECL int yasm_error_matches | ( | yasm_error_class | eclass | ) |
Check the error indicator against an error class.
To check if any error has been set, check against the YASM_ERROR_GENERAL class. This function properly checks error subclasses.
eclass | base error class to check against |
yasm_error_class yasm_error_occurred | ( | void | ) |
Get the error indicator.
YASM_ERROR_NONE is returned if no error has been set. Note that as YASM_ERROR_NONE is 0, the return value can also be treated as a boolean value.
YASM_LIB_DECL void yasm_error_set | ( | yasm_error_class | eclass, |
const char * | format, | ||
... | |||
) |
Set the error indicator.
Has no effect if the error indicator is already set.
eclass | error class |
format | printf format string |
... | argument list for format |
YASM_LIB_DECL void yasm_error_set_va | ( | yasm_error_class | eclass, |
const char * | format, | ||
va_list | va | ||
) |
Set the error indicator (va_list version).
Has no effect if the error indicator is already set.
eclass | error class |
format | printf format string |
va | argument list for format |
YASM_LIB_DECL void yasm_error_set_xref | ( | unsigned long | xrefline, |
const char * | format, | ||
... | |||
) |
Set a cross-reference for a new error.
Has no effect if the error indicator is already set (e.g. with yasm_error_set()). This function must be called prior to its corresponding yasm_error_set() call.
xrefline | virtual line to cross-reference to (should not be 0) |
format | printf format string |
... | argument list for format |
YASM_LIB_DECL void yasm_error_set_xref_va | ( | unsigned long | xrefline, |
const char * | format, | ||
va_list | va | ||
) |
Set a cross-reference for a new error (va_list version).
Has no effect if the error indicator is already set (e.g. with yasm_error_set()). This function must be called prior to its corresponding yasm_error_set() call.
xrefline | virtual line to cross-reference to (should not be 0) |
format | printf format string |
va | argument list for format |
YASM_LIB_DECL void yasm_errwarn_initialize | ( | void | ) |
Initialize any internal data structures.
YASM_LIB_DECL void yasm_errwarn_propagate | ( | yasm_errwarns * | errwarns, |
unsigned long | line | ||
) |
Propagate error indicator and warning indicator(s) to an error/warning set.
Has no effect if the error indicator and warning indicator are not set. Does not print immediately; yasm_errwarn_output_all() outputs accumulated errors and warnings. Generally multiple errors on the same line will be reported, but errors of class YASM_ERROR_PARSE will get overwritten by any other class on the same line.
errwarns | error/warning set |
line | virtual line |
YASM_LIB_DECL yasm_errwarns* yasm_errwarns_create | ( | void | ) |
Create an error/warning set for collection of multiple error/warnings.
YASM_LIB_DECL void yasm_errwarns_destroy | ( | yasm_errwarns * | errwarns | ) |
Destroy an error/warning set.
errwarns | error/warning set |
YASM_LIB_DECL unsigned int yasm_errwarns_num_errors | ( | yasm_errwarns * | errwarns, |
int | warning_as_error | ||
) |
Get total number of errors logged.
errwarns | error/warning set |
warning_as_error | if nonzero, warnings are treated as errors. |
YASM_LIB_DECL void yasm_errwarns_output_all | ( | yasm_errwarns * | errwarns, |
yasm_linemap * | lm, | ||
int | warning_as_error, | ||
yasm_print_error_func | print_error, | ||
yasm_print_warning_func | print_warning | ||
) |
Outputs error/warning set in sorted order (sorted by virtual line number).
errwarns | error/warning set |
lm | line map (to convert virtual lines into filename/line pairs) |
warning_as_error | if nonzero, treat warnings as errors. |
print_error | function called to print out errors |
print_warning | function called to print out warnings |
YASM_LIB_DECL void yasm_warn_clear | ( | void | ) |
Unconditionally clear all warning indicators, freeing any associated data.
Has no effect if no warning indicators have been set.
YASM_LIB_DECL void yasm_warn_disable | ( | yasm_warn_class | wclass | ) |
Disable a class of warnings.
wclass | warning class |
YASM_LIB_DECL void yasm_warn_disable_all | ( | void | ) |
Disable all classes of warnings.
YASM_LIB_DECL void yasm_warn_enable | ( | yasm_warn_class | wclass | ) |
Enable a class of warnings.
wclass | warning class |
YASM_LIB_DECL void yasm_warn_fetch | ( | yasm_warn_class * | wclass, |
char ** | str | ||
) |
Fetch the first warning indicator and all associated data.
If there is at least one warning indicator, the output pointers are set to the first warning indicator values, and first warning indicator is removed. The code using this function is then responsible for yasm_xfree()'ing str and xrefstr (if non-NULL). If there is no warning indicator set, all output values are set to 0 (including wclass, which is set to YASM_WARN_NONE).
wclass | warning class (output) |
str | warning message |
YASM_LIB_DECL yasm_warn_class yasm_warn_occurred | ( | void | ) |
Get the first warning indicator.
YASM_WARN_NONE is returned if no warning has been set. Note that as YASM_WARN_NONE is 0, the return value can also be treated as a boolean value.
YASM_LIB_DECL void yasm_warn_set | ( | yasm_warn_class | wclass, |
const char * | format, | ||
... | |||
) |
Add a warning indicator.
wclass | warning class |
format | printf format string |
... | argument list for format |
YASM_LIB_DECL void yasm_warn_set_va | ( | yasm_warn_class | wclass, |
const char * | format, | ||
va_list | va | ||
) |
Add a warning indicator (va_list version).
wclass | warning class |
format | printf format string |
va | argument list for format |
YASM_LIB_DECL void(* yasm_fatal)(const char *message, va_list va) |
Reporting point of fatal errors.
message | fatal error message |
va | va_list argument list for message |
YASM_LIB_DECL const char*(* yasm_gettext_hook)(const char *msgid) |
Hook for library users to map to gettext() if GNU gettext is being used.
msgid | message catalog identifier |
YASM_LIB_DECL void(* yasm_internal_error_)(const char *file, unsigned int line, const char *message) |
Reporting point of internal errors.
These are usually due to sanity check failures in the code.
file | source file (ala FILE) |
line | source line (ala LINE) |
message | internal error message |