]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Renamed vg_errcontext.c as errormgr.c, and carved off the relevant parts of
authorNicholas Nethercote <njn@valgrind.org>
Tue, 19 Apr 2005 04:10:25 +0000 (04:10 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 19 Apr 2005 04:10:25 +0000 (04:10 +0000)
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

coregrind/Makefile.am
coregrind/core.h
coregrind/errormgr.c [moved from coregrind/vg_errcontext.c with 99% similarity]
coregrind/pub_core_errormgr.h [new file with mode: 0644]
coregrind/vg_main.c
coregrind/vg_scheduler.c
coregrind/vg_signals.c
include/Makefile.am
include/pub_tool_errormgr.h [new file with mode: 0644]
include/tool.h.base

index 993c3a52331ce20e2783e520e43b708a9058eb64..12bf6b7406ed0018b531d9ca090fb100c3f9df17 100644 (file)
@@ -27,6 +27,7 @@ noinst_LIBRARIES = lib_replace_malloc.a
 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_LDFLAGS=-static -g
 valgrind_LDADD=
 
 stage2_SOURCES = \
+       errormgr.c \
        execontext.c \
        stacktrace.c \
        ume.c \
@@ -58,7 +60,6 @@ stage2_SOURCES = \
        vg_scheduler.c \
        vg_default.c \
        vg_demangle.c \
-       vg_errcontext.c \
        vg_hashtable.c \
        vg_replace_malloc.c \
        vg_main.c \
index 40d65a46246f4f3c21323e712daf1173fe368fbd..f6aacdeda3311491cb57d547d01c05f1962a1436 100644 (file)
@@ -861,26 +861,6 @@ Bool VG_(translate) ( ThreadId tid,
                       Bool     debugging_translation,
                       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
    ------------------------------------------------------------------ */
similarity index 99%
rename from coregrind/vg_errcontext.c
rename to coregrind/errormgr.c
index 9a9c8fca03440bc63d11c8929456a304ecee7181..fa61362d0e0cbb824e7d0e339b08c1331ed6630b 100644 (file)
@@ -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 @@ struct _Error {
 
    // 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 @@ void do_actions_on_error(Error* err, Bool allow_db_attach)
 
    /* 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 (file)
index 0000000..460297c
--- /dev/null
@@ -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                                                          ---*/
+/*--------------------------------------------------------------------*/
index a7505702a6c155dc042056cc3e01fd8c076b5718..c9b184d94e330db5ba045f9e7c6956a927686269 100644 (file)
@@ -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>
index 9898e32cb266045eda3c55aa9a2448c614dab5a7..c73fdac8b887cd66dcef8690f0771d3ee6c4e5e9 100644 (file)
@@ -61,7 +61,7 @@
 #include "core.h"
 
 #include "pub_core_stacktrace.h"
-
+#include "pub_core_errormgr.h"
 
 /* ---------------------------------------------------------------------
    Types and globals for the scheduler.
index bd4a28a66bb5bd6ac9fe1b6ef87b9386c84fd02c..da40315b903a7bbe3d41553148be2f5c2305058b 100644 (file)
@@ -81,6 +81,8 @@
 
 #include "core.h"
 
+#include "pub_core_errormgr.h"
+
 /* Define to give more sanity checking for signals. */
 #define DEBUG_SIGNALS
 
index d41672a12362bc9ca8d420f3dbb3154786573e8a..6bdd5fc278ea201b9a8df6b181955f19f6b11fef 100644 (file)
@@ -13,8 +13,9 @@ incinc_HEADERS = \
        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 (file)
index 0000000..6c5211a
--- /dev/null
@@ -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                                                          ---*/
+/*--------------------------------------------------------------------*/
index 7205b4d66e3acac7869a685a25f77170059c8d3f..c9e97a4a8bd66b3a30569e552ec874d2ca902c6d 100644 (file)
@@ -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"
@@ -573,102 +574,6 @@ extern void VG_(cpuid) ( UInt eax,
                          UInt *eax_ret, UInt *ebx_ret,
                          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                                  ===*/
 /*====================================================================*/