sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 3 | /*--- Header included by every core C file. pub_core_basics.h ---*/ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 5 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 6 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 9 | |
Elliott Hughes | ed39800 | 2017-06-21 14:41:24 -0700 | [diff] [blame^] | 10 | Copyright (C) 2000-2017 Julian Seward |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 11 | jseward@acm.org |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 28 | The GNU General Public License is contained in the file COPYING. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 31 | #ifndef __PUB_CORE_BASICS_H |
| 32 | #define __PUB_CORE_BASICS_H |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 33 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This header should be imported by every single C file |
| 36 | // in the core. It contains the basic types and other things needed |
| 37 | // everywhere. |
| 38 | //-------------------------------------------------------------------- |
| 39 | |
| 40 | #include "pub_tool_basics.h" |
| 41 | |
| 42 | /* --------------------------------------------------------------------- |
sewardj | 59570ff | 2010-01-01 11:59:33 +0000 | [diff] [blame] | 43 | A struct to hold starting values for stack unwinding. |
| 44 | ------------------------------------------------------------------ */ |
| 45 | |
| 46 | /* This really shouldn't be here. But putting it elsewhere leads to a |
| 47 | veritable swamp of new module cycles. */ |
| 48 | |
| 49 | /* To support CFA-based stack unwinding, and stack unwinding in |
| 50 | general, we need to be able to get hold of the values of specific |
| 51 | registers, in order to start the unwinding process. This is |
| 52 | unavoidably arch and platform dependent. Here is a struct which |
| 53 | holds the relevant values. All platforms must have a program |
| 54 | counter and a stack pointer register, but the other fields (frame |
| 55 | pointer? link register? misc other regs?) are ad-hoc. Note, the |
| 56 | common fields are 64-bit, so as to make this host-independent. */ |
| 57 | |
| 58 | typedef |
| 59 | struct { |
sewardj | 5db1540 | 2012-06-07 09:13:21 +0000 | [diff] [blame] | 60 | ULong r_pc; /* x86:EIP, amd64:RIP, ppc:CIA, arm:R15, mips:pc */ |
| 61 | ULong r_sp; /* x86:ESP, amd64:RSP, ppc:R1, arm:R13, mips:sp */ |
sewardj | 59570ff | 2010-01-01 11:59:33 +0000 | [diff] [blame] | 62 | union { |
| 63 | struct { |
| 64 | UInt r_ebp; |
| 65 | } X86; |
| 66 | struct { |
| 67 | ULong r_rbp; |
| 68 | } AMD64; |
| 69 | struct { |
| 70 | UInt r_lr; |
| 71 | } PPC32; |
| 72 | struct { |
| 73 | ULong r_lr; |
| 74 | } PPC64; |
| 75 | struct { |
| 76 | UInt r14; |
| 77 | UInt r12; |
| 78 | UInt r11; |
sewardj | fa5ce56 | 2010-09-23 22:05:59 +0000 | [diff] [blame] | 79 | UInt r7; |
sewardj | 59570ff | 2010-01-01 11:59:33 +0000 | [diff] [blame] | 80 | } ARM; |
sewardj | b5b8740 | 2011-03-07 16:05:35 +0000 | [diff] [blame] | 81 | struct { |
sewardj | f0c1250 | 2014-01-12 12:54:00 +0000 | [diff] [blame] | 82 | ULong x29; /* FP */ |
| 83 | ULong x30; /* LR */ |
| 84 | } ARM64; |
| 85 | struct { |
sewardj | b5b8740 | 2011-03-07 16:05:35 +0000 | [diff] [blame] | 86 | ULong r_fp; |
| 87 | ULong r_lr; |
| 88 | } S390X; |
sewardj | 5db1540 | 2012-06-07 09:13:21 +0000 | [diff] [blame] | 89 | struct { |
| 90 | UInt r30; /* Stack frame pointer or subroutine variable */ |
| 91 | UInt r31; /* Return address of the last subroutine call */ |
| 92 | UInt r28; |
| 93 | } MIPS32; |
petarj | 4df0bfc | 2013-02-27 23:17:33 +0000 | [diff] [blame] | 94 | struct { |
| 95 | ULong r30; /* Stack frame pointer or subroutine variable */ |
| 96 | ULong r31; /* Return address of the last subroutine call */ |
| 97 | ULong r28; |
| 98 | } MIPS64; |
sewardj | 59570ff | 2010-01-01 11:59:33 +0000 | [diff] [blame] | 99 | } misc; |
| 100 | } |
| 101 | UnwindStartRegs; |
| 102 | |
| 103 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 104 | #endif // __PUB_CORE_BASICS_H |
nethercote | c06e213 | 2004-09-03 13:45:29 +0000 | [diff] [blame] | 105 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 106 | /*--------------------------------------------------------------------*/ |
nethercote | 109d0df | 2004-09-02 08:10:13 +0000 | [diff] [blame] | 107 | /*--- end ---*/ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 108 | /*--------------------------------------------------------------------*/ |