From: Nicholas Nethercote Date: Mon, 2 Aug 2004 12:21:09 +0000 (+0000) Subject: Make the Supp and Error types local to vg_errcontext.h; they don't need to be X-Git-Tag: svn/VALGRIND_2_2_0~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde70741c700f71719e2626b6fdca459e0268bfc;p=thirdparty%2Fvalgrind.git Make the Supp and Error types local to vg_errcontext.h; they don't need to be global. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2545 --- diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index b4338a8c06..646cebc8a1 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -52,6 +52,139 @@ static UInt vg_n_errs_suppressed = 0; static Supp* is_suppressible_error ( Error* err ); +/*------------------------------------------------------------*/ +/*--- Error type ---*/ +/*------------------------------------------------------------*/ + +/* Note: it is imperative this doesn't overlap with (0..) at all, as skins + * effectively extend it by defining their own enums in the (0..) range. */ +typedef + enum { + PThreadErr = -1, // Pthreading error + } + CoreErrorKind; + +/* Errors. Extensible (via the 'extra' field). Tools can use a normal + enum (with element values in the normal range (0..)) for `ekind'. + Functions for getting/setting the tool-relevant fields are in + include/vg_skin.h. + + When errors are found and recorded with VG_(maybe_record_error)(), all + the tool must do is pass in the four parameters; core will + allocate/initialise the error record. +*/ +struct _Error { + struct _Error* next; + // NULL if unsuppressed; or ptr to suppression record. + Supp* supp; + Int count; + ThreadId tid; + + // The tool-specific part + ExeContext* where; // Initialised by core + Int ekind; // Used by ALL. Must be in the range (0..) + Addr addr; // Used frequently + Char* string; // Used frequently + void* extra; // For any tool-specific extras +}; + +ExeContext* VG_(get_error_where) ( Error* err ) +{ + return err->where; +} + +ErrorKind VG_(get_error_kind) ( Error* err ) +{ + return err->ekind; +} + +Addr VG_(get_error_address) ( Error* err ) +{ + return err->addr; +} + +Char* VG_(get_error_string) ( Error* err ) +{ + return err->string; +} + +void* VG_(get_error_extra) ( Error* err ) +{ + return err->extra; +} + +/*------------------------------------------------------------*/ +/*--- Suppression type ---*/ +/*------------------------------------------------------------*/ + +/* Note: it is imperative this doesn't overlap with (0..) at all, as tools + * effectively extend it by defining their own enums in the (0..) range. */ +typedef + enum { + PThreadSupp = -1, /* Matches PThreadErr */ + } + CoreSuppKind; + +/* For each caller specified for a suppression, record the nature of + the caller name. Not of interest to tools. */ +typedef + enum { + ObjName, /* Name is of an shared object file. */ + FunName /* Name is of a function. */ + } + SuppLocTy; + +/* Suppressions. Tools can get/set tool-relevant parts with functions + declared in include/vg_skin.h. Extensible via the 'extra' field. + Tools can use a normal enum (with element values in the normal range + (0..)) for `skind'. */ +struct _Supp { + struct _Supp* next; + Int count; // The number of times this error has been suppressed. + Char* sname; // The name by which the suppression is referred to. + /* First two (name of fn where err occurs, and immediate caller) + * are mandatory; extra two are optional. */ + SuppLocTy caller_ty[VG_N_SUPP_CALLERS]; + Char* caller [VG_N_SUPP_CALLERS]; + + /* The tool-specific part */ + SuppKind skind; // What kind of suppression. Must use the range (0..). + Char* string; // String -- use is optional. NULL by default. + void* extra; // Anything else -- use is optional. NULL by default. +}; + +SuppKind VG_(get_supp_kind) ( Supp* su ) +{ + return su->skind; +} + +Char* VG_(get_supp_string) ( Supp* su ) +{ + return su->string; +} + +void* VG_(get_supp_extra) ( Supp* su ) +{ + return su->extra; +} + + +void VG_(set_supp_kind) ( Supp* su, SuppKind skind ) +{ + su->skind = skind; +} + +void VG_(set_supp_string) ( Supp* su, Char* string ) +{ + su->string = string; +} + +void VG_(set_supp_extra) ( Supp* su, void* extra ) +{ + su->extra = extra; +} + + /*------------------------------------------------------------*/ /*--- Helper fns ---*/ /*------------------------------------------------------------*/ diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 9be483e67f..fbb4e00be0 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -1215,85 +1215,6 @@ extern ExeContext* VG_(get_ExeContext2) ( Addr eip, Addr ebp, Exports of vg_errcontext.c. ------------------------------------------------------------------ */ -/* Note: it is imperative this doesn't overlap with (0..) at all, as skins - * effectively extend it by defining their own enums in the (0..) range. */ -typedef - enum { - PThreadSupp = -1, /* Matches PThreadErr */ - } - CoreSuppKind; - -/* For each caller specified for a suppression, record the nature of - the caller name. Not of interest to skins. */ -typedef - enum { - ObjName, /* Name is of an shared object file. */ - FunName /* Name is of a function. */ - } - SuppLocTy; - -/* Suppressions. Skins can get/set skin-relevant parts with functions - declared in include/vg_skin.h. Extensible via the 'extra' field. - Skins can use a normal enum (with element values in the normal range - (0..)) for `skind'. */ -struct _Supp { - struct _Supp* next; - /* The number of times this error has been suppressed. */ - Int count; - /* The name by which the suppression is referred to. */ - Char* sname; - /* First two (name of fn where err occurs, and immediate caller) - * are mandatory; extra two are optional. */ - SuppLocTy caller_ty[VG_N_SUPP_CALLERS]; - Char* caller [VG_N_SUPP_CALLERS]; - - /* The skin-specific part */ - /* What kind of suppression. Must use the range (0..) */ - SuppKind skind; - /* String -- use is optional. NULL by default. */ - Char* string; - /* Anything else -- use is optional. NULL by default. */ - void* extra; -}; - -/* Note: it is imperative this doesn't overlap with (0..) at all, as skins - * effectively extend it by defining their own enums in the (0..) range. */ -typedef - enum { - PThreadErr = -1, /* Pthreading error */ - } - CoreErrorKind; - -/* Errors. Extensible (via the 'extra' field). Skins can use a normal - enum (with element values in the normal range (0..)) for `ekind'. - Functions for getting/setting the skin-relevant fields are in - include/vg_skin.h. - - When errors are found and recorded with VG_(maybe_record_error)(), all - the skin must do is pass in the four parameters; core will - allocate/initialise the error record. -*/ -struct _Error { - struct _Error* next; - /* NULL if unsuppressed; or ptr to suppression record. */ - Supp* supp; - Int count; - ThreadId tid; - - /* The skin-specific part */ - /* Initialised by core */ - ExeContext* where; - /* Used by ALL. Must be in the range (0..) */ - Int ekind; - /* Used frequently */ - Addr addr; - /* Used frequently */ - Char* string; - /* For any skin-specific extras */ - void* extra; -}; - - extern void VG_(load_suppressions) ( void ); extern void VG_(record_pthread_error) ( ThreadId tid, Char* msg ); diff --git a/coregrind/vg_needs.c b/coregrind/vg_needs.c index f41328d657..cef8a15695 100644 --- a/coregrind/vg_needs.c +++ b/coregrind/vg_needs.c @@ -190,68 +190,6 @@ UInstr* VG_(get_last_instr) ( UCodeBlock* cb ) return & cb->instrs[cb->used-1]; } -/*--------------------------------------------------------------------*/ -/* Suppressions */ - -SuppKind VG_(get_supp_kind) ( Supp* su ) -{ - return su->skind; -} - -Char* VG_(get_supp_string) ( Supp* su ) -{ - return su->string; -} - -void* VG_(get_supp_extra) ( Supp* su ) -{ - return su->extra; -} - - -void VG_(set_supp_kind) ( Supp* su, SuppKind skind ) -{ - su->skind = skind; -} - -void VG_(set_supp_string) ( Supp* su, Char* string ) -{ - su->string = string; -} - -void VG_(set_supp_extra) ( Supp* su, void* extra ) -{ - su->extra = extra; -} - -/*--------------------------------------------------------------------*/ -/* Errors */ - -ExeContext* VG_(get_error_where) ( Error* err ) -{ - return err->where; -} - -ErrorKind VG_(get_error_kind) ( Error* err ) -{ - return err->ekind; -} - -Addr VG_(get_error_address) ( Error* err ) -{ - return err->addr; -} - -Char* VG_(get_error_string) ( Error* err ) -{ - return err->string; -} - -void* VG_(get_error_extra) ( Error* err ) -{ - return err->extra; -} - /*--------------------------------------------------------------------*/ /*--- end vg_needs.c ---*/ /*--------------------------------------------------------------------*/