2 * File stabs.c - read stabs information from the wine executable itself.
4 * Copyright (C) 1996, Eric Youngdale.
19 #define PATH_MAX _MAX_PATH
24 #if defined(__svr4__) || defined(__sun)
34 #elif defined(__EMX__)
64 * This is how we translate stab types into our internal representations
67 static struct datatype ** stab_types = NULL;
68 static int num_stab_types = 0;
71 * Set so that we know the main executable name and path.
78 struct stab_nlist *n_next;
84 unsigned long n_value;
88 * This is used to keep track of known datatypes so that we don't redefine
89 * them over and over again. It sucks up lots of memory otherwise.
93 struct known_typedef * next;
96 struct datatype * types[0];
99 #define NR_STAB_HASH 521
101 struct known_typedef * ktd_head[NR_STAB_HASH] = {NULL,};
103 static unsigned int stab_hash( const char * name )
105 unsigned int hash = 0;
113 hash = (hash << 4) + *p++;
115 if( (tmp = (hash & 0xf0000000)) )
121 return hash % NR_STAB_HASH;
125 static void stab_strcpy(char * dest, const char * source)
128 * A strcpy routine that stops when we hit the ':' character.
129 * Faster than copying the whole thing, and then nuking the
132 while(*source != '\0' && *source != ':')
137 #define MAX_TD_NESTING 128
139 static int **typenums;
140 static int *nroftypenums=NULL;
141 static int nrofnroftypenums=0;
142 static int curtypenum = 0;
146 DEBUG_FileSubNr2StabEnum(int filenr,int subnr) {
147 if (nrofnroftypenums<=filenr) {
148 nroftypenums = DBG_realloc(nroftypenums,sizeof(nroftypenums[0])*(filenr+1));
149 memset(nroftypenums+nrofnroftypenums,0,(filenr+1-nrofnroftypenums)*sizeof(nroftypenums[0]));
150 typenums = DBG_realloc(typenums,sizeof(typenums[0])*(filenr+1));
151 memset(typenums+nrofnroftypenums,0,sizeof(typenums[0])*(filenr+1-nrofnroftypenums));
152 nrofnroftypenums=filenr+1;
154 if (nroftypenums[filenr]<=subnr) {
155 typenums[filenr] = DBG_realloc(typenums[filenr],sizeof(typenums[0][0])*(subnr+1));
156 memset(typenums[filenr]+nroftypenums[filenr],0,sizeof(typenums[0][0])*(subnr+1-nroftypenums[filenr]));
157 nroftypenums[filenr] = subnr+1;
159 if (!typenums[filenr][subnr])
160 typenums[filenr][subnr]=++curtypenum;
162 if( num_stab_types <= curtypenum ) {
163 num_stab_types = curtypenum + 256;
164 stab_types = (struct datatype **) DBG_realloc(stab_types,
165 num_stab_types * sizeof(struct datatype *)
167 memset( stab_types + curtypenum, 0, sizeof(struct datatype *) * (num_stab_types - curtypenum) );
169 /*fprintf(stderr,"(%d,%d) is %d\n",filenr,subnr,typenums[filenr][subnr]); */
170 return typenums[filenr][subnr];
175 DEBUG_ReadTypeEnumBackwards(char*x) {
182 filenr=strtol(x,&x,10); /* <int> */
184 subnr=strtol(x,&x,10); /* <int> */
187 while ((*x>='0') && (*x<='9'))
192 return DEBUG_FileSubNr2StabEnum(filenr,subnr);
197 DEBUG_ReadTypeEnum(char **x) {
202 filenr=strtol(*x,x,10); /* <int> */
204 subnr=strtol(*x,x,10); /* <int> */
208 subnr = strtol(*x,x,10); /* <int> */
210 return DEBUG_FileSubNr2StabEnum(filenr,subnr);
215 DEBUG_RegisterTypedef(const char * name, struct datatype ** types, int ndef)
218 struct known_typedef * ktd;
223 ktd = (struct known_typedef *) DBG_alloc(sizeof(struct known_typedef)
224 + ndef * sizeof(struct datatype *));
226 hash = stab_hash(name);
228 ktd->name = DBG_strdup(name);
230 memcpy(&ktd->types[0], types, ndef * sizeof(struct datatype *));
231 ktd->next = ktd_head[hash];
232 ktd_head[hash] = ktd;
239 DEBUG_HandlePreviousTypedef(const char * name, const char * stab)
242 enum debug_type expect;
244 struct known_typedef * ktd;
247 hash = stab_hash(name);
249 for(ktd = ktd_head[hash]; ktd; ktd = ktd->next)
250 if ((ktd->name[0] == name[0]) && (strcmp(name, ktd->name) == 0) )
254 * Didn't find it. This must be a new one.
260 * Examine the stab to make sure it has the same number of definitions.
263 for(ptr = strchr(stab, '='); ptr; ptr = strchr(ptr+1, '='))
265 if( count >= ktd->ndefs )
269 * Make sure the types of all of the objects is consistent with
270 * what we have already parsed.
299 fprintf(stderr, "Unknown type (%c).\n",ptr[1]);
302 if( expect != DEBUG_GetType(ktd->types[count]) )
307 if( ktd->ndefs != count )
311 * Go through, dig out all of the type numbers, and substitute the
312 * appropriate things.
315 for(ptr = strchr(stab, '='); ptr; ptr = strchr(ptr+1, '='))
316 stab_types[DEBUG_ReadTypeEnumBackwards(ptr-1)] = ktd->types[count++];
321 static int DEBUG_FreeRegisteredTypedefs()
325 struct known_typedef * ktd;
326 struct known_typedef * next;
329 for(j=0; j < NR_STAB_HASH; j++ )
331 for(ktd = ktd_head[j]; ktd; ktd = next)
347 DEBUG_ParseTypedefStab(char * ptr, const char * typename)
352 struct datatype * curr_type;
353 struct datatype * datatype;
354 struct datatype * curr_types[MAX_TD_NESTING];
355 char element_name[1024];
358 const char * orig_typename;
364 orig_typename = typename;
366 if( DEBUG_HandlePreviousTypedef(typename, ptr) )
370 * Go from back to front. First we go through and figure out what
371 * type numbers we need, and register those types. Then we go in
372 * and fill the details.
375 for( c = strchr(ptr, '='); c != NULL; c = strchr(c + 1, '=') )
378 * Back up until we get to a non-numeric character. This is the type
381 typenum = DEBUG_ReadTypeEnumBackwards(c-1);
383 if( ntypes >= MAX_TD_NESTING )
386 * If this ever happens, just bump the counter.
388 fprintf(stderr, "Typedef nesting overflow\n");
395 stab_types[typenum] = DEBUG_NewDataType(DT_POINTER, NULL);
396 curr_types[ntypes++] = stab_types[typenum];
400 stab_types[typenum] = DEBUG_NewDataType(DT_STRUCT, typename);
401 curr_types[ntypes++] = stab_types[typenum];
404 stab_types[typenum] = DEBUG_NewDataType(DT_ARRAY, NULL);
405 curr_types[ntypes++] = stab_types[typenum];
410 stab_types[typenum] = DEBUG_NewDataType(DT_BASIC, typename);
411 curr_types[ntypes++] = stab_types[typenum];
414 stab_strcpy(element_name, c + 3);
415 stab_types[typenum] = DEBUG_NewDataType(DT_STRUCT, element_name);
416 curr_types[ntypes++] = stab_types[typenum];
419 stab_types[typenum] = DEBUG_NewDataType(DT_ENUM, NULL);
420 curr_types[ntypes++] = stab_types[typenum];
423 stab_types[typenum] = DEBUG_NewDataType(DT_FUNC, NULL);
424 curr_types[ntypes++] = stab_types[typenum];
427 fprintf(stderr, "Unknown type (%c).\n",c[1]);
433 * Now register the type so that if we encounter it again, we will know
436 DEBUG_RegisterTypedef(orig_typename, curr_types, ntypes);
439 * OK, now take a second sweep through. Now we will be digging
440 * out the definitions of the various components, and storing
441 * them in the skeletons that we have already allocated. We take
442 * a right-to left search as this is much easier to parse.
444 for( c = strrchr(ptr, '='); c != NULL; c = strrchr(ptr, '=') )
446 int typenum = DEBUG_ReadTypeEnumBackwards(c-1);
447 curr_type = stab_types[typenum];
464 datatype = stab_types[DEBUG_ReadTypeEnum(&tc)];
465 DEBUG_SetPointerType(curr_type, datatype);
475 * We have already handled these above.
480 /* ar<typeinfo_nodef>;<int>;<int>;<typeinfo>,<int>,<int>;; */
484 DEBUG_ReadTypeEnum(&tc);
486 arrmin = strtol(tc, &tc, 10); /* <int> */
488 arrmax = strtol(tc, &tc, 10); /* <int> */
490 datatype = stab_types[DEBUG_ReadTypeEnum(&tc)]; /* <typeinfo> */
495 DEBUG_SetArrayParams(curr_type, arrmin, arrmax, datatype);
502 if( DEBUG_SetStructSize(curr_type, strtol(tc, &tc, 10)) == FALSE )
505 * We have already filled out this structure. Nothing to do,
506 * so just skip forward to the end of the definition.
508 while( tc[0] != ';' && tc[1] != ';' )
521 * Now parse the individual elements of the structure/union.
532 datatype = stab_types[DEBUG_ReadTypeEnum(&tc)];
535 offset = strtol(tc, &tc, 10);
537 size = strtol(tc, &tc, 10);
540 DEBUG_AddStructElement(curr_type, element_name, datatype, offset, size);
543 /* ... but proceed parsing to the end of the stab */
548 /* if we had a undeclared value this one is undeclared too.
549 * remove it from the stab_types.
550 * I just set it to NULL to detect bugs in my thoughtprocess.
551 * FIXME: leaks the memory for the structure elements.
552 * FIXME: such structures should have been optimized away
555 stab_types[typenum] = NULL;
566 * Now parse the individual elements of the structure/union.
575 offset = strtol(tc, &tc, 10);
577 DEBUG_AddStructElement(curr_type, element_name, NULL, offset, 0);
585 fprintf(stderr, "Unknown type (%c).\n",c[1]);
594 static struct datatype *
595 DEBUG_ParseStabType(const char * stab)
600 * Look through the stab definition, and figure out what datatype
601 * this represents. If we have something we know about, assign the
604 c = strchr(stab, ':');
610 * The next character says more about the type (i.e. data, function, etc)
611 * of symbol. Skip it.
615 * The next is either an integer or a (integer,integer).
616 * The DEBUG_ReadTypeEnum takes care that stab_types is large enough.
618 return stab_types[DEBUG_ReadTypeEnum(&c)];
622 DEBUG_ParseStabs(char * addr, unsigned int load_offset,
623 unsigned int staboff, int stablen,
624 unsigned int strtaboff, int strtablen)
626 struct name_hash * curr_func = NULL;
627 struct wine_locals * curr_loc = NULL;
628 struct name_hash * curr_sym = NULL;
629 char currpath[PATH_MAX];
639 struct stab_nlist * stab_ptr;
642 char * subpath = NULL;
645 nstab = stablen / sizeof(struct stab_nlist);
646 stab_ptr = (struct stab_nlist *) (addr + staboff);
647 strs = (char *) (addr + strtaboff);
649 memset(currpath, 0, sizeof(currpath));
652 * Allocate a buffer into which we can build stab strings for cases
653 * where the stab is continued over multiple lines.
656 stabbuff = (char *) DBG_alloc(stabbufflen);
660 for(i=0; i < nstab; i++, stab_ptr++ )
662 ptr = strs + (unsigned int) stab_ptr->n_un.n_name;
663 if( ptr[strlen(ptr) - 1] == '\\' )
666 * Indicates continuation. Append this to the buffer, and go onto the
667 * next record. Repeat the process until we find a stab without the
668 * '/' character, as this indicates we have the whole thing.
671 if( strlen(stabbuff) + len > stabbufflen )
673 stabbufflen += 65536;
674 stabbuff = (char *) DBG_realloc(stabbuff, stabbufflen);
676 strncat(stabbuff, ptr, len - 1);
679 else if( stabbuff[0] != '\0' )
681 strcat( stabbuff, ptr);
685 if( strchr(ptr, '=') != NULL )
688 * The stabs aren't in writable memory, so copy it over so we are
689 * sure we can scribble on it.
691 if( ptr != stabbuff )
693 strcpy(stabbuff, ptr);
696 stab_strcpy(symname, ptr);
697 DEBUG_ParseTypedefStab(ptr, symname);
700 switch(stab_ptr->n_type)
704 * These are useless with ELF. They have no value, and you have to
705 * read the normal symbol table to get the address. Thus we
706 * ignore them, and when we process the normal symbol table
707 * we should do the right thing.
709 * With a.out, they actually do make some amount of sense.
712 new_addr.type = DEBUG_ParseStabType(ptr);
713 new_addr.off = load_offset + stab_ptr->n_value;
715 stab_strcpy(symname, ptr);
717 curr_sym = DEBUG_AddSymbol( symname, &new_addr, currpath,
718 SYM_WINE | SYM_DATA | SYM_INVALID);
720 curr_sym = DEBUG_AddSymbol( symname, &new_addr, currpath,
721 SYM_WINE | SYM_DATA );
727 * We need to keep track of these so we get symbol scoping
728 * right for local variables. For now, we just ignore them.
729 * The hooks are already there for dealing with this however,
730 * so all we need to do is to keep count of the nesting level,
731 * and find the RBRAC for each matching LBRAC.
737 * These are static symbols and BSS symbols.
740 new_addr.type = DEBUG_ParseStabType(ptr);
741 new_addr.off = load_offset + stab_ptr->n_value;
743 stab_strcpy(symname, ptr);
744 curr_sym = DEBUG_AddSymbol( symname, &new_addr, currpath,
745 SYM_WINE | SYM_DATA );
749 * These are function parameters.
751 if( (curr_func != NULL)
752 && (stab_ptr->n_value != 0) )
754 stab_strcpy(symname, ptr);
755 curr_loc = DEBUG_AddLocal(curr_func, 0,
756 stab_ptr->n_value, 0, 0, symname);
757 DEBUG_SetLocalSymbolType( curr_loc, DEBUG_ParseStabType(ptr));
761 if( curr_func != NULL )
763 stab_strcpy(symname, ptr);
764 curr_loc = DEBUG_AddLocal(curr_func, stab_ptr->n_value, 0, 0, 0, symname);
765 DEBUG_SetLocalSymbolType( curr_loc, DEBUG_ParseStabType(ptr));
769 if( (curr_func != NULL)
770 && (stab_ptr->n_value != 0) )
772 stab_strcpy(symname, ptr);
773 DEBUG_AddLocal(curr_func, 0,
774 stab_ptr->n_value, 0, 0, symname);
776 else if (curr_func == NULL)
778 stab_strcpy(symname, ptr);
783 * This is a line number. These are always relative to the start
784 * of the function (N_FUN), and this makes the lookup easier.
786 if( curr_func != NULL )
789 DEBUG_AddLineNumber(curr_func, stab_ptr->n_desc,
794 * This isn't right. The order of the stabs is different under
795 * a.out, and as a result we would end up attaching the line
796 * number to the wrong function.
798 DEBUG_AddLineNumber(curr_func, stab_ptr->n_desc,
799 stab_ptr->n_value - curr_func->addr.off);
806 * First, clean up the previous function we were working on.
808 DEBUG_Normalize(curr_func);
811 * For now, just declare the various functions. Later
812 * on, we will add the line number information and the
818 new_addr.type = DEBUG_ParseStabType(ptr);
819 new_addr.off = load_offset + stab_ptr->n_value;
821 * Copy the string to a temp buffer so we
822 * can kill everything after the ':'. We do
823 * it this way because otherwise we end up dirtying
824 * all of the pages related to the stabs, and that
825 * sucks up swap space like crazy.
827 stab_strcpy(symname, ptr);
828 curr_func = DEBUG_AddSymbol( symname, &new_addr, currpath,
829 SYM_WINE | SYM_FUNC);
834 * Don't add line number information for this function
842 * This indicates a new source file. Append the records
843 * together, to build the correct path name.
847 * With a.out, there is no NULL string N_SO entry at the end of
848 * the file. Thus when we find non-consecutive entries,
849 * we consider that a new file is started.
854 DEBUG_Normalize(curr_func);
865 DEBUG_Normalize(curr_func);
868 * The datatypes that we would need to use are reset when
869 * we start a new file.
871 memset(stab_types, 0, num_stab_types * sizeof(stab_types[0]));
873 for (i=0;i<nrofnroftypenums;i++)
874 memset(typenums[i],0,sizeof(typenums[i][0])*nroftypenums[i]);
880 strcat(currpath, ptr);
882 strcpy(currpath, ptr);
889 * This indicates we are including stuff from an include file.
890 * If this is the main source, enable the debug stuff, otherwise
893 if( subpath == NULL || strcmp(ptr, subpath) == 0 )
900 DEBUG_Normalize(curr_func);
906 strtabinc = stab_ptr->n_value;
907 DEBUG_Normalize(curr_func);
912 * Ignore this. We don't care what it points to.
919 * Always ignore these. GCC doesn't even generate them.
929 fprintf(stderr, "%d %x %s\n", stab_ptr->n_type,
930 (unsigned int) stab_ptr->n_value,
931 strs + (unsigned int) stab_ptr->n_un.n_name);
935 if( stab_types != NULL )
937 DBG_free(stab_types);
943 DEBUG_FreeRegisteredTypedefs();
951 * Walk through the entire symbol table and add any symbols we find there.
952 * This can be used in cases where we have stripped ELF shared libraries,
953 * or it can be used in cases where we have data symbols for which the address
954 * isn't encoded in the stabs.
956 * This is all really quite easy, since we don't have to worry about line
957 * numbers or local data variables.
961 DEBUG_ProcessElfSymtab(char * addr, unsigned int load_offset,
962 Elf32_Shdr * symtab, Elf32_Shdr * strtab)
964 char * curfile = NULL;
965 struct name_hash * curr_sym = NULL;
975 symp = (Elf32_Sym *) (addr + symtab->sh_offset);
976 nsym = symtab->sh_size / sizeof(*symp);
977 strp = (char *) (addr + strtab->sh_offset);
979 for(i=0; i < nsym; i++, symp++)
982 * Ignore certain types of entries which really aren't of that much
985 if( ELF32_ST_TYPE(symp->st_info) == STT_SECTION )
990 symname = strp + symp->st_name;
993 * Save the name of the current file, so we have a way of tracking
994 * static functions/data.
996 if( ELF32_ST_TYPE(symp->st_info) == STT_FILE )
1004 * See if we already have something for this symbol.
1005 * If so, ignore this entry, because it would have come from the
1006 * stabs or from a previous symbol. If the value is different,
1007 * we will have to keep the darned thing, because there can be
1008 * multiple local symbols by the same name.
1010 if( (DEBUG_GetSymbolValue(symname, -1, &new_addr, FALSE ) == TRUE)
1011 && (new_addr.off == (load_offset + symp->st_value)) )
1015 new_addr.type = NULL;
1016 new_addr.off = load_offset + symp->st_value;
1017 flags = SYM_WINE | (ELF32_ST_BIND(symp->st_info) == STT_FUNC
1018 ? SYM_FUNC : SYM_DATA);
1019 if( ELF32_ST_BIND(symp->st_info) == STB_GLOBAL )
1020 curr_sym = DEBUG_AddSymbol( symname, &new_addr, NULL, flags );
1022 curr_sym = DEBUG_AddSymbol( symname, &new_addr, curfile, flags );
1025 * Record the size of the symbol. This can come in handy in
1026 * some cases. Not really used yet, however.
1028 if( symp->st_size != 0 )
1029 DEBUG_SetSymbolSize(curr_sym, symp->st_size);
1037 DEBUG_ProcessElfObject(char * filename, unsigned int load_offset)
1040 struct stat statbuf;
1043 char * addr = (char *) 0xffffffff;
1054 * Make sure we can stat and open this file.
1056 if( filename == NULL )
1059 status = stat(filename, &statbuf);
1062 char *s,*t,*fn,*paths;
1063 if (strchr(filename,'/'))
1065 paths = DBG_strdup(getenv("PATH"));
1070 fn = (char*)DBG_alloc(strlen(filename)+1+strlen(s)+1);
1073 strcat(fn,filename);
1074 if ((rtn = DEBUG_ProcessElfObject(fn,load_offset))) {
1080 if (t) s = t+1; else break;
1082 if (!s || !*s) fprintf(stderr," not found");
1088 * Now open the file, so that we can mmap() it.
1090 fd = open(filename, O_RDONLY);
1096 * Now mmap() the file.
1098 addr = mmap(0, statbuf.st_size, PROT_READ,
1099 MAP_PRIVATE, fd, 0);
1100 if( addr == (char *) 0xffffffff )
1104 * Next, we need to find a few of the internal ELF headers within
1105 * this thing. We need the main executable header, and the section
1108 ehptr = (Elf32_Ehdr *) addr;
1110 if( load_offset == 0 )
1111 DEBUG_RegisterELFDebugInfo(ehptr->e_entry, statbuf.st_size, filename);
1113 DEBUG_RegisterELFDebugInfo(load_offset, statbuf.st_size, filename);
1115 spnt = (Elf32_Shdr *) (addr + ehptr->e_shoff);
1116 nsect = ehptr->e_shnum;
1117 shstrtab = (addr + spnt[ehptr->e_shstrndx].sh_offset);
1119 stabsect = stabstrsect = -1;
1121 for(i=0; i < nsect; i++)
1123 if( strcmp(shstrtab + spnt[i].sh_name, ".stab") == 0 )
1126 if( strcmp(shstrtab + spnt[i].sh_name, ".stabstr") == 0 )
1130 if( stabsect == -1 || stabstrsect == -1 )
1134 * OK, now just parse all of the stabs.
1136 rtn = DEBUG_ParseStabs(addr, load_offset,
1137 spnt[stabsect].sh_offset,
1138 spnt[stabsect].sh_size,
1139 spnt[stabstrsect].sh_offset,
1140 spnt[stabstrsect].sh_size);
1145 for(i=0; i < nsect; i++)
1147 if( (strcmp(shstrtab + spnt[i].sh_name, ".symtab") == 0)
1148 && (spnt[i].sh_type == SHT_SYMTAB) )
1149 DEBUG_ProcessElfSymtab(addr, load_offset,
1150 spnt + i, spnt + spnt[i].sh_link);
1152 if( (strcmp(shstrtab + spnt[i].sh_name, ".dynsym") == 0)
1153 && (spnt[i].sh_type == SHT_DYNSYM) )
1154 DEBUG_ProcessElfSymtab(addr, load_offset,
1155 spnt + i, spnt + spnt[i].sh_link);
1160 if( addr != (char *) 0xffffffff )
1161 munmap(addr, statbuf.st_size);
1171 DEBUG_ReadExecutableDbgInfo(void)
1176 struct r_debug * dbg_hdr;
1177 struct link_map * lpnt = NULL;
1179 extern Elf32_Dyn _DYNAMIC[] __attribute__ ((weak));
1181 extern Elf32_Dyn _DYNAMIC[];
1186 exe_name = DEBUG_argv0;
1189 * Make sure we can stat and open this file.
1191 if( exe_name == NULL )
1194 fprintf( stderr, "Loading symbols: %s", exe_name );
1195 rowcount = 17 + strlen(exe_name);
1196 DEBUG_ProcessElfObject(exe_name, 0);
1199 * Finally walk the tables that the dynamic loader maintains to find all
1200 * of the other shared libraries which might be loaded. Perform the
1201 * same step for all of these.
1203 if( (&_DYNAMIC == NULL) || (_DYNAMIC == NULL) )
1209 * Now walk the dynamic section (of the executable, looking for a DT_DEBUG
1212 for(; dynpnt->d_tag != DT_NULL; dynpnt++)
1213 if( dynpnt->d_tag == DT_DEBUG )
1216 if( (dynpnt->d_tag != DT_DEBUG)
1217 || (dynpnt->d_un.d_ptr == 0) )
1221 * OK, now dig into the actual tables themselves.
1223 dbg_hdr = (struct r_debug *) dynpnt->d_un.d_ptr;
1224 lpnt = dbg_hdr->r_map;
1227 * Now walk the linked list. In all known ELF implementations,
1228 * the dynamic loader maintains this linked list for us. In some
1229 * cases the first entry doesn't appear with a name, in other cases it
1232 for(; lpnt; lpnt = lpnt->l_next )
1235 * We already got the stuff for the executable using the
1236 * argv[0] entry above. Here we only need to concentrate on any
1237 * shared libraries which may be loaded.
1239 ehdr = (Elf32_Ehdr *) lpnt->l_addr;
1240 if( (lpnt->l_addr == 0) || (ehdr->e_type != ET_DYN) )
1243 if( lpnt->l_name != NULL )
1245 if (rowcount + strlen(lpnt->l_name) > 76)
1247 fprintf( stderr, "\n " );
1250 fprintf( stderr, " %s", lpnt->l_name );
1251 rowcount += strlen(lpnt->l_name) + 1;
1252 DEBUG_ProcessElfObject(lpnt->l_name, lpnt->l_addr);
1259 fprintf( stderr, "\n" );
1264 #else /* !__ELF__ */
1271 DEBUG_ReadExecutableDbgInfo(void)
1273 char * addr = (char *) 0xffffffff;
1278 unsigned int staboff;
1279 struct stat statbuf;
1281 unsigned int stroff;
1283 exe_name = DEBUG_argv0;
1286 * Make sure we can stat and open this file.
1288 if( exe_name == NULL )
1291 status = stat(exe_name, &statbuf);
1296 * Now open the file, so that we can mmap() it.
1298 fd = open(exe_name, O_RDONLY);
1304 * Now mmap() the file.
1306 addr = mmap(0, statbuf.st_size, PROT_READ,
1307 MAP_PRIVATE, fd, 0);
1308 if( addr == (char *) 0xffffffff )
1311 ahdr = (struct exec *) addr;
1313 staboff = N_SYMOFF(*ahdr);
1314 stroff = N_STROFF(*ahdr);
1315 rtn = DEBUG_ParseStabs(addr, 0,
1319 statbuf.st_size - stroff);
1322 * Give a nice status message here...
1324 fprintf( stderr, "Loading symbols: %s", exe_name );
1330 if( addr != (char *) 0xffffffff )
1331 munmap(addr, statbuf.st_size);
1341 * Non-linux, non-ELF platforms.
1344 DEBUG_ReadExecutableDbgInfo(void)
1350 #endif /* __ELF__ */