blob: a08698649779373797beaf2bc80a2bcccfb10f5e [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
2/*--------------------------------------------------------------------*/
njnc7561b92005-06-19 01:24:32 +00003/*--- Header included by every core C file. pub_core_basics.h ---*/
sewardjde4a1d02002-03-22 01:27:54 +00004/*--------------------------------------------------------------------*/
njnc7561b92005-06-19 01:24:32 +00005
sewardjde4a1d02002-03-22 01:27:54 +00006/*
njnb9c427c2004-12-01 14:14:42 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjde4a1d02002-03-22 01:27:54 +00009
sewardj03f8d3f2012-08-05 15:46:46 +000010 Copyright (C) 2000-2012 Julian Seward
sewardjde4a1d02002-03-22 01:27:54 +000011 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000012
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
njn25e49d8e72002-09-23 09:36:25 +000028 The GNU General Public License is contained in the file COPYING.
sewardjde4a1d02002-03-22 01:27:54 +000029*/
30
njnc7561b92005-06-19 01:24:32 +000031#ifndef __PUB_CORE_BASICS_H
32#define __PUB_CORE_BASICS_H
sewardjde4a1d02002-03-22 01:27:54 +000033
njnc7561b92005-06-19 01:24:32 +000034//--------------------------------------------------------------------
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).
njn767eb422005-06-10 23:09:45 +000048
49#include "libvex.h"
njnf536bbb2005-06-13 04:21:38 +000050
njn767eb422005-06-10 23:09:45 +000051#if defined(VGA_x86)
sewardjefe0f922005-06-11 10:32:57 +000052# include "libvex_guest_x86.h"
njn767eb422005-06-10 23:09:45 +000053#elif defined(VGA_amd64)
sewardjefe0f922005-06-11 10:32:57 +000054# include "libvex_guest_amd64.h"
cerion85665ca2005-06-20 15:51:07 +000055#elif defined(VGA_ppc32)
56# include "libvex_guest_ppc32.h"
sewardj2c48c7b2005-11-29 13:05:56 +000057#elif defined(VGA_ppc64)
58# include "libvex_guest_ppc64.h"
sewardj59570ff2010-01-01 11:59:33 +000059#elif defined(VGA_arm)
60# include "libvex_guest_arm.h"
sewardjb5b87402011-03-07 16:05:35 +000061#elif defined(VGA_s390x)
62# include "libvex_guest_s390x.h"
sewardj5db15402012-06-07 09:13:21 +000063#elif defined(VGA_mips32)
64# include "libvex_guest_mips32.h"
petarj4df0bfc2013-02-27 23:17:33 +000065#elif defined(VGA_mips64)
66# include "libvex_guest_mips64.h"
njn767eb422005-06-10 23:09:45 +000067#else
68# error Unknown arch
69#endif
70
sewardj59570ff2010-01-01 11:59:33 +000071
72/* ---------------------------------------------------------------------
73 A struct to hold starting values for stack unwinding.
74 ------------------------------------------------------------------ */
75
76/* This really shouldn't be here. But putting it elsewhere leads to a
77 veritable swamp of new module cycles. */
78
79/* To support CFA-based stack unwinding, and stack unwinding in
80 general, we need to be able to get hold of the values of specific
81 registers, in order to start the unwinding process. This is
82 unavoidably arch and platform dependent. Here is a struct which
83 holds the relevant values. All platforms must have a program
84 counter and a stack pointer register, but the other fields (frame
85 pointer? link register? misc other regs?) are ad-hoc. Note, the
86 common fields are 64-bit, so as to make this host-independent. */
87
88typedef
89 struct {
sewardj5db15402012-06-07 09:13:21 +000090 ULong r_pc; /* x86:EIP, amd64:RIP, ppc:CIA, arm:R15, mips:pc */
91 ULong r_sp; /* x86:ESP, amd64:RSP, ppc:R1, arm:R13, mips:sp */
sewardj59570ff2010-01-01 11:59:33 +000092 union {
93 struct {
94 UInt r_ebp;
95 } X86;
96 struct {
97 ULong r_rbp;
98 } AMD64;
99 struct {
100 UInt r_lr;
101 } PPC32;
102 struct {
103 ULong r_lr;
104 } PPC64;
105 struct {
106 UInt r14;
107 UInt r12;
108 UInt r11;
sewardjfa5ce562010-09-23 22:05:59 +0000109 UInt r7;
sewardj59570ff2010-01-01 11:59:33 +0000110 } ARM;
sewardjb5b87402011-03-07 16:05:35 +0000111 struct {
112 ULong r_fp;
113 ULong r_lr;
114 } S390X;
sewardj5db15402012-06-07 09:13:21 +0000115 struct {
116 UInt r30; /* Stack frame pointer or subroutine variable */
117 UInt r31; /* Return address of the last subroutine call */
118 UInt r28;
119 } MIPS32;
petarj4df0bfc2013-02-27 23:17:33 +0000120 struct {
121 ULong r30; /* Stack frame pointer or subroutine variable */
122 ULong r31; /* Return address of the last subroutine call */
123 ULong r28;
124 } MIPS64;
sewardj59570ff2010-01-01 11:59:33 +0000125 } misc;
126 }
127 UnwindStartRegs;
128
129
njnc7561b92005-06-19 01:24:32 +0000130#endif // __PUB_CORE_BASICS_H
nethercotec06e2132004-09-03 13:45:29 +0000131
sewardjde4a1d02002-03-22 01:27:54 +0000132/*--------------------------------------------------------------------*/
nethercote109d0df2004-09-02 08:10:13 +0000133/*--- end ---*/
sewardjde4a1d02002-03-22 01:27:54 +0000134/*--------------------------------------------------------------------*/