Solaris fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1056 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6bf5b348d1
commit
3741c5eb91
8 changed files with 73 additions and 48 deletions
|
|
@ -107,6 +107,7 @@ typedef struct WadObjectFile {
|
||||||
|
|
||||||
extern void wad_object_reset();
|
extern void wad_object_reset();
|
||||||
extern WadObjectFile *wad_object_load(const char *path);
|
extern WadObjectFile *wad_object_load(const char *path);
|
||||||
|
extern int wad_file_check(void *);
|
||||||
|
|
||||||
#define SYM_LOCAL 1
|
#define SYM_LOCAL 1
|
||||||
#define SYM_GLOBAL 2
|
#define SYM_GLOBAL 2
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ char *wad_arg_string(WadFrame *frame) {
|
||||||
#ifdef WAD_SOLARIS
|
#ifdef WAD_SOLARIS
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
wad_strcat(str,"0x");
|
wad_strcat(str,"0x");
|
||||||
wad_strcat(str,wad_format_hex(stack[8+1],0));
|
wad_strcat(str,wad_format_hex((unsigned long) stack[8+i],0));
|
||||||
if (i < 5)
|
if (i < 5)
|
||||||
wad_strcat(str,",");
|
wad_strcat(str,",");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,7 @@ wad_elf_debug_info(WadFrame *f) {
|
||||||
stab = wad_elf_section_data(f->object,nstab);
|
stab = wad_elf_section_data(f->object,nstab);
|
||||||
stabsize = wad_elf_section_size(f->object,nstab);
|
stabsize = wad_elf_section_size(f->object,nstab);
|
||||||
stabstr = (char *) wad_elf_section_data(f->object,nstabstr);
|
stabstr = (char *) wad_elf_section_data(f->object,nstabstr);
|
||||||
|
|
||||||
|
|
||||||
if (wad_search_stab(stab,stabsize,stabstr, f)) return 1;
|
if (wad_search_stab(stab,stabsize,stabstr, f)) return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -327,18 +328,22 @@ wad_elf_debug_info(WadFrame *f) {
|
||||||
stab = wad_elf_section_data(f->object,nstabexcl);
|
stab = wad_elf_section_data(f->object,nstabexcl);
|
||||||
stabsize = wad_elf_section_size(f->object, nstabexcl);
|
stabsize = wad_elf_section_size(f->object, nstabexcl);
|
||||||
stabstr = (char *) wad_elf_section_data(f->object, nstabexclstr);
|
stabstr = (char *) wad_elf_section_data(f->object, nstabexclstr);
|
||||||
|
|
||||||
if (wad_search_stab(stab,stabsize,stabstr, f)) return 1;
|
if (wad_search_stab(stab,stabsize,stabstr, f)) return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look in the .stab.index section. A Solaris oddity? */
|
/* Look in the .stab.index section. A Solaris oddity? */
|
||||||
if (nstabindex > 0) {
|
if (nstabindex > 0) {
|
||||||
|
|
||||||
stab = wad_elf_section_data(f->object,nstabindex);
|
stab = wad_elf_section_data(f->object,nstabindex);
|
||||||
stabsize = wad_elf_section_size(f->object, nstabindex);
|
stabsize = wad_elf_section_size(f->object, nstabindex);
|
||||||
stabstr = (char *) wad_elf_section_data(f->object, nstabindexstr);
|
stabstr = (char *) wad_elf_section_data(f->object, nstabindexstr);
|
||||||
|
|
||||||
if (wad_search_stab(stab,stabsize,stabstr, f)) {
|
if (wad_search_stab(stab,stabsize,stabstr, f)) {
|
||||||
WadObjectFile *wo1, *wold;
|
|
||||||
/* Hmmm. Might be in a different file */
|
/* Hmmm. Might be in a different file */
|
||||||
|
WadObjectFile *wo1, *wold;
|
||||||
char objfile[MAX_PATH];
|
char objfile[MAX_PATH];
|
||||||
|
/* printf("DEBUG %s\n", f->sym_name); */
|
||||||
wad_strcpy(objfile, f->loc_objfile);
|
wad_strcpy(objfile, f->loc_objfile);
|
||||||
wo1 = wad_object_load(objfile);
|
wo1 = wad_object_load(objfile);
|
||||||
if (wo1) {
|
if (wo1) {
|
||||||
|
|
@ -407,11 +412,11 @@ wad_find_symbol(WadFrame *f) {
|
||||||
|
|
||||||
void
|
void
|
||||||
wad_find_debug(WadFrame *f) {
|
wad_find_debug(WadFrame *f) {
|
||||||
if (f->debug_check) return;
|
/* if (f->debug_check) return; */
|
||||||
if (f->object) {
|
if (f->object) {
|
||||||
wad_elf_debug_info(f);
|
wad_elf_debug_info(f);
|
||||||
}
|
}
|
||||||
f->debug_check = 1;
|
/* f->debug_check = 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,21 @@
|
||||||
rely upon malloc() and related functions */
|
rely upon malloc() and related functions */
|
||||||
|
|
||||||
char *wad_format_hex(unsigned long u, int leading) {
|
char *wad_format_hex(unsigned long u, int leading) {
|
||||||
static char digits[] = "0123456789abcdef";
|
|
||||||
static char result[64];
|
static char result[64];
|
||||||
int i;
|
int i;
|
||||||
char *c;
|
char *c;
|
||||||
c = &result[63];
|
c = &result[63];
|
||||||
*c = 0;
|
*c = 0;
|
||||||
for (i = 0; i < (sizeof(unsigned long) << 1); i++) {
|
for (i = 0; i < (sizeof(unsigned long)*2); i++) {
|
||||||
int digit;
|
int d;
|
||||||
if (!u || leading) {
|
d = (int) (u & 0xf);
|
||||||
digit = u & 0xf;
|
c--;
|
||||||
*(--c) = digits[digit];
|
if (d < 10) {
|
||||||
|
*c = '0' + d;
|
||||||
|
} else {
|
||||||
|
*c = 'a' + (d-10);
|
||||||
}
|
}
|
||||||
|
if (!u && !leading) break;
|
||||||
u = u >> 4;
|
u = u >> 4;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
|
|
|
||||||
|
|
@ -276,3 +276,23 @@ void wad_find_object(WadFrame *f) {
|
||||||
f->object = wad_object_load(f->segment->mappath);
|
f->object = wad_object_load(f->segment->mappath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* wad_file_check(void *addr)
|
||||||
|
*
|
||||||
|
* Given an address, this function checks to see if it corresponds to a file
|
||||||
|
* we already mapped.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int
|
||||||
|
wad_file_check(void *addr) {
|
||||||
|
WadFile *f = wad_files;
|
||||||
|
while (f) {
|
||||||
|
if ((((char *) f->addr) <= ((char *) addr)) &&
|
||||||
|
(((char *) addr) < (((char *) f->addr) + f->size))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
f = f->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,10 @@ wad_segment_read() {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
s = (WadSegment *) wad_malloc(sizeof(WadSegment));
|
s = (WadSegment *) wad_malloc(sizeof(WadSegment));
|
||||||
|
skip:
|
||||||
n = segment_read(fs,s);
|
n = segment_read(fs,s);
|
||||||
if (n <= 0) break;
|
if (n <= 0) break;
|
||||||
|
if (wad_file_check(s->vaddr)) goto skip; /* Skip files we already loaded */
|
||||||
s->next = 0;
|
s->next = 0;
|
||||||
if (!lasts) {
|
if (!lasts) {
|
||||||
segments = s;
|
segments = s;
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,7 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) {
|
||||||
void wad_signal_init() {
|
void wad_signal_init() {
|
||||||
struct sigaction newvec;
|
struct sigaction newvec;
|
||||||
static stack_t sigstk;
|
static stack_t sigstk;
|
||||||
|
static int initstack = 0;
|
||||||
|
|
||||||
if (wad_debug_mode & DEBUG_INIT) {
|
if (wad_debug_mode & DEBUG_INIT) {
|
||||||
wad_printf("WAD: Initializing signal handler.\n");
|
wad_printf("WAD: Initializing signal handler.\n");
|
||||||
|
|
@ -442,15 +443,19 @@ void wad_signal_init() {
|
||||||
/* This is buggy in Linux and threads. disabled by default */
|
/* This is buggy in Linux and threads. disabled by default */
|
||||||
|
|
||||||
#ifndef WAD_LINUX
|
#ifndef WAD_LINUX
|
||||||
/* Set up an alternative stack */
|
|
||||||
|
|
||||||
sigstk.ss_sp = (char *) wad_sig_stack;
|
if (!initstack) {
|
||||||
sigstk.ss_size = STACK_SIZE;
|
/* Set up an alternative stack */
|
||||||
sigstk.ss_flags = 0;
|
|
||||||
if (!(wad_debug_mode & DEBUG_NOSTACK)) {
|
sigstk.ss_sp = (char *) wad_sig_stack;
|
||||||
if (sigaltstack(&sigstk, (stack_t*)0) < 0) {
|
sigstk.ss_size = STACK_SIZE;
|
||||||
perror("sigaltstack");
|
sigstk.ss_flags = 0;
|
||||||
|
if (!(wad_debug_mode & DEBUG_NOSTACK)) {
|
||||||
|
if (sigaltstack(&sigstk, (stack_t*)0) < 0) {
|
||||||
|
perror("sigaltstack");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
initstack=1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ typedef struct Stab {
|
||||||
#define N_LSYM 0x80 /* Local symbol */
|
#define N_LSYM 0x80 /* Local symbol */
|
||||||
#define N_PSYM 0xa0 /* Parameter */
|
#define N_PSYM 0xa0 /* Parameter */
|
||||||
#define N_LBRAC 0xc0 /* Left brace */
|
#define N_LBRAC 0xc0 /* Left brace */
|
||||||
|
#define N_RBRAC 0xe0 /* Right brace */
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* stabs type handler
|
* stabs type handler
|
||||||
|
|
@ -359,6 +359,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
||||||
int i;
|
int i;
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
int get_parms = 1;
|
int get_parms = 1;
|
||||||
|
int nbrace = 0;
|
||||||
|
|
||||||
offset = f->pc - f->sym_base;
|
offset = f->pc - f->sym_base;
|
||||||
if (wad_debug_mode & DEBUG_STABS) {
|
if (wad_debug_mode & DEBUG_STABS) {
|
||||||
|
|
@ -372,13 +373,17 @@ 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) ||
|
if ((s->n_type == N_UNDF) || (s->n_type == N_SO) || /* (s->n_type == N_FUN) || */
|
||||||
(s->n_type == N_OBJ)) return i;
|
(s->n_type == N_OBJ)) return i;
|
||||||
|
|
||||||
if (s->n_type == N_LBRAC) {
|
if (s->n_type == N_LBRAC) {
|
||||||
|
nbrace++;
|
||||||
get_parms = 0;
|
get_parms = 0;
|
||||||
}
|
}
|
||||||
|
if (s->n_type == N_RBRAC) {
|
||||||
|
nbrace--;
|
||||||
|
if (nbrace <= 0) return i;
|
||||||
|
}
|
||||||
/* Local variable declaration */
|
/* Local variable declaration */
|
||||||
|
|
||||||
if (s->n_type == N_LSYM) {
|
if (s->n_type == N_LSYM) {
|
||||||
|
|
@ -454,7 +459,7 @@ scan_function(Stab *s, char *stabstr, int ns, WadFrame *f) {
|
||||||
|
|
||||||
if (s->n_type == N_SLINE) {
|
if (s->n_type == N_SLINE) {
|
||||||
get_parms = 0;
|
get_parms = 0;
|
||||||
if (s->n_value < offset) {
|
if (s->n_value <= offset) {
|
||||||
f->loc_line = s->n_desc;
|
f->loc_line = s->n_desc;
|
||||||
}
|
}
|
||||||
} else if (((s->n_type == N_PSYM) || (s->n_type == N_RSYM)) && get_parms) {
|
} else if (((s->n_type == N_PSYM) || (s->n_type == N_RSYM)) && get_parms) {
|
||||||
|
|
@ -577,7 +582,6 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
||||||
char srcfile[MAX_PATH];
|
char srcfile[MAX_PATH];
|
||||||
char objfile[MAX_PATH];
|
char objfile[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
/* It appears to be necessary to clear the types table on each new stabs section */
|
/* It appears to be necessary to clear the types table on each new stabs section */
|
||||||
|
|
||||||
init_hash();
|
init_hash();
|
||||||
|
|
@ -592,8 +596,8 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
||||||
|
|
||||||
for (i = 0; i < ns; i++, s++) {
|
for (i = 0; i < ns; i++, s++) {
|
||||||
if (wad_debug_mode & DEBUG_STABS) {
|
if (wad_debug_mode & DEBUG_STABS) {
|
||||||
wad_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);
|
stabstr+s->n_strx); */
|
||||||
|
|
||||||
}
|
}
|
||||||
if (s->n_type == N_LSYM) {
|
if (s->n_type == N_LSYM) {
|
||||||
|
|
@ -604,8 +608,9 @@ 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
|
/* New stabs section. We need to be a little careful here. Do a recursive
|
||||||
search of the subsection. */
|
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)) {
|
||||||
wad_search_stab(s+1,s->n_desc*sizeof(Stab), stabstr, f);
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* On solaris, each stabs section seems to increment the stab string pointer. On Linux,
|
/* 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
|
the linker seems to do a certain amount of optimization that results in a single
|
||||||
|
|
@ -644,31 +649,15 @@ wad_search_stab(void *sp, int size, char *stabstr, WadFrame *f) {
|
||||||
}
|
}
|
||||||
wad_strcat(objfile,stabstr+s->n_strx);
|
wad_strcat(objfile,stabstr+s->n_strx);
|
||||||
} else if (s->n_type == N_FUN) {
|
} else if (s->n_type == N_FUN) {
|
||||||
|
if (match_stab_symbol(f->sym_name, stabstr+s->n_strx, f->sym_nlen)) {
|
||||||
/* Due to the bogosity and performance issues of managing stabs types, we are going to check
|
if (!f->sym_file || (strcmp(f->sym_file,lastfile) == 0)) {
|
||||||
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;
|
int n;
|
||||||
/* Go find debugging information for the function */
|
/* Go find debugging information for the function */
|
||||||
n = scan_function(s+1, stabstr, ns -i - 1, g);
|
n = scan_function(s+1, stabstr, ns -i - 1, f);
|
||||||
g->loc_srcfile = wad_string_lookup(srcfile);
|
f->loc_srcfile = wad_string_lookup(srcfile);
|
||||||
g->loc_objfile = wad_string_lookup(objfile);
|
f->loc_objfile = wad_string_lookup(objfile);
|
||||||
g->debug_check = 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
g = g->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue