winsock: Implement getnameinfo.
[wine] / dlls / dbghelp / mscvpdb.h
1 /*
2  * MS debug information definitions.
3  *
4  * Copyright (C) 1996 Eric Youngdale
5  * Copyright (C) 1999-2000 Ulrich Weigand
6  * Copyright (C) 2004 Eric Pouech
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /* MS has stored all its debug information in a set of structures
24  * which has been rather consistent across the years (ie you can grasp
25  * some continuity, and not so many drastic changes).
26  *
27  * A bit of history on the various formats
28  *      MSVC 1.0        PDB v1 (new format for debug info)
29  *      MSVC 2.0        Inclusion in link of debug info (PDB v2)
30  *      MSVC 5.0        Types are 24 bits (instead of 16 for <= 4.x)
31  *      MSVC x.0        PDB (change in internal streams layout)
32  *        
33  *      .DBG            Contains COFF, FPO and Codeview info
34  *      .PDB            New format for debug info (information is
35  *                      derived from Codeview information)
36  *      VCx0.PDB        x major MSVC number, stores types, while
37  *                      <project>.PDB stores symbols.
38  *
39  * Debug information can either be found in the debug section of a PE
40  * module (in something close to a .DBG file), or the debug section
41  * can actually refer to an external file, which can be in turn,
42  * either a .DBG or .PDB file. 
43  *
44  * Regarding PDB files:
45  * -------------------
46  * They are implemented as a set of internal files (as a small file
47  * system). The file is split into blocks, an internal file is made
48  * of a set of blocks. Internal files are accessed through
49  * numbers. For example, 
50  * 1/ is the ROOT (basic information on the file)
51  * 2/ is the Symbol information (global symbols, local variables...)
52  * 3/ is the Type internal file (each the symbols can have type
53  * information associated with it).
54  *
55  * Over the years, three formats existed for the PDB:
56  * - ?? was rather linked to 16 bit code (our support shall be rather
57  *   bad)
58  * - JG: it's the signature embedded in the file header. This format
59  *   has been used in MSVC 2.0 => 5.0.
60  * - DS: it's the signature embedded in the file header. It's the
61  *   current format supported my MS.
62  *
63  * Types internal stream
64  * ---------------------
65  * Types (from the Type internal file) have existed in three flavors
66  * (note that those flavors came as historical evolution, but there
67  * isn't a one to one link between types evolution and PDB formats'
68  * evolutions:
69  * - the first flavor (suffixed by V1 in this file), where the types
70  *   and subtypes are 16 bit entities; and where strings are in Pascal
71  *   format (first char is their length and are not 0 terminated) 
72  * - the second flavor (suffixed by V2) differs from first flavor with
73  *   types and subtypes as 32 bit entities. This forced some
74  *   reordering of fields in some types
75  * - the third flavor (suffixed by V3) differs from second flavor with
76  *   strings stored as C strings (ie are 0 terminated, instead of
77  *   length prefixed)
78  * The different flavors can coexist in the same file (is this really
79  * true ??)
80  * 
81  * For the evolution of types, the need of the second flavor was the
82  * number of types to be defined (limited to 0xFFFF, including the C
83  * basic types); the need of the third flavor is the increase of
84  * symbol size (to be greated than 256), which was likely needed for
85  * complex C++ types (nested + templates).
86  *
87  * It's somehow difficult to represent the layout of those types on
88  * disk because:
89  * - some integral values are stored as numeric leaf, which size is
90  *   variable depending on its value
91  * 
92  * Symbols internal stream
93  * -----------------------
94  * Here also we find three flavors (that we've suffixed with _V1, _V2
95  * and _V3) even if their evolution is closer to the evolution of
96  * types, they are not completely linked together.
97  */
98
99 #include "pshpack1.h"
100
101 /* ======================================== *
102  *             Type information
103  * ======================================== */
104
105 struct p_string
106 {
107     unsigned char               namelen;
108     char                        name[1];
109 };
110
111 union codeview_type
112 {
113     struct
114     {
115         unsigned short int      len;
116         short int               id;
117     } generic;
118
119     struct
120     {
121         unsigned short int      len;
122         short int               id;
123         short int               attribute;
124         short int               type;
125     } modifier_v1;
126
127     struct
128     {
129         unsigned short int      len;
130         short int               id;
131         int                     type;
132         short int               attribute;
133     } modifier_v2;
134
135     struct
136     {
137         unsigned short int      len;
138         short int               id;
139         short int               attribute;
140         short int               datatype;
141         struct p_string         p_name;
142     } pointer_v1;
143
144     struct
145     {
146         unsigned short int      len;
147         short int               id;
148         unsigned int            datatype;
149         unsigned int            attribute;
150         struct p_string         p_name;
151     } pointer_v2;
152
153     struct
154     {
155         unsigned short int      len;
156         short int               id;
157         unsigned char           nbits;
158         unsigned char           bitoff;
159         unsigned short          type;
160     } bitfield_v1;
161     
162     struct
163     {
164         unsigned short int      len;
165         short int               id;
166         unsigned int            type;
167         unsigned char           nbits;
168         unsigned char           bitoff;
169     } bitfield_v2;
170
171     struct
172     {
173         unsigned short int      len;
174         short int               id;
175         short int               elemtype;
176         short int               idxtype;
177         unsigned short int      arrlen;     /* numeric leaf */
178 #if 0
179         struct p_string         p_name;
180 #endif
181     } array_v1;
182
183     struct
184     {
185         unsigned short int      len;
186         short int               id;
187         unsigned int            elemtype;
188         unsigned int            idxtype;
189         unsigned short int      arrlen;    /* numeric leaf */
190 #if 0
191         struct p_string         p_name;
192 #endif
193     } array_v2;
194
195     struct
196     {
197         unsigned short int      len;
198         short int               id;
199         unsigned int            elemtype;
200         unsigned int            idxtype;
201         unsigned short int      arrlen;    /* numeric leaf */
202 #if 0
203         char                    name[1];
204 #endif
205     } array_v3;
206
207     struct
208     {
209         unsigned short int      len;
210         short int               id;
211         short int               n_element;
212         short int               fieldlist;
213         short int               property;
214         short int               derived;
215         short int               vshape;
216         unsigned short int      structlen;  /* numeric leaf */
217 #if 0
218         struct p_string         p_name;
219 #endif
220     } struct_v1;
221
222     struct
223     {
224         unsigned short int      len;
225         short int               id;
226         short int               n_element;
227         short int               property;
228         unsigned int            fieldlist;
229         unsigned int            derived;
230         unsigned int            vshape;
231         unsigned short int      structlen;  /* numeric leaf */
232 #if 0
233         struct p_string         p_name;
234 #endif
235     } struct_v2;
236
237     struct
238     {
239         unsigned short int      len;
240         short int               id;
241         short int               n_element;
242         short int               property;
243         unsigned int            fieldlist;
244         unsigned int            derived;
245         unsigned int            vshape;
246         unsigned short int      structlen;  /* numeric leaf */
247 #if 0
248         char                    name[1];
249 #endif
250     } struct_v3;
251
252     struct
253     {
254         unsigned short int      len;
255         short int               id;
256         short int               count;
257         short int               fieldlist;
258         short int               property;
259         unsigned short int      un_len;     /* numeric leaf */
260 #if 0
261         struct p_string         p_name;
262 #endif
263     } union_v1;
264
265     struct
266     {
267         unsigned short int      len;
268         short int               id;
269         short int               count;
270         short int               property;
271         unsigned int            fieldlist;
272         unsigned short int      un_len;     /* numeric leaf */
273 #if 0
274         struct p_string         p_name;
275 #endif
276     } union_v2;
277
278     struct
279     {
280         unsigned short int      len;
281         short int               id;
282         short int               count;
283         short int               property;
284         unsigned int            fieldlist;
285         unsigned short int      un_len;     /* numeric leaf */
286 #if 0
287         char                    name[1];
288 #endif
289     } union_v3;
290
291     struct
292     {
293         unsigned short int      len;
294         short int               id;
295         short int               count;
296         short int               type;
297         short int               field;
298         short int               property;
299         struct p_string         p_name;
300     } enumeration_v1;
301
302     struct
303     {
304         unsigned short int      len;
305         short int               id;
306         short int               count;
307         short int               property;
308         unsigned int            type;
309         unsigned int            field;
310         struct p_string         p_name;
311     } enumeration_v2;
312
313     struct
314     {
315         unsigned short int      len;
316         short int               id;
317         short int               count;
318         short int               property;
319         unsigned int            type;
320         unsigned int            field;
321         char                    name[1];
322     } enumeration_v3;
323
324     struct
325     {
326         unsigned short int      len;
327         short int               id;
328         unsigned char           list[1];
329     } fieldlist;
330
331     struct
332     {
333         unsigned short int      len;
334         short int               id;
335         unsigned short int      rvtype;
336         unsigned char           call;
337         unsigned char           reserved;
338         unsigned short int      params;
339         unsigned short int      arglist;
340     } procedure_v1;
341
342     struct
343     {
344         unsigned short int      len;
345         short int               id;
346         unsigned int            rvtype;
347         unsigned char           call;
348         unsigned char           reserved;
349         unsigned short int      params;
350         unsigned int            arglist;
351     } procedure_v2;
352
353     struct
354     {
355         unsigned short int      len;
356         short int               id;
357         unsigned short int      rvtype;
358         unsigned short int      class_type;
359         unsigned short int      this_type;
360         unsigned char           call;
361         unsigned char           reserved;
362         unsigned short int      params;
363         unsigned short int      arglist;
364         unsigned int            this_adjust;
365     } mfunction_v1;
366
367     struct
368     {
369         unsigned short int      len;
370         short int               id;
371         unsigned                unknown1; /* could be this_type ??? */
372         unsigned int            class_type;
373         unsigned int            rvtype;
374         unsigned char           call;
375         unsigned char           reserved;
376         unsigned short          params;
377         unsigned int            arglist;
378         unsigned int            this_adjust;
379     } mfunction_v2;
380 };
381
382 union codeview_fieldtype
383 {
384     struct
385     {
386         short int               id;
387     } generic;
388
389     struct
390     {
391         short int               id;
392         short int               type;
393         short int               attribute;
394         unsigned short int      offset;     /* numeric leaf */
395     } bclass_v1;
396
397     struct
398     {
399         short int               id;
400         short int               attribute;
401         unsigned int            type;
402         unsigned short int      offset;     /* numeric leaf */
403     } bclass_v2;
404
405     struct
406     {
407         short int               id;
408         short int               btype;
409         short int               vbtype;
410         short int               attribute;
411         unsigned short int      vbpoff;     /* numeric leaf */
412 #if 0
413         unsigned short int      vboff;      /* numeric leaf */
414 #endif
415     } vbclass_v1;
416
417     struct
418     {
419         short int               id;
420         short int               attribute;
421         unsigned int            btype;
422         unsigned int            vbtype;
423         unsigned short int      vbpoff;     /* numeric leaf */
424 #if 0
425         unsigned short int      vboff;      /* numeric leaf */
426 #endif
427     } vbclass_v2;
428
429     struct
430     {
431         short int               id;
432         short int               attribute;
433         unsigned short int      value;     /* numeric leaf */
434 #if 0
435         struct p_string         p_name;
436 #endif
437     } enumerate_v1;
438
439    struct
440     {
441         short int               id;
442         short int               attribute;
443         unsigned short int      value;     /* numeric leaf */
444 #if 0
445         char                    name[1];
446 #endif
447     } enumerate_v3;
448
449     struct
450     {
451         short int               id;
452         short int               type;
453         struct p_string         p_name;
454     } friendfcn_v1;
455
456     struct
457     {
458         short int               id;
459         short int               _pad0;
460         unsigned int            type;
461         struct p_string         p_name;
462     } friendfcn_v2;
463
464     struct
465     {
466         short int               id;
467         short int               type;
468         short int               attribute;
469         unsigned short int      offset;    /* numeric leaf */
470 #if 0
471         struct p_string         p_name;
472 #endif
473     } member_v1;
474
475     struct
476     {
477         short int               id;
478         short int               attribute;
479         unsigned int            type;
480         unsigned short int      offset;    /* numeric leaf */
481 #if 0
482         struct p_string         p_name;
483 #endif
484     } member_v2;
485
486     struct
487     {
488         short int               id;
489         short int               attribute;
490         unsigned int            type;
491         unsigned short int      offset; /* numeric leaf */
492 #if 0
493         unsigned char           name[1];
494 #endif
495     }
496     member_v3;
497
498     struct
499     {
500         short int               id;
501         short int               type;
502         short int               attribute;
503         struct p_string         p_name;
504     } stmember_v1;
505
506     struct
507     {
508         short int               id;
509         short int               attribute;
510         unsigned int            type;
511         struct p_string         p_name;
512     } stmember_v2;
513
514     struct
515     {
516         short int               id;
517         short int               count;
518         short int               mlist;
519         struct p_string         p_name;
520     } method_v1;
521
522     struct
523     {
524         short int               id;
525         short int               count;
526         unsigned int            mlist;
527         struct p_string         p_name;
528     } method_v2;
529
530     struct
531     {
532         short int               id;
533         short int               index;
534         struct p_string         p_name;
535     } nesttype_v1;
536
537     struct
538     {
539         short int               id;
540         short int               _pad0;
541         unsigned int            index;
542         struct p_string         p_name;
543     } nesttype_v2;
544
545     struct
546     {
547         short int               id;
548         short int               type;
549     } vfunctab_v1;
550
551     struct
552     {
553         short int               id;
554         short int               _pad0;
555         unsigned int            type;
556     } vfunctab_v2;
557
558     struct
559     {
560         short int               id;
561         short int               type;
562     } friendcls_v1;
563
564     struct
565     {
566         short int               id;
567         short int               _pad0;
568         unsigned int            type;
569     } friendcls_v2;
570
571     struct
572     {
573         short int               id;
574         short int               attribute;
575         short int               type;
576         struct p_string         p_name;
577     } onemethod_v1;
578
579     struct
580     {
581         short int               id;
582         short int               attribute;
583         short int               type;
584         unsigned int            vtab_offset;
585         struct p_string         p_name;
586     } onemethod_virt_v1;
587
588     struct
589     {
590         short int               id;
591         short int               attribute;
592         unsigned int            type;
593         struct p_string         p_name;
594     } onemethod_v2;
595
596     struct
597     {
598         short int               id;
599         short int               attribute;
600         unsigned int            type;
601         unsigned int            vtab_offset;
602         struct p_string         p_name;
603     } onemethod_virt_v2;
604
605     struct
606     {
607         short int               id;
608         short int               type;
609         unsigned int            offset;
610     } vfuncoff_v1;
611
612     struct
613     {
614         short int               id;
615         short int               _pad0;
616         unsigned int            type;
617         unsigned int            offset;
618     } vfuncoff_v2;
619
620     struct
621     {
622         short int               id;
623         short int               attribute;
624         short int               index;
625         struct p_string         p_name;
626     } nesttypeex_v1;
627
628     struct
629     {
630         short int               id;
631         short int               attribute;
632         unsigned int            index;
633         struct p_string         p_name;
634     } nesttypeex_v2;
635
636     struct
637     {
638         short int               id;
639         short int               attribute;
640         unsigned int            type;
641         struct p_string         p_name;
642     } membermodify_v2;
643
644 };
645
646
647 /*
648  * This covers the basic datatypes that VC++ seems to be using these days.
649  * 32 bit mode only.  There are additional numbers for the pointers in 16
650  * bit mode.  There are many other types listed in the documents, but these
651  * are apparently not used by the compiler, or represent pointer types
652  * that are not used.
653  */
654 #define T_NOTYPE                0x0000  /* Notype */
655 #define T_ABS                   0x0001  /* Abs */
656 #define T_VOID                  0x0003  /* Void */
657 #define T_CHAR                  0x0010  /* signed char */
658 #define T_SHORT                 0x0011  /* short */
659 #define T_LONG                  0x0012  /* long */
660 #define T_QUAD                  0x0013  /* long long */
661 #define T_UCHAR                 0x0020  /* unsigned  char */
662 #define T_USHORT                0x0021  /* unsigned short */
663 #define T_ULONG                 0x0022  /* unsigned long */
664 #define T_UQUAD                 0x0023  /* unsigned long long */
665 #define T_REAL32                0x0040  /* float */
666 #define T_REAL64                0x0041  /* double */
667 #define T_RCHAR                 0x0070  /* real char */
668 #define T_WCHAR                 0x0071  /* wide char */
669 #define T_INT4                  0x0074  /* int */
670 #define T_UINT4                 0x0075  /* unsigned int */
671
672 #define T_32PVOID               0x0403  /* 32 bit near pointer to void */
673 #define T_32PCHAR               0x0410  /* 16:32 near pointer to signed char */
674 #define T_32PSHORT              0x0411  /* 16:32 near pointer to short */
675 #define T_32PLONG               0x0412  /* 16:32 near pointer to int */
676 #define T_32PQUAD               0x0413  /* 16:32 near pointer to long long */
677 #define T_32PUCHAR              0x0420  /* 16:32 near pointer to unsigned char */
678 #define T_32PUSHORT             0x0421  /* 16:32 near pointer to unsigned short */
679 #define T_32PULONG              0x0422  /* 16:32 near pointer to unsigned int */
680 #define T_32PUQUAD              0x0423  /* 16:32 near pointer to long long */
681 #define T_32PREAL32             0x0440  /* 16:32 near pointer to float */
682 #define T_32PREAL64             0x0441  /* 16:32 near pointer to float */
683 #define T_32PRCHAR              0x0470  /* 16:32 near pointer to real char */
684 #define T_32PWCHAR              0x0471  /* 16:32 near pointer to real char */
685 #define T_32PINT4               0x0474  /* 16:32 near pointer to int */
686 #define T_32PUINT4              0x0475  /* 16:32 near pointer to unsigned int */
687
688
689 #define LF_MODIFIER_V1          0x0001
690 #define LF_POINTER_V1           0x0002
691 #define LF_ARRAY_V1             0x0003
692 #define LF_CLASS_V1             0x0004
693 #define LF_STRUCTURE_V1         0x0005
694 #define LF_UNION_V1             0x0006
695 #define LF_ENUM_V1              0x0007
696 #define LF_PROCEDURE_V1         0x0008
697 #define LF_MFUNCTION_V1         0x0009
698 #define LF_VTSHAPE_V1           0x000a
699 #define LF_COBOL0_V1            0x000b
700 #define LF_COBOL1_V1            0x000c
701 #define LF_BARRAY_V1            0x000d
702 #define LF_LABEL_V1             0x000e
703 #define LF_NULL_V1              0x000f
704 #define LF_NOTTRAN_V1           0x0010
705 #define LF_DIMARRAY_V1          0x0011
706 #define LF_VFTPATH_V1           0x0012
707 #define LF_PRECOMP_V1           0x0013
708 #define LF_ENDPRECOMP_V1        0x0014
709 #define LF_OEM_V1               0x0015
710 #define LF_TYPESERVER_V1        0x0016
711
712 #define LF_MODIFIER_V2          0x1001     /* variants with new 32-bit type indices (V2) */
713 #define LF_POINTER_V2           0x1002
714 #define LF_ARRAY_V2             0x1003
715 #define LF_CLASS_V2             0x1004
716 #define LF_STRUCTURE_V2         0x1005
717 #define LF_UNION_V2             0x1006
718 #define LF_ENUM_V2              0x1007
719 #define LF_PROCEDURE_V2         0x1008
720 #define LF_MFUNCTION_V2         0x1009
721 #define LF_COBOL0_V2            0x100a
722 #define LF_BARRAY_V2            0x100b
723 #define LF_DIMARRAY_V2          0x100c
724 #define LF_VFTPATH_V2           0x100d
725 #define LF_PRECOMP_V2           0x100e
726 #define LF_OEM_V2               0x100f
727
728 #define LF_SKIP_V1              0x0200
729 #define LF_ARGLIST_V1           0x0201
730 #define LF_DEFARG_V1            0x0202
731 #define LF_LIST_V1              0x0203
732 #define LF_FIELDLIST_V1         0x0204
733 #define LF_DERIVED_V1           0x0205
734 #define LF_BITFIELD_V1          0x0206
735 #define LF_METHODLIST_V1        0x0207
736 #define LF_DIMCONU_V1           0x0208
737 #define LF_DIMCONLU_V1          0x0209
738 #define LF_DIMVARU_V1           0x020a
739 #define LF_DIMVARLU_V1          0x020b
740 #define LF_REFSYM_V1            0x020c
741
742 #define LF_SKIP_V2              0x1200    /* variants with new 32-bit type indices (V2) */
743 #define LF_ARGLIST_V2           0x1201
744 #define LF_DEFARG_V2            0x1202
745 #define LF_FIELDLIST_V2         0x1203
746 #define LF_DERIVED_V2           0x1204
747 #define LF_BITFIELD_V2          0x1205
748 #define LF_METHODLIST_V2        0x1206
749 #define LF_DIMCONU_V2           0x1207
750 #define LF_DIMCONLU_V2          0x1208
751 #define LF_DIMVARU_V2           0x1209
752 #define LF_DIMVARLU_V2          0x120a
753
754 /* Field lists */
755 #define LF_BCLASS_V1            0x0400
756 #define LF_VBCLASS_V1           0x0401
757 #define LF_IVBCLASS_V1          0x0402
758 #define LF_ENUMERATE_V1         0x0403
759 #define LF_FRIENDFCN_V1         0x0404
760 #define LF_INDEX_V1             0x0405
761 #define LF_MEMBER_V1            0x0406
762 #define LF_STMEMBER_V1          0x0407
763 #define LF_METHOD_V1            0x0408
764 #define LF_NESTTYPE_V1          0x0409
765 #define LF_VFUNCTAB_V1          0x040a
766 #define LF_FRIENDCLS_V1         0x040b
767 #define LF_ONEMETHOD_V1         0x040c
768 #define LF_VFUNCOFF_V1          0x040d
769 #define LF_NESTTYPEEX_V1        0x040e
770 #define LF_MEMBERMODIFY_V1      0x040f
771
772 #define LF_BCLASS_V2            0x1400    /* variants with new 32-bit type indices (V2) */
773 #define LF_VBCLASS_V2           0x1401
774 #define LF_IVBCLASS_V2          0x1402
775 #define LF_FRIENDFCN_V2         0x1403
776 #define LF_INDEX_V2             0x1404
777 #define LF_MEMBER_V2            0x1405
778 #define LF_STMEMBER_V2          0x1406
779 #define LF_METHOD_V2            0x1407
780 #define LF_NESTTYPE_V2          0x1408
781 #define LF_VFUNCTAB_V2          0x1409
782 #define LF_FRIENDCLS_V2         0x140a
783 #define LF_ONEMETHOD_V2         0x140b
784 #define LF_VFUNCOFF_V2          0x140c
785 #define LF_NESTTYPEEX_V2        0x140d
786
787 #define LF_ENUMERATE_V3         0x1502
788 #define LF_ARRAY_V3             0x1503
789 #define LF_CLASS_V3             0x1504
790 #define LF_STRUCTURE_V3         0x1505
791 #define LF_UNION_V3             0x1506
792 #define LF_ENUM_V3              0x1507
793 #define LF_MEMBER_V3            0x150d
794
795 #define LF_NUMERIC              0x8000    /* numeric leaf types */
796 #define LF_CHAR                 0x8000
797 #define LF_SHORT                0x8001
798 #define LF_USHORT               0x8002
799 #define LF_LONG                 0x8003
800 #define LF_ULONG                0x8004
801 #define LF_REAL32               0x8005
802 #define LF_REAL64               0x8006
803 #define LF_REAL80               0x8007
804 #define LF_REAL128              0x8008
805 #define LF_QUADWORD             0x8009
806 #define LF_UQUADWORD            0x800a
807 #define LF_REAL48               0x800b
808 #define LF_COMPLEX32            0x800c
809 #define LF_COMPLEX64            0x800d
810 #define LF_COMPLEX80            0x800e
811 #define LF_COMPLEX128           0x800f
812 #define LF_VARSTRING            0x8010
813
814 /* ======================================== *
815  *            Symbol information
816  * ======================================== */
817
818 union codeview_symbol
819 {
820     struct
821     {
822         short int               len;
823         short int               id;
824     } generic;
825
826     struct
827     {
828         short int               len;
829         short int               id;
830         unsigned int            offset;
831         unsigned short          segment;
832         unsigned short          symtype;
833         struct p_string         p_name;
834     } data_v1;
835
836     struct
837     {
838         short int               len;
839         short int               id;
840         unsigned int            symtype;
841         unsigned int            offset;
842         unsigned short          segment;
843         struct p_string         p_name;
844     } data_v2;
845
846     struct
847     {
848         short int               len;
849         short int               id;
850         unsigned int            symtype;
851         unsigned int            offset;
852         unsigned short          segment;
853         char                    name[1];
854     } data_v3;
855
856     struct
857     {
858         short int               len;
859         short int               id;
860         unsigned int            pparent;
861         unsigned int            pend;
862         unsigned int            next;
863         unsigned int            offset;
864         unsigned short          segment;
865         unsigned short          thunk_len;
866         unsigned char           thtype;
867         struct p_string         p_name;
868     } thunk_v1;
869
870     struct
871     {
872         short int               len;
873         short int               id;
874         unsigned int            pparent;
875         unsigned int            pend;
876         unsigned int            next;
877         unsigned int            offset;
878         unsigned short          segment;
879         unsigned short          thunk_len;
880         unsigned char           thtype;
881         char                    name[1];
882     } thunk_v3;
883
884     struct
885     {
886         short int               len;
887         short int               id;
888         unsigned int            pparent;
889         unsigned int            pend;
890         unsigned int            next;
891         unsigned int            proc_len;
892         unsigned int            debug_start;
893         unsigned int            debug_end;
894         unsigned int            offset;
895         unsigned short          segment;
896         unsigned short          proctype;
897         unsigned char           flags;
898         struct p_string         p_name;
899     } proc_v1;
900
901     struct
902     {
903         short int               len;
904         short int               id;
905         unsigned int            pparent;
906         unsigned int            pend;
907         unsigned int            next;
908         unsigned int            proc_len;
909         unsigned int            debug_start;
910         unsigned int            debug_end;
911         unsigned int            proctype;
912         unsigned int            offset;
913         unsigned short          segment;
914         unsigned char           flags;
915         struct p_string         p_name;
916     } proc_v2;
917
918     struct
919     {
920         short int               len;
921         short int               id;
922         unsigned int            pparent;
923         unsigned int            pend;
924         unsigned int            next;
925         unsigned int            proc_len;
926         unsigned int            debug_start;
927         unsigned int            debug_end;
928         unsigned int            proctype;
929         unsigned int            offset;
930         unsigned short          segment;
931         unsigned char           flags;
932         char                    name[1];
933     } proc_v3;
934
935     struct
936     {
937         short int               len;            /* Total length of this entry */
938         short int               id;             /* Always S_BPREL_V1 */
939         unsigned int            offset;         /* Stack offset relative to BP */
940         unsigned short          symtype;
941         struct p_string         p_name;
942     } stack_v1;
943
944     struct
945     {
946         short int               len;            /* Total length of this entry */
947         short int               id;             /* Always S_BPREL_V2 */
948         unsigned int            offset;         /* Stack offset relative to EBP */
949         unsigned int            symtype;
950         struct p_string         p_name;
951     } stack_v2;
952
953     struct
954     {
955         short int               len;            /* Total length of this entry */
956         short int               id;             /* Always S_BPREL_V3 */
957         int                     offset;         /* Stack offset relative to BP */
958         unsigned int            symtype;
959         char                    name[1];
960     } stack_v3;
961
962     struct
963     {
964         short int               len;            /* Total length of this entry */
965         short int               id;             /* Always S_REGISTER */
966         unsigned short          type;
967         unsigned short          reg;
968         struct p_string         p_name;
969         /* don't handle register tracking */
970     } register_v1;
971
972     struct
973     {
974         short int               len;            /* Total length of this entry */
975         short int               id;             /* Always S_REGISTER_V2 */
976         unsigned int            type;           /* check whether type & reg are correct */
977         unsigned int            reg;
978         struct p_string         p_name;
979         /* don't handle register tracking */
980     } register_v2;
981
982     struct
983     {
984         short int               len;
985         short int               id;
986         unsigned int            parent;
987         unsigned int            end;
988         unsigned int            length;
989         unsigned int            offset;
990         unsigned short          segment;
991         struct p_string         p_name;
992     } block_v1;
993
994     struct
995     {
996         short int               len;
997         short int               id;
998         unsigned int            parent;
999         unsigned int            end;
1000         unsigned int            length;
1001         unsigned int            offset;
1002         unsigned short          segment;
1003         char                    name[1];
1004     } block_v3;
1005
1006     struct
1007     {
1008         short int               len;
1009         short int               id;
1010         unsigned int            offset;
1011         unsigned short          segment;
1012         unsigned char           flags;
1013         struct p_string         p_name;
1014     } label_v1;
1015
1016     struct
1017     {
1018         short int               len;
1019         short int               id;
1020         unsigned int            offset;
1021         unsigned short          segment;
1022         unsigned char           flags;
1023         char                    name[1];
1024     } label_v3;
1025
1026     struct
1027     {
1028         short int               len;
1029         short int               id;
1030         unsigned short          type;
1031         unsigned short          cvalue;         /* numeric leaf */
1032 #if 0
1033         struct p_string         p_name;
1034 #endif
1035     } constant_v1;
1036
1037     struct
1038     {
1039         short int               len;
1040         short int               id;
1041         unsigned                type;
1042         unsigned short          cvalue;         /* numeric leaf */
1043 #if 0
1044         struct p_string         p_name;
1045 #endif
1046     } constant_v2;
1047
1048     struct
1049     {
1050         short int               len;
1051         short int               id;
1052         unsigned                type;
1053         unsigned short          cvalue;
1054 #if 0
1055         char                    name[1];
1056 #endif
1057     } constant_v3;
1058
1059     struct
1060     {
1061         short int               len;
1062         short int               id;
1063         unsigned short          type;
1064         struct p_string         p_name;
1065     } udt_v1;
1066
1067     struct
1068     {
1069         short int               len;
1070         short int               id;
1071         unsigned                type;
1072         struct p_string         p_name;
1073     } udt_v2;
1074
1075     struct
1076     {
1077         short int               len;
1078         short int               id;
1079         unsigned int            type;
1080         char                    name[1];
1081     } udt_v3;
1082
1083     struct
1084     {
1085         short int               len;
1086         short int               id;
1087         unsigned int            unknown;
1088         struct p_string         p_name;
1089     } compiland_v1;
1090
1091     struct
1092     {
1093         short int               len;
1094         short int               id;
1095         unsigned                unknown1[4];
1096         unsigned short          unknown2;
1097         struct p_string         p_name;
1098     } compiland_v2;
1099
1100     struct
1101     {
1102         short int               len;
1103         short int               id;
1104         unsigned int            unknown;
1105         char                    name[1];
1106     } compiland_v3;
1107 };
1108
1109 #define S_COMPILAND_V1  0x0001
1110 #define S_REGISTER_V1   0x0002
1111 #define S_CONSTANT_V1   0x0003
1112 #define S_UDT_V1        0x0004
1113 #define S_SSEARCH_V1    0x0005
1114 #define S_END_V1        0x0006
1115 #define S_SKIP_V1       0x0007
1116 #define S_CVRESERVE_V1  0x0008
1117 #define S_OBJNAME_V1    0x0009
1118 #define S_ENDARG_V1     0x000a
1119 #define S_COBOLUDT_V1   0x000b
1120 #define S_MANYREG_V1    0x000c
1121 #define S_RETURN_V1     0x000d
1122 #define S_ENTRYTHIS_V1  0x000e
1123
1124 #define S_BPREL_V1      0x0200
1125 #define S_LDATA_V1      0x0201
1126 #define S_GDATA_V1      0x0202
1127 #define S_PUB_V1        0x0203
1128 #define S_LPROC_V1      0x0204
1129 #define S_GPROC_V1      0x0205
1130 #define S_THUNK_V1      0x0206
1131 #define S_BLOCK_V1      0x0207
1132 #define S_WITH_V1       0x0208
1133 #define S_LABEL_V1      0x0209
1134 #define S_CEXMODEL_V1   0x020a
1135 #define S_VFTPATH_V1    0x020b
1136 #define S_REGREL_V1     0x020c
1137 #define S_LTHREAD_V1    0x020d
1138 #define S_GTHREAD_V1    0x020e
1139
1140 #define S_PROCREF_V1    0x0400
1141 #define S_DATAREF_V1    0x0401
1142 #define S_ALIGN_V1      0x0402
1143 #define S_LPROCREF_V1   0x0403
1144
1145 #define S_REGISTER_V2   0x1001 /* Variants with new 32-bit type indices */
1146 #define S_CONSTANT_V2   0x1002
1147 #define S_UDT_V2        0x1003
1148 #define S_COBOLUDT_V2   0x1004
1149 #define S_MANYREG_V2    0x1005
1150 #define S_BPREL_V2      0x1006
1151 #define S_LDATA_V2      0x1007
1152 #define S_GDATA_V2      0x1008
1153 #define S_PUB_V2        0x1009
1154 #define S_LPROC_V2      0x100a
1155 #define S_GPROC_V2      0x100b
1156 #define S_VFTTABLE_V2   0x100c
1157 #define S_REGREL_V2     0x100d
1158 #define S_LTHREAD_V2    0x100e
1159 #define S_GTHREAD_V2    0x100f
1160 #if 0
1161 #define S_XXXXXXXXX_32  0x1012  /* seems linked to a function, content unknown */
1162 #endif
1163 #define S_COMPILAND_V2  0x1013
1164
1165 #define S_COMPILAND_V3  0x1101
1166 #define S_THUNK_V3      0x1102
1167 #define S_BLOCK_V3      0x1103
1168 #define S_LABEL_V3      0x1105
1169 #define S_CONSTANT_V3   0x1107
1170 #define S_UDT_V3        0x1108
1171 #define S_BPREL_V3      0x110B
1172 #define S_LDATA_V3      0x110C
1173 #define S_GDATA_V3      0x110D
1174 #define S_PUB_DATA_V3   0x110E
1175 #define S_LPROC_V3      0x110F
1176 #define S_GPROC_V3      0x1110
1177 #define S_MSTOOL_V3     0x1116  /* not really understood */
1178 #define S_PUB_FUNC1_V3  0x1125  /* didn't get the difference between the two */
1179 #define S_PUB_FUNC2_V3  0x1127
1180
1181 /* ======================================== *
1182  *          Line number information
1183  * ======================================== */
1184
1185 union any_size
1186 {
1187     const char*                 c;
1188     const unsigned char*        uc;
1189     const short*                s;
1190     const int*                  i;
1191     const unsigned int*         ui;
1192 };
1193
1194 struct startend
1195 {
1196     unsigned int                start;
1197     unsigned int                end;
1198 };
1199
1200 struct codeview_linetab
1201 {
1202     unsigned int                nline;
1203     unsigned int                segno;
1204     unsigned int                start;
1205     unsigned int                end;
1206     struct symt_compiland*      compiland;
1207     const unsigned short*       linetab;
1208     const unsigned int*         offtab;
1209 };
1210
1211
1212 /* ======================================== *
1213  *            PDB file information
1214  * ======================================== */
1215
1216
1217 struct PDB_FILE
1218 {
1219     DWORD               size;
1220     DWORD               unknown;
1221 };
1222
1223 struct PDB_JG_HEADER
1224 {
1225     CHAR                ident[40];
1226     DWORD               signature;
1227     DWORD               block_size;
1228     WORD                free_list;
1229     WORD                total_alloc;
1230     struct PDB_FILE     toc;
1231     WORD                toc_block[1];
1232 };
1233
1234 struct PDB_DS_HEADER
1235 {
1236     char                signature[32];
1237     DWORD               block_size;
1238     DWORD               unknown1;
1239     DWORD               num_pages;
1240     DWORD               toc_size;
1241     DWORD               unknown2;
1242     DWORD               toc_page;
1243 };
1244
1245 struct PDB_JG_TOC
1246 {
1247     DWORD               num_files;
1248     struct PDB_FILE     file[1];
1249 };
1250
1251 struct PDB_DS_TOC
1252 {
1253     DWORD               num_files;
1254     DWORD               file_size[1];
1255 };
1256
1257 struct PDB_JG_ROOT
1258 {
1259     DWORD               Version;
1260     DWORD               TimeDateStamp;
1261     DWORD               unknown;
1262     DWORD               cbNames;
1263     CHAR                names[1];
1264 };
1265
1266 struct PDB_DS_ROOT
1267 {
1268     DWORD               Version;
1269     DWORD               TimeDateStamp;
1270     DWORD               unknown;
1271     GUID                guid;
1272     DWORD               cbNames;
1273     CHAR                names[1];
1274 };
1275
1276 typedef struct _PDB_TYPES_OLD
1277 {
1278     DWORD       version;
1279     WORD        first_index;
1280     WORD        last_index;
1281     DWORD       type_size;
1282     WORD        file;
1283     WORD        pad;
1284 } PDB_TYPES_OLD, *PPDB_TYPES_OLD;
1285
1286 typedef struct _PDB_TYPES
1287 {
1288     DWORD       version;
1289     DWORD       type_offset;
1290     DWORD       first_index;
1291     DWORD       last_index;
1292     DWORD       type_size;
1293     WORD        file;
1294     WORD        pad;
1295     DWORD       hash_size;
1296     DWORD       hash_base;
1297     DWORD       hash_offset;
1298     DWORD       hash_len;
1299     DWORD       search_offset;
1300     DWORD       search_len;
1301     DWORD       unknown_offset;
1302     DWORD       unknown_len;
1303 } PDB_TYPES, *PPDB_TYPES;
1304
1305 typedef struct _PDB_SYMBOL_RANGE
1306 {
1307     WORD        segment;
1308     WORD        pad1;
1309     DWORD       offset;
1310     DWORD       size;
1311     DWORD       characteristics;
1312     WORD        index;
1313     WORD        pad2;
1314 } PDB_SYMBOL_RANGE, *PPDB_SYMBOL_RANGE;
1315
1316 typedef struct _PDB_SYMBOL_RANGE_EX
1317 {
1318     WORD        segment;
1319     WORD        pad1;
1320     DWORD       offset;
1321     DWORD       size;
1322     DWORD       characteristics;
1323     WORD        index;
1324     WORD        pad2;
1325     DWORD       timestamp;
1326     DWORD       unknown;
1327 } PDB_SYMBOL_RANGE_EX, *PPDB_SYMBOL_RANGE_EX;
1328
1329 typedef struct _PDB_SYMBOL_FILE
1330 {
1331     DWORD       unknown1;
1332     PDB_SYMBOL_RANGE range;
1333     WORD        flag;
1334     WORD        file;
1335     DWORD       symbol_size;
1336     DWORD       lineno_size;
1337     DWORD       unknown2;
1338     DWORD       nSrcFiles;
1339     DWORD       attribute;
1340     CHAR        filename[1];
1341 } PDB_SYMBOL_FILE, *PPDB_SYMBOL_FILE;
1342
1343 typedef struct _PDB_SYMBOL_FILE_EX
1344 {
1345     DWORD       unknown1;
1346     PDB_SYMBOL_RANGE_EX range;
1347     WORD        flag;
1348     WORD        file;
1349     DWORD       symbol_size;
1350     DWORD       lineno_size;
1351     DWORD       unknown2;
1352     DWORD       nSrcFiles;
1353     DWORD       attribute;
1354     DWORD       reserved[2];
1355     CHAR        filename[1];
1356 } PDB_SYMBOL_FILE_EX, *PPDB_SYMBOL_FILE_EX;
1357
1358 typedef struct _PDB_SYMBOL_SOURCE
1359 {
1360     WORD        nModules;
1361     WORD        nSrcFiles;
1362     WORD        table[1];
1363 } PDB_SYMBOL_SOURCE, *PPDB_SYMBOL_SOURCE;
1364
1365 typedef struct _PDB_SYMBOL_IMPORT
1366 {
1367     DWORD       unknown1;
1368     DWORD       unknown2;
1369     DWORD       TimeDateStamp;
1370     DWORD       nRequests;
1371     CHAR        filename[1];
1372 } PDB_SYMBOL_IMPORT, *PPDB_SYMBOL_IMPORT;
1373
1374 typedef struct _PDB_SYMBOLS_OLD
1375 {
1376     WORD        hash1_file;
1377     WORD        hash2_file;
1378     WORD        gsym_file;
1379     WORD        pad;
1380     DWORD       module_size;
1381     DWORD       offset_size;
1382     DWORD       hash_size;
1383     DWORD       srcmodule_size;
1384 } PDB_SYMBOLS_OLD, *PPDB_SYMBOLS_OLD;
1385
1386 typedef struct _PDB_SYMBOLS
1387 {
1388     DWORD       signature;
1389     DWORD       version;
1390     DWORD       unknown;
1391     DWORD       hash1_file;
1392     DWORD       hash2_file;
1393     DWORD       gsym_file;
1394     DWORD       module_size;
1395     DWORD       offset_size;
1396     DWORD       hash_size;
1397     DWORD       srcmodule_size;
1398     DWORD       pdbimport_size;
1399     DWORD       resvd[5];
1400 } PDB_SYMBOLS, *PPDB_SYMBOLS;
1401
1402 #include "poppack.h"
1403
1404 /* ----------------------------------------------
1405  * Information used for parsing
1406  * ---------------------------------------------- */
1407
1408 typedef struct
1409 {
1410     DWORD  from;
1411     DWORD  to;
1412 } OMAP_DATA;
1413
1414 struct msc_debug_info
1415 {
1416     struct module*              module;
1417     int                         nsect;
1418     const IMAGE_SECTION_HEADER* sectp;
1419     int                         nomap;
1420     const OMAP_DATA*            omapp;
1421     const BYTE*                 root;
1422 };
1423
1424 /* coff.c */
1425 extern BOOL coff_process_info(const struct msc_debug_info* msc_dbg);