@@ -210,6 +210,15 @@ DEFINE_PROCESS_UDATA_ATTRIBUTE(alignment)
210
210
DEFINE_PROCESS_UDATA_ATTRIBUTE (byte_size )
211
211
DEFINE_PROCESS_UDATA_ATTRIBUTE (encoding )
212
212
213
+ /* Match functions -- die_match_callback_t */
214
+ #define DEFINE_MATCH (type ) \
215
+ static bool match_ ##type ##_type(Dwarf_Die *die) \
216
+ { \
217
+ return dwarf_tag(die) == DW_TAG_##type##_type; \
218
+ }
219
+
220
+ DEFINE_MATCH (formal_parameter )
221
+
213
222
bool match_all (Dwarf_Die * die )
214
223
{
215
224
return true;
@@ -247,6 +256,25 @@ static int process_type_attr(struct state *state, struct die *cache,
247
256
return check (process (state , cache , "base_type void" ));
248
257
}
249
258
259
+ /* Comma-separated with DW_AT_type */
260
+ static int __process_list_type (struct state * state , struct die * cache ,
261
+ Dwarf_Die * die , const char * type )
262
+ {
263
+ check (process (state , cache , type ));
264
+ check (process_type_attr (state , cache , die ));
265
+ check (process (state , cache , "," ));
266
+ return check (process_linebreak (cache , 0 ));
267
+ }
268
+
269
+ #define DEFINE_PROCESS_LIST_TYPE (type ) \
270
+ static int process_##type##_type(struct state *state, \
271
+ struct die *cache, Dwarf_Die *die) \
272
+ { \
273
+ return __process_list_type(state, cache, die, #type " "); \
274
+ }
275
+
276
+ DEFINE_PROCESS_LIST_TYPE (formal_parameter )
277
+
250
278
/* Container types with DW_AT_type */
251
279
static int __process_type (struct state * state , struct die * cache ,
252
280
Dwarf_Die * die , const char * type )
@@ -281,6 +309,29 @@ DEFINE_PROCESS_TYPE(shared)
281
309
DEFINE_PROCESS_TYPE (volatile )
282
310
DEFINE_PROCESS_TYPE (typedef )
283
311
312
+ static int __process_subroutine_type (struct state * state , struct die * cache ,
313
+ Dwarf_Die * die , const char * type )
314
+ {
315
+ check (process (state , cache , type ));
316
+ check (process (state , cache , "(" ));
317
+ check (process_linebreak (cache , 1 ));
318
+ /* Parameters */
319
+ check (process_die_container (state , cache , die , process_type ,
320
+ match_formal_parameter_type ));
321
+ check (process_linebreak (cache , -1 ));
322
+ check (process (state , cache , ")" ));
323
+ process_linebreak (cache , 0 );
324
+ /* Return type */
325
+ check (process (state , cache , "-> " ));
326
+ return check (process_type_attr (state , cache , die ));
327
+ }
328
+
329
+ static int process_subroutine_type (struct state * state , struct die * cache ,
330
+ Dwarf_Die * die )
331
+ {
332
+ return check (__process_subroutine_type (state , cache , die ,
333
+ "subroutine_type" ));
334
+ }
284
335
static int process_base_type (struct state * state , struct die * cache ,
285
336
Dwarf_Die * die )
286
337
{
@@ -358,8 +409,11 @@ static int process_type(struct state *state, struct die *parent, Dwarf_Die *die)
358
409
PROCESS_TYPE (rvalue_reference )
359
410
PROCESS_TYPE (shared )
360
411
PROCESS_TYPE (volatile )
412
+ /* Subtypes */
413
+ PROCESS_TYPE (formal_parameter )
361
414
/* Other types */
362
415
PROCESS_TYPE (base )
416
+ PROCESS_TYPE (subroutine )
363
417
PROCESS_TYPE (typedef )
364
418
default :
365
419
debug ("unimplemented type : %x ", tag );
@@ -379,7 +433,8 @@ static int process_type(struct state *state, struct die *parent, Dwarf_Die *die)
379
433
*/
380
434
static int process_subprogram (struct state * state , Dwarf_Die * die )
381
435
{
382
- return check (process (state , NULL , "subprogram;\n" ));
436
+ check (__process_subroutine_type (state , NULL , die , "subprogram" ));
437
+ return check (process (state , NULL , ";\n" ));
383
438
}
384
439
385
440
static int process_variable (struct state * state , Dwarf_Die * die )
0 commit comments