From: Julian Seward Date: Fri, 26 Nov 2004 13:18:19 +0000 (+0000) Subject: Make VEX define the special thread-return-code values it uses. X-Git-Tag: svn/VALGRIND_3_0_1^2~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a962f1bd3c111148fb994af51f41b5a9d7752cb9;p=thirdparty%2Fvalgrind.git Make VEX define the special thread-return-code values it uses. git-svn-id: svn://svn.valgrind.org/vex/trunk@590 --- diff --git a/VEX/Makefile b/VEX/Makefile index 031216f01e..20fb76647c 100644 --- a/VEX/Makefile +++ b/VEX/Makefile @@ -2,6 +2,7 @@ PUB_HEADERS = pub/libvex_basictypes.h \ pub/libvex_ir.h \ pub/libvex.h \ + pub/libvex_trc_values.h \ pub/libvex_guest_x86.h \ pub/libvex_guest_amd64.h \ pub/libvex_guest_arm.h diff --git a/VEX/priv/host-x86/hdefs.c b/VEX/priv/host-x86/hdefs.c index ccfd28d567..70e9f8af61 100644 --- a/VEX/priv/host-x86/hdefs.c +++ b/VEX/priv/host-x86/hdefs.c @@ -35,6 +35,7 @@ #include "libvex_basictypes.h" #include "libvex.h" +#include "libvex_trc_values.h" #include "main/vex_util.h" #include "host-generic/h_generic_regs.h" @@ -1718,9 +1719,8 @@ Int emit_X86Instr ( UChar* buf, Int nbuf, X86Instr* i ) goto done; case Xin_Goto: - /* If a non-boring unconditional jump, set %ebp appropriately. - The magic numbers here have to match those defined in - vg_constants.h. */ + /* If a non-boring unconditional jump, set %ebp (the guest state + pointer) appropriately. */ if (i->Xin.Goto.cond == Xcc_ALWAYS && (i->Xin.Goto.jk == Ijk_ClientReq || i->Xin.Goto.jk == Ijk_Syscall @@ -1729,14 +1729,11 @@ Int emit_X86Instr ( UChar* buf, Int nbuf, X86Instr* i ) *p++ = 0xBD; switch (i->Xin.Goto.jk) { case Ijk_ClientReq: - /* 23 == VG_TRC_EBP_JMP_CLIENTREQ */ - p = emit32(p, 23); break; + p = emit32(p, VEX_TRC_JMP_CLIENTREQ); break; case Ijk_Syscall: - /* 19 == VG_TRC_EBP_JMP_SYSCALL */ - p = emit32(p, 19); break; + p = emit32(p, VEX_TRC_JMP_SYSCALL); break; case Ijk_Yield: - /* 27 == VG_TRC_EBP_JMP_YIELD */ - p = emit32(p, 27); break; + p = emit32(p, VEX_TRC_JMP_YIELD); break; default: ppIRJumpKind(i->Xin.Goto.jk); vpanic("emit_X86Instr.Xin_Goto: unknown jump kind"); diff --git a/VEX/pub/libvex_trc_values.h b/VEX/pub/libvex_trc_values.h new file mode 100644 index 0000000000..93088f97ff --- /dev/null +++ b/VEX/pub/libvex_trc_values.h @@ -0,0 +1,56 @@ + +/*---------------------------------------------------------------*/ +/*--- ---*/ +/*--- This file (libvex_trc_values.h) is ---*/ +/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/ +/*--- ---*/ +/*---------------------------------------------------------------*/ + +/* + This file is part of LibVEX, a library for dynamic binary + instrumentation and translation. + + Copyright (C) 2004 OpenWorks, LLP. + + 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; Version 2 dated June 1991 of the + license. + + 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, or liability + for damages. See the GNU General Public License for more details. + + Neither the names of the U.S. Department of Energy nor the + University of California nor the names of its contributors may be + used to endorse or promote products derived from this software + without prior written permission. + + 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. +*/ + +#ifndef __LIBVEX_TRC_VALUES_H +#define __LIBVEX_TRC_VALUES_H + + +/* Magic values that the guest state pointer might be set to when + returning to the dispatcher. The only other legitimate value is to + point to the start of the thread's VEX guest state. + + This file may get included in assembly code, so do not put + C-specific constructs in it. +*/ +#define VEX_TRC_JMP_SYSCALL 19 /* do a system call before continuing */ +#define VEX_TRC_JMP_CLIENTREQ 23 /* do a client req before continuing */ +#define VEX_TRC_JMP_YIELD 27 /* yield to thread sched + before continuing */ + +#endif /* ndef __LIBVEX_TRC_VALUES_H */ + +/*---------------------------------------------------------------*/ +/*--- libvex_trc_values.h ---*/ +/*---------------------------------------------------------------*/