]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/ia64/libuwx/src/uwx_self.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / ia64 / libuwx / src / uwx_self.h
1 /*
2 Copyright (c) 2003-2006 Hewlett-Packard Development Company, L.P.
3 Permission is hereby granted, free of charge, to any person
4 obtaining a copy of this software and associated documentation
5 files (the "Software"), to deal in the Software without
6 restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following
10 conditions:
11
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef __UWX_SELF_INCLUDED
26 #define __UWX_SELF_INCLUDED 1
27
28 #include <signal.h>
29
30 #ifndef __UWX_INCLUDED
31 #include "uwx.h"
32 #endif /* __UWX_INCLUDED */
33
34 #if defined(__cplusplus)
35 #define __EXTERN_C extern "C"
36 #else
37 #define __EXTERN_C extern
38 #endif
39
40 struct uwx_self_info;
41
42 __EXTERN_C struct uwx_self_info *uwx_self_init_info(struct uwx_env *env);
43
44 __EXTERN_C int uwx_self_free_info(struct uwx_self_info *info);
45
46 __EXTERN_C int uwx_self_init_context(struct uwx_env *env);
47
48 __EXTERN_C int uwx_self_init_from_sigcontext(
49     struct uwx_env *env,
50     struct uwx_self_info *info,
51     ucontext_t *ucontext);
52
53 __EXTERN_C int uwx_self_do_context_frame(
54     struct uwx_env *env,
55     struct uwx_self_info *info);
56
57 __EXTERN_C int uwx_self_copyin(
58     int request,
59     char *loc,
60     uint64_t rem,
61     int len,
62     intptr_t tok);
63
64 __EXTERN_C int uwx_self_lookupip(
65     int request,
66     uint64_t ip,
67     intptr_t tok,
68     uint64_t **resultp);
69
70 #define UWX_SELF_ERR_BADABICONTEXT  (-101)
71
72 #undef __EXTERN_C
73
74 #if defined(__cplusplus)
75
76 class UnwindExpressSelf : public UnwindExpress {
77
78 public:
79
80     UnwindExpressSelf() {
81         info = uwx_self_init_info(env);
82         (void)uwx_register_callbacks(env, (intptr_t)info,
83                                 uwx_self_copyin, uwx_self_lookupip);
84     }
85
86     ~UnwindExpressSelf() {
87         if (info != 0)
88             uwx_self_free_info(info);
89         info = 0;
90     }
91
92     int init_context() {
93         return uwx_self_init_context(env);
94     }
95
96     int init_context(ucontext_t *ucontext) {
97         return uwx_self_init_from_sigcontext(env, info, ucontext);
98     }
99
100     int do_context_frame() {
101         return uwx_self_do_context_frame(env, info);
102     }
103
104 protected:
105
106     struct uwx_self_info *info;
107
108 };
109
110 #endif /* __cplusplus */
111
112 #endif /* __UWX_SELF_INCLUDED */