]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Rename some functions and types in the top level interface to be more
authorJulian Seward <jseward@acm.org>
Mon, 17 Jan 2005 18:34:34 +0000 (18:34 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 17 Jan 2005 18:34:34 +0000 (18:34 +0000)
consistent.  Also make private some functions that Valgrind never
used.

git-svn-id: svn://svn.valgrind.org/vex/trunk@718

VEX/priv/ir/irmatch.h
VEX/priv/main/vex_main.c
VEX/priv/main/vex_util.c
VEX/priv/main/vex_util.h
VEX/pub/libvex.h
VEX/test_main.c

index 2bf124dd34a80747f8616db1588c5665aa763bd0..890d5fda9f4d003d04f08f028962169749c5e06e 100644 (file)
 #define DEFINE_PATTERN(_patt,_expr)                            \
    do {                                                        \
       if (!(_patt)) {                                          \
-         vassert(LibVEX_GetAllocMode() == AllocModeTEMPORARY); \
-         LibVEX_SetAllocMode(AllocModePERMANENT);              \
+         vassert(vexGetAllocMode() == VexAllocModeTEMP);       \
+         vexSetAllocMode(VexAllocModePERM);                    \
          _patt = (_expr);                                      \
-         LibVEX_SetAllocMode(AllocModeTEMPORARY);              \
-         vassert(LibVEX_GetAllocMode() == AllocModeTEMPORARY); \
+         vexSetAllocMode(VexAllocModeTEMP);                    \
+         vassert(vexGetAllocMode() == VexAllocModeTEMP);       \
       }                                                        \
    } while (0)
 
index c41b87b5a530efb2252f22d86a2c0e8a656db7ac..9cacd13381e5ab8fd3c7259b1db15fe07c744942 100644 (file)
@@ -55,7 +55,7 @@
 
 /* Exported to library client. */
 
-HChar* LibVEX_Version ( void )
+const HChar* LibVEX_Version ( void )
 {
 return
 #include "main/vex_svnversion.h"
@@ -146,7 +146,7 @@ void LibVEX_Init (
    vex_valgrind_support   = valgrind_support;
    vex_control            = *vcon;
    vex_initdone           = True;
-   LibVEX_SetAllocMode ( AllocModeTEMPORARY );
+   vexSetAllocMode ( VexAllocModeTEMP );
 }
 
 
@@ -154,7 +154,7 @@ void LibVEX_Init (
 
 /* Exported to library client. */
 
-TranslateResult LibVEX_Translate (
+VexTranslateResult LibVEX_Translate (
    /* The instruction sets we are translating from and to. */
    VexArch    arch_guest,
    VexSubArch subarch_guest,
@@ -232,7 +232,7 @@ TranslateResult LibVEX_Translate (
    vex_traceflags = traceflags;
 
    vassert(vex_initdone);
-   LibVEX_ClearTemporary(False);
+   vexClearTEMP();
 
 
    /* First off, check that the guest and host insn sets
@@ -314,9 +314,9 @@ TranslateResult LibVEX_Translate (
 
    if (irbb == NULL) {
       /* Access failure. */
-      LibVEX_ClearTemporary(False);
+      vexClearTEMP();
       vex_traceflags = 0;
-      return TransAccessFail;
+      return VexTransAccessFail;
    }
 
    /* If debugging, show the raw guest bytes for this bb. */
@@ -454,9 +454,9 @@ TranslateResult LibVEX_Translate (
          vex_printf("\n\n");
       }
       if (out_used + j > host_bytes_size) {
-         LibVEX_ClearTemporary(False);
+         vexClearTEMP();
          vex_traceflags = 0;
-         return TransOutputFull;
+         return VexTransOutputFull;
       }
       for (k = 0; k < j; k++) {
          host_bytes[out_used] = insn_bytes[k];
@@ -466,10 +466,10 @@ TranslateResult LibVEX_Translate (
    }
    *host_bytes_used = out_used;
 
-   LibVEX_ClearTemporary(False);
+   vexClearTEMP();
 
    vex_traceflags = 0;
-   return TransOK;
+   return VexTransOK;
 }
 
 
index 9fb32afc0e167acd18ea84573fe58ef7ec9f74ec..ea7e0114dcaf6d767f5a534497b52d24b66eba83 100644 (file)
@@ -70,19 +70,15 @@ static ULong temporary_bytes_allocd_TOT = 0;
 static ULong temporary_count_allocs_TOT = 0;
 
 /* The current allocation mode. */
-static AllocMode mode = AllocModeTEMPORARY;
+static VexAllocMode mode = VexAllocModeTEMP;
 
 
-/* Exported to library client. */
-
-void LibVEX_SetAllocMode ( AllocMode m )
+void vexSetAllocMode ( VexAllocMode m )
 {
    mode = m;
 }
 
-/* Exported to library client. */
-
-AllocMode LibVEX_GetAllocMode ( void )
+VexAllocMode vexGetAllocMode ( void )
 {
    return mode;
 }
@@ -101,7 +97,7 @@ void* LibVEX_Alloc ( Int nbytes )
       return malloc(nbytes);
    } else {
       nbytes = (nbytes + ALIGN) & ~ALIGN;
-      if (mode == AllocModeTEMPORARY) {
+      if (mode == VexAllocModeTEMP) {
          if (temporary_used + nbytes > N_TEMPORARY_BYTES)
             vpanic("VEX temporary storage exhausted.\n"
                    "Increase N_TEMPORARY_BYTES and recompile.");
@@ -120,26 +116,28 @@ void* LibVEX_Alloc ( Int nbytes )
 #  undef ALIGN
 }
 
-/* Exported to library client. */
-
-void LibVEX_ClearTemporary ( Bool verb )
+void vexClearTEMP ( void )
 {
    /* vassert(vex_initdone); */ /* causes infinite assert loops */
    temporary_bytes_allocd_TOT += (ULong)temporary_bytes_allocd;
    temporary_count_allocs_TOT += (ULong)temporary_count_allocs;
-   if (verb) {
-      vex_printf("vex storage:  P %d,  T total %lld (%lld),  T curr %d (%d)\n",
-                 permanent_used,
-                (Long)temporary_bytes_allocd_TOT, 
-                 (Long)temporary_count_allocs_TOT,
-                temporary_bytes_allocd, temporary_count_allocs );
-   }
    temporary_used = 0;
    temporary_bytes_allocd = 0;
    temporary_count_allocs = 0;
 }
 
 
+/* Exported to library client. */
+
+void LibVEX_ShowAllocStats ( void )
+{
+   vex_printf("vex storage:  P %d,  T total %lld (%lld),  T curr %d (%d)\n",
+              permanent_used,
+              (Long)temporary_bytes_allocd_TOT, 
+              (Long)temporary_count_allocs_TOT,
+              temporary_bytes_allocd, temporary_count_allocs );
+}
+
 
 /*---------------------------------------------------------*/
 /*--- Bombing out                                       ---*/
@@ -523,8 +521,6 @@ UInt vex_sprintf ( Char* buf, const HChar *format, ... )
 }
 
 
-
-
 /*---------------------------------------------------------------*/
 /*--- end                                          vex_util.c ---*/
 /*---------------------------------------------------------------*/
index 021e4e0703a33e731c256750a96da3eba33e71e6..d9e4d859972044216dcc4ca2ea07af89bade2fd9 100644 (file)
@@ -75,6 +75,25 @@ extern UInt vex_sprintf ( Char* buf, const HChar *format, ... );
 extern Bool vex_streq ( const Char* s1, const Char* s2 );
 
 
+/* Storage management: clear the area, and allocate from it. */
+
+/* By default allocation occurs in the temporary area.  However, it is
+   possible to switch to permanent area allocation if that's what you
+   want.  Permanent area allocation is very limited, tho. */
+
+typedef
+   enum {
+      VexAllocModeTEMP, 
+      VexAllocModePERM 
+   }
+   VexAllocMode;
+
+extern void         vexSetAllocMode ( VexAllocMode );
+extern VexAllocMode vexGetAllocMode ( void );
+
+extern void vexClearTEMP ( void );
+
+
 #endif /* ndef __VEX_UTIL_H */
 
 /*---------------------------------------------------------------*/
index a208f94eeb66e5a7b3ef4f49a726343e6ef19ca5..84960e82ff07a3e886563fb137a99bd97853bf5b 100644 (file)
 
 
 /*---------------------------------------------------------------*/
-/*--- Top-level interface to the library.                     ---*/
+/*--- This file defines the top-level interface to LibVEX.    ---*/
 /*---------------------------------------------------------------*/
 
-/* Describes architectures and subarchitecture variants. */
+/*-------------------------------------------------------*/
+/*--- Architectures and architecture variants         ---*/
+/*-------------------------------------------------------*/
 
 typedef 
    enum { 
@@ -73,6 +75,10 @@ extern const HChar* LibVEX_ppVexArch    ( VexArch );
 extern const HChar* LibVEX_ppVexSubArch ( VexSubArch );
 
 
+/*-------------------------------------------------------*/
+/*--- Control of Vex's optimiser (iropt).             ---*/
+/*-------------------------------------------------------*/
+
 /* Control of Vex's optimiser. */
 
 typedef
@@ -106,48 +112,38 @@ typedef
 
 /* Write the default settings into *vcon. */
 
-extern void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon );
-
-
-/* Returns the Vex SVN version. */
-
-extern HChar* LibVEX_Version ( void );
+extern 
+void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon );
 
 
-/* Initialise the translator. */
+/*-------------------------------------------------------*/
+/*--- Version information                             ---*/
+/*-------------------------------------------------------*/
 
-extern void LibVEX_Init (
-   /* failure exit function */
-   __attribute__ ((noreturn))
-   void (*failure_exit) ( void ),
-   /* logging output function */
-   void (*log_bytes) ( Char*, Int nbytes ),
-   /* debug paranoia level */
-   Int debuglevel,
-   /* Are we supporting valgrind checking? */
-   Bool valgrind_support,
-   /* Control ... */
-   /*READONLY*/VexControl* vcon
-);
+/* Returns the Vex SVN version, as a statically allocated string. */
 
+extern const HChar* LibVEX_Version ( void );
 
-/* Storage management: clear the area, and allocate from it. */
 
-/* By default allocation occurs in the temporary area.  However, it is
-   possible to switch to permanent area allocation if that's what you
-   want.  Permanent area allocation is very limited, tho. */
+/*-------------------------------------------------------*/
+/*--- Storage management control                      ---*/
+/*-------------------------------------------------------*/
 
-typedef
-   enum { AllocModeTEMPORARY, AllocModePERMANENT }
-   AllocMode;
+/* Allocate in Vex's temporary allocation area.  Be careful with this.
+   You can only call it inside an instrumentation or optimisation
+   callback that you have previously specified in a call to
+   LibVEX_Translate.  The storage allocated will only stay alive until
+   translation of the current basic block is complete.
+ */
+extern void* LibVEX_Alloc ( Int nbytes );
 
-extern void      LibVEX_SetAllocMode ( AllocMode );
-extern AllocMode LibVEX_GetAllocMode ( void );
+/* Show Vex allocation statistics. */
+extern void LibVEX_ShowAllocStats ( void );
 
-extern void LibVEX_ClearTemporary ( Bool show_stats );
-
-extern void* LibVEX_Alloc ( Int nbytes );
 
+/*-------------------------------------------------------*/
+/*--- Describing guest state layout                   ---*/
+/*-------------------------------------------------------*/
 
 /* Describe the guest state enough that the instrumentation
    functions can work. */
@@ -177,15 +173,57 @@ typedef
    }
    VexGuestLayout;
 
+/* A note about guest state layout.
+
+   LibVEX defines the layout for the guest state, in the file
+   pub/libvex_guest_<arch>.h.  The struct will have an 8-aligned size.
+   Each translated bb is assumed to be entered with a specified
+   register pointing at such a struct.  Beyond that is a shadow
+   state area with the same size as the struct.  Beyond that is
+   a spill area that LibVEX may spill into.  It must have size
+   LibVEX_N_SPILL_BYTES, and this must be a 16-aligned number.
+
+   On entry, the baseblock pointer register must be 8-aligned.
+*/
+
+#define LibVEX_N_SPILL_BYTES 768
+
 
-/* Translate a basic block. */
+/*-------------------------------------------------------*/
+/*--- Initialisation of the library                   ---*/
+/*-------------------------------------------------------*/
+
+/* Initialise the library.  You must call this first. */
+
+extern void LibVEX_Init (
+   /* failure exit function */
+   __attribute__ ((noreturn))
+   void (*failure_exit) ( void ),
+   /* logging output function */
+   void (*log_bytes) ( Char*, Int nbytes ),
+   /* debug paranoia level */
+   Int debuglevel,
+   /* Are we supporting valgrind checking? */
+   Bool valgrind_support,
+   /* Control ... */
+   /*READONLY*/VexControl* vcon
+);
+
+
+/*-------------------------------------------------------*/
+/*--- Make a translation                              ---*/
+/*-------------------------------------------------------*/
 
 typedef
-   enum { TransOK, TransAccessFail, TransOutputFull }
-   TranslateResult;
+   enum { 
+      VexTransOK, 
+      VexTransAccessFail, 
+      VexTransOutputFull 
+   }
+   VexTranslateResult;
 
 extern 
-TranslateResult LibVEX_Translate (
+VexTranslateResult LibVEX_Translate (
    /* The instruction sets we are translating from and to. */
    VexArch    arch_guest,
    VexSubArch subarch_guest,
@@ -213,28 +251,16 @@ TranslateResult LibVEX_Translate (
 );
 
 
-/* Show accumulated statistics. */
+/*-------------------------------------------------------*/
+/*--- Show accumulated statistics                     ---*/
+/*-------------------------------------------------------*/
 
 extern void LibVEX_ShowStats ( void );
 
 
-
-/* A note about baseblock layout.
-
-   LibVEX defines the layout for the guest state, in the file
-   pub/libvex_guest_<arch>.h.  The struct will have an 8-aligned size.
-   Each translated bb is assumed to be entered with a specified
-   register pointing at such a struct.  Beyond that is a shadow
-   state area with the same size as the struct.  Beyond that is
-   a spill area that LibVEX may spill into.  It must have size
-   LibVEX_N_SPILL_BYTES, and this will be a 16-aligned number.
-
-   On entry, the baseblock pointer register must be 8-aligned.
-*/
-
-#define LibVEX_N_SPILL_BYTES 768
-
-
+/*-------------------------------------------------------*/
+/*--- Notes                                           ---*/
+/*-------------------------------------------------------*/
 
 /* Code generation conventions that need to be recorded somewhere.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 047a25032fe842fefda0018bf1f7b5077fdd40d1..c588551432dad282010ef96da323d8e62fd188e9 100644 (file)
@@ -61,7 +61,7 @@ int main ( int argc, char** argv )
    Addr32 orig_addr;
    Int bb_number, n_bbs_done = 0;
    Int orig_nbytes, trans_used, orig_used;
-   TranslateResult tres;
+   VexTranslateResult tres;
    VexControl vcon;
 
    if (argc != 2) {
@@ -145,9 +145,9 @@ int main ( int argc, char** argv )
                  TEST_FLAGS 
               );
 
-      if (tres != TransOK)
+      if (tres != VexTransOK)
          printf("\ntres = %d\n", (Int)tres);
-      assert(tres == TransOK);
+      assert(tres == VexTransOK);
       assert(orig_used == orig_nbytes);
 
       sum = 0;
@@ -158,7 +158,7 @@ int main ( int argc, char** argv )
 
    fclose(f);
    printf("\n");
-   LibVEX_ClearTemporary(True);
+   LibVEX_ShowAllocStats();
 
    return 0;
 }