File tree Expand file tree Collapse file tree 4 files changed +49
-32
lines changed Expand file tree Collapse file tree 4 files changed +49
-32
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: d10d23f0ad4763642619d2d3e42f8150f7d91af3
2
+ refs/heads/master: aabff480c92d7c72f8a8ff6652d328e6624585d5
Original file line number Diff line number Diff line change
1
+ // ABI-specific routines.
2
+
3
+ #include < vector>
1
4
#include < cstdlib>
2
5
#include < stdint.h>
3
6
#include " rust_abi.h"
4
7
8
+ #define END_OF_STACK_RA (void (*)())0xdeadbeef
9
+
5
10
weak_symbol<uint32_t > abi_version (" rust_abi_version" );
6
11
7
12
uint32_t get_abi_version () {
8
13
return (*abi_version == NULL ) ? 0 : **abi_version;
9
14
}
10
15
16
+ namespace stack_walk {
17
+
18
+ std::vector<frame>
19
+ backtrace () {
20
+ std::vector<frame> frames;
21
+
22
+ // Ideally we would use the current value of EIP here, but there's no
23
+ // portable way to get that and there are never any GC roots in our C++
24
+ // frames anyhow.
25
+ frame f (__builtin_frame_address (0 ), (void (*)())NULL );
26
+
27
+ while (f.ra != END_OF_STACK_RA) {
28
+ frames.push_back (f);
29
+ f.next ();
30
+ }
31
+ return frames;
32
+ }
33
+
34
+ } // end namespace stack_walk
35
+
Original file line number Diff line number Diff line change
1
+ // ABI-specific routines.
2
+
1
3
#ifndef RUST_ABI_H
2
4
#define RUST_ABI_H
3
5
4
6
#include < cstdlib>
7
+ #include < vector>
5
8
6
9
#ifdef __WIN32__
7
10
#include < windows.h>
@@ -36,6 +39,25 @@ class weak_symbol {
36
39
T *&operator *() { fill (); return data; }
37
40
};
38
41
42
+ namespace stack_walk {
43
+
44
+ struct frame {
45
+ uint8_t *bp; // The frame pointer.
46
+ void (*ra)(); // The return address.
47
+
48
+ frame (void *in_bp, void (*in_ra)()) : bp((uint8_t *)in_bp), ra(in_ra) {}
49
+
50
+ inline void next () {
51
+ ra = *(void (**)())(bp + sizeof (void *));
52
+ bp = *(uint8_t **)bp;
53
+ }
54
+ };
55
+
56
+ std::vector<frame> backtrace ();
57
+
58
+ } // end namespace stack_walk
59
+
60
+
39
61
uint32_t get_abi_version ();
40
62
41
63
#endif
Original file line number Diff line number Diff line change 18
18
#include < dlfcn.h>
19
19
#endif
20
20
21
- # define END_OF_STACK_RA ( void (*)()) 0xdeadbeef
21
+ using namespace stack_walk ;
22
22
23
23
namespace gc {
24
24
25
25
weak_symbol<const uintptr_t > safe_point_data (" rust_gc_safe_points" );
26
26
27
- struct frame {
28
- uint8_t *bp; // The frame pointer.
29
- void (*ra)(); // The return address.
30
-
31
- frame (void *in_bp, void (*in_ra)()) : bp((uint8_t *)in_bp), ra(in_ra) {}
32
-
33
- inline void next () {
34
- ra = *(void (**)())(bp + sizeof (void *));
35
- bp = *(uint8_t **)bp;
36
- }
37
- };
38
-
39
27
struct root_info {
40
28
intptr_t frame_offset;
41
29
uintptr_t dynamic; // 0 = static, 1 = dynamic
@@ -98,9 +86,7 @@ class gc {
98
86
99
87
public:
100
88
gc (rust_task *in_task) : task(in_task) {}
101
-
102
89
void run ();
103
- std::vector<frame> backtrace ();
104
90
};
105
91
106
92
const safe_point *
@@ -135,22 +121,6 @@ gc::sweep() {
135
121
// TODO
136
122
}
137
123
138
- std::vector<frame>
139
- gc::backtrace () {
140
- std::vector<frame> frames;
141
-
142
- // Ideally we would use the current value of EIP here, but there's no
143
- // portable way to get that and there are never any GC roots in our C++
144
- // frames anyhow.
145
- frame f (__builtin_frame_address (0 ), (void (*)())NULL );
146
-
147
- while (f.ra != END_OF_STACK_RA) {
148
- frames.push_back (f);
149
- f.next ();
150
- }
151
- return frames;
152
- }
153
-
154
124
void
155
125
gc::run () {
156
126
safe_point_map map;
You can’t perform that action at this time.
0 commit comments