From cd2f18170ddac76af54e58432ac01e910f30d029 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Mon, 22 Jan 2001 13:38:48 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1010 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/WAD/Include/wad.h | 12 ++- Tools/WAD/Wad/Makefile | 6 +- Tools/WAD/Wad/Makefile.in | 4 +- Tools/WAD/Wad/elf.c | 41 ++++---- Tools/WAD/Wad/init.c | 4 +- Tools/WAD/Wad/io.c | 21 +++++ Tools/WAD/Wad/memory.c | 5 +- Tools/WAD/Wad/object.c | 194 ++++++++------------------------------ Tools/WAD/Wad/segment.c | 4 +- Tools/WAD/Wad/signal.c | 5 - Tools/WAD/Wad/stab.c | 6 +- Tools/WAD/Wad/stack.c | 16 ++-- 12 files changed, 111 insertions(+), 207 deletions(-) create mode 100644 Tools/WAD/Wad/io.c diff --git a/Tools/WAD/Include/wad.h b/Tools/WAD/Include/wad.h index 0ca9132cf..d65421002 100644 --- a/Tools/WAD/Include/wad.h +++ b/Tools/WAD/Include/wad.h @@ -40,6 +40,10 @@ extern void *wad_malloc(int nbytes); extern void wad_release_memory(); extern char *wad_strdup(const char *c); +/* I/O */ + +extern void wad_printf(const char *fmt, ...); + /* Memory segments */ typedef struct WadSegment { char *base; /* Base address for symbol lookup */ @@ -57,17 +61,15 @@ extern WadSegment *wad_segment_find(void *vaddr); /* Object file handling */ typedef struct WadObjectFile { struct WadFile *file; /* File data (private) */ - int refcnt; /* Reference count */ void *ptr; /* Pointer to data */ int len; /* Length of data */ int type; /* Type of the object file */ - char path[MAX_PATH]; /* Path name of this object */ + char *path; /* Path name of this object */ + struct WadObjectFile *next; } WadObjectFile; -extern void wad_object_init(); +extern void wad_object_reset(); extern WadObjectFile *wad_object_load(const char *path); -extern void wad_object_release(WadObjectFile *); -extern void wad_object_cleanup(); /* Symbol table information */ diff --git a/Tools/WAD/Wad/Makefile b/Tools/WAD/Wad/Makefile index c9649ea03..7eaa48a72 100644 --- a/Tools/WAD/Wad/Makefile +++ b/Tools/WAD/Wad/Makefile @@ -7,8 +7,8 @@ ####################################################################### # These are the files that make up the WAD core -WADSRCS = memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c -WADOBJS = memory.o return.o default.o stack.o stab.o elf.o object.o signal.o segment.o init.o +WADSRCS = io.c memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c +WADOBJS = io.o memory.o return.o default.o stack.o stab.o elf.o object.o signal.o segment.o init.o INCLUDE = -I../Include -I. $(SINCLUDE) WADOPT = -DWAD_LINUX @@ -76,7 +76,7 @@ wc:: wc $(SRCS) semi:: - egrep ";" $(SRCS) wadpy.cxx | wc + egrep ";" $(WADSRCS) | wc clean:: diff --git a/Tools/WAD/Wad/Makefile.in b/Tools/WAD/Wad/Makefile.in index d731b21f2..b06c96267 100644 --- a/Tools/WAD/Wad/Makefile.in +++ b/Tools/WAD/Wad/Makefile.in @@ -6,8 +6,8 @@ ####################################################################### # These are the files that make up the WAD core -WADSRCS = memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c -WADOBJS = memory.o return.o default.o stack.o stab.o elf.o object.o signal.o segment.o init.o +WADSRCS = io.c memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c +WADOBJS = io.o memory.o return.o default.o stack.o stab.o elf.o object.o signal.o segment.o init.o INCLUDE = -I../Include -I. $(SINCLUDE) WADOPT = @WADOPT@ diff --git a/Tools/WAD/Wad/elf.c b/Tools/WAD/Wad/elf.c index 4fd049a14..1e376fc67 100644 --- a/Tools/WAD/Wad/elf.c +++ b/Tools/WAD/Wad/elf.c @@ -240,7 +240,7 @@ wad_elf_find_symbol(WadObjectFile *wo, void *ptr, unsigned long base, WadSymbol localfile = name; } if (wad_debug_mode & DEBUG_SYMBOL_SEARCH) { - printf("%x(%x): %s %x + %x, %x, %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size, sym[i].st_info, sym[i].st_shndx); + wad_printf("%x(%x): %s %x + %x, %x, %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size, sym[i].st_info, sym[i].st_shndx); } if (((base + sym[i].st_value) <= vaddr) && (vaddr <= (base+sym[i].st_value + sym[i].st_size))) { @@ -281,7 +281,7 @@ wad_elf_find_symbol(WadObjectFile *wo, void *ptr, unsigned long base, WadSymbol localfile = name; } if (wad_debug_mode & DEBUG_SYMBOL_SEARCH) { - printf("%x(%x): %s %x + %x, %x, %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size, sym[i].st_info, sym[i].st_shndx); + wad_printf("%x(%x): %s %x + %x, %x, %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size, sym[i].st_info, sym[i].st_shndx); } if (((base + sym[i].st_value) <= vaddr) && (vaddr <= (base+sym[i].st_value + sym[i].st_size))) { #ifdef WAD_LINUX @@ -324,12 +324,12 @@ wad_elf_debug_info(WadObjectFile *wo, WadSymbol *wsym, unsigned long offset, Wad nstabexclstr = wad_elf_section_byname(wo,".stab.exclstr"); #ifdef DEBUG_DEBUG - printf("nstab = %d\n", nstab); - printf("nstabstr = %d\n", nstabstr); - printf("nstabindex = %d\n", nstabindex); - printf("nstabindexstr = %d\n", nstabindexstr); - printf("nstabexcl = %d\n", nstabexcl); - printf("nstabexclstr = %d\n", nstabexclstr); + wad_printf("nstab = %d\n", nstab); + wad_printf("nstabstr = %d\n", nstabstr); + wad_printf("nstabindex = %d\n", nstabindex); + wad_printf("nstabindexstr = %d\n", nstabindexstr); + wad_printf("nstabexcl = %d\n", nstabexcl); + wad_printf("nstabexclstr = %d\n", nstabexclstr); #endif /* Now start searching stabs */ @@ -365,9 +365,8 @@ wad_elf_debug_info(WadObjectFile *wo, WadSymbol *wsym, unsigned long offset, Wad wo1 = wad_object_load(objfile); if (wo1) { ret = wad_debug_info(wo1,wsym,offset,wd); - wad_object_release(wo1); } else { - /* printf("couldn't load %s\n", objfile); */ + /* wad_printf("couldn't load %s\n", objfile); */ } if (!ret) return wad_search_stab(stab,stabsize,stabstr,wsym, offset,wd); return ret; @@ -385,13 +384,13 @@ wad_elf_debug_info(WadObjectFile *wo, WadSymbol *wsym, unsigned long offset, Wad void wad_elf_debug(WadObjectFile *wo) { int i; - printf("ELF Debug : obj = %x (%s)\n", wo, wo->path); - printf(" phdrcnt = %d\n", wad_elf_phdrcnt(wo)); - printf(" phdrpos = %x\n", wad_elf_phdrpos(wo)); - printf(" shdrcnt = %d\n", wad_elf_shdrcnt(wo)); - printf(" shdrpos = %x\n", wad_elf_shdrpos(wo)); + wad_printf("ELF Debug : obj = %x (%s)\n", wo, wo->path); + wad_printf(" phdrcnt = %d\n", wad_elf_phdrcnt(wo)); + wad_printf(" phdrpos = %x\n", wad_elf_phdrpos(wo)); + wad_printf(" shdrcnt = %d\n", wad_elf_shdrcnt(wo)); + wad_printf(" shdrpos = %x\n", wad_elf_shdrpos(wo)); for (i = 0; i < wad_elf_shdrcnt(wo); i++) { - printf(" section '%s': data = 0x%x, size = %d\n", + wad_printf(" section '%s': data = 0x%x, size = %d\n", wad_elf_section_name(wo,i), wad_elf_section_data(wo,i), wad_elf_section_size(wo,i)); @@ -413,20 +412,20 @@ wad_find_symbol(WadObjectFile *wo, void *ptr, unsigned base, WadSymbol *ws) { ws->bind = 0; ws->value = 0; if (wad_debug_mode & DEBUG_SYMBOL) { - printf("wad: Searching for 0x%08x --> ", ptr); + wad_printf("wad: Searching for 0x%08x --> ", ptr); } r = wad_elf_find_symbol(wo,ptr,base,ws); if (r) { if (wad_debug_mode & DEBUG_SYMBOL) { - printf("%s", ws->name); + wad_printf("%s", ws->name); if (ws->file) - printf(" in '%s'\n", ws->file); + wad_printf(" in '%s'\n", ws->file); else - printf("\n"); + wad_printf("\n"); } } else { if (wad_debug_mode & DEBUG_SYMBOL) { - printf("?\n"); + wad_printf("?\n"); } } return r; diff --git a/Tools/WAD/Wad/init.c b/Tools/WAD/Wad/init.c index c1cd7c134..2c4671ec0 100644 --- a/Tools/WAD/Wad/init.c +++ b/Tools/WAD/Wad/init.c @@ -76,12 +76,12 @@ void wad_init() { } if (wad_debug_mode & DEBUG_INIT) { - printf("WAD: initializing\n"); + wad_printf("WAD: initializing\n"); } if (!init) { wad_signal_init(); - wad_object_init(); + wad_object_reset(); } init = 1; } diff --git a/Tools/WAD/Wad/io.c b/Tools/WAD/Wad/io.c new file mode 100644 index 000000000..2277f29a6 --- /dev/null +++ b/Tools/WAD/Wad/io.c @@ -0,0 +1,21 @@ +/* ----------------------------------------------------------------------------- + * io.c + * + * This file provides some I/O routines so that WAD can produce + * debugging output without using buffered I/O. + * + * Author(s) : David Beazley (beazley@cs.uchicago.edu) + * + * Copyright (C) 2000. The University of Chicago + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + +#include "wad.h" +#include + +void wad_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr,fmt,ap); + va_end(ap); +} diff --git a/Tools/WAD/Wad/memory.c b/Tools/WAD/Wad/memory.c index 2551e60d4..b83e25477 100644 --- a/Tools/WAD/Wad/memory.c +++ b/Tools/WAD/Wad/memory.c @@ -36,7 +36,7 @@ int wad_memory_init() { pagesize = getpagesize(); devzero = open("/dev/zero", O_RDWR); if (devzero < 0) { - printf("WAD: couldn't open /dev/zero.\n"); + wad_printf("WAD: couldn't open /dev/zero.\n"); return -1; } return 0; @@ -70,7 +70,7 @@ void *wad_malloc(int nbytes) { WadMemory *wm; char *c; int npages; - printf("wad_malloc: %d\n", nbytes); + /* wad_printf("wad_malloc: %d\n", nbytes); */ if (nbytes >= (pagesize >> 2)) { /* Large allocation. */ npages = ((nbytes + sizeof(WadMemory))/pagesize) + 1; @@ -94,6 +94,7 @@ void *wad_malloc(int nbytes) { } } if (!wm) { + wad_printf("wad_malloc: new page\n", nbytes); wm = (WadMemory *) wad_page_alloc(1); if (!wm) return 0; wm->npages = 1; diff --git a/Tools/WAD/Wad/object.c b/Tools/WAD/Wad/object.c index 321ca0de4..5bfeec78a 100644 --- a/Tools/WAD/Wad/object.c +++ b/Tools/WAD/Wad/object.c @@ -14,173 +14,84 @@ #include "wad.h" #include -/* Maximum number of files that can be loaded at once */ - -#define WAD_MAX_FILE 32 - typedef struct WadFile { - int refcnt; - void *addr; - int size; - char path[MAX_PATH]; + void *addr; /* Base address of the file */ + int size; /* Size in bytes */ + char *path; /* Path name */ + struct WadFile *next; /* Next file */ } WadFile; -static WadFile wad_files[WAD_MAX_FILE]; /* Array of file objects */ +static WadFile *wad_files = 0; /* Linked list of loaded files */ /* private function to manage the loading of raw files into memory */ static WadFile * load_file(const char *path) { int i; int fd; - WadFile *firstfree = 0; - WadFile *firstreplace = 0; WadFile *wf = wad_files; if (wad_debug_mode & DEBUG_FILE) { - printf("wad: Loading file '%s' ... ", path); + wad_printf("wad: Loading file '%s' ... ", path); } - /* Walk through the file list to see if we already know about the file */ - for (i = 0; i < WAD_MAX_FILE; i++, wf++) { - if (strcmp(wf->path, path) == 0) { - wf->refcnt++; - if (wad_debug_mode & DEBUG_FILE) { - printf("cached.\n"); - } + while (wf) { + if (strcmp(wf->path,path) == 0) { + if (wad_debug_mode & DEBUG_FILE) wad_printf("cached.\n"); return wf; } - if (wf->refcnt <= 0) { - if (wf->path[0] == 0) firstfree = wf; - else firstreplace = wf; - } + wf = wf->next; } - - if (!firstfree && !firstreplace) { - if (wad_debug_mode & DEBUG_FILE) printf("out of memory!\n"); - return 0; /* Out of space */ - } - - if (!firstfree) firstfree = firstreplace; - fd = open(path, O_RDONLY); if (fd < 0) { - if (wad_debug_mode & DEBUG_FILE) printf("not found!\n"); + if (wad_debug_mode & DEBUG_FILE) wad_printf("not found!\n"); return 0; /* Doesn't exist. Oh well */ } - if (wad_debug_mode & DEBUG_FILE) printf("loaded.\n"); - /* If already mapped, unmap the file */ - if (firstfree->addr) { - if (wad_debug_mode & DEBUG_FILE) - printf("wad: Unloading file '%s'\n", firstfree->path); - munmap(firstfree->addr,firstfree->size); - } - - firstfree->refcnt = 1; - strncpy(firstfree->path,path,MAX_PATH); + if (wad_debug_mode & DEBUG_FILE) wad_printf("loaded.\n"); + wf = (WadFile *) wad_malloc(sizeof(WadFile)); + wf->path = wad_strdup(path); /* Get file length */ - firstfree->size = lseek(fd,0,SEEK_END); + wf->size = lseek(fd,0,SEEK_END); lseek(fd,0,SEEK_SET); /* Try to mmap the file */ - firstfree->addr = mmap(NULL,firstfree->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); + wf->addr = mmap(NULL,wf->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); close(fd); - if (firstfree->addr == MAP_FAILED) { - if (wad_debug_mode & DEBUG_FILE) printf("wad: Couldn't mmap '%s'\n", path); - firstfree->refcnt = 0; - firstfree->path[0] = 0; - firstfree->addr = 0; - firstfree->size = 0; + if (wf->addr == MAP_FAILED) { + if (wad_debug_mode & DEBUG_FILE) wad_printf("wad: Couldn't mmap '%s'\n", path); return 0; } - return firstfree; + wf->next = wad_files; + wad_files = wf; + return wf; } -static void -release_file(WadFile *f) { - if (wad_debug_mode & DEBUG_FILE) printf("wad: Releasing file '%s'\n", f->path); - f->refcnt--; -} - -#define WAD_MAX_OBJECT 32 - -static WadObjectFile wad_objects[WAD_MAX_OBJECT]; /* Object file descriptor table */ -static int wad_obj_free[WAD_MAX_OBJECT]; /* Free object stack */ -static int wad_obj_nfree = 0; /* Num free object descriptors */ -/* ----------------------------------------------------------------------------- - * wad_object_init() - * - * Initialize the object file system - * ----------------------------------------------------------------------------- */ - -void wad_object_init() { - int i; - - for (i = 0; i < WAD_MAX_FILE; i++) { - wad_files[i].refcnt = 0; - wad_files[i].addr = 0; - wad_files[i].size = 0; - wad_files[i].path[0] = 0; - } - wad_obj_nfree = 0; - for (i = 0; i < WAD_MAX_OBJECT; i++) { - wad_objects[i].ptr = 0; - wad_objects[i].len = 0; - wad_objects[i].refcnt = 0; - wad_objects[i].path[0] = 0; - wad_obj_free[i] = i; - wad_obj_nfree++; - } -} +static WadObjectFile *wad_objects = 0; /* Linked list of object files */ /* ----------------------------------------------------------------------------- * wad_object_cleanup() * - * Release all files loaded during the debugging + * Reset the object file loader * ----------------------------------------------------------------------------- */ void -wad_object_cleanup() { +wad_object_reset() { int i; WadFile *f = wad_files; if (wad_debug_mode & DEBUG_OBJECT) { - printf("wad: Releasing all files.\n"); + wad_printf("wad: Releasing all files.\n"); } - for (i = 0; i < WAD_MAX_FILE; i++, f++) { + /* Unmap all of the loaded files */ + while (f) { if (f->addr) { munmap(f->addr, f->size); } - f->addr = 0; - f->size = 0; - f->path[0] = 0; - f->refcnt = 0; + f = f->next; } -} - -/* ----------------------------------------------------------------------------- - * wad_object_release() - * - * Done with the object. - * ----------------------------------------------------------------------------- */ - -void -wad_object_release(WadObjectFile *wo) { - int n; - if (!wo) return; - - wo->refcnt--; - if (wo->refcnt > 0) return; - if (wad_debug_mode & DEBUG_OBJECT) { - printf("wad: Releasing object '%s'\n", wo->path); - } - release_file(wo->file); - wo->file = 0; - wo->ptr = 0; - wo->len = 0; - wo->path[0] = 0; - n = wo - wad_objects; - wad_obj_free[wad_obj_nfree++] = n; + /* Reset the linked lists */ + wad_files = 0; + wad_objects = 0; } /* ----------------------------------------------------------------------------- @@ -198,21 +109,12 @@ wad_object_load(const char *path) { WadObjectFile *wad_arobject_load(const char *path, const char *name); if (wad_debug_mode & DEBUG_OBJECT) { - printf("wad: Loading object '%s'\n", path); + wad_printf("wad: Loading object '%s'\n", path); } - /* See if the path has already been loaded */ - for (i = 0; i < WAD_MAX_OBJECT; i++) { - if (strcmp(wad_objects[i].path,path) == 0) { - wo = &wad_objects[i]; - wo->refcnt++; - return wo; - } - } - if (wad_obj_nfree == 0) { - if (wad_debug_mode & DEBUG_OBJECT) - printf("wad: No more space in wad_object_load()\n"); - return 0; + for (wo = wad_objects; wo; wo=wo->next) { + if (strcmp(wo->path,path) == 0) return wo; } + /* Didn't find it. Now we need to go load some files */ /* If this is an archive reference like /path/libfoo.a(blah.o), we need to split up the name a little bit */ @@ -232,7 +134,8 @@ wad_object_load(const char *path) { /* Okay, I'm going to attempt to map this as a library file */ wo = wad_arobject_load(realfile,objfile); if (wo) { - strncpy(wo->path, path, MAX_PATH); + /* Reset the path */ + wo->path = wad_strdup(path); return wo; } } @@ -240,12 +143,9 @@ wad_object_load(const char *path) { wf = load_file(path); if (!wf) return 0; - wo = wad_objects + wad_obj_free[wad_obj_nfree-1]; - wad_obj_nfree--; - + wo = (WadObjectFile *) wad_malloc(sizeof(WadObjectFile)); wo->file = wf; - wo->refcnt = 1; - strncpy(wo->path,path, MAX_PATH); + wo->path = wad_strdup(path); wo->ptr = wf->addr; wo->len = wf->size; return wo; @@ -283,18 +183,10 @@ wad_arobject_load(const char *arpath, const char *robjname) { arptr = (char *) wf->addr; arlen = wf->size; - nf = wad_obj_free[wad_obj_nfree-1]; - wo = wad_objects + nf; - wad_obj_nfree--; - wo->refcnt = 1; - wo->ptr = 0; - /* Now take a look at the archive */ if (strncmp(arptr,ARMAG,SARMAG) == 0) { /* printf("Got an archive\n"); */ } else { - /* Not an archive file */ - release_file(wf); return 0; } @@ -318,7 +210,6 @@ wad_arobject_load(const char *arpath, const char *robjname) { soff = atoi(ah->ar_name+1); if (!strtab) { /* No offset table */ - release_file(wf); return 0; } e = strchr(strtab+soff,'\n'); @@ -336,18 +227,15 @@ wad_arobject_load(const char *arpath, const char *robjname) { /* Compare the names */ if (strncmp(mname,objname,sobjname) == 0) { /* Found the archive */ - - wo = wad_objects + wad_obj_free[wad_obj_nfree-1]; - wad_obj_nfree--; + wo = (WadObjectFile *) wad_malloc(sizeof(WadObjectFile)); wo->file = wf; - wo->refcnt = 1; wo->ptr = (void *) (arptr + offset); wo->len = msize; + wo->path = 0; return wo; } offset += msize; } - release_file(wf); return 0; } diff --git a/Tools/WAD/Wad/segment.c b/Tools/WAD/Wad/segment.c index 484ddea48..31bb31c68 100644 --- a/Tools/WAD/Wad/segment.c +++ b/Tools/WAD/Wad/segment.c @@ -60,7 +60,7 @@ wad_segment_read() { lasts = s; } if (wad_debug_mode & DEBUG_SEGMENT) { - printf("wad_segment: read : %08x-%08x, base=%x in %s\n", s->vaddr, ((char *) s->vaddr) + s->size, s->base, s->mappath); + wad_printf("wad_segment: read : %08x-%08x, base=%x in %s\n", s->vaddr, ((char *) s->vaddr) + s->size, s->base, s->mappath); } } close(fs); @@ -90,7 +90,7 @@ wad_segment_find(void *vaddr) { } if ((addr >= s->vaddr) && (addr < (s->vaddr + s->size))) { if (wad_debug_mode & DEBUG_SEGMENT) { - printf("wad_segment: %08x --> %08x-%08x in %s\n", vaddr, s->vaddr, ((char *) s->vaddr) + s->size, s->mappath); + wad_printf("wad_segment: %08x --> %08x-%08x in %s\n", vaddr, s->vaddr, ((char *) s->vaddr) + s->size, s->mappath); } return ls; } diff --git a/Tools/WAD/Wad/signal.c b/Tools/WAD/Wad/signal.c index 2f0a186bb..46ad96a19 100644 --- a/Tools/WAD/Wad/signal.c +++ b/Tools/WAD/Wad/signal.c @@ -259,9 +259,6 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) { wad_nlr_func = 0; - if (!wad_stacked_signal) - wad_object_init(); - context = (ucontext_t *) vcontext; if (wad_debug_mode & DEBUG_SIGNAL) { @@ -399,8 +396,6 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) { if (wad_debug_mode & DEBUG_HOLD) while(1); - wad_object_cleanup(); - /* If we found a function to which we should return, we jump to an alternative piece of code that unwinds the stack and initiates a non-local return. */ diff --git a/Tools/WAD/Wad/stab.c b/Tools/WAD/Wad/stab.c index b8b0f7949..874c93cbf 100644 --- a/Tools/WAD/Wad/stab.c +++ b/Tools/WAD/Wad/stab.c @@ -27,7 +27,7 @@ typedef struct Stab { extra information delimetered by a colon */ int match_stab_symbol(char *symbol, char *stabtext, int slen) { - /* printf("matching: %s -> %s\n", symbol, stabtext); */ + /* wad_printf("matching: %s -> %s\n", symbol, stabtext); */ if (strcmp(symbol,stabtext) == 0) { return 1; } @@ -74,9 +74,9 @@ wad_search_stab(void *sp, int size, char *stabstr, WadSymbol *wsym, unsigned lon for (i = 0; i < ns; i++, s++) { /*#define DEBUG_DEBUG */ if (wad_debug_mode & DEBUG_STABS) { - /* printf(" %10d %10x %10d %10d %10d: '%x'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, + /* wad_printf(" %10d %10x %10d %10d %10d: '%x'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, stabstr+s->n_strx); */ - printf(" %10d %10x %10d %10d %10d: '%s'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, + wad_printf(" %10d %10x %10d %10d %10d: '%s'\n", s->n_strx, s->n_type, s->n_other, s->n_desc, s->n_value, stabstr+s->n_strx); } diff --git a/Tools/WAD/Wad/stack.c b/Tools/WAD/Wad/stack.c index 7861134a1..36cd14582 100644 --- a/Tools/WAD/Wad/stack.c +++ b/Tools/WAD/Wad/stack.c @@ -28,7 +28,7 @@ static void stack_unwind(unsigned long *sp, unsigned long *pc, unsigned long *fp) { if (wad_debug_mode & DEBUG_UNWIND) { - printf("::: stack unwind : pc = %x, sp = %x, fp = %x\n", *pc, *sp, *fp); + wad_printf("::: stack unwind : pc = %x, sp = %x, fp = %x\n", *pc, *sp, *fp); } #ifdef WAD_SOLARIS *pc = *((unsigned long *) *sp+15); /* %i7 - Return address */ @@ -80,7 +80,7 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { /* Read the segments */ if (wad_segment_read() < 0) { - printf("WAD: Unable to read segment map\n"); + wad_printf("WAD: Unable to read segment map\n"); return 0; } @@ -88,7 +88,7 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { tmpnam(framefile); ffile = open(framefile, O_CREAT | O_TRUNC | O_WRONLY, 0644); if (ffile < 0) { - printf("can't open %s\n", framefile); + wad_printf("can't open %s\n", framefile); return 0; } @@ -156,7 +156,7 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { if (symname) { symsize = strlen(symname)+1; - /* printf("C++: '%s' ---> '%s'\n", symname, wad_cplus_demangle(&wsym));*/ + /* wad_printf("C++: '%s' ---> '%s'\n", symname, wad_cplus_demangle(&wsym));*/ /* Try to gather some debugging information about this symbol */ if (wad_debug_info(wo,&wsym, p_pc - (unsigned long) ws->base - value, &wd)) { @@ -171,9 +171,9 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { /* if (wd.nargs >=0) { int i; - printf("%s\n",symname); + wad_printf("%s\n",symname); for (i = 0; i < wd.nargs; i++) { - printf(" [%d] = '%s', %d, %d\n", i, wd.parms[i].name, wd.parms[i].type, wd.parms[i].value); + wad_printf(" [%d] = '%s', %d, %d\n", i, wd.parms[i].name, wd.parms[i].type, wd.parms[i].value); } } */ @@ -188,7 +188,7 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { int i; long *lsp = (long *) p_lastsp; for (i = 0; i < 16; i++) { - /* printf("regs[%d] = 0x%x\n", lsp[i]); */ + /* wad_printf("regs[%d] = 0x%x\n", lsp[i]); */ frame.regs[i] = lsp[i]; } } @@ -255,8 +255,6 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) { } write(ffile,frame.data, pad); lastsize = frame.size; - if (wo) - wad_object_release(wo); } }