*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@1042 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2001-03-03 04:39:54 +00:00
commit 6a75d99105
11 changed files with 146 additions and 133 deletions

View file

@ -12,15 +12,6 @@ WADOBJS = string.o vars.o io.o memory.o return.o default.o stack.o stab.o elf.o
INCLUDE = -I../Include -I. $(SINCLUDE)
WADOPT = -DWAD_SOLARIS
# Location of your Python installation
PYINCLUDE = -I/usr/local/include/python2.0
PYCSRCS = wadpyinit.cxx
PYOBJS = wadpy.o
# Location of your Tcl installation
TCLINCLUDE = -I/usr/local/include
TCLSRCS = wadtcl.cxx
TCLOBJS = wadtcl.o
# Location of your Perl installation
PERLINCLUDE = -I/usr/perl5/5.00503/sun4-solaris/CORE
@ -56,14 +47,6 @@ wad: $(WADOBJS) main.o
cp libwad.so ..
cp libwadcore.a ..
python: $(WADOBJS) $(PYOBJS)
$(CXXLINK) $(WADOBJS) $(PYOBJS) -o libwadpy.so
cp libwadpy.so ..
tcl: $(WADOBJS) $(TCLOBJS)
$(CXXLINK) $(WADOBJS) $(TCLOBJS) -o libwadtcl.so
cp libwadtcl.so ..
perl: wad_perl_handler.c $(WADOBJS) $(PERLOBJS)
$(CXXLINK) $(WADOBJS) $(PERLOBJS) -o libwadpl.so
cp libwadpl.so ..
@ -81,8 +64,7 @@ wc::
wc $(SRCS)
semi::
egrep ";" $(WADSRCS) plat/*.c | wc
@egrep ";" $(WADSRCS) plat/*.c | wc
clean::
rm -f *.o *.so *~

View file

@ -11,15 +11,6 @@ WADOBJS = string.o vars.o io.o memory.o return.o default.o stack.o stab.o elf.o
INCLUDE = -I../Include -I. $(SINCLUDE)
WADOPT = @WADOPT@
# Location of your Python installation
PYINCLUDE = @PYINCLUDE@
PYCSRCS = wadpyinit.cxx
PYOBJS = wadpy.o
# Location of your Tcl installation
TCLINCLUDE = @TCLINCLUDE@
TCLSRCS = wadtcl.cxx
TCLOBJS = wadtcl.o
# Location of your Perl installation
PERLINCLUDE = @PERL5EXT@
@ -55,14 +46,6 @@ wad: $(WADOBJS) main.o
cp libwad.so ..
cp libwadcore.a ..
python: $(WADOBJS) $(PYOBJS)
$(CXXLINK) $(WADOBJS) $(PYOBJS) -o libwadpy.so
cp libwadpy.so ..
tcl: $(WADOBJS) $(TCLOBJS)
$(CXXLINK) $(WADOBJS) $(TCLOBJS) -o libwadtcl.so
cp libwadtcl.so ..
perl: wad_perl_handler.c $(WADOBJS) $(PERLOBJS)
$(CXXLINK) $(WADOBJS) $(PERLOBJS) -o libwadpl.so
cp libwadpl.so ..
@ -80,8 +63,7 @@ wc::
wc $(SRCS)
semi::
egrep ";" $(SRCS) wadpy.cxx | wc
@egrep ";" $(WADSRCS) plat/*.c | wc
clean::
rm -f *.o *.so *~

View file

@ -384,12 +384,13 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
wad_restore_i386_registers(origframe, wad_nlr_levels);
#endif
} else {
wad_nlr_levels = 0;
wad_nlr_levels = -1;
}
wad_string_debug();
wad_memory_debug();
if (sig_callback) {
(*sig_callback)(sig,origframe,retname);
} else {
@ -404,7 +405,7 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
an alternative piece of code that unwinds the stack and
initiates a non-local return. */
if (wad_nlr_levels > 0) {
if (wad_nlr_levels >= 0) {
*(pc) = (greg_t) _returnsignal;
#ifdef WAD_SOLARIS
*(npc) = *(pc) + 4;

View file

@ -248,6 +248,41 @@ void wad_stack_debug(WadFrame *frame) {
}
/* -----------------------------------------------------------------------------
* wad_steal_outarg()
*
* Steal an output argument
* ----------------------------------------------------------------------------- */
long
wad_steal_outarg(WadFrame *f, char *symbol, int argno, int *error) {
long *regs;
WadFrame *lastf = 0;
*error = 0;
/* Start searching */
while (f) {
if (f->sym_name && (strcmp(f->sym_name,symbol) == 0)) {
/* Got a match */
if (lastf) {
#ifdef WAD_SOLARIS
regs = (long *) lastf->stack;
return regs[8+argno];
#endif
#ifdef WAD_LINUX
regs = (long *) f->stack;
return regs[argno+2];
#endif
}
}
lastf = f;
f = f->next;
}
*error = -1;
return 0;
}

View file

@ -1,176 +0,0 @@
/* -----------------------------------------------------------------------------
* wadtcl.cxx
*
* Dynamically loadable Tcl module for wad.
*
* 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 <tcl.h>
#include "wad.h"
#include <signal.h>
/* Handler function */
static void handler(int signo, WadFrame *frame, char *ret) {
static char message[65536];
static char temp[1024];
int len = 0;
char *name;
char *fd;
WadFrame *f;
WadFrame *fline = 0;
Tcl_Interp *interp;
int err;
char *type;
if (!ret) {
wad_default_callback(signo, frame, ret);
return;
}
strcpy(message,"[ C stack trace ]\n\n");
switch(signo) {
case SIGSEGV:
type = (char*)"Segmentation fault.";
break;
case SIGBUS:
type = (char*)"Bus error.";
break;
case SIGABRT:
type = (char*)"Abort.";
break;
case SIGFPE:
type = (char*)"Floating point exception.";
break;
default:
type = (char*)"Unknown.";
break;
}
fd = (char *) frame;
f = (WadFrame *) fd;
/* Find the last exception frame */
while (!f->last) {
fd = fd + f->size;
f = (WadFrame *) fd;
}
/* Now work backwards */
fd = fd - f->lastsize;
f = (WadFrame *) fd;
while (1) {
sprintf(temp,"#%-3d 0x%08x in ", f->frameno, f->pc);
strcat(message,temp);
strcat(message,*(fd + f->sym_off) ? fd+f->sym_off : "?");
strcat(message,"()");
if (strlen(SRCFILE(f))) {
strcat(message," in '");
strcat(message, wad_strip_dir(SRCFILE(f)));
strcat(message,"'");
if (f->line_number > 0) {
sprintf(temp,", line %d", f->line_number);
strcat(message,temp);
{
int fd;
fd = open(SRCFILE(f), O_RDONLY);
if (fd > 0) {
fline = f;
}
close(fd);
}
}
} else {
if (strlen(fd+f->obj_off)) {
strcat(message," from '");
strcat(message, wad_strip_dir(OBJFILE(f)));
strcat(message,"'");
}
}
strcat(message,"\n");
if (!f->lastsize) break;
fd = fd - f->lastsize;
f = (WadFrame *) fd;
}
if (fline) {
int first;
int last;
char *line, *c;
int i;
first = fline->line_number - 2;
last = fline->line_number + 2;
if (first < 1) first = 1;
line = wad_load_source(SRCFILE(fline),first);
if (line) {
strcat(message,"\n");
strcat(message, SRCFILE(fline));
sprintf(temp,", line %d\n\n", fline->line_number);
strcat(message, temp);
for (i = first; i <= last; i++) {
if (i == fline->line_number) strcat(message," => ");
else strcat(message," ");
c = strchr(line,'\n');
if (c) {
*c = 0;
strcat(message,line);
strcat(message,"\n");
*c = '\n';
} else {
strcat(message,line);
strcat(message,"\n");
break;
}
line = c+1;
}
wad_release_source();
strcat(message,"\n");
}
}
if (wad_heap_overflow) {
write(2, "WAD: Heap overflow detected.\n", 30);
wad_default_callback(signo, frame, ret);
}
/* Note: if the heap is blown, there is a very good chance that this
function will not succeed and we'll dump core. However, the check
above should dump a stack trace to stderr just in case we don't make it
back. */
/* Try to get the Tcl interpreter through magic */
if (ret) {
interp = (Tcl_Interp *) wad_steal_outarg(frame,ret,1,&err);
if (err == 0) {
Tcl_SetResult(interp,type,TCL_STATIC);
Tcl_AddErrorInfo(interp,message);
}
}
wad_release_trace();
}
static void tclwadinit() {
printf("WAD Enabled\n");
wad_init();
wad_set_callback(handler);
wad_set_return("TclExecuteByteCode", TCL_ERROR);
wad_set_return("EvalObjv", TCL_ERROR);
}
/* This hack is used to auto-initialize wad regardless of whether we are
used as an imported module or as a link-library for another module */
class wadinitializer {
public:
wadinitializer() {
tclwadinit();
}
};
static wadinitializer wi;
extern "C"
int Wad_Init(Tcl_Interp *interp) {
return TCL_OK;
}