Make drive letters in PIDLs always uppercase to enable PIDL
[wine] / tools / winedump / debug.c
1 /*
2  * Made after:
3  *      CVDump - Parses through a Visual Studio .DBG file in CodeView 4 format
4  *      and dumps the info to STDOUT in a human-readable format
5  *
6  *      Copyright 2000 John R. Sheets
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 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdlib.h>
27 #include <stdarg.h>
28 #include <stdio.h>
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
32 #include <time.h>
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
35 #endif
36 #ifdef HAVE_SYS_STAT_H
37 # include <sys/stat.h>
38 #endif
39 #ifdef HAVE_SYS_MMAN_H
40 #include <sys/mman.h>
41 #endif
42 #include <fcntl.h>
43
44 #include "windef.h"
45 #include "winbase.h"
46 #include "winedump.h"
47 #include "pe.h"
48 #include "cvinclude.h"
49
50 /*
51  * .DBG File Layout:
52  *
53  * IMAGE_SEPARATE_DEBUG_HEADER
54  * IMAGE_SECTION_HEADER[]
55  * IMAGE_DEBUG_DIRECTORY[]
56  * OMFSignature
57  * debug data (typical example)
58  *   - IMAGE_DEBUG_TYPE_MISC
59  *   - IMAGE_DEBUG_TYPE_FPO
60  *   - IMAGE_DEBUG_TYPE_CODEVIEW
61  * OMFDirHeader
62  * OMFDirEntry[]
63  */
64
65 /*
66  * Descriptions:
67  *
68  * (hdr)  IMAGE_SEPARATE_DEBUG_HEADER - .DBG-specific file header; holds info that
69  *        applies to the file as a whole, including # of COFF sections, file offsets, etc.
70  * (hdr)  IMAGE_SECTION_HEADER - list of COFF sections copied verbatim from .EXE;
71  *        although this directory contains file offsets, these offsets are meaningless
72  *        in the context of the .DBG file, because only the section headers are copied
73  *        to the .DBG file...not the binary data it points to.
74  * (hdr)  IMAGE_DEBUG_DIRECTORY - list of different formats of debug info contained in file
75  *        (see IMAGE_DEBUG_TYPE_* descriptions below); tells where each section starts
76  * (hdr)  OMFSignature (CV) - Contains "NBxx" signature, plus file offset telling how far
77  *        into the IMAGE_DEBUG_TYPE_CODEVIEW section the OMFDirHeader and OMFDirEntry's sit
78  * (data) IMAGE_DEBUG_TYPE_MISC - usually holds name of original .EXE file
79  * (data) IMAGE_DEBUG_TYPE_FPO - Frame Pointer Optimization data; used for dealing with
80  *        optimized stack frames (optional)
81  * (data) IMAGE_DEBUG_TYPE_CODEVIEW - *** THE GOOD STUFF ***
82  *        This block of data contains all the symbol tables, line number info, etc.,
83  *        that the Visual C++ debugger needs.
84  * (hdr)  OMFDirHeader (CV) -
85  * (hdr)  OMFDirEntry (CV) - list of subsections within CodeView debug data section
86  */
87
88 /*
89  * The .DBG file typically has three arrays of directory entries, which tell
90  * the OS or debugger where in the file to look for the actual data
91  *
92  * IMAGE_SECTION_HEADER - number of entries determined by:
93  *    (IMAGE_SEPARATE_DEBUG_HEADER.NumberOfSections)
94  *
95  * IMAGE_DEBUG_DIRECTORY - number of entries determined by:
96  *    (IMAGE_SEPARATE_DEBUG_HEADER.DebugDirectorySize / sizeof (IMAGE_DEBUG_DIRECTORY))
97  *
98  * OMFDirEntry - number of entries determined by:
99  *    (OMFDirHeader.cDir)
100  */
101
102 extern void                     *PE_base;
103
104 extern IMAGE_NT_HEADERS*        PE_nt_headers;
105
106 static  void*           cv_base /* = 0 */;
107
108 static int dump_cv_sst_module(OMFDirEntry* omfde)
109 {
110     OMFModule*  module;
111     OMFSegDesc* segDesc;
112     int         i;
113
114     module = PRD(Offset(cv_base) + omfde->lfo, sizeof(OMFModule));
115     if (!module) {printf("Can't get the OMF-Module, aborting\n"); return FALSE;}
116
117     printf("    olvNumber:          %u\n", module->ovlNumber);
118     printf("    iLib:               %u\n", module->iLib);
119     printf("    cSeg:               %u\n", module->cSeg);
120     printf("    Style:              %c%c\n", module->Style[0], module->Style[1]);
121     printf("    Name:               %.*s\n",
122            *(BYTE*)((char*)(module + 1) + sizeof(OMFSegDesc) * module->cSeg),
123            (char*)(module + 1) + sizeof(OMFSegDesc) * module->cSeg + 1);
124
125     segDesc = PRD(Offset(module + 1), sizeof(OMFSegDesc) * module->cSeg);
126     if (!segDesc) {printf("Can't get the OMF-SegDesc, aborting\n"); return FALSE;}
127
128     for (i = 0; i < module->cSeg; i++)
129     {
130         printf ("      segment #%2d: offset = [0x%8lx], size = [0x%8lx]\n",
131                 segDesc->Seg, segDesc->Off, segDesc->cbSeg);
132         segDesc++;
133     }
134     return TRUE;
135 }
136
137 static int dump_cv_sst_global_pub(OMFDirEntry* omfde)
138 {
139     long        fileoffset;
140     OMFSymHash* header;
141     BYTE*       symbols;
142     BYTE*       curpos;
143     PUBSYM32*   sym;
144     unsigned    symlen;
145     int         recordlen;
146     char        nametmp[256];
147
148     fileoffset = Offset(cv_base) + omfde->lfo;
149     printf ("    GlobalPub section starts at file offset 0x%lx\n", fileoffset);
150     printf ("    Symbol table starts at 0x%lx\n", fileoffset + sizeof (OMFSymHash));
151
152     printf ("\n                           ----- Begin Symbol Table -----\n");
153     printf ("      (type)      (symbol name)                 (offset)      (len) (seg) (ind)\n");
154
155     header = PRD(fileoffset, sizeof(OMFSymHash));
156     if (!header) {printf("Can't get OMF-SymHash, aborting\n");return FALSE;}
157
158     symbols = PRD(fileoffset + sizeof(OMFSymHash), header->cbSymbol);
159     if (!symbols) {printf("Can't OMF-SymHash details, aborting\n"); return FALSE;}
160
161     /* We don't know how many symbols are in this block of memory...only what
162      * the total size of the block is.  Because the symbol's name is tacked
163      * on to the end of the PUBSYM32 struct, each symbol may take up a different
164      * # of bytes.  This makes it harder to parse through the symbol table,
165      * since we won't know the exact location of the following symbol until we've
166      * already parsed the current one.
167      */
168     for (curpos = symbols; curpos < symbols + header->cbSymbol; curpos += recordlen)
169     {
170         /* Point to the next PUBSYM32 in the table.
171          */
172         sym = (PUBSYM32*)curpos;
173
174         if (sym->reclen < sizeof(PUBSYM32)) break;
175
176         symlen = sym->reclen - sizeof(PUBSYM32) + 1;
177         if (symlen > sizeof(nametmp)) {printf("\nsqueeze%d\n", symlen);symlen = sizeof(nametmp) - 1;}
178
179         memcpy(nametmp, curpos + sizeof (PUBSYM32) + 1, symlen);
180         nametmp[symlen] = '\0';
181
182         printf ("      0x%04x  %-30.30s  [0x%8lx]  [0x%4x]  %d     %ld\n",
183                 sym->rectyp, nametmp, sym->off, sym->reclen, sym->seg, sym->typind);
184
185         /* The entire record is null-padded to the nearest 4-byte
186          * boundary, so we must do a little extra math to keep things straight.
187          */
188         recordlen = (sym->reclen + 3) & ~3;
189     }
190
191     return TRUE;
192 }
193
194 static int dump_cv_sst_global_sym(OMFDirEntry* omfde)
195 {
196     /*** NOT YET IMPLEMENTED ***/
197     return TRUE;
198 }
199
200 static int dump_cv_sst_static_sym(OMFDirEntry* omfde)
201 {
202     /*** NOT YET IMPLEMENTED ***/
203     return TRUE;
204 }
205
206 static int dump_cv_sst_libraries(OMFDirEntry* omfde)
207 {
208     /*** NOT YET IMPLEMENTED ***/
209     return TRUE;
210 }
211
212 static int dump_cv_sst_global_types(OMFDirEntry* omfde)
213 {
214     /*** NOT YET IMPLEMENTED ***/
215     return TRUE;
216 }
217
218 static int dump_cv_sst_seg_map(OMFDirEntry* omfde)
219 {
220     OMFSegMap*          segMap;
221     OMFSegMapDesc*      segMapDesc;
222     int         i;
223
224     segMap = PRD(Offset(cv_base) + omfde->lfo, sizeof(OMFSegMap));
225     if (!segMap) {printf("Can't get SegMap, aborting\n");return FALSE;}
226
227     printf("    cSeg:          %u\n", segMap->cSeg);
228     printf("    cSegLog:       %u\n", segMap->cSegLog);
229
230     segMapDesc = PRD(Offset(segMap + 1), segMap->cSeg * sizeof(OMFSegDesc));
231     if (!segMapDesc) {printf("Can't get SegDescr array, aborting\n");return FALSE;}
232
233     for (i = 0; i < segMap->cSeg; i++)
234     {
235         printf("    SegDescr #%2d\n", i + 1);
236         printf("      flags:         %04X\n", segMapDesc[i].flags);
237         printf("      ovl:           %u\n", segMapDesc[i].ovl);
238         printf("      group:         %u\n", segMapDesc[i].group);
239         printf("      frame:         %u\n", segMapDesc[i].frame);
240         printf("      iSegName:      %u\n", segMapDesc[i].iSegName);
241         printf("      iClassName:    %u\n", segMapDesc[i].iClassName);
242         printf("      offset:        %lu\n", segMapDesc[i].offset);
243         printf("      cbSeg:         %lu\n", segMapDesc[i].cbSeg);
244     }
245
246     return TRUE;
247 }
248
249 static int dump_cv_sst_file_index(OMFDirEntry* omfde)
250 {
251     /*** NOT YET IMPLEMENTED ***/
252     return TRUE;
253 }
254
255 static int dump_cv_sst_src_module(OMFDirEntry* omfde)
256 {
257     int                 i, j;
258     BYTE*               rawdata;
259     unsigned long*      seg_info_dw;
260     unsigned short*     seg_info_w;
261     unsigned            ofs;
262     OMFSourceModule*    sourceModule;
263     OMFSourceFile*      sourceFile;
264     OMFSourceLine*      sourceLine;
265
266     rawdata = PRD(Offset(cv_base) + omfde->lfo, omfde->cb);
267     if (!rawdata) {printf("Can't get srcModule subsection details, aborting\n");return FALSE;}
268
269     /* FIXME: check ptr validity */
270     sourceModule = (void*)rawdata;
271     printf ("    Module table: Found %d file(s) and %d segment(s)\n",
272             sourceModule->cFile, sourceModule->cSeg);
273     for (i = 0; i < sourceModule->cFile; i++)
274     {
275         printf ("      File #%2d begins at an offset of 0x%lx in this section\n",
276                 i + 1, sourceModule->baseSrcFile[i]);
277     }
278
279     /* FIXME: check ptr validity */
280     seg_info_dw = (void*)((char*)(sourceModule + 1) +
281                           sizeof(unsigned long) * (sourceModule->cFile - 1));
282     seg_info_w = (unsigned short*)(&seg_info_dw[sourceModule->cSeg * 2]);
283     for (i = 0; i <  sourceModule->cSeg; i++)
284     {
285         printf ("      Segment #%2d start = 0x%lx, end = 0x%lx, seg index = %u\n",
286                 i + 1, seg_info_dw[i * 2], seg_info_dw[(i * 2) + 1],
287                 seg_info_w[i]);
288     }
289     ofs = sizeof(OMFSourceModule) + sizeof(unsigned long) * (sourceModule->cFile - 1) +
290         sourceModule->cSeg * (2 * sizeof(unsigned long) + sizeof(unsigned short));
291     ofs = (ofs + 3) & ~3;
292
293     /* the OMFSourceFile is quite unpleasant to use:
294      * we have first:
295      *  unsigned short  number of segments
296      *  unsigned short  reservered
297      *  unsigned long   baseSrcLn[# segments]
298      *  unsigned long   offset[2 * #segments]
299      *                          odd indices are start offsets
300      *                          even indices are end offsets
301      *  unsigned char   string length for file name
302      *  char            file name (length is previous field)
303      */
304     /* FIXME: check ptr validity */
305     sourceFile = (void*)(rawdata + ofs);
306     seg_info_dw = (void*)((char*)sourceFile + 2 * sizeof(unsigned short) +
307                           sourceFile->cSeg * sizeof(unsigned long));
308
309     ofs += 2 * sizeof(unsigned short) + 3 * sourceFile->cSeg * sizeof(unsigned long);
310
311     printf("    File table: %.*s\n",
312            *(BYTE*)((char*)sourceModule + ofs), (char*)sourceModule + ofs + 1);
313
314     for (i = 0; i < sourceFile->cSeg; i++)
315     {
316         printf ("      Segment #%2d start = 0x%lx, end = 0x%lx, offset = 0x%lx\n",
317                 i + 1, seg_info_dw[i * 2], seg_info_dw[(i * 2) + 1], sourceFile->baseSrcLn[i]);
318     }
319     /* add file name length */
320     ofs += *(BYTE*)((char*)sourceModule + ofs) + 1;
321     ofs = (ofs + 3) & ~3;
322
323     for (i = 0; i < sourceModule->cSeg; i++)
324     {
325         sourceLine = (void*)(rawdata + ofs);
326         seg_info_dw = (void*)((char*)sourceLine + 2 * sizeof(unsigned short));
327         seg_info_w = (void*)(&seg_info_dw[sourceLine->cLnOff]);
328
329         printf ("    Line table #%2d: Found %d line numbers for segment index %d\n",
330                 i, sourceLine->cLnOff, sourceLine->Seg);
331
332         for (j = 0; j < sourceLine->cLnOff; j++)
333         {
334             printf ("      Pair #%2d: offset = [0x%8lx], linenumber = %d\n",
335                     j + 1, seg_info_dw[j], seg_info_w[j]);
336         }
337         ofs += 2 * sizeof(unsigned short) +
338             sourceLine->cLnOff * (sizeof(unsigned long) + sizeof(unsigned short));
339         ofs = (ofs + 3) & ~3;
340     }
341
342     return TRUE;
343 }
344
345 static int dump_cv_sst_align_sym(OMFDirEntry* omfde)
346 {
347     /*** NOT YET IMPLEMENTED ***/
348
349     return TRUE;
350 }
351
352 static void dump_codeview_all_modules(OMFDirHeader *omfdh)
353 {
354     unsigned            i;
355     OMFDirEntry        *dirEntry;
356     const char*         str;
357
358     if (!omfdh || !omfdh->cDir) return;
359
360     dirEntry = PRD(Offset(omfdh + 1), omfdh->cDir * sizeof(OMFDirEntry));
361     if (!dirEntry) {printf("Can't read DirEntry array, aborting\n"); return;}
362
363     for (i = 0; i < omfdh->cDir; i++)
364     {
365         switch (dirEntry[i].SubSection)
366         {
367         case sstModule:         str = "sstModule";      break;
368         case sstAlignSym:       str = "sstAlignSym";    break;
369         case sstSrcModule:      str = "sstSrcModule";   break;
370         case sstLibraries:      str = "sstLibraries";   break;
371         case sstGlobalSym:      str = "sstGlobalSym";   break;
372         case sstGlobalPub:      str = "sstGlobalPub";   break;
373         case sstGlobalTypes:    str = "sstGlobalTypes"; break;
374         case sstSegMap:         str = "sstSegMap";      break;
375         case sstFileIndex:      str = "sstFileIndex";   break;
376         case sstStaticSym:      str = "sstStaticSym";   break;
377         default:                str = "<undefined>";    break;
378         }
379         printf("Module #%2d (%p)\n", i + 1, &dirEntry[i]);
380         printf("  SubSection:            %04X (%s)\n", dirEntry[i].SubSection, str);
381         printf("  iMod:                  %d\n", dirEntry[i].iMod);
382         printf("  lfo:                   %ld\n", dirEntry[i].lfo);
383         printf("  cb:                    %lu\n", dirEntry[i].cb);
384
385         switch (dirEntry[i].SubSection)
386         {
387         case sstModule:         dump_cv_sst_module(&dirEntry[i]);       break;
388         case sstAlignSym:       dump_cv_sst_align_sym(&dirEntry[i]);    break;
389         case sstSrcModule:      dump_cv_sst_src_module(&dirEntry[i]);   break;
390         case sstLibraries:      dump_cv_sst_libraries(&dirEntry[i]);    break;
391         case sstGlobalSym:      dump_cv_sst_global_sym(&dirEntry[i]);   break;
392         case sstGlobalPub:      dump_cv_sst_global_pub(&dirEntry[i]);   break;
393         case sstGlobalTypes:    dump_cv_sst_global_types(&dirEntry[i]); break;
394         case sstSegMap:         dump_cv_sst_seg_map(&dirEntry[i]);      break;
395         case sstFileIndex:      dump_cv_sst_file_index(&dirEntry[i]);   break;
396         case sstStaticSym:      dump_cv_sst_static_sym(&dirEntry[i]);   break;
397         default:                printf("unsupported type %x\n", dirEntry[i].SubSection); break;
398         }
399         printf("\n");
400     }
401
402     return;
403 }
404
405 static void dump_codeview_headers(unsigned long base, unsigned long len)
406 {
407     OMFDirHeader        *dirHeader;
408     OMFSignature        *signature;
409     OMFDirEntry         *dirEntry;
410     unsigned            i;
411     int modulecount = 0, alignsymcount = 0, srcmodulecount = 0, librariescount = 0;
412     int globalsymcount = 0, globalpubcount = 0, globaltypescount = 0;
413     int segmapcount = 0, fileindexcount = 0, staticsymcount = 0;
414
415     cv_base = PRD(base, len);
416     if (!cv_base) {printf("Can't get full debug content, aborting\n");return;}
417
418     signature = cv_base;
419
420     printf("    CodeView Data\n");
421
422     printf("      Signature:         %.4s\n", signature->Signature);
423     printf("      Filepos:           0x%08lX\n", signature->filepos);
424
425     if (memcmp(signature->Signature, "NB10", 4) == 0)
426     {
427         struct {DWORD TimeStamp; DWORD  Dunno; char Name[1];}* pdb_data;
428         pdb_data = (void*)(signature + 1);
429
430         printf("        TimeStamp:            %08lX (%s)\n",
431                pdb_data->TimeStamp, get_time_str(pdb_data->TimeStamp));
432         printf("        Dunno:                %08lX\n", pdb_data->Dunno);
433         printf("        Filename:             %s\n", pdb_data->Name);
434         return;
435     }
436
437     if (memcmp(signature->Signature, "NB09", 4) != 0 && memcmp(signature->Signature, "NB11", 4) != 0)
438     {
439         printf("Unsupported signature, aborting\n");
440         return;
441     }
442
443     dirHeader = PRD(Offset(cv_base) + signature->filepos, sizeof(OMFDirHeader));
444     if (!dirHeader) {printf("Can't get debug header, aborting\n"); return;}
445
446     printf("      Size of header:    0x%4X\n", dirHeader->cbDirHeader);
447     printf("      Size per entry:    0x%4X\n", dirHeader->cbDirEntry);
448     printf("      # of entries:      0x%8lX (%ld)\n", dirHeader->cDir, dirHeader->cDir);
449     printf("      Offset to NextDir: 0x%8lX\n", dirHeader->lfoNextDir);
450     printf("      Flags:             0x%8lX\n", dirHeader->flags);
451
452     if (!dirHeader->cDir) return;
453
454     dirEntry = PRD(Offset(dirHeader + 1), sizeof(OMFDirEntry) * dirHeader->cDir);
455     if (!dirEntry) {printf("Can't get DirEntry array, aborting\n");return;}
456
457     for (i = 0; i < dirHeader->cDir; i++)
458     {
459         switch (dirEntry[i].SubSection)
460         {
461         case sstModule:         modulecount++;          break;
462         case sstAlignSym:       alignsymcount++;        break;
463         case sstSrcModule:      srcmodulecount++;       break;
464         case sstLibraries:      librariescount++;       break;
465         case sstGlobalSym:      globalsymcount++;       break;
466         case sstGlobalPub:      globalpubcount++;       break;
467         case sstGlobalTypes:    globaltypescount++;     break;
468         case sstSegMap:         segmapcount++;          break;
469         case sstFileIndex:      fileindexcount++;       break;
470         case sstStaticSym:      staticsymcount++;       break;
471         }
472     }
473
474     /* This one has to be > 0
475      */
476     printf ("\nFound: %d sstModule subsections\n", modulecount);
477
478     if (alignsymcount > 0)    printf ("       %d sstAlignSym subsections\n", alignsymcount);
479     if (srcmodulecount > 0)   printf ("       %d sstSrcModule subsections\n", srcmodulecount);
480     if (librariescount > 0)   printf ("       %d sstLibraries subsections\n", librariescount);
481     if (globalsymcount > 0)   printf ("       %d sstGlobalSym subsections\n", globalsymcount);
482     if (globalpubcount > 0)   printf ("       %d sstGlobalPub subsections\n", globalpubcount);
483     if (globaltypescount > 0) printf ("       %d sstGlobalTypes subsections\n", globaltypescount);
484     if (segmapcount > 0)      printf ("       %d sstSegMap subsections\n", segmapcount);
485     if (fileindexcount > 0)   printf ("       %d sstFileIndex subsections\n", fileindexcount);
486     if (staticsymcount > 0)   printf ("       %d sstStaticSym subsections\n", staticsymcount);
487
488     dump_codeview_all_modules(dirHeader);
489 }
490
491 static const char*   get_coff_name( PIMAGE_SYMBOL coff_sym, const char* coff_strtab )
492 {
493    static       char    namebuff[9];
494    const char*          nampnt;
495
496    if( coff_sym->N.Name.Short )
497       {
498          memcpy(namebuff, coff_sym->N.ShortName, 8);
499          namebuff[8] = '\0';
500          nampnt = &namebuff[0];
501       }
502    else
503       {
504          nampnt = coff_strtab + coff_sym->N.Name.Long;
505       }
506
507    if( nampnt[0] == '_' )
508       nampnt++;
509    return nampnt;
510 }
511
512 void    dump_coff(unsigned long coffbase, unsigned long len)
513 {
514     PIMAGE_COFF_SYMBOLS_HEADER coff;
515     PIMAGE_SYMBOL                 coff_sym;
516     PIMAGE_SYMBOL                 coff_symbols;
517     PIMAGE_LINENUMBER             coff_linetab;
518     char                        * coff_strtab;
519     IMAGE_SECTION_HEADER *sectHead = (IMAGE_SECTION_HEADER*)((char*)PE_nt_headers + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + PE_nt_headers->FileHeader.SizeOfOptionalHeader);
520     unsigned int i;
521     const char                  * nampnt;
522     int naux;
523
524     coff = (PIMAGE_COFF_SYMBOLS_HEADER)PRD(coffbase, len);
525
526     coff_symbols = (PIMAGE_SYMBOL) ((unsigned int) coff + coff->LvaToFirstSymbol);
527     coff_linetab = (PIMAGE_LINENUMBER) ((unsigned int) coff + coff->LvaToFirstLinenumber);
528     coff_strtab = (char *) (coff_symbols + coff->NumberOfSymbols);
529
530     printf("\nDebug table: COFF format. modbase %p, coffbase %p\n", PE_base, coff);
531     printf("  ID  | seg:offs    [  abs   ] | symbol/function name\n");
532   for(i=0; i < coff->NumberOfSymbols; i++ )
533     {
534       coff_sym = coff_symbols + i;
535       naux = coff_sym->NumberOfAuxSymbols;
536
537       if( coff_sym->StorageClass == IMAGE_SYM_CLASS_FILE )
538         {
539           printf("file %s\n", (char *) (coff_sym + 1));
540           i += naux;
541           continue;
542         }
543
544       if(    (coff_sym->StorageClass == IMAGE_SYM_CLASS_STATIC)
545           && (naux == 0)
546           && (coff_sym->SectionNumber == 1) )
547         {
548           DWORD base = sectHead[coff_sym->SectionNumber - 1].VirtualAddress;
549           /*
550            * This is a normal static function when naux == 0.
551            * Just register it.  The current file is the correct
552            * one in this instance.
553            */
554           nampnt = get_coff_name( coff_sym, coff_strtab );
555
556           printf("%05d | %02d:%08lx [%08lx] | %s\n", i, coff_sym->SectionNumber - 1, coff_sym->Value - base, coff_sym->Value, nampnt);
557           i += naux;
558           continue;
559         }
560
561       if(    (coff_sym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL)
562           && ISFCN(coff_sym->Type)
563           && (coff_sym->SectionNumber > 0) )
564         {
565           DWORD base = sectHead[coff_sym->SectionNumber - 1].VirtualAddress;
566
567           nampnt = get_coff_name( coff_sym, coff_strtab );
568
569           /* FIXME: add code to find out the file this symbol belongs to,
570            * see winedbg */
571           printf("%05d | %02d:%08lx [%08lx] | %s\n", i, coff_sym->SectionNumber - 1, coff_sym->Value - base, coff_sym->Value, nampnt);
572           i += naux;
573           continue;
574         }
575
576       /*
577        * For now, skip past the aux entries.
578        */
579       i += naux;
580
581     }
582 }
583
584 void    dump_codeview(unsigned long base, unsigned long len)
585 {
586     dump_codeview_headers(base, len);
587 }
588
589 void    dump_frame_pointer_omission(unsigned long base, unsigned long len)
590 {
591         /* FPO is used to describe nonstandard stack frames */
592         printf("FIXME: FPO (frame pointer omission) debug symbol dumping not implemented yet.\n");
593 }