winedump: Make output of dump_data fit into 80 columns.
[wine] / tools / winedump / pdb.c
1 /*
2  *      PDB dumping utility
3  *
4  *      Copyright 2006 Eric Pouech
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 0211/0-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdlib.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #include <time.h>
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
33 #endif
34 #ifdef HAVE_SYS_STAT_H
35 # include <sys/stat.h>
36 #endif
37 #ifdef HAVE_SYS_MMAN_H
38 #include <sys/mman.h>
39 #endif
40 #include <fcntl.h>
41
42 #define NONAMELESSUNION
43 #define NONAMELESSSTRUCT
44 #include "windef.h"
45 #include "winbase.h"
46 #include "winedump.h"
47 #include "wine/mscvpdb.h"
48
49 struct pdb_reader
50 {
51     union
52     {
53         struct
54         {
55             const struct PDB_JG_HEADER* header;
56             const struct PDB_JG_TOC*    toc;
57         } jg;
58         struct
59         {
60             const struct PDB_DS_HEADER* header;
61             const struct PDB_DS_TOC*    toc;
62         } ds;
63     } u;
64     const void* (*read_file)(struct pdb_reader*, DWORD);
65     DWORD       file_used[1024];
66 };
67
68 static const void* pdb_jg_read(const struct PDB_JG_HEADER* pdb, const WORD* block_list, int size)
69 {
70     int                 i, nBlocks;
71     BYTE*               buffer;
72
73     if (!size) return NULL;
74
75     nBlocks = (size + pdb->block_size - 1) / pdb->block_size;
76     buffer = malloc(nBlocks * pdb->block_size);
77
78     for (i = 0; i < nBlocks; i++)
79         memcpy(buffer + i * pdb->block_size,
80                (const char*)pdb + block_list[i] * pdb->block_size, pdb->block_size);
81
82     return buffer;
83 }
84
85 static const void* pdb_jg_read_file(struct pdb_reader* reader, DWORD file_nr)
86 {
87     const WORD*         block_list;
88     DWORD               i;
89
90     if (!reader->u.jg.toc || file_nr >= reader->u.jg.toc->num_files) return NULL;
91
92     reader->file_used[file_nr / 32] |= 1 << (file_nr % 32);
93     if (reader->u.jg.toc->file[file_nr].size == 0 ||
94         reader->u.jg.toc->file[file_nr].size == 0xFFFFFFFF)
95         return NULL;
96     block_list = (const WORD*) &reader->u.jg.toc->file[reader->u.jg.toc->num_files];
97     for (i = 0; i < file_nr; i++)
98         block_list += (reader->u.jg.toc->file[i].size +
99                        reader->u.jg.header->block_size - 1) / reader->u.jg.header->block_size;
100
101     return pdb_jg_read(reader->u.jg.header, block_list,
102                        reader->u.jg.toc->file[file_nr].size);
103 }
104
105 static void pdb_jg_init(struct pdb_reader* reader)
106 {
107     reader->u.jg.header = PRD(0, sizeof(struct PDB_JG_HEADER));
108     reader->read_file = pdb_jg_read_file;
109     reader->u.jg.toc = pdb_jg_read(reader->u.jg.header, 
110                                    reader->u.jg.header->toc_block,
111                                    reader->u.jg.header->toc.size);
112     memset(reader->file_used, 0, sizeof(reader->file_used));
113 }
114
115 static DWORD    pdb_get_num_files(const struct pdb_reader* reader)
116 {
117     if (reader->read_file == pdb_jg_read_file)
118         return reader->u.jg.toc->num_files;
119     else
120         return reader->u.ds.toc->num_files;
121 }
122
123 static DWORD    pdb_get_file_size(const struct pdb_reader* reader, unsigned idx)
124 {
125     if (reader->read_file == pdb_jg_read_file)
126         return reader->u.jg.toc->file[idx].size;
127     else
128         return reader->u.ds.toc->file_size[idx];
129 }
130
131 static void pdb_exit(struct pdb_reader* reader)
132 {
133 #if 1
134     unsigned            i;
135     const unsigned char*file;
136     DWORD               size;
137
138     for (i = 0; i < pdb_get_num_files(reader); i++)
139     {
140         if (reader->file_used[i / 32] & (1 << (i % 32))) continue;
141
142         file = reader->read_file(reader, i);
143         if (!file) continue;
144
145         size = pdb_get_file_size(reader, i);
146
147         printf("File --unused-- #%d (%x)\n", i, size);
148         dump_data(file, size, "    ");
149         free((char*)file);
150     }
151 #endif
152     if (reader->read_file == pdb_jg_read_file)
153         free((char*)reader->u.jg.toc);
154     else
155         free((char*)reader->u.ds.toc);
156 }
157
158 static void pdb_dump_symbols(struct pdb_reader* reader)
159 {
160     const PDB_SYMBOLS*  symbols;
161     const unsigned char*modimage;
162     const char*         file;
163
164     symbols = reader->read_file(reader, 3);
165
166     if (!symbols) return;
167
168     switch (symbols->version)
169     {
170     case 0:            /* VC 4.0 */
171     case 19960307:     /* VC 5.0 */
172     case 19970606:     /* VC 6.0 */
173         break;
174     default:
175         printf("-Unknown symbol info version %d\n", symbols->version);
176     }
177     printf("Symbols:\n"
178            "\tsignature:      %08x\n"
179            "\tversion:        %u\n"
180            "\tunknown:        %08x\n"
181            "\thash1_file:     %08x\n"
182            "\thash2_file:     %08x\n"
183            "\tgsym_file:      %08x\n"
184            "\tmodule_size:    %08x\n"
185            "\toffset_size:    %08x\n"
186            "\thash_size:      %08x\n"
187            "\tsrc_module_size %08x\n"
188            "\tpdbimport_size  %08x\n",
189            symbols->signature,
190            symbols->version,
191            symbols->unknown,
192            symbols->hash1_file,
193            symbols->hash2_file,
194            symbols->gsym_file,
195            symbols->module_size,
196            symbols->offset_size,
197            symbols->hash_size,
198            symbols->srcmodule_size,
199            symbols->pdbimport_size);
200
201     if (symbols->offset_size)
202     {
203         const BYTE*                 src;
204
205         printf("\t----------offsets------------\n");
206         src = (const BYTE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + symbols->module_size);
207         dump_data(src, symbols->offset_size, "    ");
208     }
209
210     if (symbols->srcmodule_size)
211     {
212         const PDB_SYMBOL_SOURCE*src;
213         int                     i;
214         const DWORD*            offset;
215         const char*             cstr;
216
217         printf("\t----------src module------------\n");
218         src = (const PDB_SYMBOL_SOURCE*)((const char*)symbols + sizeof(PDB_SYMBOLS) + 
219                                          symbols->module_size + symbols->offset_size + symbols->hash_size);
220         printf("\tSource Modules\n"
221                "\t\tnModules:         %u\n"
222                "\t\tnSrcFiles:        %u\n"
223                "\t\ttable:\n",
224                src->nModules, src->nSrcFiles);
225
226         /* usage of table seems to be as follows:
227          * two arrays of WORD (src->nModules as size)
228          *  - first array contains index into files for "module" compilation (module = compilation unit ??)
229          *  - second array contains increment in index (if needed)
230          *  - usage of this later is not very clear. it could be that if second array entry is null, then no file
231          *    name is to be used ?
232          * an array of DWORD (src->nSrcFiles as size)
233          *  - contains offset (in following string table) of the source file name
234          * a string table
235          * - each string is a pascal string (ie. with its length as first BYTE) or
236          *   0-terminated string (depending on version)
237          */
238
239         offset = (const DWORD*)&src->table[2 * src->nModules];
240         cstr = (const char*)&src->table[2 * (src->nModules + src->nSrcFiles)];
241
242         for (i = 0; i < src->nModules; i++)
243         {
244             /* FIXME: in some cases, it's a p_string but WHEN ? */
245             if (cstr + offset[src->table[i]] < (const char*)src + symbols->srcmodule_size)
246                 printf("\t\t\tmodule[%2d]: src=%s (%04x)\n",
247                        i, cstr + offset[src->table[i]], src->table[src->nModules + i]);
248             else
249                 printf("\t\t\tmodule[%2d]: src=<<out of bounds>> (%04x)\n",
250                        i, src->table[src->nModules + i]);
251         }
252     }
253     if (symbols->pdbimport_size)
254     {
255         const PDB_SYMBOL_IMPORT*  imp;
256         const char* first;
257         const char* last;
258         const char* ptr;
259
260         printf("\t------------import--------------\n");
261         imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols + sizeof(PDB_SYMBOLS) + 
262                                          symbols->module_size + symbols->offset_size + 
263                                          symbols->hash_size + symbols->srcmodule_size);
264         first = (const char*)imp;
265         last = (const char*)imp + symbols->pdbimport_size;
266         while (imp < (const PDB_SYMBOL_IMPORT*)last)
267         {
268             ptr = (const char*)imp + sizeof(*imp) + strlen(imp->filename);
269             printf("\tImport: %x\n"
270                    "\t\tUnknown1:      %08x\n"
271                    "\t\tUnknown2:      %08x\n"
272                    "\t\tTimeDateStamp: %08x\n"
273                    "\t\tAge:           %08u\n"
274                    "\t\tfile1:         %s\n"
275                    "\t\tfile2:         %s\n",
276                    (const char*)imp - (const char*)first,
277                    imp->unknown1,
278                    imp->unknown2,
279                    imp->TimeDateStamp,
280                    imp->Age,
281                    imp->filename,
282                    ptr);
283             imp = (const PDB_SYMBOL_IMPORT*)(first + ((ptr - first + strlen(ptr) + 1 + 3) & ~3));
284         }
285     }
286
287     /* Read global symbol table */
288     modimage = reader->read_file(reader, symbols->gsym_file);
289     if (modimage)
290     {
291         printf("\t------------globals-------------\n"); 
292         codeview_dump_symbols(modimage, pdb_get_file_size(reader, symbols->gsym_file));
293         free((char*)modimage);
294     }
295
296     /* Read per-module symbol / linenumber tables */
297     file = (const char*)symbols + sizeof(PDB_SYMBOLS);
298     while (file - (const char*)symbols < sizeof(PDB_SYMBOLS) + symbols->module_size)
299     {
300         int file_nr, symbol_size, lineno_size;
301         const char* file_name;
302             
303         if (symbols->version < 19970000)
304         {
305             const PDB_SYMBOL_FILE*      sym_file = (const PDB_SYMBOL_FILE*) file;
306             file_nr     = sym_file->file;
307             file_name   = sym_file->filename;
308             symbol_size = sym_file->symbol_size;
309             lineno_size = sym_file->lineno_size;
310             printf("\t--------symbol file----------- %s\n", file_name);
311             printf("\tgot symbol_file\n"
312                    "\t\tunknown1:   %08x \n"
313                    "\t\trange\n"
314                    "\t\t\tsegment:         %04x\n"
315                    "\t\t\tpad1:            %04x\n"
316                    "\t\t\toffset:          %08x\n"
317                    "\t\t\tsize:            %08x\n"
318                    "\t\t\tcharacteristics: %08x\n"
319                    "\t\t\tindex:           %04x\n"
320                    "\t\t\tpad2:            %04x\n"
321                    "\t\tflag:       %04x\n"
322                    "\t\tfile:       %04x\n"
323                    "\t\tsymb size:  %08x\n"
324                    "\t\tline size:  %08x\n"
325                    "\t\tunknown2:   %08x\n"
326                    "\t\tnSrcFiles:  %08x\n"
327                    "\t\tattribute:  %08x\n",
328                    sym_file->unknown1,
329                    sym_file->range.segment,
330                    sym_file->range.pad1,
331                    sym_file->range.offset,
332                    sym_file->range.size,
333                    sym_file->range.characteristics,
334                    sym_file->range.index,
335                    sym_file->range.pad2,
336                    sym_file->flag,
337                    sym_file->file,
338                    sym_file->symbol_size,
339                    sym_file->lineno_size,
340                    sym_file->unknown2,
341                    sym_file->nSrcFiles,
342                    sym_file->attribute);
343         }
344         else
345         {
346             const PDB_SYMBOL_FILE_EX*   sym_file = (const PDB_SYMBOL_FILE_EX*) file;
347             file_nr     = sym_file->file;
348             file_name   = sym_file->filename;
349             symbol_size = sym_file->symbol_size;
350             lineno_size = sym_file->lineno_size;
351             printf("\t--------symbol file----------- %s\n", file_name);
352             printf("\t\tunknown1:   %08x \n"
353                    "\t\trange\n"
354                    "\t\t\tsegment:         %04x\n"
355                    "\t\t\tpad1:            %04x\n"
356                    "\t\t\toffset:          %08x\n"
357                    "\t\t\tsize:            %08x\n"
358                    "\t\t\tcharacteristics: %08x\n"
359                    "\t\t\tindex:           %04x\n"
360                    "\t\t\tpad2:            %04x\n"
361                    "\t\t\ttimestamp:       %08x\n"
362                    "\t\t\tunknown:         %08x\n"
363                    "\t\tflag:       %04x\n"
364                    "\t\tfile:       %04x\n"
365                    "\t\tsymb size:  %08x\n"
366                    "\t\tline size:  %08x\n"
367                    "\t\tunknown2:   %08x\n"
368                    "\t\tnSrcFiles:  %08x\n"
369                    "\t\tattribute:  %08x\n"
370                    "\t\treserved/0: %08x\n"
371                    "\t\treserved/1: %08x\n",
372                    sym_file->unknown1,
373                    sym_file->range.segment,
374                    sym_file->range.pad1,
375                    sym_file->range.offset,
376                    sym_file->range.size,
377                    sym_file->range.characteristics,
378                    sym_file->range.index,
379                    sym_file->range.pad2,
380                    sym_file->range.timestamp,
381                    sym_file->range.unknown,
382                    sym_file->flag,
383                    sym_file->file,
384                    sym_file->symbol_size,
385                    sym_file->lineno_size,
386                    sym_file->unknown2,
387                    sym_file->nSrcFiles,
388                    sym_file->attribute,
389                    sym_file->reserved[0],
390                    sym_file->reserved[1]);
391         }
392         modimage = reader->read_file(reader, file_nr);
393         if (modimage)
394         {
395             int total_size = pdb_get_file_size(reader, file_nr);
396
397             if (symbol_size)
398                 codeview_dump_symbols((const char*)modimage + sizeof(DWORD), symbol_size);
399
400             /* what's that part ??? */
401             if (0)
402                 dump_data(modimage + symbol_size + lineno_size, total_size - (symbol_size + lineno_size), "    ");
403             free((char*)modimage);
404         }
405
406         file_name += strlen(file_name) + 1;
407         file = (char*)((DWORD)(file_name + strlen(file_name) + 1 + 3) & ~3);
408     }
409     free((char*)symbols);
410 }
411
412 static void pdb_dump_types(struct pdb_reader* reader)
413 {
414     const PDB_TYPES*            types = NULL;
415
416     types = reader->read_file(reader, 2);
417
418     switch (types->version)
419     {
420     case 19950410:      /* VC 4.0 */
421     case 19951122:
422     case 19961031:      /* VC 5.0 / 6.0 */
423     case 19990903:      /* VC 7.0 */
424         break;
425     default:
426         printf("-Unknown type info version %d\n", types->version);
427     }
428
429     /* Read type table */
430     printf("Types:\n"
431            "\tversion:        %u\n"
432            "\ttype_offset:    %08x\n"
433            "\tfirst_index:    %x\n"
434            "\tlast_index:     %x\n"
435            "\ttype_size:      %x\n"
436            "\tfile:           %x\n"
437            "\tpad:            %x\n"
438            "\thash_size:      %x\n"
439            "\thash_base:      %x\n"
440            "\thash_offset:    %x\n"
441            "\thash_len:       %x\n"
442            "\tsearch_offset:  %x\n"
443            "\tsearch_len:     %x\n"
444            "\tunknown_offset: %x\n"
445            "\tunknown_len:    %x\n",
446            types->version,
447            types->type_offset,
448            types->first_index,
449            types->last_index,
450            types->type_size,
451            types->file,
452            types->pad,
453            types->hash_size,
454            types->hash_base,
455            types->hash_offset,
456            types->hash_len,
457            types->search_offset,
458            types->search_len,
459            types->unknown_offset,
460            types->unknown_len);
461     codeview_dump_types((const char*)types + types->type_offset, types->type_size);
462     free((char*)types);
463 }
464
465 static const char       pdb2[] = "Microsoft C/C++ program database 2.00";
466
467 static void pdb_jg_dump(void)
468 {
469     struct pdb_reader           reader;
470     const struct PDB_JG_ROOT*   root = NULL;
471
472     /*
473      * Read in TOC and well-known files
474      */
475     pdb_jg_init(&reader);
476     printf("Header (JG):\n"
477            "\tident:      %.*s\n"
478            "\tsignature:  %08x\n"
479            "\tblock_size: %08x\n"
480            "\tfree_list:  %04x\n"
481            "\ttotal_alloc:%04x\n",
482            sizeof(pdb2) - 1, reader.u.jg.header->ident,
483            reader.u.jg.header->signature,
484            reader.u.jg.header->block_size,
485            reader.u.jg.header->free_list,
486            reader.u.jg.header->total_alloc);
487
488     root = reader.read_file(&reader, 1);
489     
490     if (root)
491     {
492         printf("Root:\n"
493                "\tVersion:       %u\n"
494                "\tTimeDateStamp: %08x\n"
495                "\tAge:           %08x\n"
496                "\tnames:         %.*s\n",
497                root->Version,
498                root->TimeDateStamp,
499                root->Age,
500                (unsigned)root->cbNames,
501                root->names);
502
503         /* Check for unknown versions */
504         switch (root->Version)
505         {
506         case 19950623:      /* VC 4.0 */
507         case 19950814:
508         case 19960307:      /* VC 5.0 */
509         case 19970604:      /* VC 6.0 */
510             break;
511         default:
512             printf("-Unknown root block version %d\n", root->Version);
513         }
514         free((char*)root);
515     }
516     else printf("-Unable to get root\n");
517
518     pdb_dump_types(&reader);
519 #if 0
520     /* segments info, index is unknown */
521     {
522         const void*     segs = pdb_read_file(pdb, toc, 8); /* FIXME which index ??? */
523         const void*     ptr = segs;
524
525         if (segs) while (ptr < segs + toc->file[8].size)
526         {
527             printf("Segment %s\n", (const char*)ptr);
528             ptr += (strlen(ptr) + 1 + 3) & ~3;
529             printf("\tdword[0]: %08lx\n", *(DWORD*)ptr); ptr += 4;
530             printf("\tdword[1]: %08lx\n", *(DWORD*)ptr); ptr += 4;
531             printf("\tdword[2]: %08lx\n", *(DWORD*)ptr); ptr += 4;
532             printf("\tdword[3]: %08lx\n", *(DWORD*)ptr); ptr += 4;
533             printf("\tdword[4]: %08lx\n", *(DWORD*)ptr); ptr += 4;
534             printf("\tdword[5]: %08lx\n", *(DWORD*)ptr); ptr += 4;
535             printf("\tdword[6]: %08lx\n", *(DWORD*)ptr); ptr += 4;
536             printf("\tdword[7]: %08lx\n", *(DWORD*)ptr); ptr += 4;
537         }
538         free(segs);
539     }
540 #endif
541
542     pdb_dump_symbols(&reader);
543     pdb_exit(&reader);
544 }
545
546 static const void* pdb_ds_read(const struct PDB_DS_HEADER* header, const DWORD* block_list, int size)
547 {
548     int                 i, nBlocks;
549     BYTE*               buffer;
550
551     if (!size) return NULL;
552
553     nBlocks = (size + header->block_size - 1) / header->block_size;
554     buffer = malloc(nBlocks * header->block_size);
555
556     for (i = 0; i < nBlocks; i++)
557         memcpy(buffer + i * header->block_size,
558                (const char*)header + block_list[i] * header->block_size, header->block_size);
559
560     return buffer;
561 }
562
563 static const void* pdb_ds_read_file(struct pdb_reader* reader, DWORD file_number)
564 {
565     const DWORD*        block_list;
566     DWORD               i;
567
568     if (!reader->u.ds.toc || file_number >= reader->u.ds.toc->num_files) return NULL;
569
570     reader->file_used[file_number / 32] |= 1 << (file_number % 32);
571     if (reader->u.ds.toc->file_size[file_number] == 0 ||
572         reader->u.ds.toc->file_size[file_number] == 0xFFFFFFFF)
573         return NULL;
574     block_list = reader->u.ds.toc->file_size + reader->u.ds.toc->num_files;
575     for (i = 0; i < file_number; i++)
576         block_list += (reader->u.ds.toc->file_size[i] + reader->u.ds.header->block_size - 1) /
577             reader->u.ds.header->block_size;
578
579     return pdb_ds_read(reader->u.ds.header, block_list, reader->u.ds.toc->file_size[file_number]);
580 }
581
582 static BOOL pdb_ds_init(struct pdb_reader* reader)
583 {
584     reader->u.ds.header = PRD(0, sizeof(*reader->u.ds.header));
585     if (!reader->u.ds.header) return FALSE;
586     reader->read_file = pdb_ds_read_file;
587     reader->u.ds.toc = pdb_ds_read(reader->u.ds.header, 
588                                    (const DWORD*)((const char*)reader->u.ds.header + reader->u.ds.header->toc_page * reader->u.ds.header->block_size),
589                                    reader->u.ds.header->toc_size);
590     memset(reader->file_used, 0, sizeof(reader->file_used));
591     return TRUE;
592 }
593
594 static const char       pdb7[] = "Microsoft C/C++ MSF 7.00";
595
596 static void pdb_ds_dump(void)
597 {
598     struct pdb_reader           reader;
599     const struct PDB_DS_ROOT*   root;
600
601     pdb_ds_init(&reader);
602     printf("Header (DS)\n"
603            "\tsignature:        %.*s\n"
604            "\tblock_size:       %08x\n"
605            "\tunknown1:         %08x\n"
606            "\tnum_pages:        %08x\n"
607            "\ttoc_size:         %08x\n"
608            "\tunknown2:         %08x\n"
609            "\ttoc_page:         %08x\n",
610            sizeof(pdb7) - 1, reader.u.ds.header->signature,
611            reader.u.ds.header->block_size,
612            reader.u.ds.header->unknown1,
613            reader.u.ds.header->num_pages,
614            reader.u.ds.header->toc_size,
615            reader.u.ds.header->unknown2,
616            reader.u.ds.header->toc_page);
617
618     /* files:
619      * 0: JG says old toc pages, I'd say free pages (tbc, low prio)
620      * 1: root structure
621      * 2: types
622      * 3: modules
623      */
624     root = reader.read_file(&reader, 1);
625     if (root)
626     {
627         const char*     ptr;
628         printf("Root:\n"
629                "\tVersion:              %u\n"
630                "\tTimeDateStamp:        %08x\n"
631                "\tAge:                  %08x\n"
632                "\tguid                  {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n"
633                "\tcbNames:              %08x\n",
634                root->Version,
635                root->TimeDateStamp,
636                root->Age,
637                root->guid.Data1, root->guid.Data2, root->guid.Data3,
638                root->guid.Data4[0], root->guid.Data4[1], root->guid.Data4[2], root->guid.Data4[3],
639                root->guid.Data4[4], root->guid.Data4[5], root->guid.Data4[6], root->guid.Data4[7],
640                root->cbNames);
641         for (ptr = &root->names[0]; ptr < &root->names[0] + root->cbNames; ptr += strlen(ptr) + 1)
642             printf("\tString:               %s\n", ptr);
643         /* follows an unknown list of DWORDs */
644         free((char*)root);
645     }
646     else printf("-Unable to get root\n");
647
648     pdb_dump_types(&reader);
649     pdb_dump_symbols(&reader);
650
651     pdb_exit(&reader);
652 }
653
654 enum FileSig get_kind_pdb(void)
655 {
656     const char* head;
657
658     head = PRD(0, sizeof(pdb2) - 1);
659     if (head && !memcmp(head, pdb2, sizeof(pdb2) - 1))
660         return SIG_PDB;
661     head = PRD(0, sizeof(pdb7) - 1);
662     if (head && !memcmp(head, pdb7, sizeof(pdb7) - 1))
663         return SIG_PDB;
664     return SIG_UNKNOWN;
665 }
666
667 void pdb_dump(void)
668 {
669     const char* head;
670
671 /*    init_types(); */
672     head = PRD(0, sizeof(pdb2) - 1);
673     if (head && !memcmp(head, pdb2, sizeof(pdb2) - 1))
674         return pdb_jg_dump();
675     head = PRD(0, sizeof(pdb7) - 1);
676     if (head && !memcmp(head, pdb7, sizeof(pdb7) - 1))
677         return pdb_ds_dump();
678     printf("Unrecognized header %s\n", head);
679 }