*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@978 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2001-01-02 17:43:45 +00:00
commit 0d8b8bc105
15 changed files with 227 additions and 75 deletions

View file

@ -10,10 +10,10 @@
WADSRCS = return.c default.c stack.c stab.c elf.c object.c init.c segment.c signal.c
WADOBJS = 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
WADOPT = -DWAD_SOLARIS
# Location of your Python installation
PYINCLUDE = -I/usr/local/include/python1.5 -I/usr/local/lib/python1.5/config
PYINCLUDE = -I/usr/local/include/python2.0
PYSRCS = wadpy.cxx
PYOBJS = wadpy.o
@ -23,21 +23,21 @@ TCLSRCS = wadtcl.cxx
TCLOBJS = wadtcl.o
# Location of your Perl installation
PERLINCLUDE = -I/usr/lib/perl5/5.00503/i386-linux/CORE
PERLINCLUDE = -I/usr/perl5/5.00503/sun4-solaris/CORE
PERLSRCS = wadpl.cxx
PERLOBJS = wadpl.o
# C Compiler
CC = gcc
CFLAGS = -fpic
CC = cc -g
CFLAGS =
# C++ Compiler
CXX = c++
CXXFLAGS = -fpic
CXX = CC
CXXFLAGS = -Kpic
# Linking options
CLINK =
CXXLINK = g++ -shared
CXXLINK = CC -G
# Rules for creation of a .o file from .cxx
.SUFFIXES: .cxx

View file

@ -58,6 +58,14 @@ void wad_init() {
wad_debug_mode |= DEBUG_STACK;
}
if (getenv("WAD_DEBUG_UNWIND")) {
wad_debug_mode |= DEBUG_UNWIND;
}
if (getenv("WAD_DEBUG_SIGNAL")) {
wad_debug_mode |= DEBUG_SIGNAL;
}
if (getenv("WAD_NOSTACK")) {
wad_debug_mode |= DEBUG_NOSTACK;
}

View file

@ -12,20 +12,20 @@
* ----------------------------------------------------------------------------- */
static FILE *
static int
segment_open() {
FILE *f;
f = fopen("/proc/self/map", "r");
int f;
f = open("/proc/self/map", O_RDONLY);
return f;
}
static int
segment_read(FILE *fs, WadSegment *s) {
segment_read(int fs, WadSegment *s) {
int dz;
int n;
prmap_t pmap;
n = fread(&pmap, sizeof(prmap_t), 1, fs);
n = read(fs, &pmap, sizeof(prmap_t));
if (n <= 0) return 0;
strncpy(s->mapname, pmap.pr_mapname, MAX_PATH);
strcpy(s->mappath,"/proc/self/object/");

View file

@ -47,7 +47,7 @@
WadSegment *
wad_segment_read() {
FILE *fs;
int fs;
int dz;
int offset = 0;
int i;
@ -59,7 +59,7 @@ wad_segment_read() {
/* Try to load the virtual address map */
fs = segment_open();
if (!fs) return 0;
if (fs < 0) return 0;
nsegments = 0;
while (1) {
n = segment_read(fs,&ws);
@ -67,7 +67,7 @@ wad_segment_read() {
nsegments++;
}
nsegments+=3;
fclose(fs);
close(fs);
dz = open("/dev/zero", O_RDWR, 0644);
if (dz < 0) {
@ -110,7 +110,7 @@ wad_segment_read() {
s->offset = 0;
s->mapname[0] =0;
s->mappath[0] = 0;
fclose(fs);
close(fs);
return segments;
}

View file

@ -15,6 +15,8 @@
#define STACK_SIZE 4*SIGSTKSZ
char wad_sig_stack[STACK_SIZE];
static wad_stacked_signal = 0;
static void (*sig_callback)(int signo, WadFrame *data, char *ret) = 0;
void wad_set_callback(void (*s)(int,WadFrame *,char *ret)) {
@ -28,10 +30,10 @@ void wad_set_callback(void (*s)(int,WadFrame *,char *ret)) {
return to the caller as if the function had actually completed
normally. */
static int nlr_levels = 0;
static volatile int *volatile nlr_p = &nlr_levels;
static long nlr_value = 0;
static void (*nlr_func)(void) = 0;
int nlr_levels = 0;
volatile int *volatile nlr_p = &nlr_levels;
long nlr_value = 0;
void (*nlr_func)(void) = 0;
/* Set the return value from another module */
void wad_set_return_value(long value) {
@ -117,10 +119,15 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
nlr_func = 0;
wad_object_init();
if (!wad_stacked_signal)
wad_object_init();
context = (ucontext_t *) vcontext;
if (wad_debug_mode & DEBUG_SIGNAL) {
printf("WAD: siginfo = %x, context = %x\n", si, vcontext);
}
/* Get some information about the current context */
#ifdef WAD_SOLARIS
@ -144,14 +151,22 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
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
/* 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);
exit(1);
}
wad_stacked_signal++;
frame = wad_stack_trace(p_pc, p_sp, p_fp);
origframe =frame;
if (!frame) {
/* We're really hosed here */
wad_stacked_signal--;
return;
}
if (wad_debug_mode & DEBUG_STACK) {
/* Walk the exception frames and try to find a return point */
framedata = (char *) frame;
@ -227,6 +242,7 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
#ifdef WAD_SOLARIS
*(npc) = *(pc) + 4;
#endif
wad_stacked_signal--;
return;
}
exit(1);

View file

@ -14,12 +14,22 @@
#include <sys/mman.h>
#include <dlfcn.h>
#ifdef WAD_SOLARIS
#define STACK_BASE 0xffbf0000
#endif
#ifdef WAD_LINUX
#define STACK_BASE 0xc0000000
#endif
/* Given a stack pointer, this function performs a single level of stack
unwinding */
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);
}
#ifdef WAD_SOLARIS
*pc = *((unsigned long *) *sp+15); /* %i7 - Return address */
*sp = *((unsigned long *) *sp+14); /* %i6 - frame pointer */
@ -89,6 +99,8 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) {
if (!ws) {
/* If the stack is bad, we are really hosed here */
write(1,"Whoa. Stack is corrupted. Bailing out.\n", 39);
exit(1);
break;
}
ws = wad_segment_find(segments, (void *) p_pc);
@ -183,13 +195,14 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) {
if (p_sp) {
stacksize = p_sp - p_lastsp;
} else {
#ifdef WAD_SOLARIS
stacksize = 0xffbf0000 - p_lastsp; /* Sick hack alert. Need to get stack top from somewhere */
#endif
#ifdef WAD_LINUX
stacksize = 0xc0000000 - p_lastsp;
#endif
stacksize = STACK_BASE - p_lastsp; /* Sick hack alert. Need to get stack top from somewhere */
}
/* Sanity check */
if ((p_sp + stacksize) > STACK_BASE) {
stacksize = STACK_BASE - p_sp;
}
/* Set the frame pointer and stack size */
/* frame.fp = p_sp; */
@ -244,6 +257,7 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) {
frame.size = 0;
frame.last = 1;
frame.lastsize = lastsize;
frame.stack_size = 0;
write(ffile,&frame,sizeof(WadFrame));
close(ffile);

View file

@ -32,7 +32,7 @@ static int global_signo = 0;
static void returnfunc(void) {
SV *s;
s = perl_eval_pv("libwadpl::wad_handler_traceback(0)", 0);
s = perl_eval_pv((char*)"libwadpl::wad_handler_traceback(0)", 0);
croak("%s\n%s",SvPV(s,PL_na),message);
return;
}
@ -57,14 +57,16 @@ static void handler(int signo, WadFrame *frame, char *ret) {
switch(signo) {
case SIGSEGV:
type = "Segmentation fault.";
type = (char*)"Segmentation fault.";
break;
case SIGBUS:
type = "Bus error.";
type = (char*)"Bus error.";
break;
case SIGABRT:
type = "Abort.";
type = (char*)"Abort.";
break;
case SIGFPE:
type = (char*)"Math.";
default:
break;
}

View file

@ -34,13 +34,13 @@ static void handler(int signo, WadFrame *frame, char *ret) {
strcpy(message,"[ C stack trace ]\n\n");
switch(signo) {
case SIGSEGV:
type = "Segmentation fault.";
type = (char*)"Segmentation fault.";
break;
case SIGBUS:
type = "Bus error.";
type = (char*)"Bus error.";
break;
case SIGABRT:
type = "Abort.";
type = (char*)"Abort.";
break;
default:
break;