mscvpdb.h: Update some definitions (constants, structures) with latest information...
[wine] / include / wine / 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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         short int               elemtype;
158         short int               idxtype;
159         unsigned short int      arrlen;     /* numeric leaf */
160 #if 0
161         struct p_string         p_name;
162 #endif
163     } array_v1;
164
165     struct
166     {
167         unsigned short int      len;
168         short int               id;
169         unsigned int            elemtype;
170         unsigned int            idxtype;
171         unsigned short int      arrlen;    /* numeric leaf */
172 #if 0
173         struct p_string         p_name;
174 #endif
175     } array_v2;
176
177     struct
178     {
179         unsigned short int      len;
180         short int               id;
181         unsigned int            elemtype;
182         unsigned int            idxtype;
183         unsigned short int      arrlen;    /* numeric leaf */
184 #if 0
185         char                    name[1];
186 #endif
187     } array_v3;
188
189     struct
190     {
191         unsigned short int      len;
192         short int               id;
193         short int               n_element;
194         short int               fieldlist;
195         short int               property;
196         short int               derived;
197         short int               vshape;
198         unsigned short int      structlen;  /* numeric leaf */
199 #if 0
200         struct p_string         p_name;
201 #endif
202     } struct_v1;
203
204     struct
205     {
206         unsigned short int      len;
207         short int               id;
208         short int               n_element;
209         short int               property;
210         unsigned int            fieldlist;
211         unsigned int            derived;
212         unsigned int            vshape;
213         unsigned short int      structlen;  /* numeric leaf */
214 #if 0
215         struct p_string         p_name;
216 #endif
217     } struct_v2;
218
219     struct
220     {
221         unsigned short int      len;
222         short int               id;
223         short int               n_element;
224         short int               property;
225         unsigned int            fieldlist;
226         unsigned int            derived;
227         unsigned int            vshape;
228         unsigned short int      structlen;  /* numeric leaf */
229 #if 0
230         char                    name[1];
231 #endif
232     } struct_v3;
233
234     struct
235     {
236         unsigned short int      len;
237         short int               id;
238         short int               count;
239         short int               fieldlist;
240         short int               property;
241         unsigned short int      un_len;     /* numeric leaf */
242 #if 0
243         struct p_string         p_name;
244 #endif
245     } union_v1;
246
247     struct
248     {
249         unsigned short int      len;
250         short int               id;
251         short int               count;
252         short int               property;
253         unsigned int            fieldlist;
254         unsigned short int      un_len;     /* numeric leaf */
255 #if 0
256         struct p_string         p_name;
257 #endif
258     } union_v2;
259
260     struct
261     {
262         unsigned short int      len;
263         short int               id;
264         short int               count;
265         short int               property;
266         unsigned int            fieldlist;
267         unsigned short int      un_len;     /* numeric leaf */
268 #if 0
269         char                    name[1];
270 #endif
271     } union_v3;
272
273     struct
274     {
275         unsigned short int      len;
276         short int               id;
277         short int               count;
278         short int               type;
279         short int               fieldlist;
280         short int               property;
281         struct p_string         p_name;
282     } enumeration_v1;
283
284     struct
285     {
286         unsigned short int      len;
287         short int               id;
288         short int               count;
289         short int               property;
290         unsigned int            type;
291         unsigned int            fieldlist;
292         struct p_string         p_name;
293     } enumeration_v2;
294
295     struct
296     {
297         unsigned short int      len;
298         short int               id;
299         short int               count;
300         short int               property;
301         unsigned int            type;
302         unsigned int            fieldlist;
303         char                    name[1];
304     } enumeration_v3;
305
306     struct
307     {
308         unsigned short int      len;
309         short int               id;
310         unsigned short int      rvtype;
311         unsigned char           call;
312         unsigned char           reserved;
313         unsigned short int      params;
314         unsigned short int      arglist;
315     } procedure_v1;
316
317     struct
318     {
319         unsigned short int      len;
320         short int               id;
321         unsigned int            rvtype;
322         unsigned char           call;
323         unsigned char           reserved;
324         unsigned short int      params;
325         unsigned int            arglist;
326     } procedure_v2;
327
328     struct
329     {
330         unsigned short int      len;
331         short int               id;
332         unsigned short int      rvtype;
333         unsigned short int      class_type;
334         unsigned short int      this_type;
335         unsigned char           call;
336         unsigned char           reserved;
337         unsigned short int      params;
338         unsigned short int      arglist;
339         unsigned int            this_adjust;
340     } mfunction_v1;
341
342     struct
343     {
344         unsigned short int      len;
345         short int               id;
346         unsigned                this_type;
347         unsigned int            class_type;
348         unsigned int            rvtype;
349         unsigned char           call;
350         unsigned char           reserved;
351         unsigned short          params;
352         unsigned int            arglist;
353         unsigned int            this_adjust;
354     } mfunction_v2;
355 };
356
357 union codeview_reftype
358 {
359     struct
360     {
361         unsigned short int      len;
362         short int               id;
363     } generic;
364
365     struct
366     {
367         unsigned short int      len;
368         short int               id;
369         unsigned char           list[1];
370     } fieldlist;
371
372     struct
373     {
374         unsigned short int      len;
375         short int               id;
376         unsigned char           nbits;
377         unsigned char           bitoff;
378         unsigned short          type;
379     } bitfield_v1;
380
381     struct
382     {
383         unsigned short int      len;
384         short int               id;
385         unsigned int            type;
386         unsigned char           nbits;
387         unsigned char           bitoff;
388     } bitfield_v2;
389
390     struct
391     {
392         unsigned short int      len;
393         short int               id;
394         unsigned short          num;
395         unsigned short          args[1];
396     } arglist_v1;
397
398     struct
399     {
400         unsigned short int      len;
401         short int               id;
402         unsigned                num;
403         unsigned                args[1];
404     } arglist_v2;
405
406 };
407
408 union codeview_fieldtype
409 {
410     struct
411     {
412         short int               id;
413     } generic;
414
415     struct
416     {
417         short int               id;
418         short int               type;
419         short int               attribute;
420         unsigned short int      offset;     /* numeric leaf */
421     } bclass_v1;
422
423     struct
424     {
425         short int               id;
426         short int               attribute;
427         unsigned int            type;
428         unsigned short int      offset;     /* numeric leaf */
429     } bclass_v2;
430
431     struct
432     {
433         short int               id;
434         short int               btype;
435         short int               vbtype;
436         short int               attribute;
437         unsigned short int      vbpoff;     /* numeric leaf */
438 #if 0
439         unsigned short int      vboff;      /* numeric leaf */
440 #endif
441     } vbclass_v1;
442
443     struct
444     {
445         short int               id;
446         short int               attribute;
447         unsigned int            btype;
448         unsigned int            vbtype;
449         unsigned short int      vbpoff;     /* numeric leaf */
450 #if 0
451         unsigned short int      vboff;      /* numeric leaf */
452 #endif
453     } vbclass_v2;
454
455     struct
456     {
457         short int               id;
458         short int               attribute;
459         unsigned short int      value;     /* numeric leaf */
460 #if 0
461         struct p_string         p_name;
462 #endif
463     } enumerate_v1;
464
465    struct
466     {
467         short int               id;
468         short int               attribute;
469         unsigned short int      value;     /* numeric leaf */
470 #if 0
471         char                    name[1];
472 #endif
473     } enumerate_v3;
474
475     struct
476     {
477         short int               id;
478         short int               type;
479         struct p_string         p_name;
480     } friendfcn_v1;
481
482     struct
483     {
484         short int               id;
485         short int               _pad0;
486         unsigned int            type;
487         struct p_string         p_name;
488     } friendfcn_v2;
489
490     struct
491     {
492         short int               id;
493         short int               type;
494         short int               attribute;
495         unsigned short int      offset;    /* numeric leaf */
496 #if 0
497         struct p_string         p_name;
498 #endif
499     } member_v1;
500
501     struct
502     {
503         short int               id;
504         short int               attribute;
505         unsigned int            type;
506         unsigned short int      offset;    /* numeric leaf */
507 #if 0
508         struct p_string         p_name;
509 #endif
510     } member_v2;
511
512     struct
513     {
514         short int               id;
515         short int               attribute;
516         unsigned int            type;
517         unsigned short int      offset; /* numeric leaf */
518 #if 0
519         unsigned char           name[1];
520 #endif
521     }
522     member_v3;
523
524     struct
525     {
526         short int               id;
527         short int               type;
528         short int               attribute;
529         struct p_string         p_name;
530     } stmember_v1;
531
532     struct
533     {
534         short int               id;
535         short int               attribute;
536         unsigned int            type;
537         struct p_string         p_name;
538     } stmember_v2;
539
540     struct
541     {
542         short int               id;
543         short int               attribute;
544         unsigned int            type;
545         char                    name[1];
546     } stmember_v3;
547
548     struct
549     {
550         short int               id;
551         short int               count;
552         short int               mlist;
553         struct p_string         p_name;
554     } method_v1;
555
556     struct
557     {
558         short int               id;
559         short int               count;
560         unsigned int            mlist;
561         struct p_string         p_name;
562     } method_v2;
563
564     struct
565     {
566         short int               id;
567         short int               count;
568         unsigned int            mlist;
569         char                    name[1];
570     } method_v3;
571
572     struct
573     {
574         short int               id;
575         short int               type;
576         struct p_string         p_name;
577     } nesttype_v1;
578
579     struct
580     {
581         short int               id;
582         short int               _pad0;
583         unsigned int            type;
584         struct p_string         p_name;
585     } nesttype_v2;
586
587     struct
588     {
589         short int               id;
590         short int               _pad0;
591         unsigned int            type;
592         char                    name[1];
593     } nesttype_v3;
594
595     struct
596     {
597         short int               id;
598         short int               type;
599     } vfunctab_v1;
600
601     struct
602     {
603         short int               id;
604         short int               _pad0;
605         unsigned int            type;
606     } vfunctab_v2;
607
608     struct
609     {
610         short int               id;
611         short int               type;
612     } friendcls_v1;
613
614     struct
615     {
616         short int               id;
617         short int               _pad0;
618         unsigned int            type;
619     } friendcls_v2;
620
621     struct
622     {
623         short int               id;
624         short int               attribute;
625         short int               type;
626         struct p_string         p_name;
627     } onemethod_v1;
628
629     struct
630     {
631         short int               id;
632         short int               attribute;
633         unsigned int            type;
634         struct p_string         p_name;
635     } onemethod_v2;
636
637     struct
638     {
639         short int               id;
640         short int               attribute;
641         unsigned int            type;
642         char                    name[1];
643     } onemethod_v3;
644
645     struct
646     {
647         short int               id;
648         short int               attribute;
649         short int               type;
650         unsigned int            vtab_offset;
651         struct p_string         p_name;
652     } onemethod_virt_v1;
653
654     struct
655     {
656         short int               id;
657         short int               attribute;
658         unsigned int            type;
659         unsigned int            vtab_offset;
660         struct p_string         p_name;
661     } onemethod_virt_v2;
662
663     struct
664     {
665         short int               id;
666         short int               attribute;
667         unsigned int            type;
668         unsigned int            vtab_offset;
669         char                    name[1];
670     } onemethod_virt_v3;
671
672     struct
673     {
674         short int               id;
675         short int               type;
676         unsigned int            offset;
677     } vfuncoff_v1;
678
679     struct
680     {
681         short int               id;
682         short int               _pad0;
683         unsigned int            type;
684         unsigned int            offset;
685     } vfuncoff_v2;
686
687     struct
688     {
689         short int               id;
690         short int               attribute;
691         short int               type;
692         struct p_string         p_name;
693     } nesttypeex_v1;
694
695     struct
696     {
697         short int               id;
698         short int               attribute;
699         unsigned int            type;
700         struct p_string         p_name;
701     } nesttypeex_v2;
702
703     struct
704     {
705         short int               id;
706         short int               attribute;
707         unsigned int            type;
708         struct p_string         p_name;
709     } membermodify_v2;
710
711 };
712
713
714 /*
715  * This covers the basic datatypes that VC++ seems to be using these days.
716  * 32 bit mode only.  There are additional numbers for the pointers in 16
717  * bit mode.  There are many other types listed in the documents, but these
718  * are apparently not used by the compiler, or represent pointer types
719  * that are not used.
720  */
721 #define T_NOTYPE                0x0000  /* Notype */
722 #define T_ABS                   0x0001  /* Abs */
723 #define T_VOID                  0x0003  /* Void */
724 #define T_CHAR                  0x0010  /* signed char */
725 #define T_SHORT                 0x0011  /* short */
726 #define T_LONG                  0x0012  /* long */
727 #define T_QUAD                  0x0013  /* long long */
728 #define T_UCHAR                 0x0020  /* unsigned  char */
729 #define T_USHORT                0x0021  /* unsigned short */
730 #define T_ULONG                 0x0022  /* unsigned long */
731 #define T_UQUAD                 0x0023  /* unsigned long long */
732 #define T_REAL32                0x0040  /* float */
733 #define T_REAL64                0x0041  /* double */
734 #define T_RCHAR                 0x0070  /* real char */
735 #define T_WCHAR                 0x0071  /* wide char */
736 #define T_INT4                  0x0074  /* int */
737 #define T_UINT4                 0x0075  /* unsigned int */
738
739 #define T_32PVOID               0x0403  /* 32 bit near pointer to void */
740 #define T_32PCHAR               0x0410  /* 16:32 near pointer to signed char */
741 #define T_32PSHORT              0x0411  /* 16:32 near pointer to short */
742 #define T_32PLONG               0x0412  /* 16:32 near pointer to int */
743 #define T_32PQUAD               0x0413  /* 16:32 near pointer to long long */
744 #define T_32PUCHAR              0x0420  /* 16:32 near pointer to unsigned char */
745 #define T_32PUSHORT             0x0421  /* 16:32 near pointer to unsigned short */
746 #define T_32PULONG              0x0422  /* 16:32 near pointer to unsigned int */
747 #define T_32PUQUAD              0x0423  /* 16:32 near pointer to long long */
748 #define T_32PREAL32             0x0440  /* 16:32 near pointer to float */
749 #define T_32PREAL64             0x0441  /* 16:32 near pointer to float */
750 #define T_32PRCHAR              0x0470  /* 16:32 near pointer to real char */
751 #define T_32PWCHAR              0x0471  /* 16:32 near pointer to real char */
752 #define T_32PINT4               0x0474  /* 16:32 near pointer to int */
753 #define T_32PUINT4              0x0475  /* 16:32 near pointer to unsigned int */
754
755
756 #define LF_MODIFIER_V1          0x0001
757 #define LF_POINTER_V1           0x0002
758 #define LF_ARRAY_V1             0x0003
759 #define LF_CLASS_V1             0x0004
760 #define LF_STRUCTURE_V1         0x0005
761 #define LF_UNION_V1             0x0006
762 #define LF_ENUM_V1              0x0007
763 #define LF_PROCEDURE_V1         0x0008
764 #define LF_MFUNCTION_V1         0x0009
765 #define LF_VTSHAPE_V1           0x000a
766 #define LF_COBOL0_V1            0x000b
767 #define LF_COBOL1_V1            0x000c
768 #define LF_BARRAY_V1            0x000d
769 #define LF_LABEL_V1             0x000e
770 #define LF_NULL_V1              0x000f
771 #define LF_NOTTRAN_V1           0x0010
772 #define LF_DIMARRAY_V1          0x0011
773 #define LF_VFTPATH_V1           0x0012
774 #define LF_PRECOMP_V1           0x0013
775 #define LF_ENDPRECOMP_V1        0x0014
776 #define LF_OEM_V1               0x0015
777 #define LF_TYPESERVER_V1        0x0016
778
779 #define LF_MODIFIER_V2          0x1001     /* variants with new 32-bit type indices (V2) */
780 #define LF_POINTER_V2           0x1002
781 #define LF_ARRAY_V2             0x1003
782 #define LF_CLASS_V2             0x1004
783 #define LF_STRUCTURE_V2         0x1005
784 #define LF_UNION_V2             0x1006
785 #define LF_ENUM_V2              0x1007
786 #define LF_PROCEDURE_V2         0x1008
787 #define LF_MFUNCTION_V2         0x1009
788 #define LF_COBOL0_V2            0x100a
789 #define LF_BARRAY_V2            0x100b
790 #define LF_DIMARRAY_V2          0x100c
791 #define LF_VFTPATH_V2           0x100d
792 #define LF_PRECOMP_V2           0x100e
793 #define LF_OEM_V2               0x100f
794
795 #define LF_SKIP_V1              0x0200
796 #define LF_ARGLIST_V1           0x0201
797 #define LF_DEFARG_V1            0x0202
798 #define LF_LIST_V1              0x0203
799 #define LF_FIELDLIST_V1         0x0204
800 #define LF_DERIVED_V1           0x0205
801 #define LF_BITFIELD_V1          0x0206
802 #define LF_METHODLIST_V1        0x0207
803 #define LF_DIMCONU_V1           0x0208
804 #define LF_DIMCONLU_V1          0x0209
805 #define LF_DIMVARU_V1           0x020a
806 #define LF_DIMVARLU_V1          0x020b
807 #define LF_REFSYM_V1            0x020c
808
809 #define LF_SKIP_V2              0x1200    /* variants with new 32-bit type indices (V2) */
810 #define LF_ARGLIST_V2           0x1201
811 #define LF_DEFARG_V2            0x1202
812 #define LF_FIELDLIST_V2         0x1203
813 #define LF_DERIVED_V2           0x1204
814 #define LF_BITFIELD_V2          0x1205
815 #define LF_METHODLIST_V2        0x1206
816 #define LF_DIMCONU_V2           0x1207
817 #define LF_DIMCONLU_V2          0x1208
818 #define LF_DIMVARU_V2           0x1209
819 #define LF_DIMVARLU_V2          0x120a
820
821 /* Field lists */
822 #define LF_BCLASS_V1            0x0400
823 #define LF_VBCLASS_V1           0x0401
824 #define LF_IVBCLASS_V1          0x0402
825 #define LF_ENUMERATE_V1         0x0403
826 #define LF_FRIENDFCN_V1         0x0404
827 #define LF_INDEX_V1             0x0405
828 #define LF_MEMBER_V1            0x0406
829 #define LF_STMEMBER_V1          0x0407
830 #define LF_METHOD_V1            0x0408
831 #define LF_NESTTYPE_V1          0x0409
832 #define LF_VFUNCTAB_V1          0x040a
833 #define LF_FRIENDCLS_V1         0x040b
834 #define LF_ONEMETHOD_V1         0x040c
835 #define LF_VFUNCOFF_V1          0x040d
836 #define LF_NESTTYPEEX_V1        0x040e
837 #define LF_MEMBERMODIFY_V1      0x040f
838
839 #define LF_BCLASS_V2            0x1400    /* variants with new 32-bit type indices (V2) */
840 #define LF_VBCLASS_V2           0x1401
841 #define LF_IVBCLASS_V2          0x1402
842 #define LF_FRIENDFCN_V2         0x1403
843 #define LF_INDEX_V2             0x1404
844 #define LF_MEMBER_V2            0x1405
845 #define LF_STMEMBER_V2          0x1406
846 #define LF_METHOD_V2            0x1407
847 #define LF_NESTTYPE_V2          0x1408
848 #define LF_VFUNCTAB_V2          0x1409
849 #define LF_FRIENDCLS_V2         0x140a
850 #define LF_ONEMETHOD_V2         0x140b
851 #define LF_VFUNCOFF_V2          0x140c
852 #define LF_NESTTYPEEX_V2        0x140d
853
854 #define LF_ENUMERATE_V3         0x1502
855 #define LF_ARRAY_V3             0x1503
856 #define LF_CLASS_V3             0x1504
857 #define LF_STRUCTURE_V3         0x1505
858 #define LF_UNION_V3             0x1506
859 #define LF_ENUM_V3              0x1507
860 #define LF_MEMBER_V3            0x150d
861 #define LF_STMEMBER_V3          0x150e
862 #define LF_METHOD_V3            0x150f
863 #define LF_NESTTYPE_V3          0x1510
864 #define LF_ONEMETHOD_V3         0x1511
865
866 #define LF_NUMERIC              0x8000    /* numeric leaf types */
867 #define LF_CHAR                 0x8000
868 #define LF_SHORT                0x8001
869 #define LF_USHORT               0x8002
870 #define LF_LONG                 0x8003
871 #define LF_ULONG                0x8004
872 #define LF_REAL32               0x8005
873 #define LF_REAL64               0x8006
874 #define LF_REAL80               0x8007
875 #define LF_REAL128              0x8008
876 #define LF_QUADWORD             0x8009
877 #define LF_UQUADWORD            0x800a
878 #define LF_REAL48               0x800b
879 #define LF_COMPLEX32            0x800c
880 #define LF_COMPLEX64            0x800d
881 #define LF_COMPLEX80            0x800e
882 #define LF_COMPLEX128           0x800f
883 #define LF_VARSTRING            0x8010
884
885 /* ======================================== *
886  *            Symbol information
887  * ======================================== */
888
889 union codeview_symbol
890 {
891     struct
892     {
893         short int               len;
894         short int               id;
895     } generic;
896
897     struct
898     {
899         short int               len;
900         short int               id;
901         unsigned int            offset;
902         unsigned short          segment;
903         unsigned short          symtype;
904         struct p_string         p_name;
905     } data_v1;
906
907     struct
908     {
909         short int               len;
910         short int               id;
911         unsigned int            symtype;
912         unsigned int            offset;
913         unsigned short          segment;
914         struct p_string         p_name;
915     } data_v2;
916
917     struct
918     {
919         short int               len;
920         short int               id;
921         unsigned int            symtype;
922         unsigned int            offset;
923         unsigned short          segment;
924         char                    name[1];
925     } data_v3;
926
927     struct
928     {
929         short int               len;
930         short int               id;
931         unsigned int            pparent;
932         unsigned int            pend;
933         unsigned int            next;
934         unsigned int            offset;
935         unsigned short          segment;
936         unsigned short          thunk_len;
937         unsigned char           thtype;
938         struct p_string         p_name;
939     } thunk_v1;
940
941     struct
942     {
943         short int               len;
944         short int               id;
945         unsigned int            pparent;
946         unsigned int            pend;
947         unsigned int            next;
948         unsigned int            offset;
949         unsigned short          segment;
950         unsigned short          thunk_len;
951         unsigned char           thtype;
952         char                    name[1];
953     } thunk_v3;
954
955     struct
956     {
957         short int               len;
958         short int               id;
959         unsigned int            pparent;
960         unsigned int            pend;
961         unsigned int            next;
962         unsigned int            proc_len;
963         unsigned int            debug_start;
964         unsigned int            debug_end;
965         unsigned int            offset;
966         unsigned short          segment;
967         unsigned short          proctype;
968         unsigned char           flags;
969         struct p_string         p_name;
970     } proc_v1;
971
972     struct
973     {
974         short int               len;
975         short int               id;
976         unsigned int            pparent;
977         unsigned int            pend;
978         unsigned int            next;
979         unsigned int            proc_len;
980         unsigned int            debug_start;
981         unsigned int            debug_end;
982         unsigned int            proctype;
983         unsigned int            offset;
984         unsigned short          segment;
985         unsigned char           flags;
986         struct p_string         p_name;
987     } proc_v2;
988
989     struct
990     {
991         short int               len;
992         short int               id;
993         unsigned int            pparent;
994         unsigned int            pend;
995         unsigned int            next;
996         unsigned int            proc_len;
997         unsigned int            debug_start;
998         unsigned int            debug_end;
999         unsigned int            proctype;
1000         unsigned int            offset;
1001         unsigned short          segment;
1002         unsigned char           flags;
1003         char                    name[1];
1004     } proc_v3;
1005
1006     struct
1007     {
1008         short int               len;
1009         short int               id;
1010         unsigned int            symtype;
1011         unsigned int            offset;
1012         unsigned short          segment;
1013         struct p_string         p_name;
1014     } public_v2;
1015
1016     struct
1017     {
1018         short int               len;
1019         short int               id;
1020         unsigned int            symtype;
1021         unsigned int            offset;
1022         unsigned short          segment;
1023         char                    name[1];
1024     } public_v3;
1025
1026     struct
1027     {
1028         short int               len;            /* Total length of this entry */
1029         short int               id;             /* Always S_BPREL_V1 */
1030         unsigned int            offset;         /* Stack offset relative to BP */
1031         unsigned short          symtype;
1032         struct p_string         p_name;
1033     } stack_v1;
1034
1035     struct
1036     {
1037         short int               len;            /* Total length of this entry */
1038         short int               id;             /* Always S_BPREL_V2 */
1039         unsigned int            offset;         /* Stack offset relative to EBP */
1040         unsigned int            symtype;
1041         struct p_string         p_name;
1042     } stack_v2;
1043
1044     struct
1045     {
1046         short int               len;            /* Total length of this entry */
1047         short int               id;             /* Always S_BPREL_V3 */
1048         int                     offset;         /* Stack offset relative to BP */
1049         unsigned int            symtype;
1050         char                    name[1];
1051     } stack_v3;
1052
1053     struct
1054     {
1055         short int               len;            /* Total length of this entry */
1056         short int               id;             /* Always S_REGISTER */
1057         unsigned short          type;
1058         unsigned short          reg;
1059         struct p_string         p_name;
1060         /* don't handle register tracking */
1061     } register_v1;
1062
1063     struct
1064     {
1065         short int               len;            /* Total length of this entry */
1066         short int               id;             /* Always S_REGISTER_V2 */
1067         unsigned int            type;           /* check whether type & reg are correct */
1068         unsigned short          reg;
1069         struct p_string         p_name;
1070         /* don't handle register tracking */
1071     } register_v2;
1072
1073     struct
1074     {
1075         short int               len;            /* Total length of this entry */
1076         short int               id;             /* Always S_REGISTER_V3 */
1077         unsigned int            type;           /* check whether type & reg are correct */
1078         unsigned short          reg;
1079         char                    name[1];
1080         /* don't handle register tracking */
1081     } register_v3;
1082
1083     struct
1084     {
1085         short int               len;
1086         short int               id;
1087         unsigned int            parent;
1088         unsigned int            end;
1089         unsigned int            length;
1090         unsigned int            offset;
1091         unsigned short          segment;
1092         struct p_string         p_name;
1093     } block_v1;
1094
1095     struct
1096     {
1097         short int               len;
1098         short int               id;
1099         unsigned int            parent;
1100         unsigned int            end;
1101         unsigned int            length;
1102         unsigned int            offset;
1103         unsigned short          segment;
1104         char                    name[1];
1105     } block_v3;
1106
1107     struct
1108     {
1109         short int               len;
1110         short int               id;
1111         unsigned int            offset;
1112         unsigned short          segment;
1113         unsigned char           flags;
1114         struct p_string         p_name;
1115     } label_v1;
1116
1117     struct
1118     {
1119         short int               len;
1120         short int               id;
1121         unsigned int            offset;
1122         unsigned short          segment;
1123         unsigned char           flags;
1124         char                    name[1];
1125     } label_v3;
1126
1127     struct
1128     {
1129         short int               len;
1130         short int               id;
1131         unsigned short          type;
1132         unsigned short          cvalue;         /* numeric leaf */
1133 #if 0
1134         struct p_string         p_name;
1135 #endif
1136     } constant_v1;
1137
1138     struct
1139     {
1140         short int               len;
1141         short int               id;
1142         unsigned                type;
1143         unsigned short          cvalue;         /* numeric leaf */
1144 #if 0
1145         struct p_string         p_name;
1146 #endif
1147     } constant_v2;
1148
1149     struct
1150     {
1151         short int               len;
1152         short int               id;
1153         unsigned                type;
1154         unsigned short          cvalue;
1155 #if 0
1156         char                    name[1];
1157 #endif
1158     } constant_v3;
1159
1160     struct
1161     {
1162         short int               len;
1163         short int               id;
1164         unsigned short          type;
1165         struct p_string         p_name;
1166     } udt_v1;
1167
1168     struct
1169     {
1170         short int               len;
1171         short int               id;
1172         unsigned                type;
1173         struct p_string         p_name;
1174     } udt_v2;
1175
1176     struct
1177     {
1178         short int               len;
1179         short int               id;
1180         unsigned int            type;
1181         char                    name[1];
1182     } udt_v3;
1183
1184     struct
1185     {
1186         short int               len;
1187         short int               id;
1188         char                    signature[4];
1189         struct p_string         p_name;
1190     } objname_v1;
1191
1192     struct
1193     {
1194         short int               len;
1195         short int               id;
1196         unsigned int            unknown;
1197         struct p_string         p_name;
1198     } compiland_v1;
1199
1200     struct
1201     {
1202         short int               len;
1203         short int               id;
1204         unsigned                unknown1[4];
1205         unsigned short          unknown2;
1206         struct p_string         p_name;
1207     } compiland_v2;
1208
1209     struct
1210     {
1211         short int               len;
1212         short int               id;
1213         unsigned int            unknown;
1214         char                    name[1];
1215     } compiland_v3;
1216
1217     struct
1218     {
1219         short int               len;
1220         short int               id;
1221         unsigned int            offset;
1222         unsigned short          segment;
1223     } ssearch_v1;
1224 };
1225
1226 #define S_COMPILAND_V1  0x0001
1227 #define S_REGISTER_V1   0x0002
1228 #define S_CONSTANT_V1   0x0003
1229 #define S_UDT_V1        0x0004
1230 #define S_SSEARCH_V1    0x0005
1231 #define S_END_V1        0x0006
1232 #define S_SKIP_V1       0x0007
1233 #define S_CVRESERVE_V1  0x0008
1234 #define S_OBJNAME_V1    0x0009
1235 #define S_ENDARG_V1     0x000a
1236 #define S_COBOLUDT_V1   0x000b
1237 #define S_MANYREG_V1    0x000c
1238 #define S_RETURN_V1     0x000d
1239 #define S_ENTRYTHIS_V1  0x000e
1240
1241 #define S_BPREL_V1      0x0200
1242 #define S_LDATA_V1      0x0201
1243 #define S_GDATA_V1      0x0202
1244 #define S_PUB_V1        0x0203
1245 #define S_LPROC_V1      0x0204
1246 #define S_GPROC_V1      0x0205
1247 #define S_THUNK_V1      0x0206
1248 #define S_BLOCK_V1      0x0207
1249 #define S_WITH_V1       0x0208
1250 #define S_LABEL_V1      0x0209
1251 #define S_CEXMODEL_V1   0x020a
1252 #define S_VFTPATH_V1    0x020b
1253 #define S_REGREL_V1     0x020c
1254 #define S_LTHREAD_V1    0x020d
1255 #define S_GTHREAD_V1    0x020e
1256
1257 #define S_PROCREF_V1    0x0400
1258 #define S_DATAREF_V1    0x0401
1259 #define S_ALIGN_V1      0x0402
1260 #define S_LPROCREF_V1   0x0403
1261
1262 #define S_REGISTER_V2   0x1001 /* Variants with new 32-bit type indices */
1263 #define S_CONSTANT_V2   0x1002
1264 #define S_UDT_V2        0x1003
1265 #define S_COBOLUDT_V2   0x1004
1266 #define S_MANYREG_V2    0x1005
1267 #define S_BPREL_V2      0x1006
1268 #define S_LDATA_V2      0x1007
1269 #define S_GDATA_V2      0x1008
1270 #define S_PUB_V2        0x1009
1271 #define S_LPROC_V2      0x100a
1272 #define S_GPROC_V2      0x100b
1273 #define S_VFTTABLE_V2   0x100c
1274 #define S_REGREL_V2     0x100d
1275 #define S_LTHREAD_V2    0x100e
1276 #define S_GTHREAD_V2    0x100f
1277 #if 0
1278 #define S_XXXXXXXXX_32  0x1012  /* seems linked to a function, content unknown */
1279 #endif
1280 #define S_COMPILAND_V2  0x1013
1281
1282 #define S_COMPILAND_V3  0x1101
1283 #define S_THUNK_V3      0x1102
1284 #define S_BLOCK_V3      0x1103
1285 #define S_LABEL_V3      0x1105
1286 #define S_REGISTER_V3   0x1106
1287 #define S_CONSTANT_V3   0x1107
1288 #define S_UDT_V3        0x1108
1289 #define S_BPREL_V3      0x110B
1290 #define S_LDATA_V3      0x110C
1291 #define S_GDATA_V3      0x110D
1292 #define S_PUB_V3        0x110E
1293 #define S_LPROC_V3      0x110F
1294 #define S_GPROC_V3      0x1110
1295 #define S_MSTOOL_V3     0x1116  /* not really understood */
1296 #define S_PUB_FUNC1_V3  0x1125  /* didn't get the difference between the two */
1297 #define S_PUB_FUNC2_V3  0x1127
1298
1299 /* ======================================== *
1300  *          Line number information
1301  * ======================================== */
1302
1303 union any_size
1304 {
1305     const char*                 c;
1306     const unsigned char*        uc;
1307     const short*                s;
1308     const int*                  i;
1309     const unsigned int*         ui;
1310 };
1311
1312 struct startend
1313 {
1314     unsigned int                start;
1315     unsigned int                end;
1316 };
1317
1318 struct codeview_linetab
1319 {
1320     unsigned int                nline;
1321     unsigned int                segno;
1322     unsigned int                start;
1323     unsigned int                end;
1324     unsigned int                source;
1325     const unsigned short*       linetab;
1326     const unsigned int*         offtab;
1327 };
1328
1329
1330 /* ======================================== *
1331  *            PDB file information
1332  * ======================================== */
1333
1334
1335 struct PDB_FILE
1336 {
1337     DWORD               size;
1338     DWORD               unknown;
1339 };
1340
1341 struct PDB_JG_HEADER
1342 {
1343     CHAR                ident[40];
1344     DWORD               signature;
1345     DWORD               block_size;
1346     WORD                free_list;
1347     WORD                total_alloc;
1348     struct PDB_FILE     toc;
1349     WORD                toc_block[1];
1350 };
1351
1352 struct PDB_DS_HEADER
1353 {
1354     char                signature[32];
1355     DWORD               block_size;
1356     DWORD               unknown1;
1357     DWORD               num_pages;
1358     DWORD               toc_size;
1359     DWORD               unknown2;
1360     DWORD               toc_page;
1361 };
1362
1363 struct PDB_JG_TOC
1364 {
1365     DWORD               num_files;
1366     struct PDB_FILE     file[1];
1367 };
1368
1369 struct PDB_DS_TOC
1370 {
1371     DWORD               num_files;
1372     DWORD               file_size[1];
1373 };
1374
1375 struct PDB_JG_ROOT
1376 {
1377     DWORD               Version;
1378     DWORD               TimeDateStamp;
1379     DWORD               Age;
1380     DWORD               cbNames;
1381     CHAR                names[1];
1382 };
1383
1384 struct PDB_DS_ROOT
1385 {
1386     DWORD               Version;
1387     DWORD               TimeDateStamp;
1388     DWORD               Age;
1389     GUID                guid;
1390     DWORD               cbNames;
1391     CHAR                names[1];
1392 };
1393
1394 typedef struct _PDB_TYPES_OLD
1395 {
1396     DWORD       version;
1397     WORD        first_index;
1398     WORD        last_index;
1399     DWORD       type_size;
1400     WORD        file;
1401     WORD        pad;
1402 } PDB_TYPES_OLD, *PPDB_TYPES_OLD;
1403
1404 typedef struct _PDB_TYPES
1405 {
1406     DWORD       version;
1407     DWORD       type_offset;
1408     DWORD       first_index;
1409     DWORD       last_index;
1410     DWORD       type_size;
1411     WORD        file;
1412     WORD        pad;
1413     DWORD       hash_size;
1414     DWORD       hash_base;
1415     DWORD       hash_offset;
1416     DWORD       hash_len;
1417     DWORD       search_offset;
1418     DWORD       search_len;
1419     DWORD       unknown_offset;
1420     DWORD       unknown_len;
1421 } PDB_TYPES, *PPDB_TYPES;
1422
1423 typedef struct _PDB_SYMBOL_RANGE
1424 {
1425     WORD        segment;
1426     WORD        pad1;
1427     DWORD       offset;
1428     DWORD       size;
1429     DWORD       characteristics;
1430     WORD        index;
1431     WORD        pad2;
1432 } PDB_SYMBOL_RANGE, *PPDB_SYMBOL_RANGE;
1433
1434 typedef struct _PDB_SYMBOL_RANGE_EX
1435 {
1436     WORD        segment;
1437     WORD        pad1;
1438     DWORD       offset;
1439     DWORD       size;
1440     DWORD       characteristics;
1441     WORD        index;
1442     WORD        pad2;
1443     DWORD       timestamp;
1444     DWORD       unknown;
1445 } PDB_SYMBOL_RANGE_EX, *PPDB_SYMBOL_RANGE_EX;
1446
1447 typedef struct _PDB_SYMBOL_FILE
1448 {
1449     DWORD       unknown1;
1450     PDB_SYMBOL_RANGE range;
1451     WORD        flag;
1452     WORD        file;
1453     DWORD       symbol_size;
1454     DWORD       lineno_size;
1455     DWORD       unknown2;
1456     DWORD       nSrcFiles;
1457     DWORD       attribute;
1458     CHAR        filename[1];
1459 } PDB_SYMBOL_FILE, *PPDB_SYMBOL_FILE;
1460
1461 typedef struct _PDB_SYMBOL_FILE_EX
1462 {
1463     DWORD       unknown1;
1464     PDB_SYMBOL_RANGE_EX range;
1465     WORD        flag;
1466     WORD        file;
1467     DWORD       symbol_size;
1468     DWORD       lineno_size;
1469     DWORD       unknown2;
1470     DWORD       nSrcFiles;
1471     DWORD       attribute;
1472     DWORD       reserved[2];
1473     CHAR        filename[1];
1474 } PDB_SYMBOL_FILE_EX, *PPDB_SYMBOL_FILE_EX;
1475
1476 typedef struct _PDB_SYMBOL_SOURCE
1477 {
1478     WORD        nModules;
1479     WORD        nSrcFiles;
1480     WORD        table[1];
1481 } PDB_SYMBOL_SOURCE, *PPDB_SYMBOL_SOURCE;
1482
1483 typedef struct _PDB_SYMBOL_IMPORT
1484 {
1485     DWORD       unknown1;
1486     DWORD       unknown2;
1487     DWORD       TimeDateStamp;
1488     DWORD       Age;
1489     CHAR        filename[1];
1490 } PDB_SYMBOL_IMPORT, *PPDB_SYMBOL_IMPORT;
1491
1492 typedef struct _PDB_SYMBOLS_OLD
1493 {
1494     WORD        hash1_file;
1495     WORD        hash2_file;
1496     WORD        gsym_file;
1497     WORD        pad;
1498     DWORD       module_size;
1499     DWORD       offset_size;
1500     DWORD       hash_size;
1501     DWORD       srcmodule_size;
1502 } PDB_SYMBOLS_OLD, *PPDB_SYMBOLS_OLD;
1503
1504 typedef struct _PDB_SYMBOLS
1505 {
1506     DWORD       signature;
1507     DWORD       version;
1508     DWORD       unknown;
1509     DWORD       hash1_file;
1510     DWORD       hash2_file;
1511     DWORD       gsym_file;
1512     DWORD       module_size;
1513     DWORD       offset_size;
1514     DWORD       hash_size;
1515     DWORD       srcmodule_size;
1516     DWORD       pdbimport_size;
1517     DWORD       resvd[5];
1518 } PDB_SYMBOLS, *PPDB_SYMBOLS;
1519
1520 #include "poppack.h"
1521
1522 /* ----------------------------------------------
1523  * Information used for parsing
1524  * ---------------------------------------------- */
1525
1526 typedef struct
1527 {
1528     DWORD  from;
1529     DWORD  to;
1530 } OMAP_DATA;
1531
1532 struct msc_debug_info
1533 {
1534     struct module*              module;
1535     int                         nsect;
1536     const IMAGE_SECTION_HEADER* sectp;
1537     int                         nomap;
1538     const OMAP_DATA*            omapp;
1539     const BYTE*                 root;
1540 };
1541
1542 /* coff.c */
1543 extern BOOL coff_process_info(const struct msc_debug_info* msc_dbg);
1544
1545 /* ===================================================
1546  * The old CodeView stuff (for NB09 and NB11)
1547  * =================================================== */
1548
1549 #define sstModule      0x120
1550 #define sstTypes       0x121
1551 #define sstPublic      0x122
1552 #define sstPublicSym   0x123
1553 #define sstSymbols     0x124
1554 #define sstAlignSym    0x125
1555 #define sstSrcLnSeg    0x126
1556 #define sstSrcModule   0x127
1557 #define sstLibraries   0x128
1558 #define sstGlobalSym   0x129
1559 #define sstGlobalPub   0x12a
1560 #define sstGlobalTypes 0x12b
1561 #define sstMPC         0x12c
1562 #define sstSegMap      0x12d
1563 #define sstSegName     0x12e
1564 #define sstPreComp     0x12f
1565 #define sstFileIndex   0x133
1566 #define sstStaticSym   0x134
1567
1568 typedef struct _CODEVIEW_HEADER_NBxx
1569 {
1570     DWORD       dwSignature;
1571     DWORD       lfoDirectory;
1572 } CODEVIEW_HEADER_NBxx,* PCODEVIEW_HEADER_NBxx;
1573
1574 typedef struct _CODEVIEW_HEADER_RSDS
1575 {
1576     DWORD       dwSignature;
1577     GUID        guid;
1578     DWORD       unknown;
1579     CHAR        name[1];
1580 } CODEVIEW_HEADER_RSDS,* PCODEVIEW_HEADER_RSDS;
1581
1582 typedef struct _CODEVIEW_PDB_DATA
1583 {
1584     DWORD       timestamp;
1585     DWORD       unknown;
1586     CHAR        name[1];
1587 } CODEVIEW_PDB_DATA, *PCODEVIEW_PDB_DATA;
1588
1589 typedef struct _CV_DIRECTORY_HEADER
1590 {
1591     WORD        cbDirHeader;
1592     WORD        cbDirEntry;
1593     DWORD       cDir;
1594     DWORD       lfoNextDir;
1595     DWORD       flags;
1596 } CV_DIRECTORY_HEADER, *PCV_DIRECTORY_HEADER;
1597
1598 typedef struct _CV_DIRECTORY_ENTRY
1599 {
1600     WORD        subsection;
1601     WORD        iMod;
1602     DWORD       lfo;
1603     DWORD       cb;
1604 } CV_DIRECTORY_ENTRY, *PCV_DIRECTORY_ENTRY;
1605
1606 typedef struct _CV_ENTRY_MODULE_SEGINFO
1607 {
1608     WORD        seg;
1609     WORD        pad;
1610     DWORD       offset;
1611     DWORD       cbSeg;
1612 } CV_ENTRY_MODULE_SEGINFO;
1613
1614 typedef struct _CV_ENTRY_MODULE
1615 {
1616     WORD        ovlNumber;
1617     WORD        iLib;
1618     WORD        cSeg;
1619     WORD        Style;
1620 /*
1621     CV_ENTRY_MODULE_SEGINFO     SegInfo[cSeg];
1622     p_string    Name;
1623 */
1624 } CV_ENTRY_MODULE;
1625
1626 typedef struct _CV_ENTRY_GLOBAL_TYPES
1627 {
1628     DWORD       flags;
1629     DWORD       cTypes;
1630 /*
1631     DWORD       offset[cTypes];
1632                 types_record[];
1633 */
1634 } CV_ENTRY_GLOBAL_TYPES;