CLIENT_WaitReply: don't clear last error on success; fixed callers
[wine.git] / debugger / msc.c
blob50e35d9e89cf0661b73dc53f3065020d5b34e8fd
1 /*
2 * File msc.c - read VC++ debug information from COFF and eventually
3 * from PDB files.
5 * Copyright (C) 1996, Eric Youngdale.
7 * Note - this handles reading debug information for 32 bit applications
8 * that run under Windows-NT for example. I doubt that this would work well
9 * for 16 bit applications, but I don't think it really matters since the
10 * file format is different, and we should never get in here in such cases.
12 * TODO:
13 * Get 16 bit CV stuff working.
14 * Add symbol size to internal symbol table.
17 #include <stdio.h>
18 #include <stdlib.h>
20 #include <sys/types.h>
21 #include <sys/mman.h>
22 #include <fcntl.h>
23 #include <sys/stat.h>
24 #include <limits.h>
25 #include <string.h>
26 #include <unistd.h>
27 #ifndef PATH_MAX
28 #define PATH_MAX _MAX_PATH
29 #endif
30 #include "debugger.h"
31 #include "neexe.h"
32 #include "peexe.h"
33 #include "xmalloc.h"
34 #include "file.h"
37 *dbg_filename must be at least MAX_PATHNAME_LEN bytes in size
39 static void LocateDebugInfoFile(char *filename, char *dbg_filename)
41 char *str1 = xmalloc(MAX_PATHNAME_LEN*10);
42 char *str2 = xmalloc(MAX_PATHNAME_LEN);
43 char *file;
44 char *name_part;
45 DOS_FULL_NAME fullname;
47 file = strrchr(filename, '\\');
48 if( file == NULL ) file = filename; else file++;
50 if (GetEnvironmentVariableA("_NT_SYMBOL_PATH", str1, sizeof(str1)))
51 if (SearchPathA(str1, file, NULL, sizeof(str2), str2, &name_part))
52 goto ok;
53 if (GetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", str1, sizeof(str1)))
54 if (SearchPathA(str1, file, NULL, sizeof(str2), str2, &name_part))
55 goto ok;
56 if (SearchPathA(NULL, file, NULL, sizeof(str2), str2, &name_part))
57 goto ok;
58 else
60 quit:
61 memcpy(dbg_filename, filename, MAX_PATHNAME_LEN);
62 free(str1);
63 free(str2);
64 return;
66 ok:
67 if (DOSFS_GetFullName(str2, TRUE, &fullname))
68 memcpy(dbg_filename, fullname.long_name, MAX_PATHNAME_LEN);
69 else
70 goto quit;
71 free(str1);
72 free(str2);
73 return;
76 * This is an index we use to keep track of the debug information
77 * when we have multiple sources. We use the same database to also
78 * allow us to do an 'info shared' type of deal, and we use the index
79 * to eliminate duplicates.
81 static int DEBUG_next_index = 0;
83 union any_size
85 char * c;
86 short * s;
87 int * i;
88 unsigned int * ui;
92 * This is a convenience structure used to map portions of the
93 * line number table.
95 struct startend
97 unsigned int start;
98 unsigned int end;
102 * This is how we reference the various record types.
104 union codeview_symbol
106 struct
108 short int len;
109 short int id;
110 } generic;
112 struct
114 short int len;
115 short int id;
116 unsigned int offset;
117 unsigned short seg;
118 unsigned short symtype;
119 unsigned char namelen;
120 unsigned char name[1];
121 } data;
123 struct
125 short int len;
126 short int id;
127 unsigned int pparent;
128 unsigned int pend;
129 unsigned int next;
130 unsigned int offset;
131 unsigned short segment;
132 unsigned short thunk_len;
133 unsigned char thtype;
134 unsigned char namelen;
135 unsigned char name[1];
136 } thunk;
137 struct
139 short int len;
140 short int id;
141 unsigned int pparent;
142 unsigned int pend;
143 unsigned int next;
144 unsigned int proc_len;
145 unsigned int debug_start;
146 unsigned int debug_end;
147 unsigned int offset;
148 unsigned short segment;
149 unsigned short proctype;
150 unsigned char flags;
151 unsigned char namelen;
152 unsigned char name[1];
153 } proc;
154 struct
156 short int len; /* Total length of this entry */
157 short int id; /* Always S_BPREL32 */
158 unsigned int offset; /* Stack offset relative to BP */
159 unsigned short symtype;
160 unsigned char namelen;
161 unsigned char name[1];
162 } stack;
165 union codeview_type
167 struct
169 short int len;
170 short int id;
171 } generic;
173 struct
175 short int len;
176 short int id;
177 short int attribute;
178 short int datatype;
179 unsigned char variant[1];
180 } pointer;
182 struct
184 short int len;
185 short int id;
186 unsigned char nbits;
187 unsigned char bitoff;
188 unsigned short type;
189 } bitfield;
191 struct
193 short int len;
194 short int id;
195 short int elemtype;
196 short int idxtype;
197 unsigned char arrlen;
198 unsigned char namelen;
199 unsigned char name[1];
200 } array;
202 struct
204 short int len;
205 short int id;
206 short int n_element;
207 short int fieldlist;
208 short int property;
209 short int derived;
210 short int vshape;
211 unsigned short structlen;
212 unsigned char namelen;
213 unsigned char name[1];
214 } structure;
216 struct
218 short int len;
219 short int id;
220 short int count;
221 short int field;
222 short int property;
223 unsigned short un_len;
224 unsigned char namelen;
225 unsigned char name[1];
226 } t_union;
228 struct
230 short int len;
231 short int id;
232 short int count;
233 short int type;
234 short int field;
235 short int property;
236 unsigned char namelen;
237 unsigned char name[1];
238 } enumeration;
240 struct
242 short int id;
243 short int attribute;
244 unsigned short int value;
245 unsigned char namelen;
246 unsigned char name[1];
247 } enumerate;
249 struct
251 short int id;
252 short int type;
253 short int attribute;
254 unsigned short int offset;
255 unsigned char namelen;
256 unsigned char name[1];
257 } member;
259 struct
261 short int len;
262 short int id;
263 short int count;
264 short int type;
265 short int field;
266 short int property;
267 unsigned char namelen;
268 unsigned char name[1];
269 } fieldlist;
273 #define S_BPREL 0x200
274 #define S_LDATA 0x201
275 #define S_GDATA 0x202
276 #define S_PUB 0x203
277 #define S_LPROC 0x204
278 #define S_GPROC 0x205
279 #define S_THUNK 0x206
280 #define S_BLOCK 0x207
281 #define S_WITH 0x208
282 #define S_LABEL 0x209
284 #define S_PROCREF 0x400
285 #define S_DATAREF 0x401
286 #define S_ALIGN 0x402
287 #define S_UNKNOWN 0x403
290 * This covers the basic datatypes that VC++ seems to be using these days.
291 * 32 bit mode only. There are additional numbers for the pointers in 16
292 * bit mode. There are many other types listed in the documents, but these
293 * are apparently not used by the compiler, or represent pointer types
294 * that are not used.
296 #define T_NOTYPE 0x0000 /* Notype */
297 #define T_ABS 0x0001 /* Abs */
298 #define T_VOID 0x0003 /* Void */
299 #define T_CHAR 0x0010 /* signed char */
300 #define T_SHORT 0x0011 /* short */
301 #define T_LONG 0x0012 /* long */
302 #define T_QUAD 0x0013 /* long long */
303 #define T_UCHAR 0x0020 /* unsigned char */
304 #define T_USHORT 0x0021 /* unsigned short */
305 #define T_ULONG 0x0022 /* unsigned long */
306 #define T_UQUAD 0x0023 /* unsigned long long */
307 #define T_REAL32 0x0040 /* float */
308 #define T_REAL64 0x0041 /* double */
309 #define T_RCHAR 0x0070 /* real char */
310 #define T_WCHAR 0x0071 /* wide char */
311 #define T_INT4 0x0074 /* int */
312 #define T_UINT4 0x0075 /* unsigned int */
314 #define T_32PVOID 0x0403 /* 32 bit near pointer to void */
315 #define T_32PCHAR 0x0410 /* 16:32 near pointer to signed char */
316 #define T_32PSHORT 0x0411 /* 16:32 near pointer to short */
317 #define T_32PLONG 0x0412 /* 16:32 near pointer to int */
318 #define T_32PQUAD 0x0413 /* 16:32 near pointer to long long */
319 #define T_32PUCHAR 0x0420 /* 16:32 near pointer to unsigned char */
320 #define T_32PUSHORT 0x0421 /* 16:32 near pointer to unsigned short */
321 #define T_32PULONG 0x0422 /* 16:32 near pointer to unsigned int */
322 #define T_32PUQUAD 0x0423 /* 16:32 near pointer to long long */
323 #define T_32PREAL32 0x0440 /* 16:32 near pointer to float */
324 #define T_32PREAL64 0x0441 /* 16:32 near pointer to float */
325 #define T_32PRCHAR 0x0470 /* 16:32 near pointer to real char */
326 #define T_32PWCHAR 0x0471 /* 16:32 near pointer to real char */
327 #define T_32PINT4 0x0474 /* 16:32 near pointer to int */
328 #define T_32PUINT4 0x0475 /* 16:32 near pointer to unsigned int */
330 #define LF_MODIFIER 0x1
331 #define LF_POINTER 0x2
332 #define LF_ARRAY 0x3
333 #define LF_CLASS 0x4
334 #define LF_STRUCTURE 0x5
335 #define LF_UNION 0x6
336 #define LF_ENUMERATION 0x7
337 #define LF_PROCEDURE 0x8
338 #define LF_MFUNCTION 0x9
339 #define LF_VTSHAPE 0xa
340 #define LF_BARRAY 0xd
341 #define LF_DIMARRAY 0x11
342 #define LF_VFTPATH 0x12
344 #define LF_SKIP 0x200
345 #define LF_ARGLIST 0x201
346 #define LF_FIELDLIST 0x204
347 #define LF_DERIVED 0x205
348 #define LF_BITFIELD 0x206
350 #define LF_BCLASS 0x400
351 #define LF_VBCLASS 0x401
352 #define LF_IVBCLASS 0x402
353 #define LF_ENUMERATE 0x403
354 #define LF_FRIENDFCN 0x404
355 #define LF_INDEX 0x405
356 #define LF_MEMBER 0x406
357 #define LF_STMEMBER 0x407
358 #define LF_METHOD 0x408
359 #define LF_NESTEDTYPE 0x409
360 #define LF_VFUNCTAB 0x40a
361 #define LF_FRIENDCLS 0x40b
362 #define LF_ONEMETHOD 0x40c
363 #define LF_FUNCOFF 0x40d
365 #define MAX_BUILTIN_TYPES 0x480
366 static struct datatype * cv_basic_types[MAX_BUILTIN_TYPES];
367 static int num_cv_defined_types = 0;
368 static struct datatype **cv_defined_types = NULL;
371 * For the type CODEVIEW debug directory entries, the debug directory
372 * points to a structure like this. The cv_name field is the name
373 * of an external .PDB file.
375 struct CodeViewDebug
377 char cv_nbtype[8];
378 unsigned int cv_timestamp;
379 char cv_unknown[4];
380 char cv_name[1];
383 struct MiscDebug {
384 unsigned int DataType;
385 unsigned int Length;
386 char Unicode;
387 char Reserved[3];
388 char Data[1];
392 * This is the header that the COFF variety of debug header points to.
394 struct CoffDebug {
395 unsigned int N_Sym;
396 unsigned int SymbolOffset;
397 unsigned int N_Linenum;
398 unsigned int LinenumberOffset;
399 unsigned int Unused[4];
402 struct CoffLinenum {
403 unsigned int VirtualAddr;
404 unsigned short int Linenum;
407 struct CoffFiles {
408 unsigned int startaddr;
409 unsigned int endaddr;
410 char * filename;
411 int linetab_offset;
412 int linecnt;
413 struct name_hash **entries;
414 int neps;
415 int neps_alloc;
419 struct CoffSymbol {
420 union {
421 char ShortName[8];
422 struct {
423 unsigned int NotLong;
424 unsigned int StrTaboff;
425 } Name;
426 } N;
427 unsigned int Value;
428 short SectionNumber;
429 short Type;
430 char StorageClass;
431 unsigned char NumberOfAuxSymbols;
434 struct CoffAuxSection{
435 unsigned int Length;
436 unsigned short NumberOfRelocations;
437 unsigned short NumberOfLinenumbers;
438 unsigned int CheckSum;
439 short Number;
440 char Selection;
441 } Section;
444 * These two structures are used in the directory within a .DBG file
445 * to locate the individual important bits that we might want to see.
447 struct CV4_DirHead {
448 short unsigned int dhsize;
449 short unsigned int desize;
450 unsigned int ndir;
451 unsigned int next_offset;
452 unsigned int flags;
455 struct CV4_DirEnt {
456 short unsigned int subsect_number;
457 short unsigned int module_number;
458 unsigned int offset;
459 unsigned int size;
463 * These are the values of interest that the subsect_number field takes.
465 #define sstAlignSym 0x125
466 #define sstSrcModule 0x127
468 struct codeview_linetab_hdr
470 unsigned int nline;
471 unsigned int segno;
472 unsigned int start;
473 unsigned int end;
474 char * sourcefile;
475 unsigned short * linetab;
476 unsigned int * offtab;
479 struct codeview_pdb_hdr
481 char ident[44];
482 unsigned int blocksize; /* Extent size */
483 unsigned short loc_freelist; /* freelist. */
484 unsigned short alloc_filesize; /* # extents allocated. */
485 unsigned int toc_len;
486 unsigned int unknown;
487 unsigned short toc_ext[1]; /* array of extent #'s for toc. */
491 * This is our own structure that we use to keep track of the contents
492 * of a PDB file.
494 struct file_list
496 int record_len;
497 int nextents;
498 short int * extent_list;
499 unsigned int linetab_offset;
500 unsigned int linetab_len;
504 * These are the structures that represent how the file table is set up
505 * within the PDB file.
507 struct filetab_hdr
509 unsigned short tab1_file;
510 unsigned short tab2_file;
511 unsigned short gsym_file;
512 unsigned short padding;
513 unsigned int ftab_len;
514 unsigned int fofftab_len;
515 unsigned int hash_len;
516 unsigned int strtab_len;
519 struct file_ent
521 unsigned int reserved1;
522 unsigned short datasect_segment;
523 unsigned short reserved2;
524 unsigned int datasect_offset;
525 unsigned int datasect_size;
526 unsigned int datasect_flags;
527 unsigned short reserved3;
528 unsigned short index;
529 unsigned short num6a;
530 unsigned short file_number;
531 unsigned int linetab_offset;
532 unsigned int linetab_len;
533 unsigned int num9;
534 unsigned int num10;
535 unsigned int num11;
536 unsigned char filename[1];
540 ********************************************************************
542 struct deferred_debug_info
544 struct deferred_debug_info * next;
545 char * load_addr;
546 char * module_name;
547 char * dbg_info;
548 int dbg_size;
549 HMODULE module;
550 PIMAGE_DEBUG_DIRECTORY dbgdir;
551 PIMAGE_SECTION_HEADER sectp;
552 int nsect;
553 short int dbg_index;
554 char loaded;
557 struct deferred_debug_info * dbglist = NULL;
560 * A simple macro that tells us whether a given COFF symbol is a
561 * function or not.
563 #define N_TMASK 0x0030
564 #define IMAGE_SYM_DTYPE_FUNCTION 2
565 #define N_BTSHFT 4
566 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
570 * This is what we are looking for in the COFF symbols.
572 #define IMAGE_SYM_CLASS_EXTERNAL 0x2
573 #define IMAGE_SYM_CLASS_STATIC 0x3
574 #define IMAGE_SYM_CLASS_FILE 0x67
576 static
577 struct datatype * DEBUG_GetCVType(int typeno)
579 struct datatype * dt = NULL;
582 * Convert Codeview type numbers into something we can grok internally.
583 * Numbers < 0x1000 are all fixed builtin types. Numbers from 0x1000 and
584 * up are all user defined (structs, etc).
586 if( typeno < 0x1000 )
588 if( typeno < MAX_BUILTIN_TYPES )
590 dt = cv_basic_types[typeno];
593 else
595 if( typeno - 0x1000 < num_cv_defined_types )
597 dt = cv_defined_types[typeno - 0x1000];
601 return dt;
604 static int
605 DEBUG_ParseTypeTable(char * table, int len)
607 int arr_max;
608 int curr_type;
609 enum debug_type fieldtype;
610 int elem_size;
611 union any_size ptr;
612 union any_size ptr2;
613 struct datatype * subtype;
614 char symname[256];
615 union codeview_type * type;
616 union codeview_type * type2;
617 struct datatype * typeptr;
619 curr_type = 0x1000;
621 ptr = (union any_size) (table + 16);
622 while( ptr.c - table < len )
624 type = (union codeview_type *) ptr.c;
626 if( curr_type - 0x1000 >= num_cv_defined_types )
628 num_cv_defined_types += 0x100;
629 cv_defined_types = (struct datatype **) realloc(cv_defined_types,
630 num_cv_defined_types * sizeof(struct datatype *));
631 memset(cv_defined_types + num_cv_defined_types - 0x100,
633 0x100 * sizeof(struct datatype *));
634 if( cv_defined_types == NULL )
636 return FALSE;
640 switch(type->generic.id)
642 case LF_POINTER:
643 cv_defined_types[curr_type - 0x1000] =
644 DEBUG_FindOrMakePointerType(DEBUG_GetCVType(type->pointer.datatype));
645 break;
646 case LF_ARRAY:
647 if( type->array.arrlen >= 0x8000 )
650 * This is a numeric leaf, I am too lazy to handle this right
651 * now.
653 fprintf(stderr, "Ignoring large numberic leaf.\n");
654 break;
656 if( type->array.namelen != 0 )
658 memset(symname, 0, sizeof(symname));
659 memcpy(symname, type->array.name, type->array.namelen);
660 typeptr = DEBUG_NewDataType(DT_ARRAY, symname);
662 else
664 typeptr = DEBUG_NewDataType(DT_ARRAY, NULL);
666 cv_defined_types[curr_type - 0x1000] = typeptr;
668 subtype = DEBUG_GetCVType(type->array.elemtype);
669 if( (subtype == NULL)
670 || (elem_size = DEBUG_GetObjectSize(subtype)) == 0 )
672 arr_max = 0;
674 else
676 arr_max = type->array.arrlen / DEBUG_GetObjectSize(subtype);
679 DEBUG_SetArrayParams(typeptr, 0, arr_max, subtype);
680 break;
681 case LF_FIELDLIST:
683 * This is where the basic list of fields is defined for
684 * structures and classes.
686 * First, we need to look ahead and see whether we are building
687 * a fieldlist for an enum or a struct.
689 ptr2.i = ptr.i + 1;
690 type2 = (union codeview_type *) ptr2.c;
691 if( type2->member.id == LF_MEMBER )
693 typeptr = DEBUG_NewDataType(DT_STRUCT, NULL);
694 fieldtype = DT_STRUCT;
696 else if( type2->member.id == LF_ENUMERATE )
698 typeptr = DEBUG_NewDataType(DT_ENUM, NULL);
699 fieldtype = DT_ENUM;
701 else
703 break;
706 cv_defined_types[curr_type - 0x1000] = typeptr;
707 while( ptr2.c < (ptr.c + ((type->generic.len + 3) & ~3)) )
709 type2 = (union codeview_type *) ptr2.c;
710 if( type2->member.id == LF_MEMBER && fieldtype == DT_STRUCT )
712 memset(symname, 0, sizeof(symname));
713 memcpy(symname, type2->member.name, type2->member.namelen);
715 subtype = DEBUG_GetCVType(type2->member.type);
716 elem_size = 0;
717 if( subtype != NULL )
719 elem_size = DEBUG_GetObjectSize(subtype);
722 if( type2->member.offset >= 0x8000 )
725 * This is a numeric leaf, I am too lazy to handle this right
726 * now.
728 fprintf(stderr, "Ignoring large numberic leaf.\n");
730 else
732 DEBUG_AddStructElement(typeptr, symname, subtype,
733 type2->member.offset << 3,
734 elem_size << 3);
737 else if( type2->member.id == LF_ENUMERATE && fieldtype == DT_ENUM )
739 memset(symname, 0, sizeof(symname));
740 memcpy(symname, type2->enumerate.name, type2->enumerate.namelen);
742 if( type2->enumerate.value >= 0x8000 )
745 * This is a numeric leaf, I am too lazy to handle this right
746 * now.
748 fprintf(stderr, "Ignoring large numberic leaf.\n");
750 else
752 DEBUG_AddStructElement(typeptr, symname, NULL,
753 type2->enumerate.value, 0);
756 else
759 * Something else I have never seen before. Either wrong type of
760 * object in the fieldlist, or some other problem which I wouldn't
761 * really know how to handle until it came up.
763 fprintf(stderr, "Unexpected entry in fieldlist\n");
764 break;
768 ptr2.c += ((type2->member.namelen + 9 + 3) & ~3);
770 break;
771 case LF_STRUCTURE:
772 case LF_CLASS:
773 if( type->structure.structlen >= 0x8000 )
776 * This is a numeric leaf, I am too lazy to handle this right
777 * now.
779 fprintf(stderr, "Ignoring large numberic leaf.\n");
780 break;
782 memset(symname, 0, sizeof(symname));
783 memcpy(symname, type->structure.name, type->structure.namelen);
784 if( strcmp(symname, "__unnamed") == 0 )
786 typeptr = DEBUG_NewDataType(DT_STRUCT, NULL);
788 else
790 typeptr = DEBUG_NewDataType(DT_STRUCT, symname);
792 cv_defined_types[curr_type - 0x1000] = typeptr;
795 * Now copy the relevant bits from the fieldlist that we specified.
797 subtype = DEBUG_GetCVType(type->structure.fieldlist);
799 if( subtype != NULL )
801 DEBUG_SetStructSize(typeptr, type->structure.structlen);
802 DEBUG_CopyFieldlist(typeptr, subtype);
804 break;
805 case LF_UNION:
806 if( type->t_union.un_len >= 0x8000 )
809 * This is a numeric leaf, I am too lazy to handle this right
810 * now.
812 fprintf(stderr, "Ignoring large numberic leaf.\n");
813 break;
815 memset(symname, 0, sizeof(symname));
816 memcpy(symname, type->t_union.name, type->t_union.namelen);
818 if( strcmp(symname, "__unnamed") == 0 )
820 typeptr = DEBUG_NewDataType(DT_STRUCT, NULL);
822 else
824 typeptr = DEBUG_NewDataType(DT_STRUCT, symname);
827 cv_defined_types[curr_type - 0x1000] = typeptr;
830 * Now copy the relevant bits from the fieldlist that we specified.
832 subtype = DEBUG_GetCVType(type->t_union.field);
834 if( subtype != NULL )
836 DEBUG_SetStructSize(typeptr, type->t_union.un_len);
837 DEBUG_CopyFieldlist(typeptr, subtype);
839 break;
840 case LF_BITFIELD:
841 typeptr = DEBUG_NewDataType(DT_BITFIELD, NULL);
842 cv_defined_types[curr_type - 0x1000] = typeptr;
843 DEBUG_SetBitfieldParams(typeptr, type->bitfield.bitoff,
844 type->bitfield.nbits,
845 DEBUG_GetCVType(type->bitfield.type));
846 break;
847 case LF_ENUMERATION:
848 memset(symname, 0, sizeof(symname));
849 memcpy(symname, type->enumeration.name, type->enumeration.namelen);
850 typeptr = DEBUG_NewDataType(DT_ENUM, symname);
851 cv_defined_types[curr_type - 0x1000] = typeptr;
854 * Now copy the relevant bits from the fieldlist that we specified.
856 subtype = DEBUG_GetCVType(type->enumeration.field);
858 if( subtype != NULL )
860 DEBUG_CopyFieldlist(typeptr, subtype);
862 break;
863 case LF_DIMARRAY:
864 default:
865 break;
867 curr_type++;
868 ptr.c += (type->generic.len + 3) & ~3;
871 return TRUE;
874 void
875 DEBUG_InitCVDataTypes()
878 * These are the common builtin types that are used by VC++.
880 cv_basic_types[T_NOTYPE] = NULL;
881 cv_basic_types[T_ABS] = NULL;
882 cv_basic_types[T_VOID] = DEBUG_NewDataType(DT_BASIC, "void");
883 cv_basic_types[T_CHAR] = DEBUG_NewDataType(DT_BASIC, "char");
884 cv_basic_types[T_SHORT] = DEBUG_NewDataType(DT_BASIC, "short int");
885 cv_basic_types[T_LONG] = DEBUG_NewDataType(DT_BASIC, "long int");
886 cv_basic_types[T_QUAD] = DEBUG_NewDataType(DT_BASIC, "long long int");
887 cv_basic_types[T_UCHAR] = DEBUG_NewDataType(DT_BASIC, "unsigned char");
888 cv_basic_types[T_USHORT] = DEBUG_NewDataType(DT_BASIC, "short unsigned int");
889 cv_basic_types[T_ULONG] = DEBUG_NewDataType(DT_BASIC, "long unsigned int");
890 cv_basic_types[T_UQUAD] = DEBUG_NewDataType(DT_BASIC, "long long unsigned int");
891 cv_basic_types[T_REAL32] = DEBUG_NewDataType(DT_BASIC, "float");
892 cv_basic_types[T_REAL64] = DEBUG_NewDataType(DT_BASIC, "double");
893 cv_basic_types[T_RCHAR] = DEBUG_NewDataType(DT_BASIC, "char");
894 cv_basic_types[T_WCHAR] = DEBUG_NewDataType(DT_BASIC, "short");
895 cv_basic_types[T_INT4] = DEBUG_NewDataType(DT_BASIC, "int");
896 cv_basic_types[T_UINT4] = DEBUG_NewDataType(DT_BASIC, "unsigned int");
898 cv_basic_types[T_32PVOID] = DEBUG_FindOrMakePointerType(cv_basic_types[T_VOID]);
899 cv_basic_types[T_32PCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_CHAR]);
900 cv_basic_types[T_32PSHORT] = DEBUG_FindOrMakePointerType(cv_basic_types[T_SHORT]);
901 cv_basic_types[T_32PLONG] = DEBUG_FindOrMakePointerType(cv_basic_types[T_LONG]);
902 cv_basic_types[T_32PQUAD] = DEBUG_FindOrMakePointerType(cv_basic_types[T_QUAD]);
903 cv_basic_types[T_32PUCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_UCHAR]);
904 cv_basic_types[T_32PUSHORT] = DEBUG_FindOrMakePointerType(cv_basic_types[T_USHORT]);
905 cv_basic_types[T_32PULONG] = DEBUG_FindOrMakePointerType(cv_basic_types[T_ULONG]);
906 cv_basic_types[T_32PUQUAD] = DEBUG_FindOrMakePointerType(cv_basic_types[T_UQUAD]);
907 cv_basic_types[T_32PREAL32] = DEBUG_FindOrMakePointerType(cv_basic_types[T_REAL32]);
908 cv_basic_types[T_32PREAL64] = DEBUG_FindOrMakePointerType(cv_basic_types[T_REAL64]);
909 cv_basic_types[T_32PRCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_RCHAR]);
910 cv_basic_types[T_32PWCHAR] = DEBUG_FindOrMakePointerType(cv_basic_types[T_WCHAR]);
911 cv_basic_types[T_32PINT4] = DEBUG_FindOrMakePointerType(cv_basic_types[T_INT4]);
912 cv_basic_types[T_32PUINT4] = DEBUG_FindOrMakePointerType(cv_basic_types[T_UINT4]);
916 * In this function, we keep track of deferred debugging information
917 * that we may need later if we were to need to use the internal debugger.
918 * We don't fully process it here for performance reasons.
921 DEBUG_RegisterDebugInfo( HMODULE hModule, const char *module_name)
923 int has_codeview = FALSE;
924 int rtn = FALSE;
925 int orig_size;
926 PIMAGE_DEBUG_DIRECTORY dbgptr;
927 u_long v_addr, size;
928 PIMAGE_NT_HEADERS nth = PE_HEADER(hModule);
930 size = nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size;
931 if (size) {
932 v_addr = nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;
933 dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
934 orig_size = size;
935 for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ )
937 switch(dbgptr->Type)
939 case IMAGE_DEBUG_TYPE_CODEVIEW:
940 case IMAGE_DEBUG_TYPE_MISC:
941 has_codeview = TRUE;
942 break;
946 size = orig_size;
947 dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
948 for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ )
950 switch(dbgptr->Type)
952 case IMAGE_DEBUG_TYPE_COFF:
954 * If we have both codeview and COFF debug info, ignore the
955 * coff debug info as it would just confuse us, and it is
956 * less complete.
958 * FIXME - this is broken - if we cannot find the PDB file, then
959 * we end up with no debugging info at all. In this case, we
960 * should use the COFF info as a backup.
962 if( has_codeview )
964 break;
966 case IMAGE_DEBUG_TYPE_CODEVIEW:
967 case IMAGE_DEBUG_TYPE_MISC:
969 * This is usually an indirection to a .DBG file.
970 * This is similar to (but a slightly older format) from the
971 * PDB file.
973 * First check to see if the image was 'stripped'. If so, it
974 * means that this entry points to a .DBG file. Otherwise,
975 * it just points to itself, and we can ignore this.
983 if( (dbgptr->Type != IMAGE_DEBUG_TYPE_MISC) ||
984 (PE_HEADER(hModule)->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) != 0 )
986 char fn[PATH_MAX];
987 int fd = -1;
988 DOS_FULL_NAME full_name;
989 struct deferred_debug_info* deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
991 deefer->module = hModule;
992 deefer->load_addr = (char *)hModule;
995 * Read the important bits. What we do after this depends
996 * upon the type, but this is always enough so we are able
997 * to proceed if we know what we need to do next.
999 /* basically, the PE loader maps all sections (data, resources...), but doesn't map
1000 * the DataDirectory array's content. One its entry contains the *beloved*
1001 * debug information. (Note the DataDirectory is mapped, not its content)
1004 if (GetModuleFileNameA(hModule, fn, sizeof(fn)) > 0 &&
1005 DOSFS_GetFullName(fn, TRUE, &full_name) &&
1006 (fd = open(full_name.long_name, O_RDONLY)) > 0)
1008 deefer->dbg_info = mmap(NULL, dbgptr->SizeOfData,
1009 PROT_READ, MAP_PRIVATE, fd, dbgptr->PointerToRawData);
1010 close(fd);
1011 if( deefer->dbg_info == (char *) 0xffffffff )
1013 free(deefer);
1014 break;
1017 else
1019 free(deefer);
1020 fprintf(stderr, " (not mapped: fn=%s, lfn=%s, fd=%d)", fn, full_name.long_name, fd);
1021 break;
1023 deefer->dbg_size = dbgptr->SizeOfData;
1024 deefer->dbgdir = dbgptr;
1025 deefer->next = dbglist;
1026 deefer->loaded = FALSE;
1027 deefer->dbg_index = DEBUG_next_index;
1028 deefer->module_name = xstrdup(module_name);
1030 deefer->sectp = PE_SECTIONS(hModule);
1031 deefer->nsect = PE_HEADER(hModule)->FileHeader.NumberOfSections;
1033 dbglist = deefer;
1035 break;
1036 default:
1039 DEBUG_next_index++;
1041 /* look for .stabs/.stabstr sections */
1043 PIMAGE_SECTION_HEADER pe_seg = PE_SECTIONS(hModule);
1044 int i,stabsize=0,stabstrsize=0;
1045 unsigned int stabs=0,stabstr=0;
1047 for (i=0;i<nth->FileHeader.NumberOfSections;i++) {
1048 if (!strcasecmp(pe_seg[i].Name,".stab")) {
1049 stabs = pe_seg[i].VirtualAddress;
1050 stabsize = pe_seg[i].SizeOfRawData;
1052 if (!strncasecmp(pe_seg[i].Name,".stabstr",8)) {
1053 stabstr = pe_seg[i].VirtualAddress;
1054 stabstrsize = pe_seg[i].SizeOfRawData;
1057 if (stabstrsize && stabsize) {
1058 #ifdef _WE_SUPPORT_THE_STAB_TYPES_USED_BY_MINGW_TOO
1059 /* Won't work currently, since MINGW32 uses some special typedefs
1060 * which we do not handle yet. Support for them is a bit difficult.
1062 DEBUG_ParseStabs(hModule,0,stabs,stabsize,stabstr,stabstrsize);
1063 #endif
1064 fprintf(stderr,"(stabs not loaded)");
1067 return (rtn);
1071 * ELF modules are also entered into the list - this is so that we
1072 * can make 'info shared' types of displays possible.
1075 DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name)
1077 struct deferred_debug_info * deefer;
1079 deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
1080 deefer->module = 0;
1083 * Read the important bits. What we do after this depends
1084 * upon the type, but this is always enough so we are able
1085 * to proceed if we know what we need to do next.
1087 deefer->dbg_size = size;
1088 deefer->dbg_info = (char *) NULL;
1090 deefer->load_addr = (char *) load_addr;
1091 deefer->dbgdir = NULL;
1092 deefer->next = dbglist;
1093 deefer->loaded = TRUE;
1094 deefer->dbg_index = DEBUG_next_index;
1095 deefer->module_name = xstrdup(name);
1096 dbglist = deefer;
1098 DEBUG_next_index++;
1100 return (TRUE);
1106 * Process COFF debugging information embedded in a Win32 application.
1109 static
1111 DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
1113 struct CoffAuxSection * aux;
1114 struct CoffDebug * coff;
1115 struct CoffFiles * coff_files = NULL;
1116 struct CoffLinenum * coff_linetab;
1117 char * coff_strtab;
1118 struct CoffSymbol * coff_sym;
1119 struct CoffSymbol * coff_symbol;
1120 struct CoffFiles * curr_file = NULL;
1121 int i;
1122 int j;
1123 int k;
1124 struct CoffLinenum * linepnt;
1125 int linetab_indx;
1126 char namebuff[9];
1127 char * nampnt;
1128 int naux;
1129 DBG_ADDR new_addr;
1130 int nfiles = 0;
1131 int nfiles_alloc = 0;
1132 struct CoffFiles orig_file;
1133 int rtn = FALSE;
1134 char * this_file = NULL;
1136 coff = (struct CoffDebug *) deefer->dbg_info;
1138 coff_symbol = (struct CoffSymbol *) ((unsigned int) coff + coff->SymbolOffset);
1139 coff_linetab = (struct CoffLinenum *) ((unsigned int) coff + coff->LinenumberOffset);
1140 coff_strtab = (char *) ((unsigned int) coff_symbol + 18*coff->N_Sym);
1142 linetab_indx = 0;
1144 for(i=0; i < coff->N_Sym; i++ )
1147 * We do this because some compilers (i.e. gcc) incorrectly
1148 * pad the structure up to a 4 byte boundary. The structure
1149 * is really only 18 bytes long, so we have to manually make sure
1150 * we get it right.
1152 * FIXME - there must be a way to have autoconf figure out the
1153 * correct compiler option for this. If it is always gcc, that
1154 * makes life simpler, but I don't want to force this.
1156 coff_sym = (struct CoffSymbol *) ((unsigned int) coff_symbol + 18*i);
1157 naux = coff_sym->NumberOfAuxSymbols;
1159 if( coff_sym->StorageClass == IMAGE_SYM_CLASS_FILE )
1161 if( nfiles + 1 >= nfiles_alloc )
1163 nfiles_alloc += 10;
1164 coff_files = (struct CoffFiles *) realloc( coff_files,
1165 nfiles_alloc * sizeof(struct CoffFiles));
1167 curr_file = coff_files + nfiles;
1168 nfiles++;
1169 curr_file->startaddr = 0xffffffff;
1170 curr_file->endaddr = 0;
1171 curr_file->filename = ((char *) coff_sym) + 18;
1172 curr_file->linetab_offset = -1;
1173 curr_file->linecnt = 0;
1174 curr_file->entries = NULL;
1175 curr_file->neps = curr_file->neps_alloc = 0;
1176 #if 0
1177 fprintf(stderr,"New file %s\n", curr_file->filename);
1178 #endif
1179 i += naux;
1180 continue;
1184 * This guy marks the size and location of the text section
1185 * for the current file. We need to keep track of this so
1186 * we can figure out what file the different global functions
1187 * go with.
1189 if( (coff_sym->StorageClass == IMAGE_SYM_CLASS_STATIC)
1190 && (naux != 0)
1191 && (coff_sym->Type == 0)
1192 && (coff_sym->SectionNumber == 1) )
1194 aux = (struct CoffAuxSection *) ((unsigned int) coff_sym + 18);
1196 if( curr_file->linetab_offset != -1 )
1198 #if 0
1199 fprintf(stderr, "Duplicating sect from %s: %x %x %x %d %d\n",
1200 curr_file->filename,
1201 aux->Length,
1202 aux->NumberOfRelocations,
1203 aux->NumberOfLinenumbers,
1204 aux->Number,
1205 aux->Selection);
1206 fprintf(stderr, "More sect %d %x %d %d %d\n",
1207 coff_sym->SectionNumber,
1208 coff_sym->Value,
1209 coff_sym->Type,
1210 coff_sym->StorageClass,
1211 coff_sym->NumberOfAuxSymbols);
1212 #endif
1215 * Save this so we can copy bits from it.
1217 orig_file = *curr_file;
1220 * Duplicate the file entry. We have no way to describe
1221 * multiple text sections in our current way of handling things.
1223 if( nfiles + 1 >= nfiles_alloc )
1225 nfiles_alloc += 10;
1226 coff_files = (struct CoffFiles *) realloc( coff_files,
1227 nfiles_alloc * sizeof(struct CoffFiles));
1229 curr_file = coff_files + nfiles;
1230 nfiles++;
1231 curr_file->startaddr = 0xffffffff;
1232 curr_file->endaddr = 0;
1233 curr_file->filename = orig_file.filename;
1234 curr_file->linetab_offset = -1;
1235 curr_file->linecnt = 0;
1236 curr_file->entries = NULL;
1237 curr_file->neps = curr_file->neps_alloc = 0;
1239 #if 0
1240 else
1242 fprintf(stderr, "New text sect from %s: %x %x %x %d %d\n",
1243 curr_file->filename,
1244 aux->Length,
1245 aux->NumberOfRelocations,
1246 aux->NumberOfLinenumbers,
1247 aux->Number,
1248 aux->Selection);
1250 #endif
1252 if( curr_file->startaddr > coff_sym->Value )
1254 curr_file->startaddr = coff_sym->Value;
1257 if( curr_file->startaddr > coff_sym->Value )
1259 curr_file->startaddr = coff_sym->Value;
1262 if( curr_file->endaddr < coff_sym->Value + aux->Length )
1264 curr_file->endaddr = coff_sym->Value + aux->Length;
1267 curr_file->linetab_offset = linetab_indx;
1268 curr_file->linecnt = aux->NumberOfLinenumbers;
1269 linetab_indx += aux->NumberOfLinenumbers;
1270 i += naux;
1271 continue;
1274 if( (coff_sym->StorageClass == IMAGE_SYM_CLASS_STATIC)
1275 && (naux == 0)
1276 && (coff_sym->SectionNumber == 1) )
1279 * This is a normal static function when naux == 0.
1280 * Just register it. The current file is the correct
1281 * one in this instance.
1283 if( coff_sym->N.Name.NotLong )
1285 memcpy(namebuff, coff_sym->N.ShortName, 8);
1286 namebuff[8] = '\0';
1287 nampnt = &namebuff[0];
1289 else
1291 nampnt = coff_strtab + coff_sym->N.Name.StrTaboff;
1294 if( nampnt[0] == '_' )
1296 nampnt++;
1299 new_addr.seg = 0;
1300 new_addr.off = (int) (deefer->load_addr + coff_sym->Value);
1302 if( curr_file->neps + 1 >= curr_file->neps_alloc )
1304 curr_file->neps_alloc += 10;
1305 curr_file->entries = (struct name_hash **)
1306 realloc( curr_file->entries,
1307 curr_file->neps_alloc * sizeof(struct name_hash *));
1309 #if 0
1310 fprintf(stderr,"\tAdding static symbol %s\n", nampnt);
1311 #endif
1312 curr_file->entries[curr_file->neps++] =
1313 DEBUG_AddSymbol( nampnt, &new_addr, this_file, SYM_WIN32 );
1314 i += naux;
1315 continue;
1318 if( (coff_sym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL)
1319 && ISFCN(coff_sym->Type)
1320 && (coff_sym->SectionNumber > 0) )
1322 if( coff_sym->N.Name.NotLong )
1324 memcpy(namebuff, coff_sym->N.ShortName, 8);
1325 namebuff[8] = '\0';
1326 nampnt = &namebuff[0];
1328 else
1330 nampnt = coff_strtab + coff_sym->N.Name.StrTaboff;
1334 if( nampnt[0] == '_' )
1336 nampnt++;
1339 new_addr.seg = 0;
1340 new_addr.off = (int) (deefer->load_addr + coff_sym->Value);
1342 #if 0
1343 fprintf(stderr, "%d: %x %s\n", i, new_addr.off, nampnt);
1345 fprintf(stderr,"\tAdding global symbol %s\n", nampnt);
1346 #endif
1349 * Now we need to figure out which file this guy belongs to.
1351 this_file = NULL;
1352 for(j=0; j < nfiles; j++)
1354 if( coff_files[j].startaddr <= coff_sym->Value
1355 && coff_files[j].endaddr > coff_sym->Value )
1357 this_file = coff_files[j].filename;
1358 break;
1361 if( coff_files[j].neps + 1 >= coff_files[j].neps_alloc )
1363 coff_files[j].neps_alloc += 10;
1364 coff_files[j].entries = (struct name_hash **)
1365 realloc( coff_files[j].entries,
1366 coff_files[j].neps_alloc * sizeof(struct name_hash *));
1368 coff_files[j].entries[coff_files[j].neps++] =
1369 DEBUG_AddSymbol( nampnt, &new_addr, this_file, SYM_WIN32 );
1370 i += naux;
1371 continue;
1374 if( (coff_sym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL)
1375 && (coff_sym->SectionNumber > 0) )
1378 * Similar to above, but for the case of data symbols.
1379 * These aren't treated as entrypoints.
1381 if( coff_sym->N.Name.NotLong )
1383 memcpy(namebuff, coff_sym->N.ShortName, 8);
1384 namebuff[8] = '\0';
1385 nampnt = &namebuff[0];
1387 else
1389 nampnt = coff_strtab + coff_sym->N.Name.StrTaboff;
1393 if( nampnt[0] == '_' )
1395 nampnt++;
1398 new_addr.seg = 0;
1399 new_addr.off = (int) (deefer->load_addr + coff_sym->Value);
1401 #if 0
1402 fprintf(stderr, "%d: %x %s\n", i, new_addr.off, nampnt);
1404 fprintf(stderr,"\tAdding global data symbol %s\n", nampnt);
1405 #endif
1408 * Now we need to figure out which file this guy belongs to.
1410 DEBUG_AddSymbol( nampnt, &new_addr, NULL, SYM_WIN32 );
1411 i += naux;
1412 continue;
1415 if( (coff_sym->StorageClass == IMAGE_SYM_CLASS_STATIC)
1416 && (naux == 0) )
1419 * Ignore these. They don't have anything to do with
1420 * reality.
1422 i += naux;
1423 continue;
1426 #if 0
1427 fprintf(stderr,"Skipping unknown entry %d %d %d\n", coff_sym->StorageClass,
1428 coff_sym->SectionNumber, naux);
1429 #endif
1432 * For now, skip past the aux entries.
1434 i += naux;
1439 * OK, we now should have a list of files, and we should have a list
1440 * of entrypoints. We need to sort the entrypoints so that we are
1441 * able to tie the line numbers with the given functions within the
1442 * file.
1444 if( coff_files != NULL )
1446 for(j=0; j < nfiles; j++)
1448 if( coff_files[j].entries != NULL )
1450 qsort(coff_files[j].entries, coff_files[j].neps,
1451 sizeof(struct name_hash *), DEBUG_cmp_sym);
1456 * Now pick apart the line number tables, and attach the entries
1457 * to the given functions.
1459 for(j=0; j < nfiles; j++)
1461 i = 0;
1462 if( coff_files[j].neps != 0 )
1463 for(k=0; k < coff_files[j].linecnt; k++)
1466 * Another monstrosity caused by the fact that we are using
1467 * a 6 byte structure, and gcc wants to pad structures to 4 byte
1468 * boundaries. Otherwise we could just index into an array.
1470 linepnt = (struct CoffLinenum *)
1471 ((unsigned int) coff_linetab +
1472 6*(coff_files[j].linetab_offset + k));
1474 * If we have spilled onto the next entrypoint, then
1475 * bump the counter..
1477 while(TRUE)
1479 if (i+1 >= coff_files[j].neps) break;
1480 DEBUG_GetSymbolAddr(coff_files[j].entries[i+1], &new_addr);
1481 if( (((unsigned int)deefer->load_addr +
1482 linepnt->VirtualAddr) >= new_addr.off) )
1484 i++;
1485 } else break;
1489 * Add the line number. This is always relative to the
1490 * start of the function, so we need to subtract that offset
1491 * first.
1493 DEBUG_GetSymbolAddr(coff_files[j].entries[i], &new_addr);
1494 DEBUG_AddLineNumber(coff_files[j].entries[i],
1495 linepnt->Linenum,
1496 (unsigned int) deefer->load_addr
1497 + linepnt->VirtualAddr
1498 - new_addr.off);
1503 rtn = TRUE;
1505 if( coff_files != NULL )
1507 for(j=0; j < nfiles; j++)
1509 if( coff_files[j].entries != NULL )
1511 free(coff_files[j].entries);
1514 free(coff_files);
1517 return (rtn);
1522 * Process a codeview line number table. Digestify the thing so that
1523 * we can easily reference the thing when we process the rest of
1524 * the information.
1526 static struct codeview_linetab_hdr *
1527 DEBUG_SnarfLinetab(char * linetab,
1528 int size)
1530 int file_segcount;
1531 char filename[PATH_MAX];
1532 unsigned int * filetab;
1533 char * fn;
1534 int i;
1535 int k;
1536 struct codeview_linetab_hdr * lt_hdr;
1537 unsigned int * lt_ptr;
1538 int nfile;
1539 int nseg;
1540 union any_size pnt;
1541 union any_size pnt2;
1542 struct startend * start;
1543 int this_seg;
1546 * Now get the important bits.
1548 pnt = (union any_size) linetab;
1549 nfile = *pnt.s++;
1550 nseg = *pnt.s++;
1552 filetab = (unsigned int *) pnt.c;
1555 * Now count up the number of segments in the file.
1557 nseg = 0;
1558 for(i=0; i<nfile; i++)
1560 pnt2 = (union any_size) (linetab + filetab[i]);
1561 nseg += *pnt2.s;
1565 * Next allocate the header we will be returning.
1566 * There is one header for each segment, so that we can reach in
1567 * and pull bits as required.
1569 lt_hdr = (struct codeview_linetab_hdr *)
1570 xmalloc((nseg + 1) * sizeof(*lt_hdr));
1571 if( lt_hdr == NULL )
1573 goto leave;
1576 memset(lt_hdr, 0, sizeof(*lt_hdr) * (nseg+1));
1579 * Now fill the header we will be returning, one for each segment.
1580 * Note that this will basically just contain pointers into the existing
1581 * line table, and we do not actually copy any additional information
1582 * or allocate any additional memory.
1585 this_seg = 0;
1586 for(i=0; i<nfile; i++)
1589 * Get the pointer into the segment information.
1591 pnt2 = (union any_size) (linetab + filetab[i]);
1592 file_segcount = *pnt2.s;
1594 pnt2.ui++;
1595 lt_ptr = (unsigned int *) pnt2.c;
1596 start = (struct startend *) (lt_ptr + file_segcount);
1599 * Now snarf the filename for all of the segments for this file.
1601 fn = (unsigned char *) (start + file_segcount);
1602 memset(filename, 0, sizeof(filename));
1603 memcpy(filename, fn + 1, *fn);
1604 fn = strdup(filename);
1606 for(k = 0; k < file_segcount; k++, this_seg++)
1608 pnt2 = (union any_size) (linetab + lt_ptr[k]);
1609 lt_hdr[this_seg].start = start[k].start;
1610 lt_hdr[this_seg].end = start[k].end;
1611 lt_hdr[this_seg].sourcefile = fn;
1612 lt_hdr[this_seg].segno = *pnt2.s++;
1613 lt_hdr[this_seg].nline = *pnt2.s++;
1614 lt_hdr[this_seg].offtab = pnt2.ui;
1615 lt_hdr[this_seg].linetab = (unsigned short *)
1616 (pnt2.ui + lt_hdr[this_seg].nline);
1620 leave:
1622 return lt_hdr;
1626 static int
1627 DEBUG_SnarfCodeView( struct deferred_debug_info * deefer,
1628 char * cv_data,
1629 int size,
1630 struct codeview_linetab_hdr * linetab)
1632 struct name_hash * curr_func = NULL;
1633 struct wine_locals * curr_sym = NULL;
1634 int i;
1635 int j;
1636 int len;
1637 DBG_ADDR new_addr;
1638 int nsect;
1639 union any_size ptr;
1640 IMAGE_SECTION_HEADER * sectp;
1641 union codeview_symbol * sym;
1642 char symname[PATH_MAX];
1643 struct name_hash * thunk_sym = NULL;
1645 ptr = (union any_size) cv_data;
1646 nsect = deefer->nsect;
1647 sectp = deefer->sectp;
1650 * Skip over the first word. Don't really know what it means, but
1651 * it is useless.
1653 ptr.ui++;
1656 * Loop over the different types of records and whenever we
1657 * find something we are interested in, record it and move on.
1659 while( ptr.c - cv_data < size )
1661 sym = (union codeview_symbol *) ptr.c;
1663 if( sym->generic.len - sizeof(int) == (ptr.c - cv_data) )
1666 * This happens when we have indirect symbols that VC++ 4.2
1667 * sometimes uses when there isn't a line number table.
1668 * We ignore it - we will process and enter all of the
1669 * symbols in the global symbol table anyways, so there
1670 * isn't much point in keeping track of all of this crap.
1672 break;
1675 memset(symname, 0, sizeof(symname));
1676 switch(sym->generic.id)
1678 case S_GDATA:
1679 case S_LDATA:
1680 case S_PUB:
1682 * First, a couple of sanity checks.
1684 if( sym->data.namelen == 0 )
1686 break;
1689 if( sym->data.seg == 0 || sym->data.seg > nsect )
1691 break;
1695 * Global and local data symbols. We don't associate these
1696 * with any given source file.
1699 memcpy(symname, sym->data.name, sym->data.namelen);
1700 new_addr.seg = 0;
1701 new_addr.type = DEBUG_GetCVType(sym->data.symtype);
1702 new_addr.off = (unsigned int) deefer->load_addr +
1703 sectp[sym->data.seg - 1].VirtualAddress +
1704 sym->data.offset;
1705 DEBUG_AddSymbol( symname, &new_addr, NULL, SYM_WIN32 | SYM_DATA );
1706 break;
1707 case S_THUNK:
1709 * Sort of like a global function, but it just points
1710 * to a thunk, which is a stupid name for what amounts to
1711 * a PLT slot in the normal jargon that everyone else uses.
1713 memcpy(symname, sym->thunk.name, sym->thunk.namelen);
1714 new_addr.seg = 0;
1715 new_addr.type = NULL;
1716 new_addr.off = (unsigned int) deefer->load_addr +
1717 sectp[sym->thunk.segment - 1].VirtualAddress +
1718 sym->thunk.offset;
1719 thunk_sym = DEBUG_AddSymbol( symname, &new_addr, NULL,
1720 SYM_WIN32 | SYM_FUNC);
1721 DEBUG_SetSymbolSize(thunk_sym, sym->thunk.thunk_len);
1722 break;
1723 case S_GPROC:
1724 case S_LPROC:
1726 * Global and static functions.
1728 memcpy(symname, sym->proc.name, sym->proc.namelen);
1729 new_addr.seg = 0;
1730 new_addr.type = DEBUG_GetCVType(sym->proc.proctype);
1731 new_addr.off = (unsigned int) deefer->load_addr +
1732 sectp[sym->proc.segment - 1].VirtualAddress +
1733 sym->proc.offset;
1735 * See if we can find a segment that this goes with. If so,
1736 * it means that we also may have line number information
1737 * for this function.
1739 for(i=0; linetab[i].linetab != NULL; i++)
1741 if( ((unsigned int) deefer->load_addr
1742 + sectp[linetab[i].segno - 1].VirtualAddress
1743 + linetab[i].start <= new_addr.off)
1744 && ((unsigned int) deefer->load_addr
1745 + sectp[linetab[i].segno - 1].VirtualAddress
1746 + linetab[i].end > new_addr.off) )
1748 break;
1752 DEBUG_Normalize(curr_func);
1753 if( linetab[i].linetab == NULL )
1755 curr_func = DEBUG_AddSymbol( symname, &new_addr, NULL,
1756 SYM_WIN32 | SYM_FUNC);
1758 else
1761 * First, create the entry. Then dig through the linetab
1762 * and add whatever line numbers are appropriate for this
1763 * function.
1765 curr_func = DEBUG_AddSymbol( symname, &new_addr,
1766 linetab[i].sourcefile,
1767 SYM_WIN32 | SYM_FUNC);
1768 for(j=0; j < linetab[i].nline; j++)
1770 if( linetab[i].offtab[j] >= sym->proc.offset
1771 && linetab[i].offtab[j] < sym->proc.offset
1772 + sym->proc.proc_len )
1774 DEBUG_AddLineNumber(curr_func, linetab[i].linetab[j],
1775 linetab[i].offtab[j] - sym->proc.offset);
1782 * Add information about where we should set breakpoints
1783 * in this function.
1785 DEBUG_SetSymbolBPOff(curr_func, sym->proc.debug_start);
1786 DEBUG_SetSymbolSize(curr_func, sym->proc.proc_len);
1787 break;
1788 case S_BPREL:
1790 * Function parameters and stack variables.
1792 memcpy(symname, sym->stack.name, sym->stack.namelen);
1793 curr_sym = DEBUG_AddLocal(curr_func,
1795 sym->stack.offset,
1798 symname);
1799 DEBUG_SetLocalSymbolType(curr_sym, DEBUG_GetCVType(sym->stack.symtype));
1801 break;
1802 default:
1803 break;
1807 * Adjust pointer to point to next entry, rounding up to a word
1808 * boundary. MS preserving alignment? Stranger things have
1809 * happened.
1811 if( sym->generic.id == S_PROCREF
1812 || sym->generic.id == S_DATAREF
1813 || sym->generic.id == S_UNKNOWN )
1815 len = (sym->generic.len + 3) & ~3;
1816 len += ptr.c[16] + 1;
1817 ptr.c += (len + 3) & ~3;
1819 else
1821 ptr.c += (sym->generic.len + 3) & ~3;
1825 if( linetab != NULL )
1827 free(linetab);
1830 return TRUE;
1835 * Process PDB file which contains debug information.
1837 * These are really weird beasts. They are intended to be incrementally
1838 * updated by the incremental linker, and this means that you need to
1839 * be able to remove and add information. Thus the PDB file is sort of
1840 * like a block structured device, with a freelist and lists of extent numbers
1841 * that are used to get the relevant pieces. In all cases seen so far, the
1842 * blocksize is always 0x400 bytes. The header has a field which apparently
1843 * holds the blocksize, so if it ever changes we are safe.
1845 * In general, every time we need to extract something from the pdb file,
1846 * it is easier to copy it into another buffer so we have the information
1847 * in one contiguous block rather than attempt to try and keep track of when
1848 * we need to grab another extent from the pdb file.
1850 * The thing that is a real pain about some MS stuff is that they choose
1851 * data structures which are not representable in C. Thus we have to
1852 * hack around and diddle pointers.
1854 /* static */
1856 DEBUG_ProcessPDBFile(struct deferred_debug_info * deefer, char * full_filename)
1858 char * addr = (char *) 0xffffffff;
1859 unsigned int blocksize;
1860 unsigned int bufflen = 0;
1861 char * buffer = NULL;
1862 unsigned short * extent_table;
1863 int fd = -1;
1864 struct file_ent * fent;
1865 char filename[MAX_PATHNAME_LEN];
1866 struct file_list * filelist = NULL;
1867 unsigned int gsym_record = 0;
1868 char * gsymtab = NULL;
1869 struct filetab_hdr * hd;
1870 int i;
1871 int j;
1872 unsigned int last_extent;
1873 struct codeview_linetab_hdr * linetab;
1874 unsigned int nblocks;
1875 unsigned int npair;
1876 unsigned int offset;
1877 struct codeview_pdb_hdr * pdbhdr;
1878 unsigned int * pnt;
1879 struct stat statbuf;
1880 int status;
1881 unsigned short * table;
1882 char * toc;
1883 unsigned int toc_blocks;
1885 LocateDebugInfoFile(full_filename, filename);
1886 status = stat(filename, &statbuf);
1887 if( status == -1 )
1889 fprintf(stderr, "-Unable to open .PDB file %s\n", filename);
1890 goto leave;
1894 * Now open the file, so that we can mmap() it.
1896 fd = open(filename, O_RDONLY);
1897 if( fd == -1 )
1899 fprintf(stderr, "-Unable to open .DBG file %s\n", filename);
1900 goto leave;
1905 * Now mmap() the file.
1907 addr = mmap(0, statbuf.st_size, PROT_READ,
1908 MAP_PRIVATE, fd, 0);
1909 if( addr == (char *) 0xffffffff )
1911 fprintf(stderr, "-Unable to mmap .DBG file %s\n", filename);
1912 goto leave;
1916 * Now that we have the formalities over and done with, we need
1917 * to find the table of contents for the PDB file.
1919 pdbhdr = (struct codeview_pdb_hdr *) addr;
1920 blocksize = pdbhdr->blocksize;
1921 last_extent = (statbuf.st_size + blocksize - 1) / blocksize;
1924 * The TOC itself isn't always contiguous, so we need to extract a few
1925 * extents from the file to form the TOC.
1927 toc_blocks = (pdbhdr->toc_len + blocksize - 1) / blocksize;
1928 toc = (char *) xmalloc(toc_blocks * blocksize);
1929 table = pdbhdr->toc_ext;
1930 for(i=0; i < toc_blocks; i++)
1932 memcpy(toc + blocksize*i, addr + table[i]*blocksize, blocksize);
1936 * Next build our own table which will have the size and extent block
1937 * list for each record in the PDB file.
1939 * The TOC starts out with the number of files. Then it is followed by
1940 * (npair * 2*sizeof(int)) bytes of information, which are pairs of ints.
1941 * The first one is the size of the record (in bytes), and the second one
1942 * is something else which I haven't figured out yet.
1944 pnt = (unsigned int *) toc;
1945 npair = *pnt++;
1946 extent_table = (unsigned short *) ((unsigned int) toc +
1947 npair * 2 * sizeof(int) + sizeof(int));
1950 * Sanity check.
1952 if( sizeof(int) + 2*sizeof(int)*npair > pdbhdr->toc_len )
1954 goto leave;
1957 filelist = (struct file_list *) xmalloc(npair * sizeof(*filelist));
1958 if( filelist == NULL )
1960 goto leave;
1962 memset(filelist, 0, npair * sizeof(*filelist));
1964 nblocks = 0;
1965 for(i=0; i < npair; i++)
1967 filelist[i].record_len = pnt[i*2];
1968 filelist[i].nextents = (filelist[i].record_len + blocksize - 1)
1969 / blocksize;
1970 filelist[i].extent_list = extent_table + nblocks;
1971 nblocks += filelist[i].nextents;
1974 * These get filled in later when we parse one of the records.
1976 filelist[i].linetab_offset = 0;
1977 filelist[i].linetab_len = 0;
1981 * OK, now walk through the various records and pick out the bits we
1982 * really want to see. Some of the records are extra special, and
1983 * we need to handle these a little bit differently.
1985 for(i=0; i < npair; i++)
1987 if( filelist[i].record_len == 0xffffffff )
1989 continue;
1993 * Make sure our buffer is large enough to hold the record.
1995 if( bufflen < filelist[i].nextents * blocksize )
1997 bufflen = filelist[i].nextents * blocksize;
1998 buffer = (char *) realloc(buffer, bufflen);
2002 * Do this just for completeness. It makes debugging easier
2003 * if we have a clean indication of where the record ends.
2005 memset(buffer, 0, filelist[i].nextents * blocksize);
2008 * Next, build the record using the extent list.
2010 for(j=0; j < filelist[i].nextents; j++)
2012 memcpy(buffer + j * blocksize,
2013 addr + filelist[i].extent_list[j] * blocksize,
2014 blocksize);
2017 pnt = (unsigned int *) buffer;
2020 * OK, now figure out what to do with it.
2024 * Always ignore the first entry. It seems to contain a backup copy
2025 * of the TOC (the last time the file was modified??)
2027 if( i == 0 )
2029 continue;
2033 * The second entry as a id block. It contains a magic number
2034 * to identify the compiler, plus it also contains the timestamp
2035 * which must match the timestamp in the executable.
2037 if( i == 1 )
2040 if( ((*pnt != 19950623) && (*pnt != 19950814))
2041 || (filelist[i].record_len != 0x24)
2042 || (pnt[1] != ((struct CodeViewDebug *)(deefer->dbg_info))->cv_timestamp) )
2044 goto leave;
2049 * The third entry contains pointers to the global symbol table,
2050 * plus it also contains additional information about each record
2051 * in the PDB file.
2053 if( i == 3 )
2055 hd = (struct filetab_hdr *) buffer;
2057 gsym_record = hd->gsym_file;
2058 gsymtab = (char *) xmalloc( filelist[gsym_record].nextents
2059 * blocksize);
2060 memset(gsymtab, 0, filelist[gsym_record].nextents * blocksize);
2062 for(j=0; j < filelist[gsym_record].nextents; j++)
2064 memcpy(gsymtab + j * blocksize,
2065 addr + filelist[gsym_record].extent_list[j] * blocksize,
2066 blocksize);
2070 * This record also contains information about where in the
2071 * remaining records we will be able to find the start of the
2072 * line number table. We could locate that bit using heuristics,
2073 * but since we have the info handy, we might as well use it.
2075 offset = sizeof(*hd);
2076 while(1==1)
2078 fent = (struct file_ent *) (buffer + offset);
2079 if( offset > hd->ftab_len )
2081 break;
2084 if( fent->file_number == 0 || fent->file_number >= npair )
2086 break;
2089 filelist[fent->file_number].linetab_offset =
2090 fent->linetab_offset;
2091 filelist[fent->file_number].linetab_len =
2092 fent->linetab_len;
2094 * Figure out the offset of the next entry.
2095 * There is a fixed part of the record and a variable
2096 * length filename which we must also skip past.
2098 offset += ((unsigned int) &fent->filename - (unsigned int) fent)
2099 + strlen(fent->filename) + 1;
2100 offset += strlen(buffer+offset) + 1;
2101 offset = (offset + 3) & ~3;
2107 * Two different magic numbers used as dates.
2108 * These indicate the 'type' table.
2110 if( *pnt == 19950410
2111 || *pnt == 19951122 )
2113 DEBUG_ParseTypeTable(buffer, filelist[i].record_len);
2114 continue;
2118 * This is something we really want to look at, since it contains
2119 * real debug info. Anything that doesn't match this can be
2120 * ignored for now.
2122 if( *pnt == 1 )
2125 * First, snag the line table, if we have one. This always
2126 * occurs at the end of the record, so we take the linetab
2127 * offset as the end of the normal part of the record.
2129 linetab = NULL;
2130 if( filelist[i].linetab_len != 0 )
2132 linetab = DEBUG_SnarfLinetab(buffer + filelist[i].linetab_offset,
2133 filelist[i].linetab_len);
2134 DEBUG_SnarfCodeView(deefer, buffer,
2135 filelist[i].linetab_offset,
2136 linetab);
2138 else
2140 DEBUG_SnarfCodeView(deefer, buffer,
2141 filelist[i].record_len,
2142 linetab);
2144 continue;
2149 * Finally, process the global symbol table itself. There isn't
2150 * a line number component to this, so we just toss everything
2151 * into the mix and it all should work out.
2153 if( gsym_record != 0 )
2155 DEBUG_SnarfCodeView(deefer, gsymtab - sizeof(int),
2156 filelist[gsym_record].record_len,
2157 NULL);
2160 leave:
2162 if( gsymtab != NULL )
2164 free(gsymtab);
2165 gsymtab = NULL;
2168 if( buffer != NULL )
2170 free(buffer);
2173 if( filelist != NULL )
2175 free(filelist);
2178 if( addr != (char *) 0xffffffff )
2180 munmap(addr, statbuf.st_size);
2183 if( fd != -1 )
2185 close(fd);
2188 return TRUE;
2192 * Process DBG file which contains debug information.
2194 /* static */
2196 DEBUG_ProcessDBGFile(struct deferred_debug_info * deefer, char * filename)
2198 char * addr = (char *) 0xffffffff;
2199 char * codeview;
2200 struct CV4_DirHead * codeview_dir;
2201 struct CV4_DirEnt * codeview_dent;
2202 PIMAGE_DEBUG_DIRECTORY dbghdr;
2203 struct deferred_debug_info deefer2;
2204 int fd = -1;
2205 int i;
2206 int j;
2207 struct codeview_linetab_hdr * linetab;
2208 int nsect;
2209 PIMAGE_SEPARATE_DEBUG_HEADER pdbg = NULL;
2210 IMAGE_SECTION_HEADER * sectp;
2211 struct stat statbuf;
2212 int status;
2213 char dbg_file[MAX_PATHNAME_LEN];
2215 LocateDebugInfoFile(filename, dbg_file);
2216 status = stat(dbg_file, &statbuf);
2217 if( status == -1 )
2219 fprintf(stderr, "-Unable to open .DBG file %s\n", dbg_file);
2220 goto leave;
2224 * Now open the file, so that we can mmap() it.
2226 fd = open(dbg_file, O_RDONLY);
2227 if( fd == -1 )
2229 fprintf(stderr, "Unable to open .DBG file %s\n", dbg_file);
2230 goto leave;
2235 * Now mmap() the file.
2237 addr = mmap(0, statbuf.st_size, PROT_READ,
2238 MAP_PRIVATE, fd, 0);
2239 if( addr == (char *) 0xffffffff )
2241 fprintf(stderr, "Unable to mmap .DBG file %s\n", dbg_file);
2242 goto leave;
2245 pdbg = (PIMAGE_SEPARATE_DEBUG_HEADER) addr;
2247 if( pdbg->TimeDateStamp != deefer->dbgdir->TimeDateStamp )
2249 fprintf(stderr, "Warning - %s has incorrect internal timestamp\n",
2250 dbg_file);
2251 /* goto leave; */
2253 Well, sometimes this happens to DBG files which ARE REALLY the right .DBG
2254 files but nonetheless this check fails. Anyway, WINDBG (debugger for
2255 Windows by Microsoft) loads debug symbols which have incorrect timestamps.
2259 fprintf(stderr, "Processing symbols from %s...\n", dbg_file);
2261 dbghdr = (PIMAGE_DEBUG_DIRECTORY) ( addr + sizeof(*pdbg)
2262 + pdbg->NumberOfSections * sizeof(IMAGE_SECTION_HEADER)
2263 + pdbg->ExportedNamesSize);
2265 sectp = (PIMAGE_SECTION_HEADER) ((char *) pdbg + sizeof(*pdbg));
2266 nsect = pdbg->NumberOfSections;
2268 for( i=0; i < pdbg->DebugDirectorySize / sizeof(*pdbg); i++, dbghdr++ )
2270 switch(dbghdr->Type)
2272 case IMAGE_DEBUG_TYPE_COFF:
2274 * Dummy up a deferred debug header to handle the
2275 * COFF stuff embedded within the DBG file.
2277 memset((char *) &deefer2, 0, sizeof(deefer2));
2278 deefer2.dbg_info = (addr + dbghdr->PointerToRawData);
2279 deefer2.dbg_size = dbghdr->SizeOfData;
2280 deefer2.load_addr = deefer->load_addr;
2282 DEBUG_ProcessCoff(&deefer2);
2283 break;
2284 case IMAGE_DEBUG_TYPE_CODEVIEW:
2286 * This is the older format by which codeview stuff is
2287 * stored, known as the 'NB09' format. Newer executables
2288 * and dlls created by VC++ use PDB files instead, which
2289 * have lots of internal similarities, but the overall
2290 * format and structure is quite different.
2292 codeview = (addr + dbghdr->PointerToRawData);
2295 * The first thing in the codeview section should be
2296 * an 'NB09' identifier. As a sanity check, make sure
2297 * it is there.
2299 if( *((unsigned int*) codeview) != 0x3930424e )
2301 break;
2305 * Next we need to find the directory. This is easy too.
2307 codeview_dir = (struct CV4_DirHead *)
2308 (codeview + ((unsigned int*) codeview)[1]);
2311 * Some more sanity checks. Make sure that everything
2312 * is as we expect it.
2314 if( codeview_dir->next_offset != 0
2315 || codeview_dir->dhsize != sizeof(*codeview_dir)
2316 || codeview_dir->desize != sizeof(*codeview_dent) )
2318 break;
2320 codeview_dent = (struct CV4_DirEnt *) (codeview_dir + 1);
2322 for(j=0; j < codeview_dir->ndir; j++, codeview_dent++)
2324 if( codeview_dent->subsect_number == sstAlignSym )
2327 * Check the previous entry. If it is a
2328 * sstSrcModule, it contains the line number
2329 * info for this file.
2331 linetab = NULL;
2332 if( codeview_dent[1].module_number == codeview_dent[0].module_number
2333 && codeview_dent[1].subsect_number == sstSrcModule )
2335 linetab = DEBUG_SnarfLinetab(
2336 codeview + codeview_dent[1].offset,
2337 codeview_dent[1].size);
2340 if( codeview_dent[-1].module_number == codeview_dent[0].module_number
2341 && codeview_dent[-1].subsect_number == sstSrcModule )
2343 linetab = DEBUG_SnarfLinetab(
2344 codeview + codeview_dent[-1].offset,
2345 codeview_dent[-1].size);
2348 * Now process the CV stuff.
2350 DEBUG_SnarfCodeView(deefer,
2351 codeview + codeview_dent->offset,
2352 codeview_dent->size,
2353 linetab);
2357 break;
2358 default:
2359 break;
2362 leave:
2364 if( addr != (char *) 0xffffffff )
2366 munmap(addr, statbuf.st_size);
2369 if( fd != -1 )
2371 close(fd);
2374 return TRUE;
2378 DEBUG_ProcessDeferredDebug()
2380 struct deferred_debug_info * deefer;
2381 struct CodeViewDebug * cvd;
2382 struct MiscDebug * misc;
2383 char * filename;
2384 int last_proc = -1;
2385 int need_print =0;
2387 DEBUG_InitCVDataTypes();
2389 for(deefer = dbglist; deefer; deefer = deefer->next)
2391 if( deefer->loaded )
2393 continue;
2396 if( last_proc != deefer->dbg_index )
2398 if (!need_print)
2400 fprintf(stderr, "DeferredDebug for:");
2401 need_print=1;
2403 fprintf(stderr, " %s",deefer->module_name);
2404 last_proc = deefer->dbg_index;
2407 switch(deefer->dbgdir->Type)
2409 case IMAGE_DEBUG_TYPE_COFF:
2411 * Standard COFF debug information that VC++ adds when you
2412 * use /debugtype:both with the linker.
2414 #if 0
2415 fprintf(stderr, "Processing COFF symbols...\n");
2416 #endif
2417 DEBUG_ProcessCoff(deefer);
2418 break;
2419 case IMAGE_DEBUG_TYPE_CODEVIEW:
2421 * This is a pointer to a PDB file of some sort.
2423 cvd = (struct CodeViewDebug *) deefer->dbg_info;
2425 if( strcmp(cvd->cv_nbtype, "NB10") != 0 )
2428 * Whatever this is, we don't know how to deal with
2429 * it yet.
2431 break;
2433 DEBUG_ProcessPDBFile(deefer, cvd->cv_name);
2434 #if 0
2435 fprintf(stderr, "Processing PDB file %s\n", cvd->cv_name);
2436 #endif
2437 break;
2438 case IMAGE_DEBUG_TYPE_MISC:
2440 * A pointer to a .DBG file of some sort. These files
2441 * can contain either CV4 or COFF information. Open
2442 * the file, and try to do the right thing with it.
2444 misc = (struct MiscDebug *) deefer->dbg_info;
2446 filename = strrchr((char *) &misc->Data, '.');
2449 * Ignore the file if it doesn't have a .DBG extension.
2451 if( (filename == NULL)
2452 || ( (strcmp(filename, ".dbg") != 0)
2453 && (strcmp(filename, ".DBG") != 0)) )
2455 break;
2458 filename = (char *) &misc->Data;
2461 * Do the dirty deed...
2463 DEBUG_ProcessDBGFile(deefer, filename);
2465 break;
2466 default:
2468 * We should never get here...
2470 break;
2473 if(need_print)
2474 fprintf(stderr, "\n");
2475 return TRUE;
2479 /***********************************************************************
2480 * DEBUG_InfoShare
2482 * Display shared libarary information.
2484 void DEBUG_InfoShare(void)
2486 struct deferred_debug_info * deefer;
2488 fprintf(stderr,"Address\t\tModule\tName\n");
2490 for(deefer = dbglist; deefer; deefer = deefer->next)
2492 fprintf(stderr,"0x%8.8x\t(%s)\t%s\n", (unsigned int) deefer->load_addr,
2493 deefer->module ? "Win32" : "ELF", deefer->module_name);