1de4a1d01951937632098a6cda45859afa587a06fsewardj 2de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 3c7561b931e249acf3768ead77638545b0ccaa8f1njn/*--- Header included by every core C file. pub_core_basics.h ---*/ 4de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 5c7561b931e249acf3768ead77638545b0ccaa8f1njn 6de4a1d01951937632098a6cda45859afa587a06fsewardj/* 7b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn This file is part of Valgrind, a dynamic binary instrumentation 8b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn framework. 9de4a1d01951937632098a6cda45859afa587a06fsewardj 100f157ddb404bcde7815a1c5bf2d7e41c114f3d73sewardj Copyright (C) 2000-2013 Julian Seward 11de4a1d01951937632098a6cda45859afa587a06fsewardj jseward@acm.org 12de4a1d01951937632098a6cda45859afa587a06fsewardj 13de4a1d01951937632098a6cda45859afa587a06fsewardj This program is free software; you can redistribute it and/or 14de4a1d01951937632098a6cda45859afa587a06fsewardj modify it under the terms of the GNU General Public License as 15de4a1d01951937632098a6cda45859afa587a06fsewardj published by the Free Software Foundation; either version 2 of the 16de4a1d01951937632098a6cda45859afa587a06fsewardj License, or (at your option) any later version. 17de4a1d01951937632098a6cda45859afa587a06fsewardj 18de4a1d01951937632098a6cda45859afa587a06fsewardj This program is distributed in the hope that it will be useful, but 19de4a1d01951937632098a6cda45859afa587a06fsewardj WITHOUT ANY WARRANTY; without even the implied warranty of 20de4a1d01951937632098a6cda45859afa587a06fsewardj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21de4a1d01951937632098a6cda45859afa587a06fsewardj General Public License for more details. 22de4a1d01951937632098a6cda45859afa587a06fsewardj 23de4a1d01951937632098a6cda45859afa587a06fsewardj You should have received a copy of the GNU General Public License 24de4a1d01951937632098a6cda45859afa587a06fsewardj along with this program; if not, write to the Free Software 25de4a1d01951937632098a6cda45859afa587a06fsewardj Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26de4a1d01951937632098a6cda45859afa587a06fsewardj 02111-1307, USA. 27de4a1d01951937632098a6cda45859afa587a06fsewardj 28e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn The GNU General Public License is contained in the file COPYING. 29de4a1d01951937632098a6cda45859afa587a06fsewardj*/ 30de4a1d01951937632098a6cda45859afa587a06fsewardj 31c7561b931e249acf3768ead77638545b0ccaa8f1njn#ifndef __PUB_CORE_BASICS_H 32c7561b931e249acf3768ead77638545b0ccaa8f1njn#define __PUB_CORE_BASICS_H 33c7561b931e249acf3768ead77638545b0ccaa8f1njn 34c7561b931e249acf3768ead77638545b0ccaa8f1njn//-------------------------------------------------------------------- 35c7561b931e249acf3768ead77638545b0ccaa8f1njn// PURPOSE: This header should be imported by every single C file 36c7561b931e249acf3768ead77638545b0ccaa8f1njn// in the core. It contains the basic types and other things needed 37c7561b931e249acf3768ead77638545b0ccaa8f1njn// everywhere. 38c7561b931e249acf3768ead77638545b0ccaa8f1njn//-------------------------------------------------------------------- 39c7561b931e249acf3768ead77638545b0ccaa8f1njn 40c7561b931e249acf3768ead77638545b0ccaa8f1njn#include "pub_tool_basics.h" 41c7561b931e249acf3768ead77638545b0ccaa8f1njn 42c7561b931e249acf3768ead77638545b0ccaa8f1njn/* --------------------------------------------------------------------- 4359570ffbe31930ab4d678754daaeec0715117a3dsewardj A struct to hold starting values for stack unwinding. 4459570ffbe31930ab4d678754daaeec0715117a3dsewardj ------------------------------------------------------------------ */ 4559570ffbe31930ab4d678754daaeec0715117a3dsewardj 4659570ffbe31930ab4d678754daaeec0715117a3dsewardj/* This really shouldn't be here. But putting it elsewhere leads to a 4759570ffbe31930ab4d678754daaeec0715117a3dsewardj veritable swamp of new module cycles. */ 4859570ffbe31930ab4d678754daaeec0715117a3dsewardj 4959570ffbe31930ab4d678754daaeec0715117a3dsewardj/* To support CFA-based stack unwinding, and stack unwinding in 5059570ffbe31930ab4d678754daaeec0715117a3dsewardj general, we need to be able to get hold of the values of specific 5159570ffbe31930ab4d678754daaeec0715117a3dsewardj registers, in order to start the unwinding process. This is 5259570ffbe31930ab4d678754daaeec0715117a3dsewardj unavoidably arch and platform dependent. Here is a struct which 5359570ffbe31930ab4d678754daaeec0715117a3dsewardj holds the relevant values. All platforms must have a program 5459570ffbe31930ab4d678754daaeec0715117a3dsewardj counter and a stack pointer register, but the other fields (frame 5559570ffbe31930ab4d678754daaeec0715117a3dsewardj pointer? link register? misc other regs?) are ad-hoc. Note, the 5659570ffbe31930ab4d678754daaeec0715117a3dsewardj common fields are 64-bit, so as to make this host-independent. */ 5759570ffbe31930ab4d678754daaeec0715117a3dsewardj 5859570ffbe31930ab4d678754daaeec0715117a3dsewardjtypedef 5959570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 605db15403e889d4db339b342bc2a824ef0bfaa654sewardj ULong r_pc; /* x86:EIP, amd64:RIP, ppc:CIA, arm:R15, mips:pc */ 615db15403e889d4db339b342bc2a824ef0bfaa654sewardj ULong r_sp; /* x86:ESP, amd64:RSP, ppc:R1, arm:R13, mips:sp */ 6259570ffbe31930ab4d678754daaeec0715117a3dsewardj union { 6359570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 6459570ffbe31930ab4d678754daaeec0715117a3dsewardj UInt r_ebp; 6559570ffbe31930ab4d678754daaeec0715117a3dsewardj } X86; 6659570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 6759570ffbe31930ab4d678754daaeec0715117a3dsewardj ULong r_rbp; 6859570ffbe31930ab4d678754daaeec0715117a3dsewardj } AMD64; 6959570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 7059570ffbe31930ab4d678754daaeec0715117a3dsewardj UInt r_lr; 7159570ffbe31930ab4d678754daaeec0715117a3dsewardj } PPC32; 7259570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 7359570ffbe31930ab4d678754daaeec0715117a3dsewardj ULong r_lr; 7459570ffbe31930ab4d678754daaeec0715117a3dsewardj } PPC64; 7559570ffbe31930ab4d678754daaeec0715117a3dsewardj struct { 7659570ffbe31930ab4d678754daaeec0715117a3dsewardj UInt r14; 7759570ffbe31930ab4d678754daaeec0715117a3dsewardj UInt r12; 7859570ffbe31930ab4d678754daaeec0715117a3dsewardj UInt r11; 79fa5ce5616a17e79828fbc79f30b02b5085151e3csewardj UInt r7; 8059570ffbe31930ab4d678754daaeec0715117a3dsewardj } ARM; 81b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj struct { 82f0c1250e324f6684757c6a15545366447ef1d64fsewardj ULong x29; /* FP */ 83f0c1250e324f6684757c6a15545366447ef1d64fsewardj ULong x30; /* LR */ 84f0c1250e324f6684757c6a15545366447ef1d64fsewardj } ARM64; 85f0c1250e324f6684757c6a15545366447ef1d64fsewardj struct { 86b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj ULong r_fp; 87b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj ULong r_lr; 88b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj } S390X; 895db15403e889d4db339b342bc2a824ef0bfaa654sewardj struct { 905db15403e889d4db339b342bc2a824ef0bfaa654sewardj UInt r30; /* Stack frame pointer or subroutine variable */ 915db15403e889d4db339b342bc2a824ef0bfaa654sewardj UInt r31; /* Return address of the last subroutine call */ 925db15403e889d4db339b342bc2a824ef0bfaa654sewardj UInt r28; 935db15403e889d4db339b342bc2a824ef0bfaa654sewardj } MIPS32; 944df0bfc0614379192c780c944415dc420d9cfe8epetarj struct { 954df0bfc0614379192c780c944415dc420d9cfe8epetarj ULong r30; /* Stack frame pointer or subroutine variable */ 964df0bfc0614379192c780c944415dc420d9cfe8epetarj ULong r31; /* Return address of the last subroutine call */ 974df0bfc0614379192c780c944415dc420d9cfe8epetarj ULong r28; 984df0bfc0614379192c780c944415dc420d9cfe8epetarj } MIPS64; 99112711afefcfcd43680c7c4aa8d38ef180e8811esewardj struct { 100112711afefcfcd43680c7c4aa8d38ef180e8811esewardj ULong r52; 101112711afefcfcd43680c7c4aa8d38ef180e8811esewardj ULong r55; 102112711afefcfcd43680c7c4aa8d38ef180e8811esewardj } TILEGX; 10359570ffbe31930ab4d678754daaeec0715117a3dsewardj } misc; 10459570ffbe31930ab4d678754daaeec0715117a3dsewardj } 10559570ffbe31930ab4d678754daaeec0715117a3dsewardj UnwindStartRegs; 10659570ffbe31930ab4d678754daaeec0715117a3dsewardj 10759570ffbe31930ab4d678754daaeec0715117a3dsewardj 108c7561b931e249acf3768ead77638545b0ccaa8f1njn#endif // __PUB_CORE_BASICS_H 109c06e2137125b523897e73cf8ce9c476585d2ca1bnethercote 110de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 111109d0dfd774a018f1e425dd89734dd72bc12ab35nethercote/*--- end ---*/ 112de4a1d01951937632098a6cda45859afa587a06fsewardj/*--------------------------------------------------------------------*/ 113