@@ -55,9 +55,14 @@ static void errorAndExit(const char *message) {
55
55
abort ();
56
56
}
57
57
58
- swift_reflection_section_t
58
+ static swift_reflection_section_t
59
59
makeLocalSection (void * Buffer , RemoteSection Section ,
60
60
RemoteReflectionInfo Info ) {
61
+ if (Section .Size == 0 ) {
62
+ swift_reflection_section_t LS = {NULL , NULL };
63
+ return LS ;
64
+ }
65
+
61
66
uintptr_t Base
62
67
= (uintptr_t )Buffer + Section .StartAddress - Info .StartAddress ;
63
68
swift_reflection_section_t LS = {
@@ -67,6 +72,7 @@ makeLocalSection(void *Buffer, RemoteSection Section,
67
72
return LS ;
68
73
}
69
74
75
+ static
70
76
uintptr_t getStartAddress (const RemoteSection Sections [], size_t Count ) {
71
77
uintptr_t Start = 0 ;
72
78
for (size_t i = 0 ; i < Count ; ++ i ) {
@@ -80,6 +86,7 @@ uintptr_t getStartAddress(const RemoteSection Sections[], size_t Count) {
80
86
return Start ;
81
87
}
82
88
89
+ static
83
90
uintptr_t getEndAddress (const RemoteSection Sections [], size_t Count ) {
84
91
uintptr_t End = 0 ;
85
92
for (size_t i = 0 ; i < Count ; ++ i ) {
@@ -89,6 +96,7 @@ uintptr_t getEndAddress(const RemoteSection Sections[], size_t Count) {
89
96
return End ;
90
97
}
91
98
99
+ static
92
100
RemoteReflectionInfo makeRemoteReflectionInfo (RemoteSection fieldmd ,
93
101
RemoteSection assocty ,
94
102
RemoteSection builtin ,
@@ -118,41 +126,40 @@ RemoteReflectionInfo makeRemoteReflectionInfo(RemoteSection fieldmd,
118
126
return Info ;
119
127
}
120
128
121
- swift_reflection_section_t
122
- makeSwiftReflectionSection (uintptr_t Base , size_t Size ) {
123
- swift_reflection_section_t section ;
124
- section .Begin = (void * )Base ;
125
- section .End = (void * )(Base + Size );
126
- return section ;
127
- }
128
-
129
129
static const size_t ReadEnd = 0 ;
130
130
static const size_t WriteEnd = 1 ;
131
131
132
+ static
132
133
int PipeMemoryReader_getParentReadFD (const PipeMemoryReader * Reader ) {
133
134
return Reader -> from_child [ReadEnd ];
134
135
}
135
136
137
+ static
136
138
int PipeMemoryReader_getChildWriteFD (const PipeMemoryReader * Reader ) {
137
139
return Reader -> from_child [WriteEnd ];
138
140
}
139
141
142
+ static
140
143
int PipeMemoryReader_getParentWriteFD (const PipeMemoryReader * Reader ) {
141
144
return Reader -> to_child [WriteEnd ];
142
145
}
143
146
147
+ static
144
148
int PipeMemoryReader_getChildReadFD (const PipeMemoryReader * Reader ) {
145
149
return Reader -> to_child [ReadEnd ];
146
150
}
147
151
152
+ static
148
153
uint8_t PipeMemoryReader_getPointerSize (void * Context ) {
149
154
return sizeof (uintptr_t );
150
155
}
151
156
157
+ static
152
158
uint8_t PipeMemoryReader_getSizeSize (void * Context ) {
153
159
return sizeof (size_t );
154
160
}
155
161
162
+ static
156
163
void PipeMemoryReader_collectBytesFromPipe (const PipeMemoryReader * Reader ,
157
164
void * Dest , size_t Size ) {
158
165
int ReadFD = PipeMemoryReader_getParentReadFD (Reader );
@@ -167,6 +174,7 @@ void PipeMemoryReader_collectBytesFromPipe(const PipeMemoryReader *Reader,
167
174
}
168
175
}
169
176
177
+ static
170
178
int PipeMemoryReader_readBytes (void * Context ,
171
179
addr_t Address , void * Dest , uint64_t Size ) {
172
180
const PipeMemoryReader * Reader = (const PipeMemoryReader * )Context ;
@@ -180,6 +188,7 @@ int PipeMemoryReader_readBytes(void *Context,
180
188
return 1 ;
181
189
}
182
190
191
+ static
183
192
addr_t PipeMemoryReader_getSymbolAddress (void * Context , const char * SymbolName ,
184
193
uint64_t Length ) {
185
194
const PipeMemoryReader * Reader = (const PipeMemoryReader * )Context ;
@@ -193,7 +202,7 @@ addr_t PipeMemoryReader_getSymbolAddress(void *Context, const char *SymbolName,
193
202
return (uintptr_t )Address ;
194
203
}
195
204
196
- InstanceKind
205
+ static InstanceKind
197
206
PipeMemoryReader_receiveInstanceKind (const PipeMemoryReader * Reader ) {
198
207
int WriteFD = PipeMemoryReader_getParentWriteFD (Reader );
199
208
write (WriteFD , REQUEST_INSTANCE_KIND , 2 );
@@ -202,7 +211,7 @@ PipeMemoryReader_receiveInstanceKind(const PipeMemoryReader *Reader) {
202
211
return KindValue ;
203
212
}
204
213
205
- uintptr_t
214
+ static uintptr_t
206
215
PipeMemoryReader_receiveInstanceAddress (const PipeMemoryReader * Reader ) {
207
216
int WriteFD = PipeMemoryReader_getParentWriteFD (Reader );
208
217
write (WriteFD , REQUEST_INSTANCE_ADDRESS , 2 );
@@ -212,20 +221,13 @@ PipeMemoryReader_receiveInstanceAddress(const PipeMemoryReader *Reader) {
212
221
return InstanceAddress ;
213
222
}
214
223
224
+ static
215
225
void PipeMemoryReader_sendDoneMessage (const PipeMemoryReader * Reader ) {
216
226
int WriteFD = PipeMemoryReader_getParentWriteFD (Reader );
217
227
write (WriteFD , REQUEST_DONE , 2 );
218
228
}
219
229
220
- uint8_t PipeMemoryReader_receivePointerSize (const PipeMemoryReader * Reader ) {
221
- int WriteFD = PipeMemoryReader_getParentWriteFD (Reader );
222
- write (WriteFD , REQUEST_POINTER_SIZE , 2 );
223
- uint8_t PointerSize = 0 ;
224
- PipeMemoryReader_collectBytesFromPipe (Reader , (uint8_t * )& PointerSize ,
225
- sizeof (PointerSize ));
226
- return PointerSize ;
227
- }
228
-
230
+ static
229
231
PipeMemoryReader createPipeMemoryReader () {
230
232
PipeMemoryReader Reader ;
231
233
if (pipe (Reader .to_child ))
@@ -235,6 +237,7 @@ PipeMemoryReader createPipeMemoryReader() {
235
237
return Reader ;
236
238
}
237
239
240
+ static
238
241
RemoteSection makeRemoteSection (const PipeMemoryReader * Reader ) {
239
242
uintptr_t Start ;
240
243
size_t Size ;
@@ -246,7 +249,7 @@ RemoteSection makeRemoteSection(const PipeMemoryReader *Reader) {
246
249
return RS ;
247
250
}
248
251
249
- void
252
+ static void
250
253
PipeMemoryReader_receiveReflectionInfo (SwiftReflectionContextRef RC ,
251
254
const PipeMemoryReader * Reader ) {
252
255
int WriteFD = PipeMemoryReader_getParentWriteFD (Reader );
@@ -433,6 +436,7 @@ int doDumpHeapInstance(const char *BinaryFilename) {
433
436
return EXIT_SUCCESS ;
434
437
break ;
435
438
case None :
439
+ swift_reflection_destroyReflectionContext (RC );
436
440
printf ("Done.\n" );
437
441
return EXIT_SUCCESS ;
438
442
}
0 commit comments