• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*--------------------------------------------------------------------*/
3 /*--- Header included by every core C file.      pub_core_basics.h ---*/
4 /*--------------------------------------------------------------------*/
5 
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9 
10    Copyright (C) 2000-2013 Julian Seward
11       jseward@acm.org
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 
28    The GNU General Public License is contained in the file COPYING.
29 */
30 
31 #ifndef __PUB_CORE_BASICS_H
32 #define __PUB_CORE_BASICS_H
33 
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 /* ---------------------------------------------------------------------
43    Other headers to include
44    ------------------------------------------------------------------ */
45 
46 // Might as well have the following two in here, their contents are used so
47 // broadly (eg. in pub_core_threadstate.h).
48 
49 #include "libvex.h"
50 
51 #if defined(VGA_x86)
52 #  include "libvex_guest_x86.h"
53 #elif defined(VGA_amd64)
54 #  include "libvex_guest_amd64.h"
55 #elif defined(VGA_ppc32)
56 #  include "libvex_guest_ppc32.h"
57 #elif defined(VGA_ppc64)
58 #  include "libvex_guest_ppc64.h"
59 #elif defined(VGA_arm)
60 #  include "libvex_guest_arm.h"
61 #elif defined(VGA_arm64)
62 #  include "libvex_guest_arm64.h"
63 #elif defined(VGA_s390x)
64 #  include "libvex_guest_s390x.h"
65 #elif defined(VGA_mips32)
66 #  include "libvex_guest_mips32.h"
67 #elif defined(VGA_mips64)
68 #  include "libvex_guest_mips64.h"
69 #else
70 #  error Unknown arch
71 #endif
72 
73 
74 /* ---------------------------------------------------------------------
75    A struct to hold starting values for stack unwinding.
76    ------------------------------------------------------------------ */
77 
78 /* This really shouldn't be here.  But putting it elsewhere leads to a
79    veritable swamp of new module cycles. */
80 
81 /* To support CFA-based stack unwinding, and stack unwinding in
82    general, we need to be able to get hold of the values of specific
83    registers, in order to start the unwinding process.  This is
84    unavoidably arch and platform dependent.  Here is a struct which
85    holds the relevant values.  All platforms must have a program
86    counter and a stack pointer register, but the other fields (frame
87    pointer? link register? misc other regs?) are ad-hoc.  Note, the
88    common fields are 64-bit, so as to make this host-independent. */
89 
90 typedef
91    struct {
92       ULong r_pc; /* x86:EIP, amd64:RIP, ppc:CIA, arm:R15, mips:pc */
93       ULong r_sp; /* x86:ESP, amd64:RSP, ppc:R1,  arm:R13, mips:sp */
94       union {
95          struct {
96             UInt r_ebp;
97          } X86;
98          struct {
99             ULong r_rbp;
100          } AMD64;
101          struct {
102             UInt r_lr;
103          } PPC32;
104          struct {
105             ULong r_lr;
106          } PPC64;
107          struct {
108             UInt r14;
109             UInt r12;
110             UInt r11;
111             UInt r7;
112          } ARM;
113          struct {
114             ULong x29; /* FP */
115             ULong x30; /* LR */
116          } ARM64;
117          struct {
118             ULong r_fp;
119             ULong r_lr;
120          } S390X;
121          struct {
122             UInt r30;  /* Stack frame pointer or subroutine variable  */
123             UInt r31;  /* Return address of the last subroutine call */
124             UInt r28;
125          } MIPS32;
126          struct {
127             ULong r30;  /* Stack frame pointer or subroutine variable */
128             ULong r31;  /* Return address of the last subroutine call */
129             ULong r28;
130          } MIPS64;
131       } misc;
132    }
133    UnwindStartRegs;
134 
135 
136 #endif   // __PUB_CORE_BASICS_H
137 
138 /*--------------------------------------------------------------------*/
139 /*--- end                                                          ---*/
140 /*--------------------------------------------------------------------*/
141