HPCToolkit
ppc64-unwind-interval.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
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 //***************************************************************************
48 //
49 // HPCToolkit's PPC64 Unwinder
50 //
51 //***************************************************************************
52 
53 #ifndef ppc64_unwind_interval_h
54 #define ppc64_unwind_interval_h
55 
56 //************************* System Include Files ****************************
57 
58 #include <stddef.h>
59 #include <stdbool.h>
60 
61 //*************************** User Include Files ****************************
62 
65 
66 /******************************************************************************
67  * macro
68  ******************************************************************************/
69 /*
70  * to convert from the old unwind interval data structure
71  *
72 
73 typedef struct {
74  struct splay_interval_s common; // common splay tree fields
75  // frame type
76  sp_ty_t sp_ty : 16;
77  ra_ty_t ra_ty : 16;
78  // SPTy_Reg : Parent SP's register
79  // RATy_SPRel: Parent SP's offset from appropriate pointer
80  int sp_arg;
81  // RATy_Reg : Parent RA's register
82  // RATy_SPRel: Parent RA's offset from appropriate pointer
83  int ra_arg;
84 } unw_interval_t;
85 
86  * to the new one, which is bitree_uwi_t, a binary tree of uwi_t,
87  * and extract the unwind recipe for ppc64.
88  *
89  */
90 
91 #define UWI_RECIPE(btuwi) ((ppc64recipe_t*)bitree_uwi_recipe(btuwi))
92 
93 // same as in x8-unwind-interval.h
95 
96 typedef enum {
97  SPTy_NULL = 0,
98  SPTy_Reg, // Parent's SP is in a register (R1) (unallocated frame)
99  SPTy_SPRel, // Parent's SP is relative to current SP (saved in frame)
100 } sp_ty_t;
101 
102 
103 typedef enum {
105  RATy_Reg, // RA is in a register (either LR or R0)
106  RATy_SPRel, // RA is relative to SP
107 } ra_ty_t;
108 
109 typedef struct ppc64recipe_s{
110  // frame type
113 
114  // SPTy_Reg : Parent SP's register
115  // RATy_SPRel: Parent SP's offset from appropriate pointer
116  int sp_arg;
117 
118  // RATy_Reg : Parent RA's register
119  // RATy_SPRel: Parent RA's offset from appropriate pointer
120  int ra_arg;
121 } ppc64recipe_t;
122 
124 new_ui(
125  char *startaddr,
126  sp_ty_t sp_ty,
127  ra_ty_t ra_ty,
128  int sp_arg,
129  int ra_arg);
130 
131 #if 0
133 ppc64recipe_new(sp_ty_t sp_ty, ra_ty_t ra_ty, int sp_arg, int ra_arg);
134 #endif
135 
136 /*
137  * Concrete implementation of the abstract val_tostr function of the
138  * generic_val class.
139  * pre-condition: recipe is of type ppc64recipe_t*
140  */
141 void
142 ppc64recipe_tostr(void* recipe, char str[]);
143 
144 void
145 ppc64recipe_print(void* recipe);
146 
147 
148 static inline bool
150 {
151  ppc64recipe_t *x = UWI_RECIPE(ux);
152  ppc64recipe_t *y = UWI_RECIPE(uy);
153  return ((x->sp_ty == y->sp_ty) &&
154  (x->ra_ty == y->ra_ty) &&
155  (x->sp_arg == y->sp_arg) &&
156  (x->ra_arg == y->ra_arg));
157 }
158 
159 void
161 
162 // FIXME: these should be part of the common interface
163 void suspicious_interval(void *pc);
164 void link_ui(unwind_interval *current, unwind_interval *next);
165 
166 
167 //***************************************************************************
168 
169 #endif // ppc64_unwind_interval_h
void suspicious_interval(void *pc)
struct ppc64recipe_s ppc64recipe_t
unwind_interval * new_ui(char *startaddr, sp_ty_t sp_ty, ra_ty_t ra_ty, int sp_arg, int ra_arg)
static bool ui_cmp(unwind_interval *ux, unwind_interval *uy)
#define UWI_RECIPE(btuwi)
void link_ui(unwind_interval *current, unwind_interval *next)
struct bitree_uwi_s bitree_uwi_t
void ppc64recipe_print(void *recipe)
void ui_dump(unwind_interval *u)
bitree_uwi_t unwind_interval
void ppc64recipe_tostr(void *recipe, char str[])