From: Nicholas Nethercote Date: Thu, 12 May 2005 05:13:04 +0000 (+0000) Subject: Modularised the dispatchers in m_dispatch. X-Git-Tag: svn/VALGRIND_3_0_0~646 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e2169edd95606d1cb3cb95fb62ee16a4ed80e49;p=thirdparty%2Fvalgrind.git Modularised the dispatchers in m_dispatch. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3672 --- diff --git a/configure.in b/configure.in index 953ca14ed3..679efea497 100644 --- a/configure.in +++ b/configure.in @@ -393,8 +393,9 @@ AC_OUTPUT( include/x86-linux/Makefile auxprogs/Makefile coregrind/Makefile - coregrind/m_demangle/Makefile coregrind/m_aspacemgr/Makefile + coregrind/m_demangle/Makefile + coregrind/m_dispatch/Makefile coregrind/m_replacemalloc/Makefile coregrind/m_sigframe/Makefile coregrind/m_syscalls/Makefile diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index c430bfa24c..ea6c454926 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -2,8 +2,9 @@ include $(top_srcdir)/Makefile.all.am include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am MODULES = \ - m_demangle \ m_aspacemgr \ + m_demangle \ + m_dispatch \ m_replacemalloc \ m_sigframe \ m_syscalls @@ -40,6 +41,7 @@ noinst_HEADERS = \ pub_core_aspacemgr.h \ pub_core_debuglog.h \ pub_core_demangle.h \ + pub_core_dispatch.h \ pub_core_errormgr.h \ pub_core_execontext.h \ pub_core_mallocfree.h \ @@ -96,6 +98,7 @@ stage2_SOURCES = \ ## libplatform.a must be before libarch.a and libos.a, it seems. stage2_extra= \ + m_dispatch/libdispatch.a \ m_demangle/libdemangle.a \ m_aspacemgr/libaspacemgr.a \ m_sigframe/libsigframe.a \ diff --git a/coregrind/amd64/Makefile.am b/coregrind/amd64/Makefile.am index 61217394e6..5baea3a643 100644 --- a/coregrind/amd64/Makefile.am +++ b/coregrind/amd64/Makefile.am @@ -19,7 +19,6 @@ CLEANFILES = stage2.lds libarch_a_SOURCES = \ cpuid.S \ helpers.S \ - dispatch.S \ jmp_with_stack.c \ state.c diff --git a/coregrind/arm/Makefile.am b/coregrind/arm/Makefile.am index 0ad93dddf3..1bb806eca4 100644 --- a/coregrind/arm/Makefile.am +++ b/coregrind/arm/Makefile.am @@ -17,7 +17,6 @@ BUILT_SOURCES = stage2.lds CLEANFILES = stage2.lds libarch_a_SOURCES = \ - dispatch.S \ state.c if USE_PIE diff --git a/coregrind/core.h b/coregrind/core.h index 82076e1ed0..91bb674d91 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -661,9 +661,6 @@ extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname ); extern Addr VG_(reverse_search_one_symtab) ( const SegInfo* si, const Char* name ); -/* Set up some default redirects */ -extern void VG_(setup_code_redirect_table) ( void ); - extern Bool VG_(resolve_redir_allsegs)(CodeRedirect *redir); extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP, @@ -676,9 +673,13 @@ extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP, /* --------------------------------------------------------------------- Exports of vg_redir.c ------------------------------------------------------------------ */ + /* Redirection machinery */ extern Addr VG_(code_redirect) ( Addr orig ); +/* Set up some default redirects */ +extern void VG_(setup_code_redirect_table) ( void ); + extern void VG_(add_redirect_sym_to_addr)(const Char *from_lib, const Char *from_sym, Addr to_addr); @@ -823,25 +824,6 @@ extern Word VG_(do_syscall) ( UInt, UWord, UWord, UWord, UWord, UWord, UWord ); extern void VG_(sigreturn)(void); -/* --------------------------------------------------------------------- - Exports of vg_dispatch.S - ------------------------------------------------------------------ */ - -/* This subroutine is called from the C world. It is passed - a pointer to the VEX guest state (arch.vex). It must run code - from the instruction pointer in the guest state, and exit when - VG_(dispatch_ctr) reaches zero, or we need to defer to the scheduler. - The return value must indicate why it returned back to the scheduler. - It can also be exited if the executing code throws a non-resumable - signal, for example SIGSEGV, in which case control longjmp()s back past - here. - - This code simply handles the common case fast -- when the translation - address is found in the translation cache. For anything else, the - scheduler does the work. -*/ -extern UWord VG_(run_innerloop) ( void* guest_state ); - /* --------------------------------------------------------------------- Exports of vg_helpers.S ------------------------------------------------------------------ */ diff --git a/coregrind/m_dispatch/Makefile.am b/coregrind/m_dispatch/Makefile.am new file mode 100644 index 0000000000..d9b5cf6c8f --- /dev/null +++ b/coregrind/m_dispatch/Makefile.am @@ -0,0 +1,17 @@ +include $(top_srcdir)/Makefile.all.am +include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am + +AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g + +noinst_LIBRARIES = libdispatch.a + +## XXX: this won't work with "make dist" -- only one dispatch-XXX.S file +## will be put in the tarball. Problem exists in various other Makefiles. +libdispatch_a_SOURCES = \ + dispatch-@VG_ARCH@.S + +if USE_PIE +libdispatch_a_CFLAGS = $(AM_CFLAGS) -fpie +else +libdispatch_a_CFLAGS = $(AM_CFLAGS) +endif diff --git a/coregrind/amd64/dispatch.S b/coregrind/m_dispatch/dispatch-amd64.S similarity index 100% rename from coregrind/amd64/dispatch.S rename to coregrind/m_dispatch/dispatch-amd64.S diff --git a/coregrind/arm/dispatch.S b/coregrind/m_dispatch/dispatch-arm.S similarity index 100% rename from coregrind/arm/dispatch.S rename to coregrind/m_dispatch/dispatch-arm.S diff --git a/coregrind/x86/dispatch.S b/coregrind/m_dispatch/dispatch-x86.S similarity index 100% rename from coregrind/x86/dispatch.S rename to coregrind/m_dispatch/dispatch-x86.S diff --git a/coregrind/pub_core_dispatch.h b/coregrind/pub_core_dispatch.h new file mode 100644 index 0000000000..e337ad6065 --- /dev/null +++ b/coregrind/pub_core_dispatch.h @@ -0,0 +1,61 @@ + +/*--------------------------------------------------------------------*/ +/*--- The dispatcher. pub_core_dispatch.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_DISPATCH_H +#define __PUB_CORE_DISPATCH_H + +//-------------------------------------------------------------------- +// PURPOSE: This module deals with management of the entire process +// address space. Almost everything depends upon it, including dynamic +// memory management. Hence this module is almost completely +// standalone; the only module it uses is m_debuglog. DO NOT CHANGE +// THIS. +//-------------------------------------------------------------------- + +/* This subroutine is called from the C world. It is passed + a pointer to the VEX guest state (arch.vex). It must run code + from the instruction pointer in the guest state, and exit when + VG_(dispatch_ctr) reaches zero, or we need to defer to the scheduler. + The return value must indicate why it returned back to the scheduler. + It can also be exited if the executing code throws a non-resumable + signal, for example SIGSEGV, in which case control longjmp()s back past + here. + + This code simply handles the common case fast -- when the translation + address is found in the translation cache. For anything else, the + scheduler does the work. +*/ +extern UWord VG_(run_innerloop) ( void* guest_state ); + +#endif // __PUB_CORE_DISPATCH_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 87ab433c89..8f62a13221 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -60,6 +60,7 @@ VG_USERREQ__DISCARD_TRANSLATIONS, and others */ #include "core.h" +#include "pub_core_dispatch.h" #include "pub_core_errormgr.h" #include "pub_core_replacemalloc.h" #include "pub_core_stacktrace.h" diff --git a/coregrind/x86/Makefile.am b/coregrind/x86/Makefile.am index 95d4da1a58..65d955233f 100644 --- a/coregrind/x86/Makefile.am +++ b/coregrind/x86/Makefile.am @@ -19,7 +19,6 @@ CLEANFILES = stage2.lds libarch_a_SOURCES = \ cpuid.S \ helpers.S \ - dispatch.S \ jmp_with_stack.c \ state.c