|
From: <sv...@va...> - 2005-06-18 03:44:37
|
Author: njn
Date: 2005-06-18 04:44:34 +0100 (Sat, 18 Jun 2005)
New Revision: 3930
Log:
Moved VGA_(getArchAndSubArch) into m_translate and made it local. This
allowed the removal of $ARCH/state.c, hooray!
Removed:
trunk/coregrind/amd64/state.c
trunk/coregrind/arm/state.c
trunk/coregrind/x86/state.c
Modified:
trunk/coregrind/amd64/Makefile.am
trunk/coregrind/arm/Makefile.am
trunk/coregrind/core.h
trunk/coregrind/m_translate.c
trunk/coregrind/x86/Makefile.am
Modified: trunk/coregrind/amd64/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/amd64/Makefile.am 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/amd64/Makefile.am 2005-06-18 03:44:34 UTC (rev 3930)
@@ -3,16 +3,12 @@
=20
noinst_LIBRARIES =3D libarch.a
=20
-EXTRA_DIST =3D \
- jmp_with_stack.c
-
BUILT_SOURCES =3D stage2.lds
CLEANFILES =3D stage2.lds
=20
libarch_a_SOURCES =3D \
cpuid.S \
- jmp_with_stack.c \
- state.c
+ jmp_with_stack.c
=20
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
Deleted: trunk/coregrind/amd64/state.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/amd64/state.c 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/amd64/state.c 2005-06-18 03:44:34 UTC (rev 3930)
@@ -1,59 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Arch-specific registers, etc. amd64/state.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward
- js...@ac...
-
- 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.
-*/
-
-#include "core.h"
-#include "pub_core_libcbase.h"
-#include "pub_core_libcassert.h"
-#include "pub_core_tooliface.h"
-#include <sys/ptrace.h>
-
-#include "libvex_guest_amd64.h"
-
-
-/*------------------------------------------------------------*/
-/*--- Determining arch/subarch. ---*/
-/*------------------------------------------------------------*/
-
-// Returns the architecture and subarchitecture, or indicates
-// that this subarchitecture is unable to run Valgrind
-// Returns False to indicate we cannot proceed further.
-Bool VGA_(getArchAndSubArch)( /*OUT*/VexArch* vex_arch,=20
- /*OUT*/VexSubArch* vex_subarch )
-{
- vg_assert(VG_(has_cpuid)());
- *vex_arch =3D VexArchAMD64;
- *vex_subarch =3D VexSubArch_NONE;
- return True;
-}
-
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/arm/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/arm/Makefile.am 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/arm/Makefile.am 2005-06-18 03:44:34 UTC (rev 3930)
@@ -3,15 +3,11 @@
=20
noinst_LIBRARIES =3D libarch.a
=20
-EXTRA_DIST =3D \
- jmp_with_stack.c \
- libpthread.c
-
BUILT_SOURCES =3D stage2.lds
CLEANFILES =3D stage2.lds
=20
libarch_a_SOURCES =3D \
- state.c
+ jmp_with_stack.c
=20
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
Deleted: trunk/coregrind/arm/state.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/arm/state.c 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/arm/state.c 2005-06-18 03:44:34 UTC (rev 3930)
@@ -1,155 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Arch-specific registers, etc. x86/state.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Nicholas Nethercote
- nj...@va...
-
- 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.
-*/
-
-#include "core.h"
-#include <sys/ptrace.h>
-
-#include "libvex_guest_arm.h"
-
-
-/*------------------------------------------------------------*/
-/*--- Initialising the first thread ---*/
-/*------------------------------------------------------------*/
-
-/* Given a pointer to the ThreadArchState for thread 1 (the root
- thread), initialise the VEX guest state, and copy in essential
- starting values.
-*/
-void VGA_(init_thread1state) ( Addr client_eip,=20
- Addr esp_at_startup,
- /*MOD*/ ThreadArchState* arch )
-{
- I_die_here;
-#if 0
- // When implementing this, look at x86/state.c
-#endif
-}
-
-
-/*------------------------------------------------------------*/
-/*--- Thread stuff ---*/
-/*------------------------------------------------------------*/
-
-void VGA_(clear_thread)( ThreadArchState *arch )
-{
- I_die_here;
-#if 0
- arch->ldt =3D NULL;
- VG_(clear_TLS_for_thread)(arch->tls);
-#endif
-} =20
-
-void VGA_(cleanup_thread) ( ThreadArchState *arch )
-{ =20
- I_die_here;
-#if 0
- /* Deallocate its LDT, if it ever had one. */
- VG_(deallocate_LDT_for_thread)( arch->ldt );=20
- arch->ldt =3D NULL;
- =20
- /* Clear its TLS array. */
- VG_(clear_TLS_for_thread)( arch->tls );
-#endif
-} =20
-
-void VGA_(setup_child) ( ThreadArchState *regs, ThreadArchState *parent_=
regs )
-{ =20
- I_die_here;
-#if 0
- // XXX: look at x86/state.c
-#endif
-} =20
-
-
-/*------------------------------------------------------------*/
-/*--- pointercheck ---*/
-/*------------------------------------------------------------*/
-
-Bool VGA_(setup_pointercheck)(Addr client_base, Addr client_end)
-{
- I_die_here;
-#if 0
- vki_modify_ldt_t ldt =3D {=20
- VG_POINTERCHECK_SEGIDX, // entry_number
- VG_(client_base), // base_addr
- (VG_(client_end)-VG_(client_base)) / VKI_PAGE_SIZE, // limit
- 1, // seg_32bit
- 0, // contents: data, RW, non-expanding
- 0, // ! read_exec_only
- 1, // limit_in_pages
- 0, // ! seg not present
- 1, // useable
- };
- int ret =3D VG_(do_syscall)(__NR_modify_ldt, 1, &ldt, sizeof(ldt));
- if (ret < 0) {
- VG_(message)(Vg_UserMsg,
- "Warning: ignoring --pointercheck=3Dyes, "
- "because modify_ldt failed (errno=3D%d)", -ret);
- return False;
- } else {
- return True;
- }
-#endif
-}
-
-/*------------------------------------------------------------*/
-/*--- Debugger-related operations ---*/
-/*------------------------------------------------------------*/
-
-Int VGA_(ptrace_setregs_from_tst)(Int pid, ThreadArchState* arch)
-{
- I_die_here;
-#if 0
- struct vki_user_regs_struct regs;
-
- regs.cs =3D arch->vex.guest_CS;
- regs.ss =3D arch->vex.guest_SS;
- regs.ds =3D arch->vex.guest_DS;
- regs.es =3D arch->vex.guest_ES;
- regs.fs =3D arch->vex.guest_FS;
- regs.gs =3D arch->vex.guest_GS;
- regs.eax =3D arch->vex.guest_EAX;
- regs.ebx =3D arch->vex.guest_EBX;
- regs.ecx =3D arch->vex.guest_ECX;
- regs.edx =3D arch->vex.guest_EDX;
- regs.esi =3D arch->vex.guest_ESI;
- regs.edi =3D arch->vex.guest_EDI;
- regs.ebp =3D arch->vex.guest_EBP;
- regs.esp =3D arch->vex.guest_ESP;
- regs.eflags =3D LibVEX_GuestX86_get_eflags(&arch->vex);
- regs.eip =3D arch->vex.guest_EIP;
-
- return ptrace(PTRACE_SETREGS, pid, NULL, ®s);
-#endif
-}
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/core.h 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/core.h 2005-06-18 03:44:34 UTC (rev 3930)
@@ -49,16 +49,6 @@
=20
#include "pub_core_scheduler.h" // for types 'ThreadArchState'
=20
-// ---------------------------------------------------------------------
-// Architecture-specific things defined in eg. x86/*.c
-// ---------------------------------------------------------------------
-
-// Returns the architecture and subarchitecture, or indicates
-// that this subarchitecture is unable to run Valgrind
-// Returns False to indicate we cannot proceed further.
-extern Bool VGA_(getArchAndSubArch)( /*OUT*/VexArch*,=20
- /*OUT*/VexSubArch* );
-
/* ---------------------------------------------------------------------
Finally - autoconf-generated settings
------------------------------------------------------------------ */
Modified: trunk/coregrind/m_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_translate.c 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/m_translate.c 2005-06-18 03:44:34 UTC (rev 3930)
@@ -43,11 +43,87 @@
#include "pub_core_translate.h"
#include "pub_core_transtab.h"
=20
+/*------------------------------------------------------------*/
+/*--- Determining arch/subarch. ---*/
+/*------------------------------------------------------------*/
=20
+// Returns the architecture and subarchitecture, or indicates
+// that this subarchitecture is unable to run Valgrind
+// Returns False to indicate we cannot proceed further.
+static Bool getArchAndSubArch( /*OUT*/VexArch* vex_arch,=20
+ /*OUT*/VexSubArch* vex_subarch )
+{
+#if defined(VGA_x86)
+ Bool have_sse0, have_sse1, have_sse2;
+ UInt eax, ebx, ecx, edx;
+
+ if (!VG_(has_cpuid)())
+ /* we can't do cpuid at all. Give up. */
+ return False;
+
+ VG_(cpuid)(0, &eax, &ebx, &ecx, &edx);
+ if (eax < 1)
+ /* we can't ask for cpuid(x) for x > 0. Give up. */
+ return False;
+
+ /* get capabilities bits into edx */
+ VG_(cpuid)(1, &eax, &ebx, &ecx, &edx);
+
+ have_sse0 =3D (edx & (1<<24)) !=3D 0; /* True =3D> have fxsave/fxrsto=
r */
+ have_sse1 =3D (edx & (1<<25)) !=3D 0; /* True =3D> have sse insns */
+ have_sse2 =3D (edx & (1<<26)) !=3D 0; /* True =3D> have sse2 insns */
+
+ if (have_sse2 && have_sse1 && have_sse0) {
+ *vex_arch =3D VexArchX86;
+ *vex_subarch =3D VexSubArchX86_sse2;
+ return True;
+ }
+
+ if (have_sse1 && have_sse0) {
+ *vex_arch =3D VexArchX86;
+ *vex_subarch =3D VexSubArchX86_sse1;
+ return True;
+ }
+
+ if (have_sse0) {
+ *vex_arch =3D VexArchX86;
+ *vex_subarch =3D VexSubArchX86_sse0;
+ return True;
+ }
+
+ /* we need at least SSE state to operate. */
+ return False;
+#elif defined(VGA_amd64)
+ vg_assert(VG_(has_cpuid)());
+ *vex_arch =3D VexArchAMD64;
+ *vex_subarch =3D VexSubArch_NONE;
+ return True;
+#else
+# error Unknown architecture
+#endif
+}
+
+
/*------------------------------------------------------------*/
/*--- %SP-update pass ---*/
/*------------------------------------------------------------*/
=20
+static Bool need_to_handle_SP_assignment(void)
+{
+ return ( VG_(tdict).track_new_mem_stack_4 ||
+ VG_(tdict).track_die_mem_stack_4 ||
+ VG_(tdict).track_new_mem_stack_8 ||
+ VG_(tdict).track_die_mem_stack_8 ||
+ VG_(tdict).track_new_mem_stack_12 ||
+ VG_(tdict).track_die_mem_stack_12 ||
+ VG_(tdict).track_new_mem_stack_16 ||
+ VG_(tdict).track_die_mem_stack_16 ||
+ VG_(tdict).track_new_mem_stack_32 ||
+ VG_(tdict).track_die_mem_stack_32 ||
+ VG_(tdict).track_new_mem_stack ||
+ VG_(tdict).track_die_mem_stack );
+}
+
/* NOTE: this comment is out of date */
=20
/* For tools that want to know about %ESP changes, this pass adds
@@ -336,22 +412,6 @@
}
}
=20
-static Bool need_to_handle_SP_assignment(void)
-{
- return ( VG_(tdict).track_new_mem_stack_4 ||
- VG_(tdict).track_die_mem_stack_4 ||
- VG_(tdict).track_new_mem_stack_8 ||
- VG_(tdict).track_die_mem_stack_8 ||
- VG_(tdict).track_new_mem_stack_12 ||
- VG_(tdict).track_die_mem_stack_12 ||
- VG_(tdict).track_new_mem_stack_16 ||
- VG_(tdict).track_die_mem_stack_16 ||
- VG_(tdict).track_new_mem_stack_32 ||
- VG_(tdict).track_die_mem_stack_32 ||
- VG_(tdict).track_new_mem_stack ||
- VG_(tdict).track_die_mem_stack );
-}
-
Bool VG_(translate) ( ThreadId tid,=20
Addr64 orig_addr,
Bool debugging_translation,
@@ -373,7 +433,7 @@
static Bool vex_init_done =3D False;
=20
if (!vex_init_done) {
- Bool ok =3D VGA_(getArchAndSubArch)( &vex_arch, &vex_subarch );
+ Bool ok =3D getArchAndSubArch( &vex_arch, &vex_subarch );
if (!ok) {
VG_(printf)("\n");
VG_(printf)("valgrind: fatal error: unsupported CPU.\n");
Modified: trunk/coregrind/x86/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/x86/Makefile.am 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/x86/Makefile.am 2005-06-18 03:44:34 UTC (rev 3930)
@@ -3,16 +3,12 @@
=20
noinst_LIBRARIES =3D libarch.a
=20
-EXTRA_DIST =3D \
- jmp_with_stack.c
-
BUILT_SOURCES =3D stage2.lds
CLEANFILES =3D stage2.lds
=20
libarch_a_SOURCES =3D \
cpuid.S \
- jmp_with_stack.c \
- state.c
+ jmp_with_stack.c
=20
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
Deleted: trunk/coregrind/x86/state.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/x86/state.c 2005-06-18 03:27:58 UTC (rev 3929)
+++ trunk/coregrind/x86/state.c 2005-06-18 03:44:34 UTC (rev 3930)
@@ -1,93 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Arch-specific registers, etc. x86/state.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Nicholas Nethercote
- nj...@va...
-
- 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.
-*/
-
-#include "core.h"
-#include "pub_core_libcbase.h"
-#include "pub_core_libcassert.h"
-#include "pub_core_tooliface.h"
-#include <sys/ptrace.h>
-
-#include "libvex_guest_x86.h"
-
-
-/*------------------------------------------------------------*/
-/*--- Determining arch/subarch. ---*/
-/*------------------------------------------------------------*/
-
-// Returns the architecture and subarchitecture, or indicates
-// that this subarchitecture is unable to run Valgrind
-// Returns False to indicate we cannot proceed further.
-Bool VGA_(getArchAndSubArch)( /*OUT*/VexArch* vex_arch,=20
- /*OUT*/VexSubArch* vex_subarch )
-{
- Bool have_sse0, have_sse1, have_sse2;
- UInt eax, ebx, ecx, edx;
-
- if (!VG_(has_cpuid)())
- /* we can't do cpuid at all. Give up. */
- return False;
-
- VG_(cpuid)(0, &eax, &ebx, &ecx, &edx);
- if (eax < 1)
- /* we can't ask for cpuid(x) for x > 0. Give up. */
- return False;
-
- /* get capabilities bits into edx */
- VG_(cpuid)(1, &eax, &ebx, &ecx, &edx);
-
- have_sse0 =3D (edx & (1<<24)) !=3D 0; /* True =3D> have fxsave/fxrsto=
r */
- have_sse1 =3D (edx & (1<<25)) !=3D 0; /* True =3D> have sse insns */
- have_sse2 =3D (edx & (1<<26)) !=3D 0; /* True =3D> have sse2 insns */
-
- if (have_sse2 && have_sse1 && have_sse0) {
- *vex_arch =3D VexArchX86;
- *vex_subarch =3D VexSubArchX86_sse2;
- return True;
- }
-
- if (have_sse1 && have_sse0) {
- *vex_arch =3D VexArchX86;
- *vex_subarch =3D VexSubArchX86_sse1;
- return True;
- }
-
- if (have_sse0) {
- *vex_arch =3D VexArchX86;
- *vex_subarch =3D VexSubArchX86_sse0;
- return True;
- }
-
- /* we need at least SSE state to operate. */
- return False;
-}
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
|