]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
- Make find_auxv() word-size independent.
authorNicholas Nethercote <n.nethercote@gmail.com>
Mon, 1 Nov 2004 18:22:05 +0000 (18:22 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Mon, 1 Nov 2004 18:22:05 +0000 (18:22 +0000)
- Introduced a new file, basic_types.h, for the basic types (eg. Int, Word).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2896

coregrind/ume.c
coregrind/ume.h
coregrind/vg_main.c
include/Makefile.am
include/basic_types.h [new file with mode: 0644]
include/tool.h.base
memcheck/tests/vgtest_ume.c
valgrind.spec.in

index bc973a8bb2ae0bf7182a27702b456b87f466c177..aedbbadfe6cfee41f62476b1fbd9ba7e0f0c1b1b 100644 (file)
@@ -115,19 +115,19 @@ void foreach_map(int (*fn)(char *start, char *end,
 /*--- Finding auxv on the stack                            ---*/
 /*------------------------------------------------------------*/
 
-struct ume_auxv *find_auxv(int *esp)
+struct ume_auxv *find_auxv(UWord* sp)
 {
-   esp++;                      /* skip argc */
+   sp++;                // skip argc (Nb: is word-sized, not int-sized!)
 
-   while(*esp != 0)            /* skip argv */
-      esp++;
-   esp++;
+   while (*sp != 0)     // skip argv
+      sp++;
+   sp++;
 
-   while(*esp != 0)            /* skip env */
-      esp++;
-   esp++;
+   while (*sp != 0)     // skip env
+      sp++;
+   sp++;
    
-   return (struct ume_auxv *)esp;
+   return (struct ume_auxv *)sp;
 }
 
 /*------------------------------------------------------------*/
index a015ff07d801d059c206420dd2de7f9290a2ade7..873b93036792bd8d4ca393792d372b8e36cdebc7 100644 (file)
@@ -35,6 +35,8 @@
 #include <elf.h>
 #include <sys/types.h>
 
+#include "basic_types.h"
+
 /*------------------------------------------------------------*/
 /*--- General stuff                                        ---*/
 /*------------------------------------------------------------*/
@@ -104,7 +106,7 @@ struct ume_auxv
    } u;
 };
 
-struct ume_auxv *find_auxv(int *orig_esp);
+struct ume_auxv *find_auxv(UWord* orig_esp);
 
 /* Our private auxv entries */
 #define AT_UME_PADFD   0xff01  /* padding file fd */
index cbe991f4c93fba86aaa257730c0204d8ead64bab..d7b4f004930f13e223aa685727168212d47c5be6 100644 (file)
@@ -362,7 +362,7 @@ static void newpid(ThreadId unused)
 /* Look for our AUXV table */
 int scan_auxv(void* init_sp)
 {
-   const struct ume_auxv *auxv = find_auxv((int *)init_sp);
+   const struct ume_auxv *auxv = find_auxv((UWord*)init_sp);
    int padfile = -1, found = 0;
 
    for (; auxv->a_type != AT_NULL; auxv++)
index f9974627b547ae7265bfc4316a84b1fbfcfa1b0a..aba50fe518e820f2ce0898be709cbdd5da59de02 100644 (file)
@@ -9,6 +9,7 @@ EXTRA_DIST = \
 incincdir = $(includedir)/valgrind
 
 incinc_HEADERS = \
+       basic_types.c \
        tool.h \
        tool_asm.h \
        valgrind.h \
diff --git a/include/basic_types.h b/include/basic_types.h
new file mode 100644 (file)
index 0000000..0764315
--- /dev/null
@@ -0,0 +1,72 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Basic types                                    basic_types.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, an extensible x86 protected-mode
+   emulator for monitoring program execution on x86-Unixes.
+
+   Copyright (C) 2000-2004 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 __BASIC_TYPES_H
+#define __BASIC_TYPES_H
+
+/* ---------------------------------------------------------------------
+   Basic types
+   ------------------------------------------------------------------ */
+
+// By choosing the right types, we can get these right for 32-bit and 64-bit
+// platforms without having to do any conditional compilation or anything.
+//
+// Size in bits on:                          32-bit archs   64-bit archs
+//                                           ------------   ------------
+typedef unsigned char          UChar;     //  8              8
+typedef unsigned short         UShort;    // 16             16
+typedef unsigned int           UInt;      // 32             32
+typedef unsigned long          UWord;     // 32             64
+typedef unsigned long long     ULong;     // 64             64
+
+typedef signed char            Char;      //  8              8
+typedef signed short           Short;     // 16             16
+typedef signed int             Int;       // 32             32
+typedef signed long            Word;      // 32             64
+typedef signed long long       Long;      // 64             64
+
+typedef UWord                  Addr;      // 32             64
+
+typedef UChar                  Bool;      //  8              8
+#define False                  ((Bool)0)
+#define True                   ((Bool)1)
+
+/* ---------------------------------------------------------------------
+   Where to send bug reports to.
+   ------------------------------------------------------------------ */
+
+#define VG_BUGS_TO "valgrind.kde.org"
+
+
+#endif /* __BASIC_TYPES_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
index 5830494c8be364edbbe973567dd7ddad3e6b5ecb..34a135eb1d7b169fc0ae44a0dbd0acec47ffd192 100644 (file)
 #include <stdarg.h>       /* ANSI varargs stuff  */
 #include <setjmp.h>       /* for jmp_buf         */
 
+#include "basic_types.h"
 #include "tool_asm.h"           // asm stuff
-
-/*====================================================================*/
-/*=== Basic types                                                  ===*/
-/*====================================================================*/
-
-// By choosing the right types, we can get these right for 32-bit and 64-bit
-// platforms without having to do any conditional compilation or anything.
-//
-// Size in bits on:                          32-bit archs   64-bit archs
-//                                           ------------   ------------
-typedef unsigned char          UChar;     //  8              8
-typedef unsigned short         UShort;    // 16             16
-typedef unsigned int           UInt;      // 32             32
-typedef unsigned long          UWord;     // 32             64
-typedef unsigned long long     ULong;     // 64             64
-
-typedef signed char            Char;      //  8              8
-typedef signed short           Short;     // 16             16
-typedef signed int             Int;       // 32             32
-typedef signed long            Word;      // 32             64
-typedef signed long long       Long;      // 64             64
-
-typedef UWord                  Addr;      // 32             64
-
-typedef UChar                  Bool;      //  8              8
-#define False                  ((Bool)0)
-#define True                   ((Bool)1)
-
-/* ---------------------------------------------------------------------
-   Now the basic types are set up, we can haul in the kernel-interface
-   definitions and tool_arch.h
-   ------------------------------------------------------------------ */
-
 #include "tool_arch.h"          // arch-specific tool stuff
 #include "vki.h"
 
-/* ---------------------------------------------------------------------
-   Where to send bug reports to.
-   ------------------------------------------------------------------ */
-
-#define VG_BUGS_TO "valgrind.kde.org"
-
-
 /*====================================================================*/
 /*=== Build options and table sizes.                               ===*/
 /*====================================================================*/
index 84ca3910e14c098f3ddf0add21857387c3da5fa4..dc9acadbd18727238095c3e39f4dd2a5b7642cfd 100644 (file)
@@ -51,7 +51,7 @@ static void test__find_auxv(void)
    assert(init_sp != NULL);
    
    fprintf(stderr, "Calling find_auxv()\n");
-   auxv = find_auxv((int*)init_sp);
+   auxv = find_auxv((UWord*)init_sp);
 
    // Check the auxv value looks sane
    assert((void*)auxv > (void*)init_sp);
@@ -65,6 +65,7 @@ static void test__find_auxv(void)
          break;
    
       default:
+         fprintf(stderr, "auxv->a_type = %d\n", auxv->a_type);
          assert(0);
       }
    }
index d6290424d39fe869f6f02e2944c9b1fee91eb14f..354a5c65d56559f1daa38fe53181591c9b22a382 100644 (file)
@@ -36,6 +36,7 @@ make install DESTDIR=$RPM_BUILD_ROOT
 /usr/include/valgrind/valgrind.h
 /usr/include/valgrind/memcheck.h
 /usr/include/valgrind/helgrind.h
+/usr/include/valgrind/basic_types.h
 /usr/include/valgrind/tool.h
 /usr/include/valgrind/tool_asm.h
 /usr/include/valgrind/vg_skin.h