2 * MS debug info dumping utility
4 * Copyright 2006 Eric Pouech
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #define PSTRING(adr, ofs) \
35 ((const struct p_string*)((const char*)(adr) + (ofs)))
37 static const char* p_string(const struct p_string
* s
)
39 static char tmp
[256 + 1];
40 memcpy(tmp
, s
->name
, s
->namelen
);
41 tmp
[s
->namelen
] = '\0';
47 enum {fv_integer
, fv_longlong
} type
;
51 long long unsigned llu
;
55 static int full_numeric_leaf(struct full_value
* fv
, const unsigned short int* leaf
)
57 unsigned short int type
= *leaf
++;
60 fv
->type
= fv_integer
;
61 if (type
< LF_NUMERIC
)
71 fv
->v
.i
= *(const char*)leaf
;
76 fv
->v
.i
= *(const short*)leaf
;
86 fv
->v
.i
= *(const int*)leaf
;
91 fv
->v
.i
= *(const unsigned int*)leaf
;
96 fv
->type
= fv_longlong
;
97 fv
->v
.llu
= *(const long long int*)leaf
;
102 fv
->type
= fv_longlong
;
103 fv
->v
.llu
= *(const long long unsigned int*)leaf
;
108 printf(">>> unsupported leaf value %04x\n", type
);
109 fv
->v
.i
= 0; /* FIXME */
114 fv
->v
.i
= 0; /* FIXME */
115 printf(">>> unsupported leaf value %04x\n", type
);
120 fv
->v
.i
= 0; /* FIXME */
121 printf(">>> unsupported leaf value %04x\n", type
);
126 fv
->v
.i
= 0; /* FIXME */
127 printf(">>> unsupported leaf value %04x\n", type
);
132 fv
->v
.i
= 0; /* FIXME */
133 printf(">>> unsupported leaf value %04x\n", type
);
138 fv
->v
.i
= 0; /* FIXME */
139 printf(">>> unsupported leaf value %04x\n", type
);
144 fv
->v
.i
= 0; /* FIXME */
145 printf(">>> unsupported leaf value %04x\n", type
);
150 fv
->v
.i
= 0; /* FIXME */
151 printf(">>> unsupported leaf value %04x\n", type
);
156 fv
->v
.i
= 0; /* FIXME */
157 printf(">>> unsupported leaf value %04x\n", type
);
162 fv
->v
.i
= 0; /* FIXME */
163 printf(">>> unsupported leaf value %04x\n", type
);
167 printf(">>> Unsupported numeric leaf-id %04x\n", type
);
175 static const char* full_value_string(const struct full_value
* fv
)
177 static char tmp
[128];
181 case fv_integer
: sprintf(tmp
, "0x%x", fv
->v
.i
); break;
182 case fv_longlong
: sprintf(tmp
, "0x%x%08x", (unsigned)(fv
->v
.llu
>> 32), (unsigned)fv
->v
.llu
); break;
187 static int numeric_leaf(int* value
, const unsigned short int* leaf
)
189 struct full_value fv
;
190 int len
= full_numeric_leaf(&fv
, leaf
);
194 case fv_integer
: *value
= fv
.v
.i
; break;
195 case fv_longlong
: *value
= (unsigned)fv
.v
.llu
; printf("bad conversion\n"); break;
196 default: assert( 0 ); *value
= 0;
201 static const char* get_attr(unsigned attr
)
203 static char tmp
[256];
207 case 0: strcpy(tmp
, ""); break;
208 case 1: strcpy(tmp
, "private "); break;
209 case 2: strcpy(tmp
, "protected "); break;
210 case 3: strcpy(tmp
, "public "); break;
212 switch ((attr
>> 2) & 7)
214 case 0: strcat(tmp
, ""); break;
215 case 1: strcat(tmp
, "virtual "); break;
216 case 2: strcat(tmp
, "static "); break;
217 case 3: strcat(tmp
, "friend "); break;
218 case 4: strcat(tmp
, "introducing virtual "); break;
219 case 5: strcat(tmp
, "pure virtual "); break;
220 case 6: strcat(tmp
, "pure introducing virtual "); break;
221 case 7: strcat(tmp
, "reserved "); break;
223 if ((attr
>> 5) & 1) strcat(tmp
, "pseudo ");
224 if ((attr
>> 6) & 1) strcat(tmp
, "no-inherit ");
225 if ((attr
>> 7) & 1) strcat(tmp
, "no-construct ");
229 static const char* get_property(cv_property_t prop
)
231 static char tmp
[1024];
234 #define X(s) {if (pos) tmp[pos++] = ';'; strcpy(tmp + pos, s); pos += strlen(s);}
235 if (prop
.is_packed
) X("packed");
236 if (prop
.has_ctor
) X("w/{cd}tor");
237 if (prop
.has_overloaded_operator
) X("w/overloaded-ops");
238 if (prop
.is_nested
) X("nested-class");
239 if (prop
.has_nested
) X("has-nested-classes");
240 if (prop
.has_overloaded_assign
) X("w/overloaded-assign");
241 if (prop
.has_operator_cast
) X("w/casting-methods");
242 if (prop
.is_forward_defn
) X("forward");
243 if (prop
.is_scoped
) X("scoped");
244 if (prop
.has_decorated_name
) X("decorated-name");
245 if (prop
.is_sealed
) X("sealed");
246 if (prop
.hfa
) pos
+= sprintf(tmp
, "hfa%x", prop
.hfa
);
247 if (prop
.is_intrinsic
) X("intrinsic");
248 if (prop
.mocom
) pos
+= sprintf(tmp
, "mocom%x", prop
.mocom
);
250 if (!pos
) return "none";
253 assert(pos
< sizeof(tmp
));
258 static const char* get_funcattr(unsigned attr
)
260 static char tmp
[1024];
263 if (!attr
) return "none";
264 #define X(s) {if (pos) tmp[pos++] = ';'; strcpy(tmp + pos, s); pos += strlen(s);}
265 if (attr
& 0x0001) X("C++ReturnUDT");
266 if (attr
& 0x0002) X("Ctor");
267 if (attr
& 0x0004) X("Ctor-w/virtualbase");
268 if (attr
& 0xfff8) pos
+= sprintf(tmp
, "unk:%x", attr
& 0xfff8);
272 assert(pos
< sizeof(tmp
));
277 static const char* get_varflags(struct cv_local_varflag flags
)
279 static char tmp
[1024];
282 #define X(s) {if (pos) tmp[pos++] = ';'; strcpy(tmp + pos, s); pos += strlen(s);}
283 if (flags
.is_param
) X("param");
284 if (flags
.address_taken
) X("addr-taken");
285 if (flags
.from_compiler
) X("compiler-gen");
286 if (flags
.is_aggregate
) X("aggregated");
287 if (flags
.from_aggregate
) X("in-aggregate");
288 if (flags
.is_aliased
) X("aliased");
289 if (flags
.from_alias
) X("alias");
290 if (flags
.is_return_value
) X("retval");
291 if (flags
.optimized_out
) X("optimized-out");
292 if (flags
.enreg_global
) X("enreg-global");
293 if (flags
.enreg_static
) X("enreg-static");
294 if (flags
.unused
) pos
+= sprintf(tmp
, "unk:%x", flags
.unused
);
297 if (!pos
) return "none";
299 assert(pos
< sizeof(tmp
));
304 static const char* get_machine(unsigned m
)
310 case CV_CFL_8080
: machine
= "Intel 8080"; break;
311 case CV_CFL_8086
: machine
= "Intel 8086"; break;
312 case CV_CFL_80286
: machine
= "Intel 80286"; break;
313 case CV_CFL_80386
: machine
= "Intel 80386"; break;
314 case CV_CFL_80486
: machine
= "Intel 80486"; break;
315 case CV_CFL_PENTIUM
: machine
= "Intel Pentium"; break;
316 case CV_CFL_PENTIUMII
: machine
= "Intel Pentium II"; break;
317 case CV_CFL_PENTIUMIII
: machine
= "Intel Pentium III"; break;
319 case CV_CFL_MIPS
: machine
= "MIPS R4000"; break;
320 case CV_CFL_MIPS16
: machine
= "MIPS16"; break;
321 case CV_CFL_MIPS32
: machine
= "MIPS32"; break;
322 case CV_CFL_MIPS64
: machine
= "MIPS64"; break;
323 case CV_CFL_MIPSI
: machine
= "MIPS I"; break;
324 case CV_CFL_MIPSII
: machine
= "MIPS II"; break;
325 case CV_CFL_MIPSIII
: machine
= "MIPS III"; break;
326 case CV_CFL_MIPSIV
: machine
= "MIPS IV"; break;
327 case CV_CFL_MIPSV
: machine
= "MIPS V"; break;
329 case CV_CFL_M68000
: machine
= "M68000"; break;
330 case CV_CFL_M68010
: machine
= "M68010"; break;
331 case CV_CFL_M68020
: machine
= "M68020"; break;
332 case CV_CFL_M68030
: machine
= "M68030"; break;
333 case CV_CFL_M68040
: machine
= "M68040"; break;
335 case CV_CFL_ALPHA_21064
: machine
= "Alpha 21064"; break;
336 case CV_CFL_ALPHA_21164
: machine
= "Alpha 21164"; break;
337 case CV_CFL_ALPHA_21164A
: machine
= "Alpha 21164A"; break;
338 case CV_CFL_ALPHA_21264
: machine
= "Alpha 21264"; break;
339 case CV_CFL_ALPHA_21364
: machine
= "Alpha 21364"; break;
341 case CV_CFL_PPC601
: machine
= "PowerPC 601"; break;
342 case CV_CFL_PPC603
: machine
= "PowerPC 603"; break;
343 case CV_CFL_PPC604
: machine
= "PowerPC 604"; break;
344 case CV_CFL_PPC620
: machine
= "PowerPC 620"; break;
345 case CV_CFL_PPCFP
: machine
= "PowerPC FP"; break;
347 case CV_CFL_SH3
: machine
= "SH3"; break;
348 case CV_CFL_SH3E
: machine
= "SH3E"; break;
349 case CV_CFL_SH3DSP
: machine
= "SH3DSP"; break;
350 case CV_CFL_SH4
: machine
= "SH4"; break;
351 case CV_CFL_SHMEDIA
: machine
= "SHMEDIA"; break;
353 case CV_CFL_ARM3
: machine
= "ARM 3"; break;
354 case CV_CFL_ARM4
: machine
= "ARM 4"; break;
355 case CV_CFL_ARM4T
: machine
= "ARM 4T"; break;
356 case CV_CFL_ARM5
: machine
= "ARM 5"; break;
357 case CV_CFL_ARM5T
: machine
= "ARM 5T"; break;
358 case CV_CFL_ARM6
: machine
= "ARM 6"; break;
359 case CV_CFL_ARM_XMAC
: machine
= "ARM XMAC"; break;
360 case CV_CFL_ARM_WMMX
: machine
= "ARM WMMX"; break;
361 case CV_CFL_ARM7
: machine
= "ARM 7"; break;
363 case CV_CFL_OMNI
: machine
= "OMNI"; break;
365 case CV_CFL_IA64_1
: machine
= "Itanium"; break;
366 case CV_CFL_IA64_2
: machine
= "Itanium 2"; break;
368 case CV_CFL_CEE
: machine
= "CEE"; break;
370 case CV_CFL_AM33
: machine
= "AM33"; break;
372 case CV_CFL_M32R
: machine
= "M32R"; break;
374 case CV_CFL_TRICORE
: machine
= "TRICORE"; break;
376 case CV_CFL_X64
: machine
= "x86_64"; break;
378 case CV_CFL_EBC
: machine
= "EBC"; break;
380 case CV_CFL_THUMB
: machine
= "Thumb"; break;
381 case CV_CFL_ARMNT
: machine
= "ARM NT"; break;
382 case CV_CFL_ARM64
: machine
= "ARM 64"; break;
384 case CV_CFL_D3D11_SHADER
: machine
= "D3D11 shader"; break;
388 sprintf(tmp
, "machine=%x", m
);
396 static const char* get_language(unsigned l
)
402 case CV_CFL_C
: lang
= "C"; break;
403 case CV_CFL_CXX
: lang
= "C++"; break;
404 case CV_CFL_FORTRAN
: lang
= "Fortran"; break;
405 case CV_CFL_MASM
: lang
= "Masm"; break;
406 case CV_CFL_PASCAL
: lang
= "Pascal"; break;
407 case CV_CFL_BASIC
: lang
= "Basic"; break;
408 case CV_CFL_COBOL
: lang
= "Cobol"; break;
409 case CV_CFL_LINK
: lang
= "Link"; break;
410 case CV_CFL_CVTRES
: lang
= "Resource"; break;
411 case CV_CFL_CVTPGD
: lang
= "PoGo"; break;
412 case CV_CFL_CSHARP
: lang
= "C#"; break;
413 case CV_CFL_VB
: lang
= "VisualBasic"; break;
414 case CV_CFL_ILASM
: lang
= "IL ASM"; break;
415 case CV_CFL_JAVA
: lang
= "Java"; break;
416 case CV_CFL_JSCRIPT
: lang
= "JavaScript"; break;
417 case CV_CFL_MSIL
: lang
= "MSIL"; break;
418 case CV_CFL_HLSL
: lang
= "HLSL"; break;
422 sprintf(tmp
, "lang=%x", l
);
430 static const char* get_callconv(unsigned cc
)
432 const char* callconv
;
436 case CV_CALL_NEAR_C
: callconv
= "near C"; break;
437 case CV_CALL_FAR_C
: callconv
= "far C"; break;
438 case CV_CALL_NEAR_PASCAL
: callconv
= "near pascal"; break;
439 case CV_CALL_FAR_PASCAL
: callconv
= "far pascal"; break;
440 case CV_CALL_NEAR_FAST
: callconv
= "near fast"; break;
441 case CV_CALL_FAR_FAST
: callconv
= "far fast"; break;
442 case CV_CALL_SKIPPED
: callconv
= "skipped"; break;
443 case CV_CALL_NEAR_STD
: callconv
= "near std"; break;
444 case CV_CALL_FAR_STD
: callconv
= "far std"; break;
445 case CV_CALL_NEAR_SYS
: callconv
= "near sys"; break;
446 case CV_CALL_FAR_SYS
: callconv
= "far sys"; break;
447 case CV_CALL_THISCALL
: callconv
= "this call"; break;
448 case CV_CALL_MIPSCALL
: callconv
= "mips call"; break;
449 case CV_CALL_GENERIC
: callconv
= "generic"; break;
450 case CV_CALL_ALPHACALL
: callconv
= "alpha call"; break;
451 case CV_CALL_PPCCALL
: callconv
= "ppc call"; break;
452 case CV_CALL_SHCALL
: callconv
= "sh call"; break;
453 case CV_CALL_ARMCALL
: callconv
= "arm call"; break;
454 case CV_CALL_AM33CALL
: callconv
= "am33 call"; break;
455 case CV_CALL_TRICALL
: callconv
= "tri call"; break;
456 case CV_CALL_SH5CALL
: callconv
= "sh5 call"; break;
457 case CV_CALL_M32RCALL
: callconv
= "m32r call"; break;
458 case CV_CALL_CLRCALL
: callconv
= "clr call"; break;
459 case CV_CALL_INLINE
: callconv
= "inline"; break;
460 case CV_CALL_NEAR_VECTOR
: callconv
= "near vector"; break;
461 case CV_CALL_RESERVED
: callconv
= "reserved"; break;
465 sprintf(tmp
, "callconv=%x", cc
);
473 static const char* get_pubflags(unsigned flags
)
478 #define X(s) {if (ret[0]) strcat(ret, ";"); strcat(ret, s);}
479 if (flags
& 1) X("code");
480 if (flags
& 2) X("func");
481 if (flags
& 4) X("manage");
482 if (flags
& 8) X("msil");
487 static void do_field(const unsigned char* start
, const unsigned char* end
)
490 * A 'field list' is a CodeView-specific data type which doesn't
491 * directly correspond to any high-level data type. It is used
492 * to hold the collection of members of a struct, class, union
493 * or enum type. The actual definition of that type will follow
494 * later, and refer to the field list definition record.
496 * As we don't have a field list type ourselves, we look ahead
497 * in the field list to try to find out whether this field list
498 * will be used for an enum or struct type, and create a dummy
499 * type of the corresponding sort. Later on, the definition of
500 * the 'real' type will copy the member / enumeration data.
502 const unsigned char* ptr
= start
;
504 const struct p_string
* pstr
;
506 struct full_value full_value
;
510 const union codeview_fieldtype
* fieldtype
= (const union codeview_fieldtype
*)ptr
;
512 if (*ptr
>= 0xf0) /* LF_PAD... */
518 switch (fieldtype
->generic
.id
)
520 case LF_ENUMERATE_V1
:
521 leaf_len
= full_numeric_leaf(&full_value
, &fieldtype
->enumerate_v1
.value
);
522 pstr
= PSTRING(&fieldtype
->enumerate_v1
.value
, leaf_len
);
523 printf("\t\tEnumerate V1: '%s' value:%s\n",
524 p_string(pstr
), full_value_string(&full_value
));
525 ptr
+= 2 + 2 + leaf_len
+ 1 + pstr
->namelen
;
528 case LF_ENUMERATE_V3
:
529 leaf_len
= full_numeric_leaf(&full_value
, &fieldtype
->enumerate_v3
.value
);
530 cstr
= (const char*)&fieldtype
->enumerate_v3
.value
+ leaf_len
;
531 printf("\t\tEnumerate V3: '%s' value:%s\n",
532 cstr
, full_value_string(&full_value
));
533 ptr
+= 2 + 2 + leaf_len
+ strlen(cstr
) + 1;
537 leaf_len
= numeric_leaf(&value
, &fieldtype
->member_v1
.offset
);
538 pstr
= PSTRING(&fieldtype
->member_v1
.offset
, leaf_len
);
539 printf("\t\tMember V1: '%s' type:%x attr:%s @%d\n",
540 p_string(pstr
), fieldtype
->member_v1
.type
,
541 get_attr(fieldtype
->member_v1
.attribute
), value
);
542 ptr
+= 2 + 2 + 2 + leaf_len
+ 1 + pstr
->namelen
;
546 leaf_len
= numeric_leaf(&value
, &fieldtype
->member_v2
.offset
);
547 pstr
= PSTRING(&fieldtype
->member_v2
.offset
, leaf_len
);
548 printf("\t\tMember V2: '%s' type:%x attr:%s @%d\n",
549 p_string(pstr
), fieldtype
->member_v2
.type
,
550 get_attr(fieldtype
->member_v2
.attribute
), value
);
551 ptr
+= 2 + 2 + 4 + leaf_len
+ 1 + pstr
->namelen
;
555 leaf_len
= numeric_leaf(&value
, &fieldtype
->member_v3
.offset
);
556 cstr
= (const char*)&fieldtype
->member_v3
.offset
+ leaf_len
;
557 printf("\t\tMember V3: '%s' type:%x attr:%s @%d\n",
558 cstr
, fieldtype
->member_v3
.type
,
559 get_attr(fieldtype
->member_v3
.attribute
), value
);
560 ptr
+= 2 + 2 + 4 + leaf_len
+ strlen(cstr
) + 1;
563 case LF_ONEMETHOD_V1
:
564 switch ((fieldtype
->onemethod_v1
.attribute
>> 2) & 7)
567 printf("\t\tVirtual-method V1: '%s' attr:%s type:%x vtable_offset:%u\n",
568 p_string(&fieldtype
->onemethod_virt_v1
.p_name
),
569 get_attr(fieldtype
->onemethod_virt_v1
.attribute
),
570 fieldtype
->onemethod_virt_v1
.type
,
571 fieldtype
->onemethod_virt_v1
.vtab_offset
);
572 ptr
+= 2 + 2 + 2 + 4 + (1 + fieldtype
->onemethod_virt_v1
.p_name
.namelen
);
576 printf("\t\tMethod V1: '%s' attr:%s type:%x\n",
577 p_string(&fieldtype
->onemethod_v1
.p_name
),
578 get_attr(fieldtype
->onemethod_v1
.attribute
),
579 fieldtype
->onemethod_v1
.type
);
580 ptr
+= 2 + 2 + 2 + (1 + fieldtype
->onemethod_v1
.p_name
.namelen
);
585 case LF_ONEMETHOD_V2
:
586 switch ((fieldtype
->onemethod_v2
.attribute
>> 2) & 7)
589 printf("\t\tVirtual-method V2: '%s' attr:%s type:%x vtable_offset:%u\n",
590 p_string(&fieldtype
->onemethod_virt_v2
.p_name
),
591 get_attr(fieldtype
->onemethod_virt_v2
.attribute
),
592 fieldtype
->onemethod_virt_v2
.type
,
593 fieldtype
->onemethod_virt_v2
.vtab_offset
);
594 ptr
+= 2 + 2 + 4 + 4 + (1 + fieldtype
->onemethod_virt_v2
.p_name
.namelen
);
598 printf("\t\tMethod V2: '%s' attr:%s type:%x\n",
599 p_string(&fieldtype
->onemethod_v2
.p_name
),
600 get_attr(fieldtype
->onemethod_v2
.attribute
),
601 fieldtype
->onemethod_v2
.type
);
602 ptr
+= 2 + 2 + 4 + (1 + fieldtype
->onemethod_v2
.p_name
.namelen
);
607 case LF_ONEMETHOD_V3
:
608 switch ((fieldtype
->onemethod_v3
.attribute
>> 2) & 7)
611 printf("\t\tVirtual-method V3: '%s' attr:%s type:%x vtable_offset:%u\n",
612 fieldtype
->onemethod_virt_v3
.name
,
613 get_attr(fieldtype
->onemethod_virt_v3
.attribute
),
614 fieldtype
->onemethod_virt_v3
.type
,
615 fieldtype
->onemethod_virt_v3
.vtab_offset
);
616 ptr
+= 2 + 2 + 4 + 4 + (strlen(fieldtype
->onemethod_virt_v3
.name
) + 1);
620 printf("\t\tMethod V3: '%s' attr:%s type:%x\n",
621 fieldtype
->onemethod_v3
.name
,
622 get_attr(fieldtype
->onemethod_v3
.attribute
),
623 fieldtype
->onemethod_v3
.type
);
624 ptr
+= 2 + 2 + 4 + (strlen(fieldtype
->onemethod_v3
.name
) + 1);
630 printf("\t\tMethod V1: '%s' overloaded=#%d method-list=%x\n",
631 p_string(&fieldtype
->method_v1
.p_name
),
632 fieldtype
->method_v1
.count
, fieldtype
->method_v1
.mlist
);
633 ptr
+= 2 + 2 + 2 + (1 + fieldtype
->method_v1
.p_name
.namelen
);
637 printf("\t\tMethod V2: '%s' overloaded=#%d method-list=%x\n",
638 p_string(&fieldtype
->method_v2
.p_name
),
639 fieldtype
->method_v2
.count
, fieldtype
->method_v2
.mlist
);
640 ptr
+= 2 + 2 + 4 + (1 + fieldtype
->method_v2
.p_name
.namelen
);
644 printf("\t\tMethod V3: '%s' overloaded=#%d method-list=%x\n",
645 fieldtype
->method_v3
.name
,
646 fieldtype
->method_v3
.count
, fieldtype
->method_v3
.mlist
);
647 ptr
+= 2 + 2 + 4 + (strlen(fieldtype
->method_v3
.name
) + 1);
651 printf("\t\tStatic member V1: '%s' attr:%s type:%x\n",
652 p_string(&fieldtype
->stmember_v1
.p_name
),
653 get_attr(fieldtype
->stmember_v1
.attribute
),
654 fieldtype
->stmember_v1
.type
);
655 ptr
+= 2 + 2 + 2 + (1 + fieldtype
->stmember_v1
.p_name
.namelen
);
659 printf("\t\tStatic member V2: '%s' attr:%s type:%x\n",
660 p_string(&fieldtype
->stmember_v2
.p_name
),
661 get_attr(fieldtype
->stmember_v2
.attribute
),
662 fieldtype
->stmember_v2
.type
);
663 ptr
+= 2 + 2 + 4 + (1 + fieldtype
->stmember_v2
.p_name
.namelen
);
667 printf("\t\tStatic member V3: '%s' attr:%s type:%x\n",
668 fieldtype
->stmember_v3
.name
,
669 get_attr(fieldtype
->stmember_v3
.attribute
),
670 fieldtype
->stmember_v3
.type
);
671 ptr
+= 2 + 2 + 4 + (strlen(fieldtype
->stmember_v3
.name
) + 1);
674 case LF_FRIENDFCN_V1
:
675 printf("\t\tFriend function V1: '%s' type:%x\n",
676 p_string(&fieldtype
->friendfcn_v1
.p_name
),
677 fieldtype
->friendfcn_v1
.type
);
678 ptr
+= 2 + 2 + (1 + fieldtype
->stmember_v2
.p_name
.namelen
);
681 case LF_FRIENDFCN_V2
:
682 printf("\t\tFriend function V2: '%s' type:%x\n",
683 p_string(&fieldtype
->friendfcn_v2
.p_name
),
684 fieldtype
->friendfcn_v2
.type
);
685 ptr
+= 2 + 2 + 4 + (1 + fieldtype
->stmember_v2
.p_name
.namelen
);
688 case LF_FRIENDFCN_V3
:
689 printf("\t\tFriend function V3: '%s' type:%x\n",
690 fieldtype
->friendfcn_v3
.name
,
691 fieldtype
->friendfcn_v3
.type
);
692 ptr
+= 2 + 2 + 4 + (strlen(fieldtype
->stmember_v3
.name
) + 1);
696 leaf_len
= numeric_leaf(&value
, &fieldtype
->bclass_v1
.offset
);
697 printf("\t\tBase class V1: type:%x attr:%s @%d\n",
698 fieldtype
->bclass_v1
.type
,
699 get_attr(fieldtype
->bclass_v1
.attribute
), value
);
700 ptr
+= 2 + 2 + 2 + leaf_len
;
704 leaf_len
= numeric_leaf(&value
, &fieldtype
->bclass_v2
.offset
);
705 printf("\t\tBase class V2: type:%x attr:%s @%d\n",
706 fieldtype
->bclass_v2
.type
,
707 get_attr(fieldtype
->bclass_v2
.attribute
), value
);
708 ptr
+= 2 + 2 + 4 + leaf_len
;
713 leaf_len
= numeric_leaf(&value
, &fieldtype
->vbclass_v1
.vbpoff
);
714 printf("\t\t%sirtual base class V1: type:%x (ptr:%x) attr:%s vbpoff:%d ",
715 (fieldtype
->generic
.id
== LF_VBCLASS_V2
) ? "V" : "Indirect v",
716 fieldtype
->vbclass_v1
.btype
, fieldtype
->vbclass_v1
.vbtype
,
717 get_attr(fieldtype
->vbclass_v1
.attribute
), value
);
718 ptr
+= 2 + 2 + 2 + 2 + leaf_len
;
719 leaf_len
= numeric_leaf(&value
, (const unsigned short*)ptr
);
720 printf("vboff:%d\n", value
);
726 leaf_len
= numeric_leaf(&value
, &fieldtype
->vbclass_v1
.vbpoff
);
727 printf("\t\t%sirtual base class V2: type:%x (ptr:%x) attr:%s vbpoff:%d ",
728 (fieldtype
->generic
.id
== LF_VBCLASS_V2
) ? "V" : "Indirect v",
729 fieldtype
->vbclass_v2
.btype
, fieldtype
->vbclass_v2
.vbtype
,
730 get_attr(fieldtype
->vbclass_v2
.attribute
), value
);
731 ptr
+= 2 + 2 + 4 + 4 + leaf_len
;
732 leaf_len
= numeric_leaf(&value
, (const unsigned short*)ptr
);
733 printf("vboff:%d\n", value
);
737 case LF_FRIENDCLS_V1
:
738 printf("\t\tFriend class V1: type:%x\n", fieldtype
->friendcls_v1
.type
);
742 case LF_FRIENDCLS_V2
:
743 printf("\t\tFriend class V2: type:%x\n", fieldtype
->friendcls_v2
.type
);
748 printf("\t\tNested type V1: '%s' type:%x\n",
749 p_string(&fieldtype
->nesttype_v1
.p_name
),
750 fieldtype
->nesttype_v1
.type
);
751 ptr
+= 2 + 2 + (1 + fieldtype
->nesttype_v1
.p_name
.namelen
);
755 printf("\t\tNested type V2: '%s' pad0:%u type:%x\n",
756 p_string(&fieldtype
->nesttype_v2
.p_name
),
757 fieldtype
->nesttype_v2
._pad0
, fieldtype
->nesttype_v2
.type
);
758 ptr
+= 2 + 2 + 4 + (1 + fieldtype
->nesttype_v2
.p_name
.namelen
);
762 printf("\t\tNested type V3: '%s' pad0:%u type:%x\n",
763 fieldtype
->nesttype_v3
.name
,
764 fieldtype
->nesttype_v3
._pad0
, fieldtype
->nesttype_v3
.type
);
765 ptr
+= 2 + 2 + 4 + (strlen(fieldtype
->nesttype_v3
.name
) + 1);
769 printf("\t\tVirtual function table V1: type:%x\n",
770 fieldtype
->vfunctab_v1
.type
);
775 printf("\t\tVirtual function table V2: type:%x\n",
776 fieldtype
->vfunctab_v2
.type
);
781 printf("\t\tVirtual function table offset V1: type:%x offset:%x\n",
782 fieldtype
->vfuncoff_v1
.type
, fieldtype
->vfuncoff_v1
.offset
);
787 printf("\t\tVirtual function table offset V2: type:%x offset:%x\n",
788 fieldtype
->vfuncoff_v2
.type
, fieldtype
->vfuncoff_v2
.offset
);
789 ptr
+= 2 + 2 + 4 + 4;
793 printf("\t\tIndex V1: index:%x\n", fieldtype
->index_v1
.ref
);
798 printf("\t\tIndex V2: index:%x\n", fieldtype
->index_v2
.ref
);
803 printf(">>> Unsupported field-id %x\n", fieldtype
->generic
.id
);
804 dump_data((const void*)fieldtype
, 0x30, "\t");
810 static void codeview_dump_one_type(unsigned curr_type
, const union codeview_type
* type
)
812 const union codeview_reftype
* reftype
= (const union codeview_reftype
*)type
;
813 int i
, leaf_len
, value
;
817 switch (type
->generic
.id
)
819 /* types from TPI (aka #2) stream */
821 printf("\t%x => Pointer V1 to type:%x\n",
822 curr_type
, type
->pointer_v1
.datatype
);
825 printf("\t%x => Pointer V2 to type:%x\n",
826 curr_type
, type
->pointer_v2
.datatype
);
829 leaf_len
= numeric_leaf(&value
, &type
->array_v1
.arrlen
);
830 printf("\t%x => Array V1-'%s'[%u type:%x] type:%x\n",
831 curr_type
, p_string(PSTRING(&type
->array_v1
.arrlen
, leaf_len
)),
832 value
, type
->array_v1
.idxtype
, type
->array_v1
.elemtype
);
835 leaf_len
= numeric_leaf(&value
, &type
->array_v2
.arrlen
);
836 printf("\t%x => Array V2-'%s'[%u type:%x] type:%x\n",
837 curr_type
, p_string(PSTRING(&type
->array_v2
.arrlen
, leaf_len
)),
838 value
, type
->array_v2
.idxtype
, type
->array_v2
.elemtype
);
841 leaf_len
= numeric_leaf(&value
, &type
->array_v3
.arrlen
);
842 str
= (const char*)&type
->array_v3
.arrlen
+ leaf_len
;
843 printf("\t%x => Array V3-'%s'[%u type:%x] type:%x\n",
844 curr_type
, str
, value
,
845 type
->array_v3
.idxtype
, type
->array_v3
.elemtype
);
848 /* a bitfields is a CodeView specific data type which represent a bitfield
849 * in a structure or a class. For now, we store it in a SymTag-like type
850 * (so that the rest of the process is seamless), but check at udt inclusion
851 * type for its presence
854 printf("\t%x => Bitfield V1:%x offset:%u #bits:%u\n",
855 curr_type
, reftype
->bitfield_v1
.type
, reftype
->bitfield_v1
.bitoff
,
856 reftype
->bitfield_v1
.nbits
);
860 printf("\t%x => Bitfield V2:%x offset:%u #bits:%u\n",
861 curr_type
, reftype
->bitfield_v2
.type
, reftype
->bitfield_v2
.bitoff
,
862 reftype
->bitfield_v2
.nbits
);
865 case LF_FIELDLIST_V1
:
866 case LF_FIELDLIST_V2
:
867 printf("\t%x => Fieldlist\n", curr_type
);
868 do_field(reftype
->fieldlist
.list
, (const BYTE
*)type
+ reftype
->generic
.len
+ 2);
871 case LF_STRUCTURE_V1
:
873 leaf_len
= numeric_leaf(&value
, &type
->struct_v1
.structlen
);
874 printf("\t%x => %s V1 '%s' elts:%u property:%s fieldlist-type:%x derived-type:%x vshape:%x size:%u\n",
875 curr_type
, type
->generic
.id
== LF_CLASS_V1
? "Class" : "Struct",
876 p_string(PSTRING(&type
->struct_v1
.structlen
, leaf_len
)),
877 type
->struct_v1
.n_element
, get_property(type
->struct_v1
.property
),
878 type
->struct_v1
.fieldlist
, type
->struct_v1
.derived
,
879 type
->struct_v1
.vshape
, value
);
882 case LF_STRUCTURE_V2
:
884 leaf_len
= numeric_leaf(&value
, &type
->struct_v2
.structlen
);
885 printf("\t%x => %s V2 '%s' elts:%u property:%s\n"
886 " fieldlist-type:%x derived-type:%x vshape:%x size:%u\n",
887 curr_type
, type
->generic
.id
== LF_CLASS_V2
? "Class" : "Struct",
888 p_string(PSTRING(&type
->struct_v2
.structlen
, leaf_len
)),
889 type
->struct_v2
.n_element
, get_property(type
->struct_v2
.property
),
890 type
->struct_v2
.fieldlist
, type
->struct_v2
.derived
,
891 type
->struct_v2
.vshape
, value
);
894 case LF_STRUCTURE_V3
:
896 leaf_len
= numeric_leaf(&value
, &type
->struct_v3
.structlen
);
897 str
= (const char*)&type
->struct_v3
.structlen
+ leaf_len
;
898 printf("\t%x => %s V3 '%s' elts:%u property:%s\n"
899 " fieldlist-type:%x derived-type:%x vshape:%x size:%u\n",
900 curr_type
, type
->generic
.id
== LF_CLASS_V3
? "Class" : "Struct",
901 str
, type
->struct_v3
.n_element
, get_property(type
->struct_v3
.property
),
902 type
->struct_v3
.fieldlist
, type
->struct_v3
.derived
,
903 type
->struct_v3
.vshape
, value
);
904 if (type
->union_v3
.property
.has_decorated_name
)
905 printf("\t\tDecorated name:%s\n", str
+ strlen(str
) + 1);
909 leaf_len
= numeric_leaf(&value
, &type
->union_v1
.un_len
);
910 printf("\t%x => Union V1 '%s' count:%u property:%s fieldlist-type:%x size:%u\n",
911 curr_type
, p_string(PSTRING(&type
->union_v1
.un_len
, leaf_len
)),
912 type
->union_v1
.count
, get_property(type
->union_v1
.property
),
913 type
->union_v1
.fieldlist
, value
);
917 leaf_len
= numeric_leaf(&value
, &type
->union_v2
.un_len
);
918 printf("\t%x => Union V2 '%s' count:%u property:%s fieldlist-type:%x size:%u\n",
919 curr_type
, p_string(PSTRING(&type
->union_v2
.un_len
, leaf_len
)),
920 type
->union_v2
.count
, get_property(type
->union_v2
.property
),
921 type
->union_v2
.fieldlist
, value
);
925 leaf_len
= numeric_leaf(&value
, &type
->union_v3
.un_len
);
926 str
= (const char*)&type
->union_v3
.un_len
+ leaf_len
;
927 printf("\t%x => Union V3 '%s' count:%u property:%s fieldlist-type:%x size:%u\n",
928 curr_type
, str
, type
->union_v3
.count
,
929 get_property(type
->union_v3
.property
),
930 type
->union_v3
.fieldlist
, value
);
931 if (type
->union_v3
.property
.has_decorated_name
)
932 printf("\t\tDecorated name:%s\n", str
+ strlen(str
) + 1);
936 printf("\t%x => Enum V1 '%s' type:%x field-type:%x count:%u property:%s\n",
937 curr_type
, p_string(&type
->enumeration_v1
.p_name
),
938 type
->enumeration_v1
.type
,
939 type
->enumeration_v1
.fieldlist
,
940 type
->enumeration_v1
.count
,
941 get_property(type
->enumeration_v1
.property
));
945 printf("\t%x => Enum V2 '%s' type:%x field-type:%x count:%u property:%s\n",
946 curr_type
, p_string(&type
->enumeration_v2
.p_name
),
947 type
->enumeration_v2
.type
,
948 type
->enumeration_v2
.fieldlist
,
949 type
->enumeration_v2
.count
,
950 get_property(type
->enumeration_v2
.property
));
954 printf("\t%x => Enum V3 '%s' type:%x field-type:%x count:%u property:%s\n",
955 curr_type
, type
->enumeration_v3
.name
,
956 type
->enumeration_v3
.type
,
957 type
->enumeration_v3
.fieldlist
,
958 type
->enumeration_v3
.count
,
959 get_property(type
->enumeration_v3
.property
));
960 if (type
->union_v3
.property
.has_decorated_name
)
961 printf("\t\tDecorated name:%s\n", type
->enumeration_v3
.name
+ strlen(type
->enumeration_v3
.name
) + 1);
965 printf("\t%x => Arglist V1(#%u):", curr_type
, reftype
->arglist_v1
.num
);
966 for (i
= 0; i
< reftype
->arglist_v1
.num
; i
++)
968 printf(" %x", reftype
->arglist_v1
.args
[i
]);
974 printf("\t%x => Arglist V2(#%u):", curr_type
, reftype
->arglist_v2
.num
);
975 for (j
= 0; j
< reftype
->arglist_v2
.num
; j
++)
977 printf("\t %x", reftype
->arglist_v2
.args
[j
]);
982 case LF_PROCEDURE_V1
:
983 printf("\t%x => Procedure V1 ret_type:%x callconv:%s attr:%s (#%u args_type:%x)\n",
984 curr_type
, type
->procedure_v1
.rvtype
,
985 get_callconv(type
->procedure_v1
.callconv
), get_funcattr(type
->procedure_v1
.funcattr
),
986 type
->procedure_v1
.params
, type
->procedure_v1
.arglist
);
989 case LF_PROCEDURE_V2
:
990 printf("\t%x => Procedure V2 ret_type:%x callconv:%s attr:%s (#%u args_type:%x)\n",
991 curr_type
, type
->procedure_v2
.rvtype
,
992 get_callconv(type
->procedure_v2
.callconv
), get_funcattr(type
->procedure_v1
.funcattr
),
993 type
->procedure_v2
.params
, type
->procedure_v2
.arglist
);
996 case LF_MFUNCTION_V2
:
997 printf("\t%x => MFunction V2 ret-type:%x callconv:%s class-type:%x this-type:%x attr:%s\n"
998 "\t\t#args:%x args-type:%x this_adjust:%x\n",
1000 type
->mfunction_v2
.rvtype
,
1001 get_callconv(type
->mfunction_v2
.callconv
),
1002 type
->mfunction_v2
.class_type
,
1003 type
->mfunction_v2
.this_type
,
1004 get_funcattr(type
->mfunction_v2
.funcattr
),
1005 type
->mfunction_v2
.params
,
1006 type
->mfunction_v2
.arglist
,
1007 type
->mfunction_v2
.this_adjust
);
1010 case LF_MODIFIER_V1
:
1011 printf("\t%x => Modifier V1 type:%x modif:%x\n",
1012 curr_type
, type
->modifier_v1
.type
, type
->modifier_v1
.attribute
);
1015 case LF_MODIFIER_V2
:
1016 printf("\t%x => Modifier V2 type:%x modif:%x\n",
1017 curr_type
, type
->modifier_v2
.type
, type
->modifier_v2
.attribute
);
1020 case LF_METHODLIST_V1
:
1022 const unsigned short* pattr
= (const unsigned short*)((const char*)type
+ 4);
1024 printf("\t%x => Method list\n", curr_type
);
1025 while ((const char*)pattr
< (const char*)type
+ type
->generic
.len
+ 2)
1027 switch ((*pattr
>> 2) & 7)
1030 printf("\t\t\tattr:%s type:%x vtab-offset:%x\n",
1031 get_attr(pattr
[0]), pattr
[1],
1032 *(const unsigned*)(&pattr
[2]));
1036 printf("\t\t\tattr:%s type:%x\n",
1037 get_attr(pattr
[0]), pattr
[1]);
1044 case LF_METHODLIST_V2
:
1046 const unsigned* pattr
= (const unsigned*)((const char*)type
+ 4);
1048 printf("\t%x => Method list\n", curr_type
);
1049 while ((const char*)pattr
< (const char*)type
+ type
->generic
.len
+ 2)
1051 switch ((*pattr
>> 2) & 7)
1054 printf("\t\t\tattr:%s type:%x vtab-offset:%x\n",
1055 get_attr(pattr
[0]), pattr
[1], pattr
[2]);
1059 printf("\t\t\tattr:%s type:%x\n",
1060 get_attr(pattr
[0]), pattr
[1]);
1069 int count
= *(const unsigned short*)((const char*)type
+ 4);
1071 const char* ptr
= (const char*)type
+ 6;
1072 const char* desc
[] = {"Near", "Far", "Thin", "Disp to outermost",
1073 "Pointer to metaclass", "Near32", "Far32"};
1074 printf("\t%x => VT Shape #%d: ", curr_type
, count
);
1077 if (((*ptr
<< shift
) & 0xF) <= 6)
1078 printf("%s ", desc
[(*ptr
<< shift
) & 0xF]);
1080 printf("%x ", (*ptr
<< shift
) & 0xF);
1081 if (shift
== 0) shift
= 4; else {shift
= 0; ptr
++;}
1088 printf("\t%x => Derived V1(#%u):", curr_type
, reftype
->derived_v1
.num
);
1089 for (i
= 0; i
< reftype
->derived_v1
.num
; i
++)
1091 printf(" %x", reftype
->derived_v1
.drvdcls
[i
]);
1097 printf("\t%x => Derived V2(#%u):", curr_type
, reftype
->derived_v2
.num
);
1098 for (j
= 0; j
< reftype
->derived_v2
.num
; j
++)
1100 printf(" %x", reftype
->derived_v2
.drvdcls
[j
]);
1106 printf("\t%x => VFTable V3 base:%x baseVfTable:%x offset%u\n",
1107 curr_type
, reftype
->vftable_v3
.type
, reftype
->vftable_v3
.baseVftable
, reftype
->vftable_v3
.offsetInObjectLayout
);
1109 const char* str
= reftype
->vftable_v3
.names
;
1110 const char* last
= str
+ reftype
->vftable_v3
.cbstr
;
1113 printf("\t\t%s\n", str
);
1114 str
+= strlen(str
) + 1;
1119 /* types from IPI (aka #4) stream */
1121 printf("\t%x => FuncId %s scopeId:%04x type:%04x\n",
1122 curr_type
, type
->func_id_v3
.name
,
1123 type
->func_id_v3
.scopeId
, type
->func_id_v3
.type
);
1126 printf("\t%x => MFuncId %s parent:%04x type:%04x\n",
1127 curr_type
, type
->mfunc_id_v3
.name
,
1128 type
->mfunc_id_v3
.parentType
, type
->mfunc_id_v3
.type
);
1131 printf("\t%x => BuildInfo count:%d\n", curr_type
, type
->buildinfo_v3
.count
);
1132 if (type
->buildinfo_v3
.count
>= 1) printf("\t\tcurrent dir: %04x\n", type
->buildinfo_v3
.arg
[0]);
1133 if (type
->buildinfo_v3
.count
>= 2) printf("\t\tbuild tool: %04x\n", type
->buildinfo_v3
.arg
[1]);
1134 if (type
->buildinfo_v3
.count
>= 3) printf("\t\tsource file: %04x\n", type
->buildinfo_v3
.arg
[2]);
1135 if (type
->buildinfo_v3
.count
>= 4) printf("\t\tPDB file: %04x\n", type
->buildinfo_v3
.arg
[3]);
1136 if (type
->buildinfo_v3
.count
>= 5) printf("\t\tArguments: %04x\n", type
->buildinfo_v3
.arg
[4]);
1138 case LF_SUBSTR_LIST
:
1139 printf("\t%x => SubstrList V3(#%u):", curr_type
, reftype
->arglist_v2
.num
);
1140 for (j
= 0; j
< reftype
->arglist_v2
.num
; j
++)
1142 printf("\t %x", reftype
->arglist_v2
.args
[j
]);
1147 printf("\t%x => StringId %s strid:%04x\n",
1148 curr_type
, type
->string_id_v3
.name
, type
->string_id_v3
.strid
);
1150 case LF_UDT_SRC_LINE
:
1151 printf("\t%x => Udt-SrcLine type:%04x src:%04x line:%d\n",
1152 curr_type
, type
->udt_src_line_v3
.type
,
1153 type
->udt_src_line_v3
.src
, type
->udt_src_line_v3
.line
);
1155 case LF_UDT_MOD_SRC_LINE
:
1156 printf("\t%x => Udt-ModSrcLine type:%04x src:%04x line:%d mod:%d\n",
1157 curr_type
, type
->udt_mod_src_line_v3
.type
,
1158 type
->udt_mod_src_line_v3
.src
, type
->udt_mod_src_line_v3
.line
,
1159 type
->udt_mod_src_line_v3
.imod
);
1163 printf(">>> Unsupported type-id %x for %x\n", type
->generic
.id
, curr_type
);
1164 dump_data((const void*)type
, type
->generic
.len
+ 2, "");
1169 BOOL
codeview_dump_types_from_offsets(const void* table
, const DWORD
* offsets
, unsigned num_types
)
1173 for (i
= 0; i
< num_types
; i
++)
1175 codeview_dump_one_type(0x1000 + i
,
1176 (const union codeview_type
*)((const char*)table
+ offsets
[i
]));
1182 BOOL
codeview_dump_types_from_block(const void* table
, unsigned long len
)
1184 unsigned int curr_type
= 0x1000;
1185 const unsigned char*ptr
= table
;
1187 while (ptr
- (const unsigned char*)table
< len
)
1189 const union codeview_type
* type
= (const union codeview_type
*)ptr
;
1191 codeview_dump_one_type(curr_type
, type
);
1193 ptr
+= type
->generic
.len
+ 2;
1199 static void dump_defrange(const struct cv_addr_range
* range
, const void* last
, unsigned indent
)
1201 const struct cv_addr_gap
* gap
;
1203 printf("%*s\\- %04x:%08x range:#%x\n", indent
, "", range
->isectStart
, range
->offStart
, range
->cbRange
);
1204 for (gap
= (const struct cv_addr_gap
*)(range
+ 1); (const void*)(gap
+ 1) <= last
; ++gap
)
1205 printf("%*s | offset:%x range:#%x\n", indent
, "", gap
->gapStartOffset
, gap
->cbRange
);
1208 /* return address of first byte after the symbol */
1209 static inline const char* get_last(const union codeview_symbol
* sym
)
1211 return (const char*)sym
+ sym
->generic
.len
+ 2;
1214 static unsigned binannot_uncompress(const unsigned char** pptr
)
1216 unsigned res
= (unsigned)(-1);
1217 const unsigned char* ptr
= *pptr
;
1219 if ((*ptr
& 0x80) == 0x00)
1220 res
= (unsigned)(*ptr
++);
1221 else if ((*ptr
& 0xC0) == 0x80)
1223 res
= (unsigned)((*ptr
++ & 0x3f) << 8);
1226 else if ((*ptr
& 0xE0) == 0xC0)
1228 res
= (*ptr
++ & 0x1f) << 24;
1229 res
|= *ptr
++ << 16;
1233 else res
= (unsigned)(-1);
1238 static inline int binannot_getsigned(unsigned i
)
1240 return (i
& 1) ? -(int)(i
>> 1) : (i
>> 1);
1243 static void dump_binannot(const unsigned char* ba
, const char* last
, unsigned indent
)
1245 while (ba
< (const unsigned char*)last
)
1247 unsigned opcode
= binannot_uncompress(&ba
);
1251 /* not clear if param? */
1252 printf("%*s | Invalid\n", indent
, "");
1254 case BA_OP_CodeOffset
:
1255 printf("%*s | CodeOffset %u\n", indent
, "", binannot_uncompress(&ba
));
1257 case BA_OP_ChangeCodeOffsetBase
:
1258 printf("%*s | ChangeCodeOffsetBase %u\n", indent
, "", binannot_uncompress(&ba
));
1260 case BA_OP_ChangeCodeOffset
:
1261 printf("%*s | ChangeCodeOffset %u\n", indent
, "", binannot_uncompress(&ba
));
1263 case BA_OP_ChangeCodeLength
:
1264 printf("%*s | ChangeCodeLength %u\n", indent
, "", binannot_uncompress(&ba
));
1266 case BA_OP_ChangeFile
:
1267 printf("%*s | ChangeFile %u\n", indent
, "", binannot_uncompress(&ba
));
1269 case BA_OP_ChangeLineOffset
:
1270 printf("%*s | ChangeLineOffset %d\n", indent
, "", binannot_getsigned(binannot_uncompress(&ba
)));
1272 case BA_OP_ChangeLineEndDelta
:
1273 printf("%*s | ChangeLineEndDelta %u\n", indent
, "", binannot_uncompress(&ba
));
1275 case BA_OP_ChangeRangeKind
:
1276 printf("%*s | ChangeRangeKind %u\n", indent
, "", binannot_uncompress(&ba
));
1278 case BA_OP_ChangeColumnStart
:
1279 printf("%*s | ChangeColumnStart %u\n", indent
, "", binannot_uncompress(&ba
));
1281 case BA_OP_ChangeColumnEndDelta
:
1282 printf("%*s | ChangeColumnEndDelta %u\n", indent
, "", binannot_uncompress(&ba
));
1284 case BA_OP_ChangeCodeOffsetAndLineOffset
:
1286 unsigned p1
= binannot_uncompress(&ba
);
1287 printf("%*s | ChangeCodeOffsetAndLineOffset %u %d (0x%x)\n", indent
, "", p1
& 0xf, binannot_getsigned(p1
>> 4), p1
);
1290 case BA_OP_ChangeCodeLengthAndCodeOffset
:
1292 unsigned p1
= binannot_uncompress(&ba
);
1293 unsigned p2
= binannot_uncompress(&ba
);
1294 printf("%*s | ChangeCodeLengthAndCodeOffset %u %u\n", indent
, "", p1
, p2
);
1297 case BA_OP_ChangeColumnEnd
:
1298 printf("%*s | ChangeColumnEnd %u\n", indent
, "", binannot_uncompress(&ba
));
1301 default: printf(">>> Unsupported op %d %x\n", opcode
, opcode
); /* may cause issues because of param */
1306 struct symbol_dumper
1313 const union codeview_symbol
* sym
;
1317 static void init_symbol_dumper(struct symbol_dumper
* sd
)
1321 sd
->stack
= xmalloc(sd
->alloc
* sizeof(sd
->stack
[0]));
1324 static void push_symbol_dumper(struct symbol_dumper
* sd
, const union codeview_symbol
* sym
, unsigned end
)
1326 if (!sd
->stack
) return;
1327 if (sd
->depth
>= sd
->alloc
) sd
->stack
= xrealloc(sd
->stack
, (sd
->alloc
*= 2) * sizeof(sd
->stack
[0]));
1328 sd
->stack
[sd
->depth
].end
= end
;
1329 sd
->stack
[sd
->depth
].sym
= sym
;
1333 static unsigned short pop_symbol_dumper(struct symbol_dumper
* sd
, unsigned end
)
1335 if (!sd
->stack
) return 0;
1338 printf(">>> Error in stack\n");
1342 if (sd
->stack
[sd
->depth
].end
!= end
)
1343 printf(">>> Wrong end reference\n");
1344 return sd
->stack
[sd
->depth
].sym
->generic
.id
;
1347 static void dispose_symbol_dumper(struct symbol_dumper
* sd
)
1352 BOOL
codeview_dump_symbols(const void* root
, unsigned long start
, unsigned long size
)
1356 struct symbol_dumper sd
;
1358 init_symbol_dumper(&sd
);
1360 * Loop over the different types of records and whenever we
1361 * find something we are interested in, record it and move on.
1363 for (i
= start
; i
< size
; i
+= length
)
1365 const union codeview_symbol
* sym
= (const union codeview_symbol
*)((const char*)root
+ i
);
1366 unsigned indent
, ref
;
1368 length
= sym
->generic
.len
+ 2;
1369 if (!sym
->generic
.id
|| length
< 4) break;
1370 indent
= printf(" %04x => ", i
);
1372 switch (sym
->generic
.id
)
1375 case S_INLINESITE_END
:
1376 indent
+= printf("%*s", 2 * sd
.depth
- 2, "");
1379 indent
+= printf("%*s", 2 * sd
.depth
, "");
1383 switch (sym
->generic
.id
)
1386 * Global and local data symbols. We don't associate these
1387 * with any given source file.
1391 printf("%s-Data V2 '%s' %04x:%08x type:%08x\n",
1392 sym
->generic
.id
== S_GDATA32_ST
? "Global" : "Local",
1393 get_symbol_str(p_string(&sym
->data_v2
.p_name
)),
1394 sym
->data_v2
.segment
, sym
->data_v2
.offset
, sym
->data_v2
.symtype
);
1399 /* EPP case S_DATA32: */
1400 printf("%s-Data V3 '%s' (%04x:%08x) type:%08x\n",
1401 sym
->generic
.id
== S_GDATA32
? "Global" : "Local",
1402 get_symbol_str(sym
->data_v3
.name
),
1403 sym
->data_v3
.segment
, sym
->data_v3
.offset
,
1404 sym
->data_v3
.symtype
);
1408 printf("Public V1 '%s' %04x:%08x flags:%s\n",
1409 get_symbol_str(p_string(&sym
->public_v1
.p_name
)),
1410 sym
->public_v1
.segment
, sym
->public_v1
.offset
,
1411 get_pubflags(sym
->public_v1
.pubsymflags
));
1415 printf("Public V2 '%s' %04x:%08x flags:%s\n",
1416 get_symbol_str(p_string(&sym
->public_v2
.p_name
)),
1417 sym
->public_v2
.segment
, sym
->public_v2
.offset
,
1418 get_pubflags(sym
->public_v2
.pubsymflags
));
1422 printf("Public V3 '%s' %04x:%08x flags:%s\n",
1423 get_symbol_str(sym
->public_v3
.name
),
1424 sym
->public_v3
.segment
, sym
->public_v3
.offset
,
1425 get_pubflags(sym
->public_v3
.pubsymflags
));
1431 printf("%sref V3 '%s' %04x:%08x name:%08x\n",
1432 sym
->generic
.id
== S_DATAREF
? "Data" :
1433 (sym
->generic
.id
== S_PROCREF
? "Proc" : "Lproc"),
1434 get_symbol_str(sym
->refsym2_v3
.name
),
1435 sym
->refsym2_v3
.imod
, sym
->refsym2_v3
.ibSym
, sym
->refsym2_v3
.sumName
);
1439 * Sort of like a global function, but it just points
1440 * to a thunk, which is a stupid name for what amounts to
1441 * a PLT slot in the normal jargon that everyone else uses.
1444 printf("Thunk V1 '%s' (%04x:%08x#%x) type:%x\n",
1445 p_string(&sym
->thunk_v1
.p_name
),
1446 sym
->thunk_v1
.segment
, sym
->thunk_v1
.offset
,
1447 sym
->thunk_v1
.thunk_len
, sym
->thunk_v1
.thtype
);
1448 push_symbol_dumper(&sd
, sym
, sym
->thunk_v1
.pend
);
1452 printf("Thunk V3 '%s' (%04x:%08x#%x) type:%x\n",
1454 sym
->thunk_v3
.segment
, sym
->thunk_v3
.offset
,
1455 sym
->thunk_v3
.thunk_len
, sym
->thunk_v3
.thtype
);
1456 push_symbol_dumper(&sd
, sym
, sym
->thunk_v3
.pend
);
1459 /* Global and static functions */
1462 printf("%s-Proc V1: '%s' (%04x:%08x#%x) type:%x attr:%x\n",
1463 sym
->generic
.id
== S_GPROC32_16t
? "Global" : "Local",
1464 p_string(&sym
->proc_v1
.p_name
),
1465 sym
->proc_v1
.segment
, sym
->proc_v1
.offset
,
1466 sym
->proc_v1
.proc_len
, sym
->proc_v1
.proctype
,
1467 sym
->proc_v1
.flags
);
1468 printf("%*s\\- Debug: start=%08x end=%08x\n",
1469 indent
, "", sym
->proc_v1
.debug_start
, sym
->proc_v1
.debug_end
);
1470 printf("%*s\\- parent:<%x> end:<%x> next<%x>\n",
1471 indent
, "", sym
->proc_v1
.pparent
, sym
->proc_v1
.pend
, sym
->proc_v1
.next
);
1472 push_symbol_dumper(&sd
, sym
, sym
->proc_v1
.pend
);
1477 printf("%s-Proc V2: '%s' (%04x:%08x#%x) type:%x attr:%x\n",
1478 sym
->generic
.id
== S_GPROC32_ST
? "Global" : "Local",
1479 p_string(&sym
->proc_v2
.p_name
),
1480 sym
->proc_v2
.segment
, sym
->proc_v2
.offset
,
1481 sym
->proc_v2
.proc_len
, sym
->proc_v2
.proctype
,
1482 sym
->proc_v2
.flags
);
1483 printf("%*s\\- Debug: start=%08x end=%08x\n",
1484 indent
, "", sym
->proc_v2
.debug_start
, sym
->proc_v2
.debug_end
);
1485 printf("%*s\\- parent:<%x> end:<%x> next<%x>\n",
1486 indent
, "", sym
->proc_v2
.pparent
, sym
->proc_v2
.pend
, sym
->proc_v2
.next
);
1487 push_symbol_dumper(&sd
, sym
, sym
->proc_v2
.pend
);
1492 printf("%s-Procedure V3 '%s' (%04x:%08x#%x) type:%x attr:%x\n",
1493 sym
->generic
.id
== S_GPROC32
? "Global" : "Local",
1495 sym
->proc_v3
.segment
, sym
->proc_v3
.offset
,
1496 sym
->proc_v3
.proc_len
, sym
->proc_v3
.proctype
,
1497 sym
->proc_v3
.flags
);
1498 printf("%*s\\- Debug: start=%08x end=%08x\n",
1499 indent
, "", sym
->proc_v3
.debug_start
, sym
->proc_v3
.debug_end
);
1500 printf("%*s\\- parent:<%x> end:<%x> next<%x>\n",
1501 indent
, "", sym
->proc_v3
.pparent
, sym
->proc_v3
.pend
, sym
->proc_v3
.next
);
1502 push_symbol_dumper(&sd
, sym
, sym
->proc_v3
.pend
);
1505 /* Function parameters and stack variables */
1507 printf("BP-relative V1: '%s' @%d type:%x\n",
1508 p_string(&sym
->stack_v1
.p_name
),
1509 sym
->stack_v1
.offset
, sym
->stack_v1
.symtype
);
1513 printf("BP-relative V2: '%s' @%d type:%x\n",
1514 p_string(&sym
->stack_v2
.p_name
),
1515 sym
->stack_v2
.offset
, sym
->stack_v2
.symtype
);
1519 printf("BP-relative V3: '%s' @%d type:%x\n",
1520 sym
->stack_v3
.name
, sym
->stack_v3
.offset
,
1521 sym
->stack_v3
.symtype
);
1525 printf("Reg-relative V3: '%s' @%d type:%x reg:%x\n",
1526 sym
->regrel_v3
.name
, sym
->regrel_v3
.offset
,
1527 sym
->regrel_v3
.symtype
, sym
->regrel_v3
.reg
);
1530 case S_REGISTER_16t
:
1531 printf("Register V1 '%s' type:%x register:%x\n",
1532 p_string(&sym
->register_v1
.p_name
),
1533 sym
->register_v1
.reg
, sym
->register_v1
.type
);
1537 printf("Register V2 '%s' type:%x register:%x\n",
1538 p_string(&sym
->register_v2
.p_name
),
1539 sym
->register_v2
.reg
, sym
->register_v2
.type
);
1543 printf("Register V3 '%s' type:%x register:%x\n",
1544 sym
->register_v3
.name
, sym
->register_v3
.reg
, sym
->register_v3
.type
);
1548 printf("Block V1 '%s' (%04x:%08x#%08x)\n",
1549 p_string(&sym
->block_v1
.p_name
),
1550 sym
->block_v1
.segment
, sym
->block_v1
.offset
,
1551 sym
->block_v1
.length
);
1552 push_symbol_dumper(&sd
, sym
, sym
->block_v1
.end
);
1556 printf("Block V3 '%s' (%04x:%08x#%08x) parent:<%u> end:<%x>\n",
1558 sym
->block_v3
.segment
, sym
->block_v3
.offset
, sym
->block_v3
.length
,
1559 sym
->block_v3
.parent
, sym
->block_v3
.end
);
1560 push_symbol_dumper(&sd
, sym
, sym
->block_v3
.end
);
1563 /* Additional function information */
1565 printf("Frame-Info V2: frame-size:%x unk2:%x unk3:%x saved-regs-sz:%x eh(%04x:%08x) flags:%08x\n",
1566 sym
->frame_info_v2
.sz_frame
,
1567 sym
->frame_info_v2
.unknown2
,
1568 sym
->frame_info_v2
.unknown3
,
1569 sym
->frame_info_v2
.sz_saved_regs
,
1570 sym
->frame_info_v2
.eh_sect
,
1571 sym
->frame_info_v2
.eh_offset
,
1572 sym
->frame_info_v2
.flags
);
1576 printf("Security Cookie V3 @%d unk:%x\n",
1577 sym
->security_cookie_v3
.offset
, sym
->security_cookie_v3
.unknown
);
1581 ref
= sd
.depth
? (const char*)sd
.stack
[sd
.depth
- 1].sym
- (const char*)root
: 0;
1582 switch (pop_symbol_dumper(&sd
, i
))
1586 printf("End-Of block <%x>\n", ref
);
1589 printf("End-Of <%x>\n", ref
);
1595 printf("Compile V1 machine:%s lang:%s _unk:%x '%s'\n",
1596 get_machine(sym
->compile_v1
.machine
),
1597 get_language(sym
->compile_v1
.flags
.language
),
1598 sym
->compile_v1
.flags
._dome
,
1599 p_string(&sym
->compile_v1
.p_name
));
1603 printf("Compile2-V2 lang:%s machine:%s _unk:%x front-end:%d.%d.%d back-end:%d.%d.%d '%s'\n",
1604 get_language(sym
->compile2_v2
.flags
.iLanguage
),
1605 get_machine(sym
->compile2_v2
.machine
),
1606 sym
->compile2_v2
.flags
._dome
,
1607 sym
->compile2_v2
.fe_major
, sym
->compile2_v2
.fe_minor
, sym
->compile2_v2
.fe_build
,
1608 sym
->compile2_v2
.be_major
, sym
->compile2_v2
.be_minor
, sym
->compile2_v2
.be_build
,
1609 p_string(&sym
->compile2_v2
.p_name
));
1611 const char* ptr
= sym
->compile2_v2
.p_name
.name
+ sym
->compile2_v2
.p_name
.namelen
;
1614 printf("%*s| %s => ", indent
, "", ptr
); ptr
+= strlen(ptr
) + 1;
1615 printf("%s\n", ptr
); ptr
+= strlen(ptr
) + 1;
1621 printf("Compile2-V3 lang:%s machine:%s _unk:%x front-end:%d.%d.%d back-end:%d.%d.%d '%s'\n",
1622 get_language(sym
->compile2_v3
.flags
.iLanguage
),
1623 get_machine(sym
->compile2_v3
.machine
),
1624 sym
->compile2_v3
.flags
._dome
,
1625 sym
->compile2_v3
.fe_major
, sym
->compile2_v3
.fe_minor
, sym
->compile2_v3
.fe_build
,
1626 sym
->compile2_v3
.be_major
, sym
->compile2_v3
.be_minor
, sym
->compile2_v3
.be_build
,
1627 sym
->compile2_v3
.name
);
1629 const char* ptr
= sym
->compile2_v3
.name
+ strlen(sym
->compile2_v3
.name
) + 1;
1632 printf("%*s| %s => ", indent
, "", ptr
); ptr
+= strlen(ptr
) + 1;
1633 printf("%s\n", ptr
); ptr
+= strlen(ptr
) + 1;
1639 printf("Compile3-V3 lang:%s machine:%s _unk:%x front-end:%d.%d.%d back-end:%d.%d.%d '%s'\n",
1640 get_language(sym
->compile3_v3
.flags
.iLanguage
),
1641 get_machine(sym
->compile3_v3
.machine
),
1642 sym
->compile3_v3
.flags
._dome
,
1643 sym
->compile3_v3
.fe_major
, sym
->compile3_v3
.fe_minor
, sym
->compile3_v3
.fe_build
,
1644 sym
->compile3_v3
.be_major
, sym
->compile3_v3
.be_minor
, sym
->compile3_v3
.be_build
,
1645 sym
->compile3_v3
.name
);
1650 const char* x1
= (const char*)sym
+ 4 + 1;
1653 printf("Tool conf V3\n");
1656 x2
= x1
+ strlen(x1
) + 1;
1658 printf("%*s| %s: %s\n", indent
, "", x1
, x2
);
1659 x1
= x2
+ strlen(x2
) + 1;
1665 printf("ObjName V3 sig:%x '%s'\n",
1666 sym
->objname_v3
.signature
, sym
->objname_v3
.name
);
1670 printf("ObjName V1 sig:%x '%s'\n",
1671 sym
->objname_v1
.signature
, p_string(&sym
->objname_v1
.p_name
));
1675 printf("Trampoline V3 kind:%u %04x:%08x#%x -> %04x:%08x\n",
1676 sym
->trampoline_v3
.trampType
,
1677 sym
->trampoline_v3
.sectThunk
,
1678 sym
->trampoline_v3
.offThunk
,
1679 sym
->trampoline_v3
.cbThunk
,
1680 sym
->trampoline_v3
.sectTarget
,
1681 sym
->trampoline_v3
.offTarget
);
1685 printf("Label V1 '%s' (%04x:%08x)\n",
1686 p_string(&sym
->label_v1
.p_name
),
1687 sym
->label_v1
.segment
, sym
->label_v1
.offset
);
1691 printf("Label V3 '%s' (%04x:%08x) flag:%x\n",
1692 sym
->label_v3
.name
, sym
->label_v3
.segment
,
1693 sym
->label_v3
.offset
, sym
->label_v3
.flags
);
1699 struct full_value fv
;
1701 vlen
= full_numeric_leaf(&fv
, &sym
->constant_v2
.cvalue
);
1702 printf("Constant V2 '%s' = %s type:%x\n",
1703 p_string(PSTRING(&sym
->constant_v2
.cvalue
, vlen
)),
1704 full_value_string(&fv
), sym
->constant_v2
.type
);
1711 struct full_value fv
;
1713 vlen
= full_numeric_leaf(&fv
, &sym
->constant_v3
.cvalue
);
1714 printf("Constant V3 '%s' = %s type:%x\n",
1715 (const char*)&sym
->constant_v3
.cvalue
+ vlen
,
1716 full_value_string(&fv
), sym
->constant_v3
.type
);
1721 printf("Udt V1 '%s': type:0x%x\n",
1722 p_string(&sym
->udt_v1
.p_name
), sym
->udt_v1
.type
);
1726 printf("Udt V2 '%s': type:0x%x\n",
1727 p_string(&sym
->udt_v2
.p_name
), sym
->udt_v2
.type
);
1731 printf("Udt V3 '%s': type:0x%x\n",
1732 sym
->udt_v3
.name
, sym
->udt_v3
.type
);
1735 * These are special, in that they are always followed by an
1736 * additional length-prefixed string which is *not* included
1737 * into the symbol length count. We need to skip it.
1740 printf("Procref V1 "); goto doaref
;
1742 printf("Dataref V1 "); goto doaref
;
1744 printf("L-Procref V1 "); goto doaref
;
1747 const struct p_string
* pname
;
1749 pname
= PSTRING(sym
, length
);
1750 length
+= (pname
->namelen
+ 1 + 3) & ~3;
1751 printf("%08x %08x %08x '%s'\n",
1752 ((const UINT
*)sym
)[1], ((const UINT
*)sym
)[2], ((const UINT
*)sym
)[3],
1758 /* simply skip it */
1762 printf("Search V1: (%04x:%08x)\n",
1763 sym
->ssearch_v1
.segment
, sym
->ssearch_v1
.offset
);
1767 printf("Section Info: seg=%04x ?=%04x rva=%08x size=%08x attr=%08x %s\n",
1768 *(const unsigned short*)((const char*)sym
+ 4),
1769 *(const unsigned short*)((const char*)sym
+ 6),
1770 *(const unsigned*)((const char*)sym
+ 8),
1771 *(const unsigned*)((const char*)sym
+ 12),
1772 *(const unsigned*)((const char*)sym
+ 16),
1773 (const char*)sym
+ 20);
1777 printf("SubSection Info: addr=%04x:%08x size=%08x attr=%08x %s\n",
1778 *(const unsigned short*)((const char*)sym
+ 16),
1779 *(const unsigned*)((const char*)sym
+ 12),
1780 *(const unsigned*)((const char*)sym
+ 4),
1781 *(const unsigned*)((const char*)sym
+ 8),
1782 (const char*)sym
+ 18);
1786 printf("EntryPoint: id=%x '%s'\n",
1787 *(const unsigned*)((const char*)sym
+ 4), (const char*)sym
+ 8);
1790 case S_LTHREAD32_16t
:
1791 case S_GTHREAD32_16t
:
1792 printf("Thread %s Var V1 '%s' seg=%04x offset=%08x type=%x\n",
1793 sym
->generic
.id
== S_LTHREAD32_16t
? "global" : "local",
1794 p_string(&sym
->thread_v1
.p_name
),
1795 sym
->thread_v1
.segment
, sym
->thread_v1
.offset
, sym
->thread_v1
.symtype
);
1798 case S_LTHREAD32_ST
:
1799 case S_GTHREAD32_ST
:
1800 printf("Thread %s Var V2 '%s' seg=%04x offset=%08x type=%x\n",
1801 sym
->generic
.id
== S_LTHREAD32_ST
? "global" : "local",
1802 p_string(&sym
->thread_v2
.p_name
),
1803 sym
->thread_v2
.segment
, sym
->thread_v2
.offset
, sym
->thread_v2
.symtype
);
1808 printf("Thread %s Var V3 '%s' seg=%04x offset=%08x type=%x\n",
1809 sym
->generic
.id
== S_LTHREAD32
? "global" : "local", sym
->thread_v3
.name
,
1810 sym
->thread_v3
.segment
, sym
->thread_v3
.offset
, sym
->thread_v3
.symtype
);
1814 printf("Local V3 '%s' type=%x flags=%s\n",
1815 sym
->local_v3
.name
, sym
->local_v3
.symtype
,
1816 get_varflags(sym
->local_v3
.varflags
));
1820 printf("DefRange dia:%x\n", sym
->defrange_v3
.program
);
1821 dump_defrange(&sym
->defrange_v3
.range
, get_last(sym
), indent
);
1823 case S_DEFRANGE_SUBFIELD
:
1824 printf("DefRange-subfield V3 dia:%x off-parent:%x\n",
1825 sym
->defrange_subfield_v3
.program
, sym
->defrange_subfield_v3
.offParent
);
1826 dump_defrange(&sym
->defrange_subfield_v3
.range
, get_last(sym
), indent
);
1828 case S_DEFRANGE_REGISTER
:
1829 printf("DefRange-register V3 reg:%x attr-unk:%x\n",
1830 sym
->defrange_register_v3
.reg
, sym
->defrange_register_v3
.attr
);
1831 dump_defrange(&sym
->defrange_register_v3
.range
, get_last(sym
), indent
);
1833 case S_DEFRANGE_FRAMEPOINTER_REL
:
1834 printf("DefRange-framepointer-rel V3 offFP:%x\n",
1835 sym
->defrange_frameptrrel_v3
.offFramePointer
);
1836 dump_defrange(&sym
->defrange_frameptrrel_v3
.range
, get_last(sym
), indent
);
1838 case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE
:
1839 printf("DefRange-framepointer-rel-fullscope V3 offFP:%x\n",
1840 sym
->defrange_frameptr_relfullscope_v3
.offFramePointer
);
1842 case S_DEFRANGE_SUBFIELD_REGISTER
:
1843 printf("DefRange-subfield-register V3 reg:%d attr-unk:%x off-parent:%x\n",
1844 sym
->defrange_subfield_register_v3
.reg
,
1845 sym
->defrange_subfield_register_v3
.attr
,
1846 sym
->defrange_subfield_register_v3
.offParent
);
1847 dump_defrange(&sym
->defrange_subfield_register_v3
.range
, get_last(sym
), indent
);
1849 case S_DEFRANGE_REGISTER_REL
:
1850 printf("DefRange-register-rel V3 reg:%x off-parent:%x off-BP:%x\n",
1851 sym
->defrange_registerrel_v3
.baseReg
, sym
->defrange_registerrel_v3
.offsetParent
,
1852 sym
->defrange_registerrel_v3
.offBasePointer
);
1853 dump_defrange(&sym
->defrange_registerrel_v3
.range
, get_last(sym
), indent
);
1856 case S_CALLSITEINFO
:
1857 printf("Call-site-info V3 %04x:%08x typeindex:%x\n",
1858 sym
->callsiteinfo_v3
.sect
, sym
->callsiteinfo_v3
.off
, sym
->callsiteinfo_v3
.typind
);
1862 printf("Build-info V3 item:%04x\n", sym
->build_info_v3
.itemid
);
1866 printf("Inline-site V3 parent:<%x> end:<%x> inlinee:%x\n",
1867 sym
->inline_site_v3
.pParent
, sym
->inline_site_v3
.pEnd
, sym
->inline_site_v3
.inlinee
);
1868 dump_binannot(sym
->inline_site_v3
.binaryAnnotations
, get_last(sym
), indent
);
1869 push_symbol_dumper(&sd
, sym
, sym
->inline_site_v3
.pEnd
);
1873 printf("Inline-site2 V3 parent:<%x> end:<%x> inlinee:%x #inv:%u\n",
1874 sym
->inline_site2_v3
.pParent
, sym
->inline_site2_v3
.pEnd
, sym
->inline_site2_v3
.inlinee
,
1875 sym
->inline_site2_v3
.invocations
);
1876 dump_binannot(sym
->inline_site2_v3
.binaryAnnotations
, get_last(sym
), indent
);
1877 push_symbol_dumper(&sd
, sym
, sym
->inline_site2_v3
.pEnd
);
1880 case S_INLINESITE_END
:
1881 ref
= sd
.depth
? (const char*)sd
.stack
[sd
.depth
- 1].sym
- (const char*)root
: 0;
1882 pop_symbol_dumper(&sd
, i
);
1883 printf("Inline-site-end <%x>\n", ref
);
1891 const unsigned* invoc
;
1894 if (sym
->generic
.id
== S_CALLERS
) tag
= "Callers";
1895 else if (sym
->generic
.id
== S_CALLEES
) tag
= "Callees";
1896 else tag
= "Inlinees";
1897 printf("%s V3 count:%u\n", tag
, sym
->function_list_v3
.count
);
1898 invoc
= (const unsigned*)&sym
->function_list_v3
.funcs
[sym
->function_list_v3
.count
];
1899 ninvoc
= (const unsigned*)get_last(sym
) - invoc
;
1901 for (i
= 0; i
< sym
->function_list_v3
.count
; ++i
)
1902 printf("%*s| func:%x invoc:%u\n",
1903 indent
, "", sym
->function_list_v3
.funcs
[i
], i
< ninvoc
? invoc
[i
] : 0);
1907 case S_HEAPALLOCSITE
:
1908 printf("Heap-alloc-site V3 %04x:%08x#%x type:%04x\n",
1909 sym
->heap_alloc_site_v3
.sect_idx
,
1910 sym
->heap_alloc_site_v3
.offset
,
1911 sym
->heap_alloc_site_v3
.inst_len
,
1912 sym
->heap_alloc_site_v3
.index
);
1916 printf("File-static V3 '%s' type:%04x modOff:%08x flags:%s\n",
1917 sym
->file_static_v3
.name
,
1918 sym
->file_static_v3
.typind
,
1919 sym
->file_static_v3
.modOffset
,
1920 get_varflags(sym
->file_static_v3
.varflags
));
1923 case S_UNAMESPACE_ST
:
1924 printf("UNameSpace V2 '%s'\n", p_string(&sym
->unamespace_v2
.pname
));
1928 printf("UNameSpace V3 '%s'\n", sym
->unamespace_v3
.name
);
1932 printf("SepCode V3 parent:<%x> end:<%x> separated:%04x:%08x (#%u) from %04x:%08x\n",
1933 sym
->sepcode_v3
.pParent
, sym
->sepcode_v3
.pEnd
,
1934 sym
->sepcode_v3
.sect
, sym
->sepcode_v3
.off
, sym
->sepcode_v3
.length
,
1935 sym
->sepcode_v3
.sectParent
, sym
->sepcode_v3
.offParent
);
1936 push_symbol_dumper(&sd
, sym
, sym
->sepcode_v3
.pEnd
);
1940 printf("Annotation V3 %04x:%08x\n",
1941 sym
->annotation_v3
.seg
, sym
->annotation_v3
.off
);
1943 const char* ptr
= sym
->annotation_v3
.rgsz
;
1944 const char* last
= ptr
+ sym
->annotation_v3
.csz
;
1945 for (; ptr
< last
; ptr
+= strlen(ptr
) + 1)
1946 printf("%*s| %s\n", indent
, "", ptr
);
1951 printf("PogoData V3 inv:%d dynCnt:%lld inst:%d staInst:%d\n",
1952 sym
->pogoinfo_v3
.invocations
, (long long)sym
->pogoinfo_v3
.dynCount
,
1953 sym
->pogoinfo_v3
.numInstrs
, sym
->pogoinfo_v3
.staInstLive
);
1957 printf("\n\t\t>>> Unsupported symbol-id %x sz=%d\n", sym
->generic
.id
, sym
->generic
.len
+ 2);
1958 dump_data((const void*)sym
, sym
->generic
.len
+ 2, " ");
1961 dispose_symbol_dumper(&sd
);
1965 void codeview_dump_linetab(const char* linetab
, BOOL pascal_str
, const char* pfx
)
1967 const char* ptr
= linetab
;
1968 int nfile
, nseg
, nline
;
1970 const unsigned int* filetab
;
1971 const unsigned int* lt_ptr
;
1972 const struct startend
* start
;
1974 nfile
= *(const short*)linetab
;
1975 filetab
= (const unsigned int*)(linetab
+ 2 * sizeof(short));
1976 printf("%s%d files with %d ???\n", pfx
, nfile
, *(const short*)(linetab
+ sizeof(short)));
1978 for (i
= 0; i
< nfile
; i
++)
1980 ptr
= linetab
+ filetab
[i
];
1981 nseg
= *(const short*)ptr
;
1982 ptr
+= 2 * sizeof(short);
1983 lt_ptr
= (const unsigned int*)ptr
;
1984 start
= (const struct startend
*)(lt_ptr
+ nseg
);
1987 * Now snarf the filename for all of the segments for this file.
1991 char filename
[MAX_PATH
];
1992 const struct p_string
* p_fn
;
1994 p_fn
= (const struct p_string
*)(start
+ nseg
);
1995 memset(filename
, 0, sizeof(filename
));
1996 memcpy(filename
, p_fn
->name
, p_fn
->namelen
);
1997 printf("%slines for file #%d/%d %s %d\n", pfx
, i
, nfile
, filename
, nseg
);
2000 printf("%slines for file #%d/%d %s %d\n", pfx
, i
, nfile
, (const char*)(start
+ nseg
), nseg
);
2002 for (j
= 0; j
< nseg
; j
++)
2004 ptr
= linetab
+ *lt_ptr
++;
2005 nline
= *(const short*)(ptr
+ 2);
2006 printf("%s %04x:%08x-%08x #%d\n",
2007 pfx
, *(const short*)(ptr
+ 0), start
[j
].start
, start
[j
].end
, nline
);
2009 for (k
= 0; k
< nline
; k
++)
2011 printf("%s %x %d\n",
2012 pfx
, ((const unsigned int*)ptr
)[k
],
2013 ((const unsigned short*)((const unsigned int*)ptr
+ nline
))[k
]);
2019 void codeview_dump_linetab2(const char* linetab
, DWORD size
, const PDB_STRING_TABLE
* strimage
, const char* pfx
)
2022 const struct CV_DebugSSubsectionHeader_t
* hdr
;
2023 const struct CV_DebugSSubsectionHeader_t
* next_hdr
;
2024 const struct CV_DebugSLinesHeader_t
* lines_hdr
;
2025 const struct CV_DebugSLinesFileBlockHeader_t
* files_hdr
;
2026 const struct CV_Column_t
* cols
;
2027 const struct CV_Checksum_t
* chksms
;
2028 const struct CV_InlineeSourceLine_t
* inlsrc
;
2029 const struct CV_InlineeSourceLineEx_t
* inlsrcex
;
2031 static const char* subsect_types
[] = /* starting at 0xf1 */
2033 "SYMBOLS", "LINES", "STRINGTABLE", "FILECHKSMS",
2034 "FRAMEDATA", "INLINEELINES", "CROSSSCOPEIMPORTS", "CROSSSCOPEEXPORTS",
2035 "IL_LINES", "FUNC_MDTOKEN_MAP", "TYPE_MDTOKEN_MAP", "MERGED_ASSEMBLYINPUT",
2038 hdr
= (const struct CV_DebugSSubsectionHeader_t
*)linetab
;
2039 while (CV_IS_INSIDE(hdr
, linetab
+ size
))
2041 next_hdr
= CV_RECORD_GAP(hdr
, hdr
->cbLen
);
2042 if (hdr
->type
& DEBUG_S_IGNORE
)
2044 printf("%s------ debug subsection <ignored>\n", pfx
);
2049 printf("%s------ debug subsection %s\n", pfx
,
2050 (hdr
->type
>= 0xf1 && hdr
->type
- 0xf1 < ARRAY_SIZE(subsect_types
)) ?
2051 subsect_types
[hdr
->type
- 0xf1] : "<<unknown>>");
2055 lines_hdr
= CV_RECORD_AFTER(hdr
);
2056 printf("%s block from %04x:%08x flags:%x size=%u\n",
2057 pfx
, lines_hdr
->segCon
, lines_hdr
->offCon
, lines_hdr
->flags
, lines_hdr
->cbCon
);
2058 files_hdr
= CV_RECORD_AFTER(lines_hdr
);
2059 /* FIXME: as of today partial coverage:
2060 * - only one files_hdr has been seen in PDB files
2061 * OTOH, MS github presents two different structures
2063 * - next files_hdr (depending on previous question, can be a void question)
2064 * is code correct ; what do MS and llvm do?
2066 while (CV_IS_INSIDE(files_hdr
, next_hdr
))
2068 const struct CV_Line_t
* lines
;
2069 printf("%s file=%u lines=%d size=%x\n", pfx
, files_hdr
->offFile
,
2070 files_hdr
->nLines
, files_hdr
->cbBlock
);
2071 lines
= CV_RECORD_AFTER(files_hdr
);
2072 cols
= (const struct CV_Column_t
*)&lines
[files_hdr
->nLines
];
2073 for (i
= 0; i
< files_hdr
->nLines
; i
++)
2075 printf("%s offset=%8x line=%d deltaLineEnd=%u %s",
2076 pfx
, lines
[i
].offset
, lines
[i
].linenumStart
, lines
[i
].deltaLineEnd
,
2077 lines
[i
].fStatement
? "statement" : "expression");
2078 if (lines_hdr
->flags
& CV_LINES_HAVE_COLUMNS
)
2079 printf(" cols[start=%u end=%u]",
2080 cols
[i
].offColumnStart
, cols
[i
].offColumnEnd
);
2083 if (lines_hdr
->flags
& CV_LINES_HAVE_COLUMNS
)
2084 files_hdr
= (const struct CV_DebugSLinesFileBlockHeader_t
*)&cols
[files_hdr
->nLines
];
2086 files_hdr
= (const struct CV_DebugSLinesFileBlockHeader_t
*)&lines
[files_hdr
->nLines
];
2089 case DEBUG_S_FILECHKSMS
:
2090 chksms
= CV_RECORD_AFTER(hdr
);
2091 while (CV_IS_INSIDE(chksms
, next_hdr
))
2093 const char* meth
[] = {"None", "MD5", "SHA1", "SHA256"};
2094 printf("%s %d] name=%s size=%u method=%s checksum=[",
2095 pfx
, (unsigned)((const char*)chksms
- (const char*)(hdr
+ 1)),
2096 pdb_get_string_table_entry(strimage
, chksms
->strOffset
),
2097 chksms
->size
, chksms
->method
< ARRAY_SIZE(meth
) ? meth
[chksms
->method
] : "<<unknown>>");
2098 for (i
= 0; i
< chksms
->size
; ++i
) printf("%02x", chksms
->checksum
[i
]);
2100 chksms
= CV_ALIGN(CV_RECORD_GAP(chksms
, chksms
->size
), 4);
2103 case DEBUG_S_INLINEELINES
:
2104 /* subsection starts with a DWORD signature */
2105 switch (*(DWORD
*)CV_RECORD_AFTER(hdr
))
2107 case CV_INLINEE_SOURCE_LINE_SIGNATURE
:
2108 inlsrc
= CV_RECORD_GAP(hdr
, sizeof(DWORD
));
2109 while (CV_IS_INSIDE(inlsrc
, next_hdr
))
2111 printf("%s inlinee=%x fileref=%d srcstart=%d\n",
2112 pfx
, inlsrc
->inlinee
, inlsrc
->fileId
, inlsrc
->sourceLineNum
);
2116 case CV_INLINEE_SOURCE_LINE_SIGNATURE_EX
:
2117 inlsrcex
= CV_RECORD_GAP(hdr
, sizeof(DWORD
));
2118 while (CV_IS_INSIDE(inlsrcex
, next_hdr
))
2120 printf("%s inlinee=%x fileref=%d srcstart=%d numExtraFiles=%d\n",
2121 pfx
, inlsrcex
->inlinee
, inlsrcex
->fileId
, inlsrcex
->sourceLineNum
,
2122 inlsrcex
->countOfExtraFiles
);
2123 inlsrcex
= CV_RECORD_GAP(inlsrcex
, inlsrcex
->countOfExtraFiles
* sizeof(inlsrcex
->extraFileId
[0]));
2127 printf("%sUnknown signature %x in INLINEELINES subsection\n", pfx
, *(UINT
*)CV_RECORD_AFTER(hdr
));
2132 dump_data(CV_RECORD_AFTER(hdr
), hdr
->cbLen
, pfx
);