*** empty log message ***
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1046 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a62a269464
commit
27122d0332
23 changed files with 1101 additions and 354 deletions
|
|
@ -10,25 +10,25 @@
|
|||
WADSRCS = string.c vars.c io.c memory.c return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c
|
||||
WADOBJS = string.o vars.o 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_SOLARIS
|
||||
WADOPT = -DWAD_LINUX
|
||||
|
||||
|
||||
# Location of your Perl installation
|
||||
PERLINCLUDE = -I/usr/perl5/5.00503/sun4-solaris/CORE
|
||||
PERLINCLUDE = -I/usr/lib/perl5/5.00503/i386-linux/CORE
|
||||
PERLSRCS = wadpl.cxx
|
||||
PERLOBJS = wadpl.o
|
||||
|
||||
# C Compiler
|
||||
CC = cc
|
||||
CFLAGS = #
|
||||
CC = gcc -Wall
|
||||
CFLAGS = #-fpic
|
||||
|
||||
# C++ Compiler
|
||||
CXX = CC
|
||||
CXXFLAGS = #-Kpic
|
||||
CXX = c++
|
||||
CXXFLAGS = #-fpic
|
||||
|
||||
# Linking options
|
||||
CLINK =
|
||||
CXXLINK = CC -G
|
||||
CXXLINK = g++ -shared
|
||||
|
||||
# AR
|
||||
AR = ar
|
||||
|
|
|
|||
|
|
@ -5,8 +5,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -20,7 +33,6 @@
|
|||
|
||||
char *wad_arg_string(WadFrame *frame) {
|
||||
static char str[1024];
|
||||
static char temp[64];
|
||||
WadLocal *wp;
|
||||
long *stack;
|
||||
long *nextstack;
|
||||
|
|
@ -58,20 +70,21 @@ char *wad_arg_string(WadFrame *frame) {
|
|||
|
||||
#ifdef WAD_SOLARIS
|
||||
for (i = 0; i < 6; i++) {
|
||||
sprintf(temp,"0x%x", stack[8+i]);
|
||||
strcat(str,temp);
|
||||
wad_strcpy(temp,"0x");
|
||||
wad_strcat(temp,wad_format_hex(stack[8+1],0));
|
||||
wad_strcat(str,temp);
|
||||
if (i < 5)
|
||||
strcat(str,",");
|
||||
wad_strcat(str,",");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
/* We were able to get some argument information out the debugging table */
|
||||
wp = frame->debug_args;
|
||||
for (i = 0; i < frame->debug_nargs; i++, wp = wp->next) {
|
||||
strcat(str,wp->name);
|
||||
strcat(str,"=");
|
||||
strcat(str,wad_format_var(wp));
|
||||
if (i < (frame->debug_nargs-1)) strcat(str,",");
|
||||
wad_strcat(str,wp->name);
|
||||
wad_strcat(str,"=");
|
||||
wad_strcat(str,wad_format_var(wp));
|
||||
if (i < (frame->debug_nargs-1)) wad_strcat(str,",");
|
||||
}
|
||||
}
|
||||
return str;
|
||||
|
|
@ -120,7 +133,7 @@ char *wad_load_source(char *path, int line) {
|
|||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
strcpy(src_path,path);
|
||||
wad_strcpy(src_path,path);
|
||||
}
|
||||
n = 0;
|
||||
start = src_file;
|
||||
|
|
@ -156,7 +169,6 @@ void wad_release_source() {
|
|||
|
||||
char *wad_debug_src_string(WadFrame *f, int window) {
|
||||
static char temp[16384];
|
||||
char ntemp[64];
|
||||
|
||||
if (f->loc_srcfile && strlen(f->loc_srcfile) && (f->loc_line > 0)) {
|
||||
char *line, *c;
|
||||
|
|
@ -167,22 +179,22 @@ char *wad_debug_src_string(WadFrame *f, int window) {
|
|||
if (first < 1) first = 1;
|
||||
line = wad_load_source(f->loc_srcfile,first);
|
||||
if (line) {
|
||||
strcpy(temp,f->loc_srcfile);
|
||||
strcat(temp,", line ");
|
||||
sprintf(ntemp,"%d\n\n", f->loc_line);
|
||||
strcat(temp,ntemp);
|
||||
wad_strcpy(temp,f->loc_srcfile);
|
||||
wad_strcat(temp,", line ");
|
||||
wad_strcat(temp,wad_format_signed(f->loc_line,-1));
|
||||
wad_strcat(temp,"\n\n");
|
||||
for (i = first; i <= last; i++) {
|
||||
if (i == f->loc_line) strcat(temp," => ");
|
||||
else strcat(temp," ");
|
||||
if (i == f->loc_line) wad_strcat(temp," => ");
|
||||
else wad_strcat(temp," ");
|
||||
c = strchr(line,'\n');
|
||||
if (c) {
|
||||
*c = 0;
|
||||
strcat(temp,line);
|
||||
strcat(temp,"\n");
|
||||
wad_strcat(temp,line);
|
||||
wad_strcat(temp,"\n");
|
||||
*c = '\n';
|
||||
} else {
|
||||
strcat(temp,line);
|
||||
strcat(temp,"\n");
|
||||
wad_strcat(temp,line);
|
||||
wad_strcat(temp,"\n");
|
||||
break;
|
||||
}
|
||||
line = c+1;
|
||||
|
|
@ -204,31 +216,34 @@ char *wad_debug_src_string(WadFrame *f, int window) {
|
|||
void
|
||||
wad_debug_make_strings(WadFrame *f) {
|
||||
static char msg[16384];
|
||||
char temp[1024];
|
||||
while (f) {
|
||||
sprintf(msg,"#%-3d 0x%08x in ", f->frameno, f->pc);
|
||||
strcat(msg, f->sym_name ? f->sym_name : "?");
|
||||
strcat(msg,"(");
|
||||
strcat(msg,wad_arg_string(f));
|
||||
strcat(msg,")");
|
||||
wad_strcpy(msg,"#");
|
||||
wad_strcat(msg,wad_format_signed(f->frameno,3));
|
||||
wad_strcat(msg," 0x");
|
||||
wad_strcat(msg,wad_format_hex(f->pc,1));
|
||||
wad_strcat(msg," in ");
|
||||
wad_strcat(msg, f->sym_name ? f->sym_name : "?");
|
||||
wad_strcat(msg,"(");
|
||||
wad_strcat(msg,wad_arg_string(f));
|
||||
wad_strcat(msg,")");
|
||||
if (f->loc_srcfile && strlen(f->loc_srcfile)) {
|
||||
strcat(msg," in '");
|
||||
strcat(msg, wad_strip_dir(f->loc_srcfile));
|
||||
strcat(msg,"'");
|
||||
wad_strcat(msg," in '");
|
||||
wad_strcat(msg, wad_strip_dir(f->loc_srcfile));
|
||||
wad_strcat(msg,"'");
|
||||
if (f->loc_line > 0) {
|
||||
sprintf(temp,", line %d", f->loc_line);
|
||||
strcat(msg,temp);
|
||||
wad_strcat(msg,", line ");
|
||||
wad_strcat(msg,wad_format_signed(f->loc_line,-1));
|
||||
/* Try to locate the source file */
|
||||
wad_debug_src_string(f, WAD_SRC_WINDOW);
|
||||
}
|
||||
} else {
|
||||
if (f->loc_objfile && strlen(f->loc_objfile)) {
|
||||
strcat(msg," from '");
|
||||
strcat(msg, wad_strip_dir(f->loc_objfile));
|
||||
strcat(msg,"'");
|
||||
wad_strcat(msg," from '");
|
||||
wad_strcat(msg, wad_strip_dir(f->loc_objfile));
|
||||
wad_strcat(msg,"'");
|
||||
}
|
||||
}
|
||||
strcat(msg,"\n");
|
||||
wad_strcat(msg,"\n");
|
||||
f->debug_str = wad_strdup(msg);
|
||||
f = f->next;
|
||||
}
|
||||
|
|
@ -239,8 +254,6 @@ wad_debug_make_strings(WadFrame *f) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void wad_default_callback(int signo, WadFrame *f, char *ret) {
|
||||
char *fd;
|
||||
WadFrame *fline = 0;
|
||||
char *srcstr = 0;
|
||||
|
||||
switch(signo) {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -20,11 +33,8 @@
|
|||
#endif
|
||||
|
||||
/* --- What's needed here (high level interface) :
|
||||
|
||||
- Mapping of addresses to symbols
|
||||
- Mapping of symbols to file+line
|
||||
- Parameter passing information?
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -37,8 +47,6 @@
|
|||
|
||||
int
|
||||
wad_elf_check(WadObjectFile *wo) {
|
||||
int t;
|
||||
|
||||
if (strncmp((char *)wo->ptr,ELFMAG, SELFMAG) != 0)
|
||||
return 0;
|
||||
|
||||
|
|
@ -247,6 +255,7 @@ int elf_search_section_sym(WadFrame *f, char *secname, char *strname) {
|
|||
if (sym[i].st_shndx == 0) continue;
|
||||
#endif
|
||||
f->sym_name = name;
|
||||
f->sym_nlen = strlen(name);
|
||||
f->sym_base = base + sym[i].st_value;
|
||||
f->sym_size = sym[i].st_size;
|
||||
if (ELF32_ST_BIND(sym[i].st_info) == STB_LOCAL) {
|
||||
|
|
@ -330,7 +339,7 @@ wad_elf_debug_info(WadFrame *f) {
|
|||
WadObjectFile *wo1, *wold;
|
||||
/* Hmmm. Might be in a different file */
|
||||
char objfile[MAX_PATH];
|
||||
strcpy(objfile, f->loc_objfile);
|
||||
wad_strcpy(objfile, f->loc_objfile);
|
||||
wo1 = wad_object_load(objfile);
|
||||
if (wo1) {
|
||||
wold = f->object;
|
||||
|
|
@ -398,8 +407,11 @@ wad_find_symbol(WadFrame *f) {
|
|||
|
||||
void
|
||||
wad_find_debug(WadFrame *f) {
|
||||
if (f->object)
|
||||
if (f->debug_check) return;
|
||||
if (f->object) {
|
||||
wad_elf_debug_info(f);
|
||||
}
|
||||
f->debug_check = 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
|
|||
|
|
@ -6,13 +6,92 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Utility functions used to generate strings that are guaranteed not to
|
||||
rely upon malloc() and related functions */
|
||||
|
||||
char *wad_format_hex(unsigned long u, int leading) {
|
||||
static char digits[] = "0123456789abcdef";
|
||||
static char result[64];
|
||||
int i;
|
||||
char *c;
|
||||
c = &result[63];
|
||||
*c = 0;
|
||||
for (i = 0; i < (sizeof(unsigned long) << 1); i++) {
|
||||
int digit;
|
||||
if (!u || leading) {
|
||||
digit = u & 0xf;
|
||||
*(--c) = digits[digit];
|
||||
}
|
||||
u = u >> 4;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
char *wad_format_unsigned(unsigned long u, int width) {
|
||||
static char result[128];
|
||||
static char digits[] = "0123456789";
|
||||
char *c, *w;
|
||||
int count = 0;
|
||||
int i;
|
||||
c = &result[64];
|
||||
while (u) {
|
||||
int digit = u % 10;
|
||||
*(--c) = digits[digit];
|
||||
count++;
|
||||
u = u / 10;
|
||||
}
|
||||
if (!count) {
|
||||
*(--c) = '0';
|
||||
count++;
|
||||
}
|
||||
w = &result[64];
|
||||
for (i = count; i < width; i++) {
|
||||
*(w++) = ' ';
|
||||
}
|
||||
*w = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
char *wad_format_signed(signed long s, int width) {
|
||||
static char result[128];
|
||||
unsigned long u;
|
||||
char *c = result;
|
||||
if (s < 0) {
|
||||
*(c++) = '-';
|
||||
width--;
|
||||
u = (unsigned long) (-s);
|
||||
if (u == 0) {
|
||||
u = (unsigned long) s;
|
||||
}
|
||||
} else {
|
||||
u = (unsigned long) s;
|
||||
}
|
||||
*c = 0;
|
||||
wad_strcat(result, wad_format_unsigned(u,width));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void wad_printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,21 @@
|
|||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 2001. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -23,7 +36,6 @@ typedef struct _WadMemory {
|
|||
} WadMemory;
|
||||
|
||||
static WadMemory *current = 0; /* Current memory block */
|
||||
static WadMemory *persistent = 0; /* Persistent memory data */
|
||||
static int pagesize = 0; /* System page size */
|
||||
static int devzero = 0;
|
||||
static int npalloc = 8; /* Number of pages per alloc */
|
||||
|
|
@ -110,26 +122,6 @@ void *wad_malloc(int nbytes) {
|
|||
return c;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* wad_release_memory()
|
||||
*
|
||||
* Releases all memory previously allocated by wad_malloc(). This is inherently
|
||||
* dangerous.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void wad_release_memory() {
|
||||
WadMemory *wm, *next;
|
||||
|
||||
return;
|
||||
wm = current;
|
||||
while (wm) {
|
||||
next = wm->next;
|
||||
munmap((char *) wm, wm->npages*pagesize);
|
||||
wm = next;
|
||||
}
|
||||
current = 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* wad_strdup()
|
||||
*
|
||||
|
|
@ -140,10 +132,23 @@ char *wad_strdup(const char *c) {
|
|||
char *t;
|
||||
if (!c) c = "";
|
||||
t = (char *) wad_malloc(strlen(c)+1);
|
||||
strcpy(t,c);
|
||||
wad_strcpy(t,c);
|
||||
return t;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* wad_memcpy()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void wad_memcpy(void *t, const void *s, unsigned len) {
|
||||
char *tc, *sc;
|
||||
int i;
|
||||
tc = (char *) t;
|
||||
sc = (char *) s;
|
||||
for (i = 0; i < len; i++, tc++, sc++)
|
||||
*tc = *sc;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* wad_memory_debug()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -159,6 +164,6 @@ void wad_memory_debug() {
|
|||
inuse += m->last;
|
||||
m = m->next;
|
||||
}
|
||||
printf("WAD: memory allocated %d bytes (%d bytes used).\n", total_alloc, inuse);
|
||||
wad_printf("WAD: memory allocated %d bytes (%d bytes used).\n", total_alloc, inuse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -34,7 +47,6 @@ 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 *wf = wad_files;
|
||||
|
||||
|
|
@ -84,7 +96,6 @@ static WadObjectFile *wad_objects = 0; /* Linked list of object fil
|
|||
|
||||
void
|
||||
wad_object_reset() {
|
||||
int i;
|
||||
WadFile *f = wad_files;
|
||||
if (wad_debug_mode & DEBUG_OBJECT) {
|
||||
wad_printf("wad: Releasing all files.\n");
|
||||
|
|
@ -112,7 +123,6 @@ WadObjectFile *
|
|||
wad_object_load(const char *path) {
|
||||
WadObjectFile *wo;
|
||||
WadFile *wf;
|
||||
int i;
|
||||
WadObjectFile *wad_arobject_load(const char *path, const char *name);
|
||||
|
||||
if (wad_debug_mode & DEBUG_OBJECT) {
|
||||
|
|
@ -139,7 +149,7 @@ wad_object_load(const char *path) {
|
|||
char *c;
|
||||
c = strchr(path,'(');
|
||||
if (c) {
|
||||
strcpy(realfile,path);
|
||||
wad_strcpy(realfile,path);
|
||||
c = strchr(realfile,'(');
|
||||
*c = 0;
|
||||
objfile = c+1;
|
||||
|
|
@ -181,9 +191,6 @@ WadObjectFile *
|
|||
wad_arobject_load(const char *arpath, const char *robjname) {
|
||||
WadObjectFile *wo;
|
||||
WadFile *wf;
|
||||
int nf;
|
||||
int fd;
|
||||
int i;
|
||||
int arlen;
|
||||
char *arptr;
|
||||
struct ar_hdr *ah;
|
||||
|
|
@ -193,8 +200,8 @@ wad_arobject_load(const char *arpath, const char *robjname) {
|
|||
int sobjname;
|
||||
char objname[MAX_PATH];
|
||||
|
||||
strcpy(objname,robjname);
|
||||
strcat(objname,"/");
|
||||
wad_strcpy(objname,robjname);
|
||||
wad_strcat(objname,"/");
|
||||
sobjname = strlen(objname);
|
||||
|
||||
wf = load_file(arpath);
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* segment_linux.c
|
||||
*
|
||||
* This file reads the virtual memory map on Linux machines.
|
||||
* This file is not compiled directly, it is included in the
|
||||
* segment.c file.
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char linux_firstsegment[1024];
|
||||
static int linux_first = 1;
|
||||
|
||||
static int
|
||||
segment_open() {
|
||||
FILE *f;
|
||||
f = fopen("/proc/self/maps", "r");
|
||||
linux_first =1;
|
||||
return (int) f;
|
||||
}
|
||||
|
||||
static int
|
||||
segment_read(int fd, WadSegment *s)
|
||||
{
|
||||
char pbuffer[1024];
|
||||
char *c;
|
||||
int len;
|
||||
FILE *fs = (FILE *) fd;
|
||||
c = fgets(pbuffer,1024,fs);
|
||||
if (!c) return 0;
|
||||
|
||||
pbuffer[strlen(pbuffer)-1] = 0; /* Chop off endline */
|
||||
|
||||
/* Break up the field into records */
|
||||
/* 0-8 : Starting address
|
||||
9-17 : Ending Address
|
||||
18 : r
|
||||
19 : w
|
||||
20 : x
|
||||
21 : p
|
||||
23-31 : Offset
|
||||
49- : Filename */
|
||||
|
||||
len = strlen(pbuffer);
|
||||
pbuffer[8] = 0;
|
||||
pbuffer[17] = 0;
|
||||
pbuffer[31] = 0;
|
||||
if (len >= 49) {
|
||||
s->mapname = wad_strdup(pbuffer+49);
|
||||
s->mappath = s->mapname;
|
||||
} else {
|
||||
s->mapname = "";
|
||||
s->mappath = s->mapname;
|
||||
}
|
||||
if (linux_first) {
|
||||
strcpy(linux_firstsegment, s->mappath);
|
||||
linux_first = 0;
|
||||
}
|
||||
s->vaddr = (char *) strtoul(pbuffer,NULL,16);
|
||||
s->size = strtoul(pbuffer+9,NULL,16) - (long) (s->vaddr);
|
||||
s->offset = strtoul(pbuffer+23,NULL,16);
|
||||
if (strcmp(linux_firstsegment, s->mappath) == 0) {
|
||||
s->base = 0;
|
||||
} else {
|
||||
s->base = s->vaddr;
|
||||
}
|
||||
s++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* segment_solaris.c
|
||||
*
|
||||
* This file reads the virtual memory map on Solaris machines.
|
||||
* This file is not compiled directly, it is included in the
|
||||
* segment.c file.
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static int
|
||||
segment_open() {
|
||||
int f;
|
||||
f = open("/proc/self/map", O_RDONLY);
|
||||
return f;
|
||||
}
|
||||
|
||||
static int
|
||||
segment_read(int fs, WadSegment *s) {
|
||||
int dz;
|
||||
int n;
|
||||
prmap_t pmap;
|
||||
|
||||
n = read(fs, &pmap, sizeof(prmap_t));
|
||||
if (n <= 0) return 0;
|
||||
s->mapname = wad_strdup(pmap.pr_mapname);
|
||||
s->mappath = (char *) wad_malloc(20+strlen(pmap.pr_mapname));
|
||||
strcpy(s->mappath,"/proc/self/object/");
|
||||
strcat(s->mappath,pmap.pr_mapname);
|
||||
s->vaddr = (char *) pmap.pr_vaddr;
|
||||
|
||||
/* This is a solaris oddity. a.out section starts 1 page up, but
|
||||
symbols are relative to a base of 0 */
|
||||
|
||||
if (strcmp(s->mapname,"a.out") == 0) s->base = 0;
|
||||
else s->base = s->vaddr;
|
||||
|
||||
s->size = pmap.pr_size;
|
||||
s->offset = pmap.pr_offset;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -5,8 +5,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -20,7 +33,7 @@ static int num_return = 0;
|
|||
void wad_set_return(const char *name, long value) {
|
||||
WadReturnFunc *rp;
|
||||
rp = &return_points[num_return];
|
||||
strcpy(rp->name,name);
|
||||
wad_strcpy(rp->name,name);
|
||||
rp->value = value;
|
||||
num_return++;
|
||||
if (wad_debug_mode & DEBUG_RETURN) {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -20,12 +33,105 @@
|
|||
/* Include the proper code for reading the segment map */
|
||||
|
||||
#ifdef WAD_SOLARIS
|
||||
#include "plat/segment_solaris.c"
|
||||
#endif
|
||||
|
||||
/* This code is used to read the process virtual memory map on Solaris machines */
|
||||
|
||||
static int
|
||||
segment_open() {
|
||||
int f;
|
||||
f = open("/proc/self/map", O_RDONLY);
|
||||
return f;
|
||||
}
|
||||
|
||||
static int
|
||||
segment_read(int fs, WadSegment *s) {
|
||||
int dz;
|
||||
int n;
|
||||
prmap_t pmap;
|
||||
|
||||
n = read(fs, &pmap, sizeof(prmap_t));
|
||||
if (n <= 0) return 0;
|
||||
s->mapname = wad_strdup(pmap.pr_mapname);
|
||||
s->mappath = (char *) wad_malloc(20+strlen(pmap.pr_mapname));
|
||||
wad_strcpy(s->mappath,"/proc/self/object/");
|
||||
strcat(s->mappath,pmap.pr_mapname);
|
||||
s->vaddr = (char *) pmap.pr_vaddr;
|
||||
|
||||
/* This is a solaris oddity. a.out section starts 1 page up, but
|
||||
symbols are relative to a base of 0 */
|
||||
|
||||
if (strcmp(s->mapname,"a.out") == 0) s->base = 0;
|
||||
else s->base = s->vaddr;
|
||||
|
||||
s->size = pmap.pr_size;
|
||||
s->offset = pmap.pr_offset;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* WAD_SOLARIS */
|
||||
|
||||
#ifdef WAD_LINUX
|
||||
#include "plat/segment_linux.c"
|
||||
#endif
|
||||
static char linux_firstsegment[1024];
|
||||
static int linux_first = 1;
|
||||
|
||||
static int
|
||||
segment_open() {
|
||||
FILE *f;
|
||||
f = fopen("/proc/self/maps", "r");
|
||||
linux_first =1;
|
||||
return (int) f;
|
||||
}
|
||||
|
||||
static int
|
||||
segment_read(int fd, WadSegment *s)
|
||||
{
|
||||
char pbuffer[1024];
|
||||
char *c;
|
||||
int len;
|
||||
FILE *fs = (FILE *) fd;
|
||||
c = fgets(pbuffer,1024,fs);
|
||||
if (!c) return 0;
|
||||
|
||||
pbuffer[strlen(pbuffer)-1] = 0; /* Chop off endline */
|
||||
|
||||
/* Break up the field into records */
|
||||
/* 0-8 : Starting address
|
||||
9-17 : Ending Address
|
||||
18 : r
|
||||
19 : w
|
||||
20 : x
|
||||
21 : p
|
||||
23-31 : Offset
|
||||
49- : Filename */
|
||||
|
||||
len = strlen(pbuffer);
|
||||
pbuffer[8] = 0;
|
||||
pbuffer[17] = 0;
|
||||
pbuffer[31] = 0;
|
||||
if (len >= 49) {
|
||||
s->mapname = wad_strdup(pbuffer+49);
|
||||
s->mappath = s->mapname;
|
||||
} else {
|
||||
s->mapname = "";
|
||||
s->mappath = s->mapname;
|
||||
}
|
||||
if (linux_first) {
|
||||
wad_strcpy(linux_firstsegment, s->mappath);
|
||||
linux_first = 0;
|
||||
}
|
||||
s->vaddr = (char *) strtoul(pbuffer,NULL,16);
|
||||
s->size = strtoul(pbuffer+9,NULL,16) - (long) (s->vaddr);
|
||||
s->offset = strtoul(pbuffer+23,NULL,16);
|
||||
if (strcmp(linux_firstsegment, s->mappath) == 0) {
|
||||
s->base = 0;
|
||||
} else {
|
||||
s->base = s->vaddr;
|
||||
}
|
||||
s++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* WAD_LINUX */
|
||||
|
||||
static WadSegment *segments = 0; /* Linked list of segments */
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -309,20 +322,17 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
|||
p_sp = (unsigned long) (*sp);
|
||||
#ifdef WAD_LINUX
|
||||
p_fp = (unsigned long) (*fp);
|
||||
/* printf("fault at address %x, pc = %x, sp = %x, fp = %x\n", addr, p_pc, p_sp, p_fp); */
|
||||
#endif
|
||||
#ifdef WAD_SOLARIS
|
||||
p_fp = (unsigned long) *(((long *) p_sp) + 14);
|
||||
#endif
|
||||
/* printf("fault at address %x, pc = %x, sp = %x, fp = %x\n", addr, p_pc, p_sp, p_fp);*/
|
||||
|
||||
|
||||
if (wad_debug_mode & DEBUG_SIGNAL) {
|
||||
printf("fault at address %x, pc = %x, sp = %x, fp = %x\n", addr, p_pc, p_sp, p_fp);
|
||||
wad_printf("fault at address %x, pc = %x, sp = %x, fp = %x\n", addr, p_pc, p_sp, p_fp);
|
||||
}
|
||||
|
||||
if (wad_stacked_signal) {
|
||||
printf("Fault in wad at pc = %x, sp = %x\n", p_pc, p_sp);
|
||||
wad_printf("Fault in wad at pc = %x, sp = %x\n", p_pc, p_sp);
|
||||
exit(1);
|
||||
}
|
||||
wad_stacked_signal++;
|
||||
|
|
@ -330,11 +340,10 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
|||
|
||||
if (!frame) {
|
||||
/* We're really hosed. Not possible to generate a stack trace */
|
||||
printf("WAD: Unable to generate stack trace.\n");
|
||||
printf("WAD: Maybe the call stack has been corrupted by buffer overflow.\n");
|
||||
wad_printf("WAD: Unable to generate stack trace.\n");
|
||||
wad_printf("WAD: Maybe the call stack has been corrupted by buffer overflow.\n");
|
||||
wad_signal_clear();
|
||||
return;
|
||||
/* exit(1); */
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -342,12 +351,15 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
|||
while (f) {
|
||||
wad_find_object(f);
|
||||
wad_find_symbol(f);
|
||||
f = f->next;
|
||||
}
|
||||
f = frame;
|
||||
while (f) {
|
||||
wad_find_debug(f);
|
||||
wad_build_vars(f);
|
||||
f = f->next;
|
||||
}
|
||||
}
|
||||
|
||||
wad_heap_overflow = 0;
|
||||
if (sig == SIGSEGV) {
|
||||
if (addr >= current_brk) wad_heap_overflow = 1;
|
||||
|
|
@ -428,10 +440,10 @@ void wad_signal_init() {
|
|||
static stack_t sigstk;
|
||||
|
||||
if (wad_debug_mode & DEBUG_INIT) {
|
||||
printf("WAD: Initializing signal handler.\n");
|
||||
wad_printf("WAD: Initializing signal handler.\n");
|
||||
}
|
||||
|
||||
/* This is buggy in Linux and threads. disabled by default */
|
||||
|
||||
#ifndef WAD_LINUX
|
||||
/* Set up an alternative stack */
|
||||
|
||||
|
|
@ -470,7 +482,7 @@ void wad_signal_init() {
|
|||
|
||||
return;
|
||||
werror:
|
||||
printf("WAD: Couldn't install signal handler!\n");
|
||||
wad_printf("WAD: Couldn't install signal handler!\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -484,3 +496,6 @@ void wad_signal_clear() {
|
|||
signal(SIGFPE, SIG_DFL);
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -147,7 +160,6 @@ static void type_add(char *name, char *value) {
|
|||
add_more:
|
||||
if (vr) {
|
||||
/* There is a mapping to another type */
|
||||
/* printf("adding '%s', '%s'\n", v, vr); */
|
||||
type_add(v,vr);
|
||||
}
|
||||
}
|
||||
|
|
@ -274,7 +286,7 @@ static void types_print() {
|
|||
for (i = 0; i < HASH_SIZE; i++) {
|
||||
s = lnames[i];
|
||||
while (s) {
|
||||
printf("%20s %s\n", s->name, s->value);
|
||||
wad_printf("%20s %s\n", s->name, s->value);
|
||||
s = s->next;
|
||||
}
|
||||
}
|
||||
|
|
@ -318,7 +330,6 @@ stab_symbol(Stab *s, char *stabstr) {
|
|||
char *pstr;
|
||||
char name[1024];
|
||||
char value[65536];
|
||||
int a;
|
||||
|
||||
str = stabstr+s->n_strx;
|
||||
pstr = stab_string_parm(str);
|
||||
|
|
@ -331,7 +342,7 @@ stab_symbol(Stab *s, char *stabstr) {
|
|||
/* printf("stab lsym: other=%d, desc=%d, value=%d, str='%s'\n", s->n_other,s->n_desc,s->n_value,
|
||||
stabstr+s->n_strx); */
|
||||
/* wad_printf("name = '%s', pstr='%s'\n", name, pstr+2); */
|
||||
strcpy(value,pstr+2);
|
||||
wad_strcpy(value,pstr+2);
|
||||
type_add(name,value);
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +354,7 @@ stab_symbol(Stab *s, char *stabstr) {
|
|||
* Collect stabs data for a function definition.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
static int
|
||||
scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
||||
int i;
|
||||
unsigned long offset;
|
||||
|
|
@ -362,7 +373,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
|||
}
|
||||
|
||||
if ((s->n_type == N_UNDF) || (s->n_type == N_SO) || (s->n_type == N_FUN) ||
|
||||
(s->n_type == N_OBJ)) return;
|
||||
(s->n_type == N_OBJ)) return i;
|
||||
|
||||
if (s->n_type == N_LBRAC) {
|
||||
get_parms = 0;
|
||||
|
|
@ -372,7 +383,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
|||
|
||||
if (s->n_type == N_LSYM) {
|
||||
/* This might be a local variable definition */
|
||||
/* printf("local: n_value = %d, offset = %d\n", s->n_value, offset);*/
|
||||
/* wad_printf("local: n_value = %d, offset = %d\n", s->n_value, offset);*/
|
||||
if (s->n_desc <= f->loc_line)
|
||||
{
|
||||
/* Okay. We can pay attention to it */
|
||||
|
|
@ -426,7 +437,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
|||
t = type_resolve(tname);
|
||||
arg->type = type_typecode(t);
|
||||
if (wad_debug_mode & DEBUG_STABS) {
|
||||
printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type);
|
||||
wad_printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type);
|
||||
}
|
||||
}
|
||||
if (f->debug_locals) {
|
||||
|
|
@ -523,7 +534,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
|||
t = type_resolve(tname);
|
||||
arg->type = type_typecode(t);
|
||||
if (wad_debug_mode & DEBUG_STABS) {
|
||||
printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type);
|
||||
wad_printf("type_resolve '%s' -> '%s' (%d)\n", tname, t, arg->type);
|
||||
}
|
||||
}
|
||||
if (f->debug_args) {
|
||||
|
|
@ -537,6 +548,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
|||
f->debug_nargs++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Given a stabs data segment (obtained somehow), this function tries to
|
||||
|
|
@ -557,19 +569,15 @@ int
|
|||
wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
||||
Stab *s;
|
||||
int ns;
|
||||
int infunc;
|
||||
int slen;
|
||||
int i;
|
||||
int found = 0;
|
||||
int filefound = 0;
|
||||
|
||||
char *file, *lastfile = 0;
|
||||
int chk = 0;
|
||||
WadLocal *arg;
|
||||
|
||||
char srcfile[MAX_PATH];
|
||||
char objfile[MAX_PATH];
|
||||
|
||||
|
||||
/* It appears to be necessary to clear the types table on each new stabs section */
|
||||
|
||||
init_hash();
|
||||
|
|
@ -579,7 +587,6 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
|||
s = (Stab *) sp; /* Stabs data */
|
||||
ns = size/sizeof(Stab); /* number of stabs */
|
||||
|
||||
slen = strlen(f->sym_name);
|
||||
srcfile[0] = 0;
|
||||
objfile[0] = 0;
|
||||
|
||||
|
|
@ -597,7 +604,8 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
|||
/* New stabs section. We need to be a little careful here. Do a recursive
|
||||
search of the subsection. */
|
||||
|
||||
if (wad_search_stab(s+1,s->n_desc*sizeof(Stab), stabstr, f)) return 1;
|
||||
/* if (wad_search_stab(s+1,s->n_desc*sizeof(Stab), stabstr, f)) return 1; */
|
||||
wad_search_stab(s+1,s->n_desc*sizeof(Stab), stabstr, f);
|
||||
|
||||
/* On solaris, each stabs section seems to increment the stab string pointer. On Linux,
|
||||
the linker seems to do a certain amount of optimization that results in a single
|
||||
|
|
@ -616,9 +624,9 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
|||
/* Look for directory */
|
||||
file = stabstr+s->n_strx;
|
||||
if (strlen(file) && (file[strlen(file)-1] == '/')) {
|
||||
strcpy(srcfile,file);
|
||||
wad_strcpy(srcfile,file);
|
||||
} else {
|
||||
strcat(srcfile,file);
|
||||
wad_strcat(srcfile,file);
|
||||
}
|
||||
objfile[0] = 0;
|
||||
/* If we have a file match, we might be looking for a local symbol. If so,
|
||||
|
|
@ -626,37 +634,54 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
|||
|
||||
/* We're going to check for a file match. Maybe we're looking for a local symbol */
|
||||
if (f->sym_file && strcmp(f->sym_file,file) == 0) {
|
||||
filefound = 1;
|
||||
found = 1;
|
||||
}
|
||||
lastfile = file;
|
||||
} else if (s->n_type == N_OBJ) {
|
||||
/* Object file specifier */
|
||||
if (objfile[0]) {
|
||||
strcat(objfile,"/");
|
||||
wad_strcat(objfile,"/");
|
||||
}
|
||||
strcat(objfile,stabstr+s->n_strx);
|
||||
wad_strcat(objfile,stabstr+s->n_strx);
|
||||
} else if (s->n_type == N_FUN) {
|
||||
if (match_stab_symbol(f->sym_name, stabstr+s->n_strx, slen)) {
|
||||
if (!f->sym_file || (strcmp(f->sym_file,lastfile) == 0)) {
|
||||
/* Go find debugging information for the function */
|
||||
scan_function(s+1, stabstr, ns -i - 1, f);
|
||||
f->loc_srcfile = wad_string_lookup(srcfile);
|
||||
f->loc_objfile = wad_string_lookup(objfile);
|
||||
/* f->loc_srcfile = wad_strdup(srcfile);
|
||||
f->loc_objfile = wad_strdup(objfile); */
|
||||
|
||||
return 1;
|
||||
/* Due to the bogosity and performance issues of managing stabs types, we are going to check
|
||||
the current frame as well as all remaining unchecked stack frames for a match. Generally,
|
||||
it is much faster for us to scan the stabs data once checking N stack frames than it
|
||||
is to check N stack frames, scanning the stabs data each time.
|
||||
*/
|
||||
|
||||
WadFrame *g;
|
||||
g = f;
|
||||
while (g) {
|
||||
if ((!g->sym_name) || (g->debug_check)) {
|
||||
g = g->next;
|
||||
continue;
|
||||
}
|
||||
if (match_stab_symbol(g->sym_name, stabstr+s->n_strx, g->sym_nlen)) {
|
||||
if (!g->sym_file || (strcmp(g->sym_file,lastfile) == 0)) {
|
||||
int n;
|
||||
/* Go find debugging information for the function */
|
||||
n = scan_function(s+1, stabstr, ns -i - 1, g);
|
||||
g->loc_srcfile = wad_string_lookup(srcfile);
|
||||
g->loc_objfile = wad_string_lookup(objfile);
|
||||
g->debug_check = 1;
|
||||
}
|
||||
}
|
||||
g = g->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
/* If found, but no other debugging information was filled in, go ahead and copy the
|
||||
source and objfile information */
|
||||
|
||||
if ((found) && (!f->debug_check)) {
|
||||
f->loc_srcfile = wad_string_lookup(srcfile);
|
||||
f->loc_objfile = wad_string_lookup(objfile);
|
||||
/* f->loc_srcfile = wad_strdup(srcfile);
|
||||
f->loc_objfile = wad_strdup(objfile); */
|
||||
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -31,6 +44,7 @@ new_frame() {
|
|||
f->stack_size = 0;
|
||||
|
||||
f->sym_name = 0;
|
||||
f->sym_nlen = 0;
|
||||
f->sym_file = 0;
|
||||
f->sym_base = 0;
|
||||
f->sym_size = 0;
|
||||
|
|
@ -41,6 +55,7 @@ new_frame() {
|
|||
f->loc_srcfile = 0;
|
||||
f->loc_line = 0;
|
||||
|
||||
f->debug_check = 0;
|
||||
f->debug_nargs = -1;
|
||||
f->debug_args = 0;
|
||||
f->debug_lastarg = 0;
|
||||
|
|
@ -111,7 +126,7 @@ stack_unwind(unsigned long *pc, unsigned long *sp, unsigned long *fp) {
|
|||
f->stack_size = fake_fp - *sp;
|
||||
/* Make a copy of the call stack */
|
||||
f->stack = (char *) wad_malloc(f->stack_size);
|
||||
memcpy(f->stack,(void *) *sp, f->stack_size);
|
||||
wad_memcpy(f->stack,(void *) *sp, f->stack_size);
|
||||
|
||||
/* Update the sp, fp, and pc */
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -90,4 +103,26 @@ void wad_string_debug() {
|
|||
}
|
||||
}
|
||||
|
||||
/* Our own string copy */
|
||||
char *wad_strcpy(char *t, const char *s) {
|
||||
if (s)
|
||||
for (; *s; s++, t++) *t = *s;
|
||||
*t = 0;
|
||||
return t;
|
||||
}
|
||||
|
||||
char *
|
||||
wad_strcat(char *t, const char *s) {
|
||||
while (*t) t++;
|
||||
return wad_strcpy(t,s);
|
||||
}
|
||||
|
||||
int
|
||||
wad_strlen(const char *s) {
|
||||
int count = 0;
|
||||
while (*(s++)) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,21 @@
|
|||
*
|
||||
* 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.
|
||||
* Copyright (C) 2001
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "wad.h"
|
||||
|
|
@ -27,8 +40,6 @@ void wad_build_vars(WadFrame *f) {
|
|||
char *nstack = 0;
|
||||
char *pstack = 0;
|
||||
WadLocal *loc;
|
||||
int laststack = 0;
|
||||
WadLocal *lastloc = 0;
|
||||
int n;
|
||||
|
||||
stack = (char *) f->stack;
|
||||
|
|
@ -99,9 +110,9 @@ char *wad_format_int(char *ptr, int nbytes, int sgn) {
|
|||
value = (value << 8) + *s;
|
||||
}
|
||||
if (sgn) {
|
||||
sprintf(fmt,"%ld", (long) value);
|
||||
return wad_format_signed((long) value,-1);
|
||||
} else {
|
||||
sprintf(fmt,"%lu", value);
|
||||
return wad_format_unsigned((unsigned long) value, -1);
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
|
|
@ -117,32 +128,35 @@ char *wad_format_var(WadLocal *l) {
|
|||
|
||||
switch(l->type) {
|
||||
case WAD_TYPE_INT32:
|
||||
strcpy(buffer,wad_format_int(l->ptr,4,1));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,4,1));
|
||||
break;
|
||||
case WAD_TYPE_UINT32:
|
||||
strcpy(buffer,wad_format_int(l->ptr,4,0));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,4,0));
|
||||
break;
|
||||
case WAD_TYPE_INT16:
|
||||
strcpy(buffer,wad_format_int(l->ptr,2,1));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,2,1));
|
||||
break;
|
||||
case WAD_TYPE_UINT16:
|
||||
strcpy(buffer,wad_format_int(l->ptr,2,0));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,2,0));
|
||||
break;
|
||||
case WAD_TYPE_INT8:
|
||||
strcpy(buffer,wad_format_int(l->ptr,1,1));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,1,1));
|
||||
break;
|
||||
case WAD_TYPE_UINT8:
|
||||
strcpy(buffer,wad_format_int(l->ptr,1,0));
|
||||
wad_strcpy(buffer,wad_format_int(l->ptr,1,0));
|
||||
break;
|
||||
case WAD_TYPE_CHAR:
|
||||
sprintf(buffer,"'%c'", *((char *)l->ptr));
|
||||
buffer[0] = '\'';
|
||||
buffer[1] = *((char *) l->ptr);
|
||||
buffer[2] = '\'';
|
||||
buffer[3] = 0;
|
||||
break;
|
||||
case WAD_TYPE_FLOAT:
|
||||
memcpy(&fval,l->ptr,sizeof(float));
|
||||
wad_memcpy(&fval,l->ptr,sizeof(float));
|
||||
sprintf(buffer,"%g",fval);
|
||||
break;
|
||||
case WAD_TYPE_DOUBLE:
|
||||
memcpy(&dval,l->ptr,sizeof(double));
|
||||
wad_memcpy(&dval,l->ptr,sizeof(double));
|
||||
sprintf(buffer,"%g",dval);
|
||||
break;
|
||||
case WAD_TYPE_UNKNOWN:
|
||||
|
|
@ -155,6 +169,7 @@ char *wad_format_var(WadLocal *l) {
|
|||
int leading = 1;
|
||||
char *c;
|
||||
char *ptr;
|
||||
|
||||
#ifdef WAD_LITTLE_ENDIAN
|
||||
ptr = ((char *) l->ptr) + 3;
|
||||
incr = -1;
|
||||
|
|
@ -162,9 +177,9 @@ char *wad_format_var(WadLocal *l) {
|
|||
ptr = (char *) l->ptr;
|
||||
incr =1 ;
|
||||
#endif
|
||||
strcat(buffer,"0x");
|
||||
wad_strcat(buffer,"0x");
|
||||
c = buffer+2;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < sizeof(void *); i++) {
|
||||
b = (int) *ptr;
|
||||
if (!leading || (b)) {
|
||||
if (!leading || (b & 0xf0))
|
||||
|
|
@ -195,39 +210,37 @@ long wad_local_as_long(WadLocal *loc) {
|
|||
|
||||
switch(loc->type) {
|
||||
case WAD_TYPE_INT32:
|
||||
memcpy(&i32,loc->ptr,4);
|
||||
wad_memcpy(&i32,loc->ptr,4);
|
||||
value = (long) i32;
|
||||
break;
|
||||
case WAD_TYPE_UINT32:
|
||||
memcpy(&u32,loc->ptr,4);
|
||||
wad_memcpy(&u32,loc->ptr,4);
|
||||
value = (long) u32;
|
||||
break;
|
||||
case WAD_TYPE_INT16:
|
||||
memcpy(&i16,loc->ptr,2);
|
||||
wad_memcpy(&i16,loc->ptr,2);
|
||||
value = (long) i16;
|
||||
break;
|
||||
case WAD_TYPE_UINT16:
|
||||
memcpy(&u16,loc->ptr,2);
|
||||
wad_memcpy(&u16,loc->ptr,2);
|
||||
value = (long) u16;
|
||||
break;
|
||||
case WAD_TYPE_INT8:
|
||||
case WAD_TYPE_CHAR:
|
||||
memcpy(&i8, loc->ptr,1);
|
||||
wad_memcpy(&i8, loc->ptr,1);
|
||||
value = (long) i8;
|
||||
break;
|
||||
case WAD_TYPE_UINT8:
|
||||
memcpy(&u8, loc->ptr,1);
|
||||
wad_memcpy(&u8, loc->ptr,1);
|
||||
value = (long) u8;
|
||||
break;
|
||||
default:
|
||||
memcpy(&u32,loc->ptr,4);
|
||||
wad_memcpy(&u32,loc->ptr,4);
|
||||
value = (long) u32;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Convert a wad local variable to a long */
|
||||
double wad_local_as_double(WadLocal *loc) {
|
||||
double value = 0;
|
||||
|
|
@ -235,10 +248,10 @@ double wad_local_as_double(WadLocal *loc) {
|
|||
|
||||
switch(loc->type) {
|
||||
case WAD_TYPE_DOUBLE:
|
||||
memcpy(&value,loc->ptr,8);
|
||||
wad_memcpy(&value,loc->ptr,8);
|
||||
break;
|
||||
case WAD_TYPE_FLOAT:
|
||||
memcpy(&fval,loc->ptr,4);
|
||||
wad_memcpy(&fval,loc->ptr,4);
|
||||
value = (double) fval;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue