Pre-python paper checkin
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@937 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
657f04395e
commit
8d6a32bb08
10 changed files with 225 additions and 21 deletions
|
|
@ -17,6 +17,10 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH 1024
|
#define MAX_PATH 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -67,10 +71,19 @@ extern void wad_object_release(WadObject *);
|
||||||
|
|
||||||
extern void wad_init();
|
extern void wad_init();
|
||||||
extern void wad_signalhandler(int, siginfo_t *, void *);
|
extern void wad_signalhandler(int, siginfo_t *, void *);
|
||||||
extern void wad_set_return(char *name, long value);
|
extern void wad_set_return(const char *name, long value);
|
||||||
|
extern void wad_set_return_value(long value);
|
||||||
|
|
||||||
extern int wad_elf_check(WadObject *wo);
|
extern int wad_elf_check(WadObject *wo);
|
||||||
extern void wad_elf_debug(WadObject *wo);
|
extern void wad_elf_debug(WadObject *wo);
|
||||||
|
|
||||||
|
typedef struct WadParm {
|
||||||
|
char name[64];
|
||||||
|
int loc;
|
||||||
|
int type;
|
||||||
|
int value;
|
||||||
|
} WadParm;
|
||||||
|
|
||||||
/* Debugging information */
|
/* Debugging information */
|
||||||
typedef struct WadDebug {
|
typedef struct WadDebug {
|
||||||
int found; /* Whether or not debugging information was found */
|
int found; /* Whether or not debugging information was found */
|
||||||
|
|
@ -78,8 +91,12 @@ typedef struct WadDebug {
|
||||||
char objfile[1024]; /* Object file */
|
char objfile[1024]; /* Object file */
|
||||||
int line_number; /* Line number */
|
int line_number; /* Line number */
|
||||||
int nargs; /* Number of function arguments */
|
int nargs; /* Number of function arguments */
|
||||||
|
WadParm parms[100]; /* Parameters */
|
||||||
} WadDebug;
|
} WadDebug;
|
||||||
|
|
||||||
|
#define PARM_REGISTER 1
|
||||||
|
#define PARM_STACK 2
|
||||||
|
|
||||||
extern WadDebug *wad_search_stab(void *stab, int size, char *stabstr, char *symbol, unsigned long offset);
|
extern WadDebug *wad_search_stab(void *stab, int size, char *stabstr, char *symbol, unsigned long offset);
|
||||||
extern WadDebug *wad_debug_info(WadObject *wo, char *symbol, unsigned long offset);
|
extern WadDebug *wad_debug_info(WadObject *wo, char *symbol, unsigned long offset);
|
||||||
|
|
||||||
|
|
@ -89,16 +106,52 @@ extern WadDebug *wad_debug_info(WadObject *wo, char *symbol, unsigned long offse
|
||||||
|
|
||||||
typedef struct WadFrame {
|
typedef struct WadFrame {
|
||||||
long size; /* Frame size */
|
long size; /* Frame size */
|
||||||
|
long lastsize; /* Size of previous frame */
|
||||||
|
long last; /* Last frame ? */
|
||||||
long frameno; /* Frame number */
|
long frameno; /* Frame number */
|
||||||
long pc; /* Program counter */
|
long pc; /* Program counter */
|
||||||
long sp; /* Stack pointer */
|
long sp; /* Stack pointer */
|
||||||
long fp; /* Frame pointer */
|
long fp; /* Frame pointer */
|
||||||
|
long nargs; /* Number of arguments */
|
||||||
|
long arg_off; /* Argument offset */
|
||||||
long line_number; /* Source line number */
|
long line_number; /* Source line number */
|
||||||
long sym_base; /* Symbol base address */
|
long sym_base; /* Symbol base address */
|
||||||
long sym_off; /* Symbol name offset */
|
long sym_off; /* Symbol name offset */
|
||||||
long src_off; /* Source filename offset */
|
long src_off; /* Source filename offset */
|
||||||
long obj_off; /* Object filename offset */
|
long obj_off; /* Object filename offset */
|
||||||
|
long stack_off; /* Stack offset */
|
||||||
|
long stack_size; /* Size of the stack segment */
|
||||||
|
long regs[16]; /* Integer registers (%on, %ln) */
|
||||||
|
double fregs[16]; /* Floating point registers */
|
||||||
char data[8]; /* Frame data */
|
char data[8]; /* Frame data */
|
||||||
} WadFrame;
|
} WadFrame;
|
||||||
|
|
||||||
|
#define SRCFILE(x) ((char *) x) + x->src_off
|
||||||
|
#define SYMBOL(x) ((char *) x) + x->sym_off
|
||||||
|
#define OBJFILE(x) ((char *) x) + x->obj_off
|
||||||
|
#define STACK(x) (long *) (((char *) x) + x->stack_off)
|
||||||
|
#define ARGUMENTS(x) (WadParm *) (((char *) x) + x->arg_off)
|
||||||
|
|
||||||
|
extern WadFrame *wad_stack_trace(unsigned long, unsigned long, unsigned long);
|
||||||
|
extern char *wad_strip_dir(char *);
|
||||||
|
extern void wad_default_callback(int signo, WadFrame *frame, char *ret);
|
||||||
|
extern void wad_set_callback(void (*h)(int, WadFrame *, char *));
|
||||||
|
extern char *wad_load_source(char *, int line);
|
||||||
|
extern void wad_release_source();
|
||||||
|
extern void wad_release_trace();
|
||||||
|
extern long wad_steal_arg(WadFrame *f, char *symbol, int argno, int *error);
|
||||||
|
extern long wad_steal_outarg(WadFrame *f, char *symbol, int argno, int *error);
|
||||||
|
|
||||||
|
extern char *wad_arg_string(WadFrame *f);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
long value;
|
||||||
|
} WadReturnFunc;
|
||||||
|
|
||||||
|
extern void wad_set_returns(WadReturnFunc *rf);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@ all::
|
||||||
python::
|
python::
|
||||||
cc -c $(INCLUDE) $(SRCS)
|
cc -c $(INCLUDE) $(SRCS)
|
||||||
CC -Kpic -c $(INCLUDE) $(PYINCLUDE) wadpy.cxx
|
CC -Kpic -c $(INCLUDE) $(PYINCLUDE) wadpy.cxx
|
||||||
CC -G $(OBJS) wadpy.o -o wadmodule.so
|
CC -G $(OBJS) wadpy.o -o libwadpy.so
|
||||||
cp wadmodule.so libwadpy.so
|
|
||||||
cp libwadpy.so ..
|
cp libwadpy.so ..
|
||||||
|
|
||||||
tcl::
|
tcl::
|
||||||
|
|
@ -33,7 +32,7 @@ wc::
|
||||||
wc $(SRCS)
|
wc $(SRCS)
|
||||||
|
|
||||||
semi::
|
semi::
|
||||||
egrep ";" $(SRCS) | wc
|
egrep ";" $(SRCS) wadpy.cxx | wc
|
||||||
|
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,16 @@ char *wad_arg_string(WadFrame *frame) {
|
||||||
/* Parameter is located on the call stack */
|
/* Parameter is located on the call stack */
|
||||||
unsigned long argloc = wp->value; /* Location relative to frame pointer */
|
unsigned long argloc = wp->value; /* Location relative to frame pointer */
|
||||||
if ((argloc & 0x3) == 0) {
|
if ((argloc & 0x3) == 0) {
|
||||||
/* Is word aligned, make some kind of attempt to print this out */
|
if (argloc >= 0) {
|
||||||
unsigned long *p = (unsigned long *) (((char *) nextstack) + argloc);
|
/* Is word aligned, make some kind of attempt to print this out */
|
||||||
sprintf(temp,"0x%x", *p);
|
unsigned long *p = (unsigned long *) (((char *) nextstack) + argloc);
|
||||||
strcat(str,temp);
|
sprintf(temp,"0x%x", *p);
|
||||||
|
strcat(str,temp);
|
||||||
|
} else {
|
||||||
|
unsigned long *p = (unsigned long *) (((char *) stack) + frame->stack_size + argloc);
|
||||||
|
sprintf(temp,"0x%x", *p);
|
||||||
|
strcat(str,temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (wp->loc == PARM_REGISTER) {
|
} else if (wp->loc == PARM_REGISTER) {
|
||||||
if ((wp->value >= 24) && (wp->value < 32)) {
|
if ((wp->value >= 24) && (wp->value < 32)) {
|
||||||
|
|
@ -166,6 +172,12 @@ void wad_default_callback(int signo, WadFrame *framedata, char *ret) {
|
||||||
case SIGABRT:
|
case SIGABRT:
|
||||||
printf("Abort.\n");
|
printf("Abort.\n");
|
||||||
break;
|
break;
|
||||||
|
case SIGFPE:
|
||||||
|
printf("Floating point exception.\n");
|
||||||
|
break;
|
||||||
|
case SIGILL:
|
||||||
|
printf("Illegal instruction.\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Signal %d\n", signo);
|
printf("Signal %d\n", signo);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ wad_elf_section_byname(WadObject *wo, char *name) {
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
wad_elf_find_symbol(WadObject *wo, void *ptr, unsigned base, unsigned long *value) {
|
wad_elf_find_symbol(WadObject *wo, void *ptr, unsigned long base, unsigned long *value) {
|
||||||
int nsymtab;
|
int nsymtab;
|
||||||
int nstrtab;
|
int nstrtab;
|
||||||
int symtab_size;
|
int symtab_size;
|
||||||
|
|
@ -228,13 +228,38 @@ wad_elf_find_symbol(WadObject *wo, void *ptr, unsigned base, unsigned long *valu
|
||||||
nsym = (symtab_size/sizeof(Elf32_Sym));
|
nsym = (symtab_size/sizeof(Elf32_Sym));
|
||||||
for (i = 0; i < nsym; i++) {
|
for (i = 0; i < nsym; i++) {
|
||||||
name = str + sym[i].st_name;
|
name = str + sym[i].st_name;
|
||||||
|
/* printf("%s %x\n", name, sym[i].st_value); */
|
||||||
if (((base + sym[i].st_value) <= vaddr) && (vaddr < (base+sym[i].st_value + sym[i].st_size))) {
|
if (((base + sym[i].st_value) <= vaddr) && (vaddr < (base+sym[i].st_value + sym[i].st_size))) {
|
||||||
if (value)
|
if (value)
|
||||||
*value = sym[i].st_value;
|
*value = sym[i].st_value;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
/* printf("%s %x\n", name, sym[i].st_value); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we didn't find it in the .symtab section. Maybe it's in the .dynsym, .dynstr section */
|
||||||
|
|
||||||
|
nsymtab = wad_elf_section_byname(wo,".dynsym");
|
||||||
|
if (nsymtab < 0) return 0;
|
||||||
|
nstrtab = wad_elf_section_byname(wo,".dynstr");
|
||||||
|
if (nstrtab < 0) return 0;
|
||||||
|
|
||||||
|
symtab_size = wad_elf_section_size(wo,nsymtab);
|
||||||
|
sym = (Elf32_Sym *) wad_elf_section_data(wo,nsymtab);
|
||||||
|
str = (char *) wad_elf_section_data(wo,nstrtab);
|
||||||
|
|
||||||
|
nsym = (symtab_size/sizeof(Elf32_Sym));
|
||||||
|
for (i = 0; i < nsym; i++) {
|
||||||
|
name = str + sym[i].st_name;
|
||||||
|
/* printf("%x(%x): %s %x + %x\n", base, vaddr, name, sym[i].st_value, sym[i].st_size); */
|
||||||
|
if (((base + sym[i].st_value) <= vaddr) && (vaddr < (base+sym[i].st_value + sym[i].st_size))) {
|
||||||
|
if (value)
|
||||||
|
*value = sym[i].st_value;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,15 @@ void wad_init() {
|
||||||
sigaddset(&newvec.sa_mask, SIGSEGV);
|
sigaddset(&newvec.sa_mask, SIGSEGV);
|
||||||
sigaddset(&newvec.sa_mask, SIGBUS);
|
sigaddset(&newvec.sa_mask, SIGBUS);
|
||||||
sigaddset(&newvec.sa_mask, SIGABRT);
|
sigaddset(&newvec.sa_mask, SIGABRT);
|
||||||
newvec.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESETHAND;
|
sigaddset(&newvec.sa_mask, SIGILL);
|
||||||
|
sigaddset(&newvec.sa_mask, SIGFPE);
|
||||||
|
newvec.sa_flags = SA_SIGINFO | SA_ONSTACK;
|
||||||
newvec.sa_sigaction = ((void (*)(int,siginfo_t *, void *)) wad_signalhandler);
|
newvec.sa_sigaction = ((void (*)(int,siginfo_t *, void *)) wad_signalhandler);
|
||||||
sigaction(SIGSEGV, &newvec, NULL);
|
sigaction(SIGSEGV, &newvec, NULL);
|
||||||
sigaction(SIGBUS, &newvec, NULL);
|
sigaction(SIGBUS, &newvec, NULL);
|
||||||
sigaction(SIGABRT, &newvec, NULL);
|
sigaction(SIGABRT, &newvec, NULL);
|
||||||
|
sigaction(SIGFPE, &newvec, NULL);
|
||||||
|
sigaction(SIGILL, &newvec, NULL);
|
||||||
}
|
}
|
||||||
init = 1;
|
init = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,15 @@ wad_segment_find(wadaddr_t addr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
segment.mapname[0] = 0;
|
||||||
|
|
||||||
read_segment = 0;
|
read_segment = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
n = read(fd,&pmap,sizeof(prmap_t));
|
n = read(fd,&pmap,sizeof(prmap_t));
|
||||||
if (n <= 0) break;
|
if (n <= 0) break;
|
||||||
offset += n;
|
offset += n;
|
||||||
if ((addr >= (wadaddr_t) pmap.pr_vaddr) && (addr <= (wadaddr_t) (pmap.pr_vaddr + pmap.pr_size))) {
|
if ((addr >= (wadaddr_t) pmap.pr_vaddr) && (addr <= (wadaddr_t) (pmap.pr_vaddr + pmap.pr_size))) {
|
||||||
|
/* We are in a new segment */
|
||||||
strncpy(segment.mapname, pmap.pr_mapname, MAX_PATH);
|
strncpy(segment.mapname, pmap.pr_mapname, MAX_PATH);
|
||||||
strcpy(segment.mappath,dirname);
|
strcpy(segment.mappath,dirname);
|
||||||
strcat(segment.mappath,"/object/");
|
strcat(segment.mappath,"/object/");
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
/* Data structures for containing information about non-local returns */
|
/* Data structures for containing information about non-local returns */
|
||||||
|
|
||||||
|
|
@ -25,7 +26,7 @@ typedef struct nonlocal {
|
||||||
|
|
||||||
static nonlocal *return_points = 0;
|
static nonlocal *return_points = 0;
|
||||||
|
|
||||||
void wad_set_return(char *name, long value) {
|
void wad_set_return(const char *name, long value) {
|
||||||
nonlocal *nl;
|
nonlocal *nl;
|
||||||
nl = (nonlocal *) malloc(sizeof(nonlocal));
|
nl = (nonlocal *) malloc(sizeof(nonlocal));
|
||||||
strcpy(nl->symname,name);
|
strcpy(nl->symname,name);
|
||||||
|
|
@ -34,6 +35,14 @@ void wad_set_return(char *name, long value) {
|
||||||
return_points = nl;
|
return_points = nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wad_set_returns(WadReturnFunc *rf) {
|
||||||
|
int i;
|
||||||
|
while (rf[i].name) {
|
||||||
|
wad_set_return(rf[i].name, rf[i].value);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void (*sig_callback)(int signo, WadFrame *data, char *ret) = 0;
|
static void (*sig_callback)(int signo, WadFrame *data, char *ret) = 0;
|
||||||
|
|
||||||
void wad_set_callback(void (*s)(int,WadFrame *,char *ret)) {
|
void wad_set_callback(void (*s)(int,WadFrame *,char *ret)) {
|
||||||
|
|
@ -112,6 +121,15 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
||||||
p_pc = (unsigned long) (*pc);
|
p_pc = (unsigned long) (*pc);
|
||||||
p_sp = (unsigned long) (*sp);
|
p_sp = (unsigned long) (*sp);
|
||||||
|
|
||||||
|
|
||||||
|
/* {
|
||||||
|
Dl_info dli;
|
||||||
|
if (dladdr((void *) p_pc, &dli) >= 0) {
|
||||||
|
printf("dli_fname = %s\n", dli.dli_fname);
|
||||||
|
printf("dli_sname = %s\n", dli.dli_sname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
frame = wad_stack_trace(p_pc, p_sp, 0);
|
frame = wad_stack_trace(p_pc, p_sp, 0);
|
||||||
origframe =frame;
|
origframe =frame;
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
|
|
@ -167,4 +185,5 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
||||||
*(npc) = *(pc) + 4;
|
*(npc) = *(pc) + 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ wad_search_stab(void *sp, int size, char *stabstr, char *symbol, unsigned long o
|
||||||
debug.parms[debug.nargs].loc = PARM_STACK;
|
debug.parms[debug.nargs].loc = PARM_STACK;
|
||||||
|
|
||||||
debug.parms[debug.nargs].value = s->n_value;
|
debug.parms[debug.nargs].value = s->n_value;
|
||||||
|
/* printf("%s : %d: %d : %s\n", debug.parms[debug.nargs].name, s->n_type, debug.parms[debug.nargs].value,pname); */
|
||||||
|
|
||||||
debug.nargs++;
|
debug.nargs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
/* Given a stack pointer, this function performs a single level of stack
|
/* Given a stack pointer, this function performs a single level of stack
|
||||||
unwinding */
|
unwinding */
|
||||||
|
|
@ -91,10 +92,17 @@ wad_stack_trace(unsigned long pc, unsigned long sp, unsigned long fp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to find the symbol corresponding to this PC */
|
/* Try to find the symbol corresponding to this PC */
|
||||||
if (wo)
|
if (wo) {
|
||||||
symname = wad_find_symbol(wo,(void *) p_pc, (unsigned long) ws->vaddr, &value);
|
symname = wad_find_symbol(wo, (void *) p_pc, (unsigned long) ws->vaddr, &value);
|
||||||
else
|
/* if (!symname) {
|
||||||
|
Dl_info dli;
|
||||||
|
if (dladdr((void *) p_pc, &dli) >= 0) {
|
||||||
|
symname = (char *) dli.dli_sname;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
} else {
|
||||||
symname = 0;
|
symname = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Build up some information about the exception frame */
|
/* Build up some information about the exception frame */
|
||||||
frame.frameno = n;
|
frame.frameno = n;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,79 @@
|
||||||
static PyObject *segfault_exc = 0;
|
static PyObject *segfault_exc = 0;
|
||||||
static PyObject *buserror_exc = 0;
|
static PyObject *buserror_exc = 0;
|
||||||
static PyObject *abort_exc = 0;
|
static PyObject *abort_exc = 0;
|
||||||
|
static PyObject *illegal_exc = 0;
|
||||||
|
|
||||||
|
/* Function return points and values */
|
||||||
|
|
||||||
|
static WadReturnFunc retpts[] = {
|
||||||
|
{"call_builtin", 0},
|
||||||
|
{"_PyImport_LoadDynamicModule", 0},
|
||||||
|
{"PyEval_EvalCode", 0},
|
||||||
|
{"PyObject_GetAttrString", 0},
|
||||||
|
{"PyObject_SetAttrString", -1},
|
||||||
|
{"PyObject_Repr", 0},
|
||||||
|
{"PyObject_Print", -1},
|
||||||
|
{"PyObject_CallFunction", 0},
|
||||||
|
{"PyObject_CallMethod", 0},
|
||||||
|
{"PyObject_CallObject", 0},
|
||||||
|
{"PyObject_Cmp", -1},
|
||||||
|
{"PyObject_Compare", -1},
|
||||||
|
{"PyObject_DelAttrString",-1},
|
||||||
|
{"PyObject_DelItem",-1},
|
||||||
|
{"PyObject_GetItem",0},
|
||||||
|
{"PyObject_SetItem",-1},
|
||||||
|
{"PyObject_HasAttrString",-1},
|
||||||
|
{"PyObject_Hash",-1},
|
||||||
|
{"PyObject_Length",-1},
|
||||||
|
{"PyObject_Str",0},
|
||||||
|
{"PyObject_Type", 0},
|
||||||
|
|
||||||
|
{"PyNumber_Absolute", 0},
|
||||||
|
{"PyNumber_Add",0},
|
||||||
|
{"PyNumber_And",0},
|
||||||
|
{"PyNumber_Coerce",0},
|
||||||
|
{"PyNumber_Divide",0},
|
||||||
|
{"PyNumber_Divmod",0},
|
||||||
|
{"PyNumber_Float",0},
|
||||||
|
{"PyNumber_Int",0},
|
||||||
|
{"PyNumber_Invert",0},
|
||||||
|
{"PyNumber_Long",0},
|
||||||
|
{"PyNumber_Lshift",0},
|
||||||
|
{"PyNumber_Multiply", 0},
|
||||||
|
{"PyNumber_Negative", 0},
|
||||||
|
{"PyNumber_Or",0},
|
||||||
|
{"PyNumber_Positive", 0},
|
||||||
|
{"PyNumber_Power",0},
|
||||||
|
{"PyNumber_Remainder",0},
|
||||||
|
{"PyNumber_Rshift",0},
|
||||||
|
{"PyNumber_Subtract",0},
|
||||||
|
{"PyNumber_Xor",0},
|
||||||
|
|
||||||
|
{"PySequence_Concat",0},
|
||||||
|
{"PySequence_Count",-1},
|
||||||
|
{"PySequence_Delitem",-1},
|
||||||
|
{"PySequence_DelSlice",-1},
|
||||||
|
{"PySequence_Getitem",0},
|
||||||
|
{"PySequence_GetSlice",0},
|
||||||
|
{"PySequence_In",-1},
|
||||||
|
{"PySequence_Index",-1},
|
||||||
|
{"PySequence_Repeat",0},
|
||||||
|
{"PySequence_SetItem",-1},
|
||||||
|
{"PySequence_SetSlice",-1},
|
||||||
|
{"PySequence_Tuple",0},
|
||||||
|
|
||||||
|
{"PyMapping_Clear",-1},
|
||||||
|
{"PyMapping_DelItem",-1},
|
||||||
|
{"PyMapping_DelItemString",-1},
|
||||||
|
{"PyMapping_GetItemString",0},
|
||||||
|
{"PyMapping_HasKey",-1},
|
||||||
|
{"PyMapping_HasKeyString",-1},
|
||||||
|
{"PyMapping_Items",0},
|
||||||
|
{"PyMapping_Keys",0},
|
||||||
|
{"PyMapping_Length", -1},
|
||||||
|
{"PyMapping_SetItemString", -1},
|
||||||
|
{"PyMapping_Values", 0},
|
||||||
|
{0,0}};
|
||||||
|
|
||||||
/* Handler function */
|
/* Handler function */
|
||||||
static void handler(int signo, WadFrame *frame, char *ret) {
|
static void handler(int signo, WadFrame *frame, char *ret) {
|
||||||
|
|
@ -47,6 +120,12 @@ static void handler(int signo, WadFrame *frame, char *ret) {
|
||||||
case SIGABRT:
|
case SIGABRT:
|
||||||
type = abort_exc;
|
type = abort_exc;
|
||||||
break;
|
break;
|
||||||
|
case SIGFPE:
|
||||||
|
type = PyExc_FloatingPointError;
|
||||||
|
break;
|
||||||
|
case SIGILL:
|
||||||
|
type = illegal_exc;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
type = PyExc_RuntimeError;
|
type = PyExc_RuntimeError;
|
||||||
break;
|
break;
|
||||||
|
|
@ -144,12 +223,12 @@ static void pywadinit() {
|
||||||
abort_exc = PyErr_NewException((char*)"exceptions.AbortError", NULL, NULL);
|
abort_exc = PyErr_NewException((char*)"exceptions.AbortError", NULL, NULL);
|
||||||
PyDict_SetItemString(d,(char *)"AbortError",abort_exc);
|
PyDict_SetItemString(d,(char *)"AbortError",abort_exc);
|
||||||
|
|
||||||
|
illegal_exc = PyErr_NewException((char *)"exceptions.IllegalInstruction", NULL, NULL);
|
||||||
|
PyDict_SetItemString(d,(char *)"IllegalInstruction",illegal_exc);
|
||||||
|
|
||||||
wad_init();
|
wad_init();
|
||||||
wad_set_callback(handler);
|
wad_set_callback(handler);
|
||||||
wad_set_return((char *)"call_builtin",0);
|
wad_set_returns(retpts);
|
||||||
wad_set_return((char *)"_PyImport_LoadDynamicModule",0);
|
|
||||||
wad_set_return((char *)"PyEval_EvalCode",0);
|
|
||||||
wad_set_return((char *)"PyObject_GetAttr",0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This hack is used to auto-initialize wad regardless of whether we are
|
/* This hack is used to auto-initialize wad regardless of whether we are
|
||||||
|
|
@ -169,6 +248,6 @@ static PyMethodDef wadmethods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void initwad() {
|
void initlibwadpy() {
|
||||||
Py_InitModule((char *)"wad",wadmethods);
|
Py_InitModule((char *)"libwadpy",wadmethods);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue