HPCToolkit
x86-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 #ifndef INTERVALS_H
48 #define INTERVALS_H
49 
50 #include <stdbool.h>
51 
53 
54 /******************************************************************************
55  * macros
56  ******************************************************************************/
57 
58 #define lstartaddr ((unsigned long) startaddr)
59 #define lendaddr ((unsigned long) endaddr)
60 
61 /*
62  * macros to convert the old unwind interval data structure
63  *
64 
65 struct unwind_interval_t {
66  struct splay_interval_s common;
67  ra_loc ra_status;
68  int sp_ra_pos;
69  int sp_bp_pos;
70  bp_loc bp_status;
71  int bp_ra_pos;
72  int bp_bp_pos;
73  struct unwind_interval_t *prev_canonical;
74  int restored_canonical;
75  bool has_tail_calls;
76 };
77 typedef struct unwind_interval_t unwind_interval;
78 
79  * to the new one, which is bitree_uwi_t, a binary tree of uwi_t.
80  *
81  */
82 
83 #define UWI_RECIPE(btuwi) ((x86recipe_t*)bitree_uwi_recipe(btuwi))
84 
85 
86 /*************************************************************************************
87  * type declarations
88  ************************************************************************************/
89 
91 
92 typedef enum {
94 } ra_loc;
95 
96 typedef enum {
98 } bp_loc;
99 
100 typedef struct x86registers_s {
101  int sp_ra_pos; /* return address offset from sp */
102  int sp_bp_pos; /* BP offset from sp */
103 
104  bp_loc bp_status; /* how to find the bp register */
105 
106  int bp_ra_pos; /* return address offset from bp */
107  int bp_bp_pos; /* (caller's) BP offset from bp */
109 
110 typedef struct x86recipe_s {
111  ra_loc ra_status; /* how to find the return address */
113 
115 
117 } x86recipe_t;
118 
119 
120 /*************************************************************************************
121  * interface operations
122  ************************************************************************************/
123 
124 #ifdef __cplusplus
125 extern "C" {
126 #endif
127 
129 
131 
133  new_ui(char *startaddr, ra_loc ra_status, const x86registers_t *reg);
134 
135  unwind_interval *fluke_ui(char *pc,unsigned int sp_ra_pos);
136 
137  void link_ui(unwind_interval *current, unwind_interval *next);
138  void dump_ui(unwind_interval *u, int dump_to_stderr);
140  void dump_ui_log(unwind_interval *u);
141  void dump_ui_dbg(unwind_interval *u);
143 
144  void suspicious_interval(void *pc);
145 
146  /*
147  * Concrete implementation of the abstract val_tostr function of the
148  * generic_val class.
149  * pre-condition: recipe is of type x86recipe_t*
150  */
151  void
152  x86recipe_tostr(void* recipe, char str[]);
153 
154  void
155  x86recipe_print(void* recipe);
156 
157 
158 #ifdef __cplusplus
159 };
160 #endif
161 
162 
163 
164 #endif // INTERVALS_H
void dump_ui_dbg(unwind_interval *u)
void dump_ui_stderr(unwind_interval *u)
struct x86registers_s x86registers_t
void suspicious_interval(void *pc)
void x86recipe_tostr(void *recipe, char str[])
bitree_uwi_t unwind_interval
x86registers_t reg
struct x86recipe_s x86recipe_t
struct bitree_uwi_s bitree_uwi_t
unwind_interval * fluke_ui(char *pc, unsigned int sp_ra_pos)
void set_ui_canonical(unwind_interval *u, unwind_interval *value)
void dump_ui_troll(unwind_interval *u)
void link_ui(unwind_interval *current, unwind_interval *next)
void dump_ui(unwind_interval *u, int dump_to_stderr)
bitree_uwi_t unwind_interval
void x86recipe_print(void *recipe)
bitree_uwi_t * prev_canonical
void dump_ui_log(unwind_interval *u)
unwind_interval * new_ui(char *startaddr, ra_loc ra_status, const x86registers_t *reg)