1ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 2ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--------------------------------------------------------------------*/ 3ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--- Header included by every core C file. pub_core_basics.h ---*/ 4ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--------------------------------------------------------------------*/ 5ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 6ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* 7ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This file is part of Valgrind, a dynamic binary instrumentation 8ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown framework. 9ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 10663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Copyright (C) 2000-2012 Julian Seward 11ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown jseward@acm.org 12ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 13ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This program is free software; you can redistribute it and/or 14ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown modify it under the terms of the GNU General Public License as 15ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown published by the Free Software Foundation; either version 2 of the 16ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown License, or (at your option) any later version. 17ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 18ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This program is distributed in the hope that it will be useful, but 19ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown WITHOUT ANY WARRANTY; without even the implied warranty of 20ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown General Public License for more details. 22ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 23ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown You should have received a copy of the GNU General Public License 24ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown along with this program; if not, write to the Free Software 25ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 02111-1307, USA. 27ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 28ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown The GNU General Public License is contained in the file COPYING. 29ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/ 30ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 31ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef __PUB_CORE_BASICS_H 32ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define __PUB_CORE_BASICS_H 33ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 34ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//-------------------------------------------------------------------- 35ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// PURPOSE: This header should be imported by every single C file 36ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// in the core. It contains the basic types and other things needed 37ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// everywhere. 38ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//-------------------------------------------------------------------- 39ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 40ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include "pub_tool_basics.h" 41ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 42ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* --------------------------------------------------------------------- 43ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Other headers to include 44ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ------------------------------------------------------------------ */ 45ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 46ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// Might as well have the following two in here, their contents are used so 47ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// broadly (eg. in pub_core_threadstate.h). 48ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 49ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include "libvex.h" 50ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 51ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if defined(VGA_x86) 52ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# include "libvex_guest_x86.h" 53ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#elif defined(VGA_amd64) 54ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# include "libvex_guest_amd64.h" 55ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#elif defined(VGA_ppc32) 56ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# include "libvex_guest_ppc32.h" 57ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#elif defined(VGA_ppc64) 58ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# include "libvex_guest_ppc64.h" 59ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#elif defined(VGA_arm) 60ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# include "libvex_guest_arm.h" 61b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#elif defined(VGA_s390x) 62b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov# include "libvex_guest_s390x.h" 63663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#elif defined(VGA_mips32) 64663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng# include "libvex_guest_mips32.h" 65ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#else 66ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown# error Unknown arch 67ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif 68ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 69ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 70ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* --------------------------------------------------------------------- 71ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown A struct to hold starting values for stack unwinding. 72ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ------------------------------------------------------------------ */ 73ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 74ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This really shouldn't be here. But putting it elsewhere leads to a 75ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown veritable swamp of new module cycles. */ 76ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 77ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* To support CFA-based stack unwinding, and stack unwinding in 78ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown general, we need to be able to get hold of the values of specific 79ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown registers, in order to start the unwinding process. This is 80ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown unavoidably arch and platform dependent. Here is a struct which 81ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown holds the relevant values. All platforms must have a program 82ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown counter and a stack pointer register, but the other fields (frame 83ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown pointer? link register? misc other regs?) are ad-hoc. Note, the 84ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown common fields are 64-bit, so as to make this host-independent. */ 85ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 86ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef 87ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 88663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong r_pc; /* x86:EIP, amd64:RIP, ppc:CIA, arm:R15, mips:pc */ 89663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong r_sp; /* x86:ESP, amd64:RSP, ppc:R1, arm:R13, mips:sp */ 90ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown union { 91ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 92ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r_ebp; 93ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } X86; 94ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 95ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ULong r_rbp; 96ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } AMD64; 97ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 98ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r_lr; 99ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } PPC32; 100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ULong r_lr; 102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } PPC64; 103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown struct { 104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r14; 105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r12; 106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r11; 107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r7; 108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } ARM; 109b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov struct { 110b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov ULong r_fp; 111b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov ULong r_lr; 112b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov } S390X; 113663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng struct { 114663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng UInt r30; /* Stack frame pointer or subroutine variable */ 115663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng UInt r31; /* Return address of the last subroutine call */ 116663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng UInt r28; 117663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng } MIPS32; 118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } misc; 119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown } 120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UnwindStartRegs; 121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif // __PUB_CORE_BASICS_H 124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--------------------------------------------------------------------*/ 126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--- end ---*/ 127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--------------------------------------------------------------------*/ 128