HPCToolkit
x86-gcc-main64.c
Go to the documentation of this file.
1
// -*-Mode: C++;-*- // technically C99
2
3
// * BeginRiceCopyright *****************************************************
4
//
5
// $HeadURL: https://hpctoolkit.googlecode.com/svn/trunk/src/tool/hpcrun/unwind/x86-family/manual-intervals/x86-intel11-f90main.c $
6
// $Id: x86-intel11-f90main.c 4422 2014-02-10 21:24:59Z mwkrentel $
7
//
8
// --------------------------------------------------------------------------
9
// Part of HPCToolkit (hpctoolkit.org)
10
//
11
// Information about sources of support for research and development of
12
// HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13
// --------------------------------------------------------------------------
14
//
15
// Copyright ((c)) 2002-2019, Rice University
16
// All rights reserved.
17
//
18
// Redistribution and use in source and binary forms, with or without
19
// modification, are permitted provided that the following conditions are
20
// met:
21
//
22
// * Redistributions of source code must retain the above copyright
23
// notice, this list of conditions and the following disclaimer.
24
//
25
// * Redistributions in binary form must reproduce the above copyright
26
// notice, this list of conditions and the following disclaimer in the
27
// documentation and/or other materials provided with the distribution.
28
//
29
// * Neither the name of Rice University (RICE) nor the names of its
30
// contributors may be used to endorse or promote products derived from
31
// this software without specific prior written permission.
32
//
33
// This software is provided by RICE and contributors "as is" and any
34
// express or implied warranties, including, but not limited to, the
35
// implied warranties of merchantability and fitness for a particular
36
// purpose are disclaimed. In no event shall RICE or contributors be
37
// liable for any direct, indirect, incidental, special, exemplary, or
38
// consequential damages (including, but not limited to, procurement of
39
// substitute goods or services; loss of use, data, or profits; or
40
// business interruption) however caused and on any theory of liability,
41
// whether in contract, strict liability, or tort (including negligence
42
// or otherwise) arising in any way out of the use of this software, even
43
// if advised of the possibility of such damage.
44
//
45
// ******************************************************* EndRiceCopyright *
46
47
#include <string.h>
48
#include "
x86-unwind-interval-fixup.h
"
49
#include "
x86-unwind-interval.h
"
50
51
static
char
gcc_main64_signature
[] = {
52
0x4c, 0x8d, 0x54, 0x24, 0x08,
// lea 0x8(%rsp),%r10
53
0x48, 0x83, 0xe4, 0xe0,
// and $0xffffffffffffffe0,%rsp
54
0x41, 0xff, 0x72, 0xf8,
// pushq -0x8(%r10)
55
0x55,
// push %rbp
56
0x48, 0x89, 0xe5,
// mov %rsp,%rbp
57
};
58
59
60
int
61
x86_adjust_gcc_main64_intervals
(
char
*ins,
int
len,
btuwi_status_t
*stat)
62
{
63
int
siglen =
sizeof
(
gcc_main64_signature
);
64
65
if
(len > siglen && strncmp((
char
*)
gcc_main64_signature
, ins, siglen) == 0) {
66
// signature matched
67
unwind_interval
*ui = (
unwind_interval
*) stat->
first
;
68
69
// this won't fix all of the intervals, but it will fix the ones
70
// that we care about.
71
//
72
// The method is as follows:
73
// Ignore (do not correct) intervals before 1st std frame
74
// For 1st STD_FRAME, compute the corrections for this interval and subsequent intervals
75
// For this interval and subsequent interval, apply the corrected offsets
76
//
77
78
for
(;
UWI_RECIPE
(ui)->ra_status !=
RA_STD_FRAME
; ui =
UWI_NEXT
(ui));
79
80
// this is only correct for 64-bit code
81
for
(; ui; ui =
UWI_NEXT
(ui)) {
82
x86recipe_t
*xr =
UWI_RECIPE
(ui);
83
if
(xr->
ra_status
==
RA_SP_RELATIVE
)
continue
;
84
if
((xr->
ra_status
==
RA_STD_FRAME
) ||
85
(xr->
ra_status
==
RA_BP_FRAME
)) {
86
xr->
ra_status
=
RA_BP_FRAME
;
87
xr->
reg
.
bp_ra_pos
= 8;
88
xr->
reg
.
bp_bp_pos
= 0;
89
}
90
}
91
92
return
1;
93
}
94
return
0;
95
}
RA_BP_FRAME
Definition:
x86-unwind-interval.h:93
btuwi_status_s::first
bitree_uwi_t * first
Definition:
binarytree_uwi.h:62
x86-unwind-interval.h
btuwi_status_s
Definition:
binarytree_uwi.h:60
UWI_RECIPE
#define UWI_RECIPE(btuwi)
Definition:
ppc64-unwind-interval.h:91
x86recipe_s::ra_status
ra_loc ra_status
Definition:
x86-unwind-interval.h:111
x86recipe_s::reg
x86registers_t reg
Definition:
x86-unwind-interval.h:112
RA_STD_FRAME
Definition:
x86-unwind-interval.h:93
x86-unwind-interval-fixup.h
x86registers_s::bp_ra_pos
int bp_ra_pos
Definition:
x86-unwind-interval.h:106
x86recipe_s
Definition:
x86-unwind-interval.h:110
RA_SP_RELATIVE
Definition:
x86-unwind-interval.h:93
UWI_NEXT
#define UWI_NEXT(btuwi)
Definition:
binarytree_uwi.h:42
x86registers_s::bp_bp_pos
int bp_bp_pos
Definition:
x86-unwind-interval.h:107
x86_adjust_gcc_main64_intervals
int x86_adjust_gcc_main64_intervals(char *ins, int len, btuwi_status_t *stat)
Definition:
x86-gcc-main64.c:61
unwind_interval
bitree_uwi_t unwind_interval
Definition:
ppc64-unwind-interval.h:94
gcc_main64_signature
static char gcc_main64_signature[]
Definition:
x86-gcc-main64.c:51
src
tool
hpcrun
unwind
x86-family
manual-intervals
x86-gcc-main64.c
Generated by
1.8.13