Renamed vg_errcontext.c as errormgr.c, and carved off the relevant parts of
core.h and tool.h into pub_core_errormgr.h and pub_tool_errormgr.h. All
just to improve general modularity.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3532 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 993c3a5..12bf6b7 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -27,6 +27,7 @@
noinst_HEADERS = \
core.h \
core_asm.h \
+ pub_core_errormgr.h \
pub_core_execontext.h \
pub_core_stacktrace.h \
ume.h \
@@ -51,6 +52,7 @@
valgrind_LDADD=
stage2_SOURCES = \
+ errormgr.c \
execontext.c \
stacktrace.c \
ume.c \
@@ -58,7 +60,6 @@
vg_scheduler.c \
vg_default.c \
vg_demangle.c \
- vg_errcontext.c \
vg_hashtable.c \
vg_replace_malloc.c \
vg_main.c \
diff --git a/coregrind/core.h b/coregrind/core.h
index 40d65a4..f6aacde 100644
--- a/coregrind/core.h
+++ b/coregrind/core.h
@@ -862,26 +862,6 @@
Int debugging_verbosity );
/* ---------------------------------------------------------------------
- Exports of vg_errcontext.c.
- ------------------------------------------------------------------ */
-
-typedef
- enum {
- ThreadErr = -1, // Thread error
- MutexErr = -2, // Mutex error
- }
- CoreErrorKind;
-
-extern void VG_(load_suppressions) ( void );
-
-extern void VG_(show_all_errors) ( void );
-
-extern Bool VG_(is_action_requested) ( Char* action, Bool* clo );
-
-extern UInt VG_(get_n_errs_found) ( void );
-
-
-/* ---------------------------------------------------------------------
Exports of vg_procselfmaps.c
------------------------------------------------------------------ */
diff --git a/coregrind/vg_errcontext.c b/coregrind/errormgr.c
similarity index 98%
rename from coregrind/vg_errcontext.c
rename to coregrind/errormgr.c
index 9a9c8fc..fa61362 100644
--- a/coregrind/vg_errcontext.c
+++ b/coregrind/errormgr.c
@@ -1,6 +1,6 @@
/*--------------------------------------------------------------------*/
-/*--- Management of error messages. vg_errcontext.c ---*/
+/*--- Management of error messages. errormgr.c ---*/
/*--------------------------------------------------------------------*/
/*
@@ -29,7 +29,9 @@
*/
#include "core.h"
+#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
+#include "pub_core_stacktrace.h"
/*------------------------------------------------------------*/
/*--- Globals ---*/
@@ -92,7 +94,7 @@
// The tool-specific part
ExeContext* where; // Initialised by core
- Int ekind; // Used by ALL. Must be in the range (0..)
+ ErrorKind 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
@@ -394,16 +396,15 @@
/* Perhaps we want a debugger attach at this point? */
if (allow_db_attach &&
- VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) ))
- {
+ VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) ))
+ {
VG_(printf)("starting debugger\n");
VG_(start_debugger)( err->tid );
- }
+ }
/* Or maybe we want to generate the error's suppression? */
if (VG_(clo_gen_suppressions) == 2
|| (VG_(clo_gen_suppressions) == 1
- && VG_(is_action_requested)( "Print suppression",
- &still_noisy ))
+ && VG_(is_action_requested)( "Print suppression", &still_noisy ))
) {
gen_suppression(err);
if (VG_(clo_gen_suppressions) == 1 && !still_noisy)
diff --git a/coregrind/pub_core_errormgr.h b/coregrind/pub_core_errormgr.h
new file mode 100644
index 0000000..460297c
--- /dev/null
+++ b/coregrind/pub_core_errormgr.h
@@ -0,0 +1,64 @@
+/*--------------------------------------------------------------------*/
+/*--- ErrorMgr: management of errors and suppressions. ---*/
+/*--- pub_core_errormgr.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_CORE_ERRORMGR_H
+#define __PUB_CORE_ERRORMGR_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This module manages errors recording and printing,
+// which includes suppression reading and writing.
+//--------------------------------------------------------------------
+
+#include "pub_tool_errormgr.h"
+
+//#include "pub_core_stacktrace.h"
+
+// XXX: should this be in pthreadmodel.c?
+// These must be negative, so as to not overlap with tool error kinds.
+typedef
+ enum {
+ ThreadErr = -1, // Thread error
+ MutexErr = -2, // Mutex error
+ }
+ CoreErrorKind;
+
+extern void VG_(load_suppressions) ( void );
+
+extern void VG_(show_all_errors) ( void );
+
+extern Bool VG_(is_action_requested) ( Char* action, Bool* clo );
+
+extern UInt VG_(get_n_errs_found) ( void );
+
+#endif // __PUB_CORE_ERRORMGR_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c
index a750570..c9b184d 100644
--- a/coregrind/vg_main.c
+++ b/coregrind/vg_main.c
@@ -33,6 +33,7 @@
#include "core.h"
#include "ume.h"
#include "pub_core_execontext.h"
+#include "pub_core_errormgr.h"
#include <dirent.h>
#include <dlfcn.h>
diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c
index 9898e32..c73fdac 100644
--- a/coregrind/vg_scheduler.c
+++ b/coregrind/vg_scheduler.c
@@ -61,7 +61,7 @@
#include "core.h"
#include "pub_core_stacktrace.h"
-
+#include "pub_core_errormgr.h"
/* ---------------------------------------------------------------------
Types and globals for the scheduler.
diff --git a/coregrind/vg_signals.c b/coregrind/vg_signals.c
index bd4a28a..da40315 100644
--- a/coregrind/vg_signals.c
+++ b/coregrind/vg_signals.c
@@ -81,6 +81,8 @@
#include "core.h"
+#include "pub_core_errormgr.h"
+
/* Define to give more sanity checking for signals. */
#define DEBUG_SIGNALS
diff --git a/include/Makefile.am b/include/Makefile.am
index d41672a..6bdd5fc 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -13,8 +13,9 @@
basic_types.h \
tool.h \
tool_asm.h \
- pub_tool_stacktrace.h \
+ pub_tool_errormgr.h \
pub_tool_execontext.h \
+ pub_tool_stacktrace.h \
valgrind.h
BUILT_SOURCES = tool.h valgrind.h
diff --git a/include/pub_tool_errormgr.h b/include/pub_tool_errormgr.h
new file mode 100644
index 0000000..6c5211a
--- /dev/null
+++ b/include/pub_tool_errormgr.h
@@ -0,0 +1,131 @@
+/*--------------------------------------------------------------------*/
+/*--- ErrorMgr: management of errors and suppressions. ---*/
+/*--- pub_tool_errormgr.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_ERRORMGR_H
+#define __PUB_TOOL_ERRORMGR_H
+
+#include "pub_tool_execontext.h"
+
+/* ------------------------------------------------------------------ */
+/* Error records contain enough info to generate an error report. The idea
+ is that (typically) the same few points in the program generate thousands
+ of errors, and we don't want to spew out a fresh error message for each
+ one. Instead, we use these structures to common up duplicates.
+*/
+
+typedef
+ Int /* Do not make this unsigned! */
+ ErrorKind;
+
+/* The tool-relevant parts of an Error are:
+ kind: what kind of error; must be in the range (0..)
+ addr: use is optional. 0 by default.
+ string: use is optional. NULL by default.
+ extra: use is optional. NULL by default. void* so it's extensible.
+*/
+typedef
+ struct _Error
+ Error;
+
+/* Useful in TL_(error_matches_suppression)(), TL_(pp_Error)(), etc */
+ExeContext* VG_(get_error_where) ( Error* err );
+ErrorKind VG_(get_error_kind) ( Error* err );
+Addr VG_(get_error_address) ( Error* err );
+Char* VG_(get_error_string) ( Error* err );
+void* VG_(get_error_extra) ( Error* err );
+
+/* Call this when an error occurs. It will be recorded if it hasn't been
+ seen before. If it has, the existing error record will have its count
+ incremented.
+
+ 'tid' can be found as for VG_(record_ExeContext)(). The `extra' field can
+ be stack-allocated; it will be copied by the core if needed (but it
+ won't be copied if it's NULL).
+
+ If no 'a', 's' or 'extra' of interest needs to be recorded, just use
+ NULL for them. */
+extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
+ Addr a, Char* s, void* extra );
+
+/* Similar to VG_(maybe_record_error)(), except this one doesn't record the
+ error -- useful for errors that can only happen once. The errors can be
+ suppressed, though. Return value is True if it was suppressed.
+ `print_error' dictates whether to print the error, which is a bit of a
+ hack that's useful sometimes if you just want to know if the error would
+ be suppressed without possibly printing it. `count_error' dictates
+ whether to add the error in the error total count (another mild hack). */
+extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
+ Addr a, Char* s, void* extra,
+ ExeContext* where, Bool print_error,
+ Bool allow_GDB_attach, Bool count_error );
+
+/* Gets a non-blank, non-comment line of at most nBuf chars from fd.
+ Skips leading spaces on the line. Returns True if EOF was hit instead.
+ Useful for reading in extra tool-specific suppression lines. */
+extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf );
+
+
+/* ------------------------------------------------------------------ */
+/* Suppressions describe errors which we want to suppress, ie, not
+ show the user, usually because it is caused by a problem in a library
+ which we can't fix, replace or work around. Suppressions are read from
+ a file at startup time. This gives flexibility so that new
+ suppressions can be added to the file as and when needed.
+*/
+typedef
+ Int /* Do not make this unsigned! */
+ SuppKind;
+
+/* The tool-relevant parts of a suppression are:
+ kind: what kind of suppression; must be in the range (0..)
+ string: use is optional. NULL by default.
+ extra: use is optional. NULL by default. void* so it's extensible.
+*/
+typedef
+ struct _Supp
+ Supp;
+
+/* Useful in TL_(error_matches_suppression)() */
+SuppKind VG_(get_supp_kind) ( Supp* su );
+Char* VG_(get_supp_string) ( Supp* su );
+void* VG_(get_supp_extra) ( Supp* su );
+
+/* Must be used in VG_(recognised_suppression)() */
+void VG_(set_supp_kind) ( Supp* su, SuppKind suppkind );
+/* May be used in VG_(read_extra_suppression_info)() */
+void VG_(set_supp_string) ( Supp* su, Char* string );
+void VG_(set_supp_extra) ( Supp* su, void* extra );
+
+
+#endif // __PUB_TOOL_ERRORMGR_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/tool.h.base b/include/tool.h.base
index 7205b4d..c9e97a4 100644
--- a/include/tool.h.base
+++ b/include/tool.h.base
@@ -37,7 +37,8 @@
#include "tool_arch.h" /* arch-specific tool stuff */
#include "vki.h"
-#include "pub_tool_execontext.h" // needed for type 'ExeContext'
+#include "pub_tool_errormgr.h" // needed for 'Error', 'Supp'
+#include "pub_tool_execontext.h" // needed for 'ExeContext'
#include "libvex.h"
#include "libvex_ir.h"
@@ -574,102 +575,6 @@
UInt *ecx_ret, UInt *edx_ret );
/*====================================================================*/
-/*=== Error reporting ===*/
-/*====================================================================*/
-
-/* ------------------------------------------------------------------ */
-/* Suppressions describe errors which we want to suppress, ie, not
- show the user, usually because it is caused by a problem in a library
- which we can't fix, replace or work around. Suppressions are read from
- a file at startup time. This gives flexibility so that new
- suppressions can be added to the file as and when needed.
-*/
-
-typedef
- Int /* Do not make this unsigned! */
- SuppKind;
-
-/* The tool-relevant parts of a suppression are:
- kind: what kind of suppression; must be in the range (0..)
- string: use is optional. NULL by default.
- extra: use is optional. NULL by default. void* so it's extensible.
-*/
-typedef
- struct _Supp
- Supp;
-
-/* Useful in TL_(error_matches_suppression)() */
-SuppKind VG_(get_supp_kind) ( Supp* su );
-Char* VG_(get_supp_string) ( Supp* su );
-void* VG_(get_supp_extra) ( Supp* su );
-
-/* Must be used in VG_(recognised_suppression)() */
-void VG_(set_supp_kind) ( Supp* su, SuppKind suppkind );
-/* May be used in VG_(read_extra_suppression_info)() */
-void VG_(set_supp_string) ( Supp* su, Char* string );
-void VG_(set_supp_extra) ( Supp* su, void* extra );
-
-
-/* ------------------------------------------------------------------ */
-/* Error records contain enough info to generate an error report. The idea
- is that (typically) the same few points in the program generate thousands
- of errors, and we don't want to spew out a fresh error message for each
- one. Instead, we use these structures to common up duplicates.
-*/
-
-typedef
- Int /* Do not make this unsigned! */
- ErrorKind;
-
-/* The tool-relevant parts of an Error are:
- kind: what kind of error; must be in the range (0..)
- addr: use is optional. 0 by default.
- string: use is optional. NULL by default.
- extra: use is optional. NULL by default. void* so it's extensible.
-*/
-typedef
- struct _Error
- Error;
-
-/* Useful in TL_(error_matches_suppression)(), TL_(pp_Error)(), etc */
-ExeContext* VG_(get_error_where) ( Error* err );
-SuppKind VG_(get_error_kind) ( Error* err );
-Addr VG_(get_error_address) ( Error* err );
-Char* VG_(get_error_string) ( Error* err );
-void* VG_(get_error_extra) ( Error* err );
-
-/* Call this when an error occurs. It will be recorded if it hasn't been
- seen before. If it has, the existing error record will have its count
- incremented.
-
- 'tid' can be found as for VG_(record_ExeContext)(). The `extra' field can
- be stack-allocated; it will be copied by the core if needed (but it
- won't be copied if it's NULL).
-
- If no 'a', 's' or 'extra' of interest needs to be recorded, just use
- NULL for them. */
-extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
- Addr a, Char* s, void* extra );
-
-/* Similar to VG_(maybe_record_error)(), except this one doesn't record the
- error -- useful for errors that can only happen once. The errors can be
- suppressed, though. Return value is True if it was suppressed.
- `print_error' dictates whether to print the error, which is a bit of a
- hack that's useful sometimes if you just want to know if the error would
- be suppressed without possibly printing it. `count_error' dictates
- whether to add the error in the error total count (another mild hack). */
-extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
- Addr a, Char* s, void* extra,
- ExeContext* where, Bool print_error,
- Bool allow_GDB_attach, Bool count_error );
-
-/* Gets a non-blank, non-comment line of at most nBuf chars from fd.
- Skips leading spaces on the line. Returns True if EOF was hit instead.
- Useful for reading in extra tool-specific suppression lines. */
-extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf );
-
-
-/*====================================================================*/
/*=== Obtaining debug information ===*/
/*====================================================================*/