Hi Rod, Forgive me for this rather lengthy email, but I hope I have managed to fix a bug or two in ups. I've appended a complete context diff of the official and my version of ups below. Please let me know what do you think. Thanks, --Laci ============================================================================== I have downloaded ups-3.33 yesterday, both the binary for linux and the source. The binary crashed on me when trying to click on a variable of non-basic type (actually, a pointer to a non-basic type), so I set out to compile and debug ups. My system: PentiumII running linux, debian 2.0, 2.0.35 kernel, glibc2, C compiler is egcs 1.1b (actually, the pentium optimized egcs-1.1b) except for system stuff and a few important codes, like ups :-), where I still use gcc 2.7.2.3. ups didn't compile to start with, I had to include in a few files. Also I compiled it with -Wall and got a bunch of warnings. Most of them are just about undefined functions, but few were more interesting: - in render.c the code has '*iptr++;' twice. the '*' has no effect whatsoever so I've removed it. - in obj_misc.c (last diff) the test is very suspicious. '==' has higher precedence than '&', so I put in those parentheses. - also in obj_misc.c I got a warning: obj_misc.c:495: warning: passing arg 1 of `iterate_over_source_files' from incompatible pointer type I wasn't sure whether this is improtant or not, so left it as it was. - in ci_func.c (see next to last diff) '(expr != NULL, "%s")' always evaluates to true 'cos expr != NULL has no effect on anything there. I think my change fixes it correctly. - in ci_compile.c again '!=' has higher precedence in the test than '&' so I put in parentheses, that's how it seemed logical. - sys/reg.h had to be included in ao_text.c, ao_target.c and ao_ptrace.c to compile successfully - in ao_ptrace.c the #define's of PTRACE_PEEKUSER and PTRACE_POKEUSER had to be taken out to compile successfully After these changes ups did compile but still crashed when trying to examine a variable of non-basic type. I started to debug ups and found that the stf_mapsize field was set to 1 in the symbol table structure. I have checked where it gets set, and found that it's counted in scan_symtab and set in wrapup_stf. However, in scan_symtab mapsize is increased only in the part that's ifdef'd for OS_SUNOS. Since linux is elf as well as solaris I gambled and in the files ao_symload.c, ao_symparse.c and ao_symscan.c I've changed the '#ifdef OS_SUNOS' lines to '#if defined(OS_SUNOS) || defined(OS_LINUX)'. After this ups compiled and I don't seem to have any problems although I haven't yet tested things extensively. ============================================================================== diff -c -r ups-3.33/Makefile ups-3.33.orig/Makefile *** ups-3.33/Makefile Wed Oct 7 23:56:38 1998 --- ups-3.33.orig/Makefile Fri Sep 25 13:26:04 1998 *************** *** 19,30 **** # The directory where X include files live. # Comment out or change this line if you don't want # /usr/openwin/include searched ! #X11INCLUDE=-I/usr/openwin/include # The arguments to cc needed to link against the Xlib library. # Change this to an explicit path (e.g. /usr/X11/lib/libX11.a) # if your Xlib lives in a place that won't be found by -lX11. ! X11LIB = /usr/X11R6/lib/libX11.a # # For Red Hat 5.0 Linux, uncomment the line below to get the X11 library #X11LIB = /usr/X11/lib/libX11.a --- 19,30 ---- # The directory where X include files live. # Comment out or change this line if you don't want # /usr/openwin/include searched ! X11INCLUDE=-I/usr/openwin/include # The arguments to cc needed to link against the Xlib library. # Change this to an explicit path (e.g. /usr/X11/lib/libX11.a) # if your Xlib lives in a place that won't be found by -lX11. ! X11LIB = -lX11 # # For Red Hat 5.0 Linux, uncomment the line below to get the X11 library #X11LIB = /usr/X11/lib/libX11.a *************** *** 56,71 **** MAKE = make # for makes that don't do this automatically ! CC = gcc ! CFLAGS = -g -Wall # Use these flags by default ! #RANLIB = : ! #SVR4_LINKFLAGS=-R/usr/openwin/lib -L/usr/openwin/lib ! #LINKFLAGS = ${SVR4_LINKFLAGS} # Flags for SunOS 4.1.3 ! RANLIB = ranlib SUBMAKEFLAGS= CC="${CC}" RANLIB="${RANLIB}" CFLAGS="${CFLAGS}" ${EXTRA_SUBMAKEFLAGS} --- 56,71 ---- MAKE = make # for makes that don't do this automatically ! CC = cc ! CFLAGS = -g # Use these flags by default ! RANLIB = : ! SVR4_LINKFLAGS=-R/usr/openwin/lib -L/usr/openwin/lib ! LINKFLAGS = ${SVR4_LINKFLAGS} # Flags for SunOS 4.1.3 ! #RANLIB = ranlib SUBMAKEFLAGS= CC="${CC}" RANLIB="${RANLIB}" CFLAGS="${CFLAGS}" ${EXTRA_SUBMAKEFLAGS} diff -c -r ups-3.33/lib/libedit/render.c ups-3.33.orig/lib/libedit/render.c *** ups-3.33/lib/libedit/render.c Wed Oct 7 19:12:34 1998 --- ups-3.33.orig/lib/libedit/render.c Mon Sep 29 14:17:53 1997 *************** *** 747,753 **** while(*iptr != '\n' && iptr != ilim) { xpos += char_width; ! iptr++; point++; } break; --- 747,753 ---- while(*iptr != '\n' && iptr != ilim) { xpos += char_width; ! *iptr++; point++; } break; *************** *** 862,868 **** while(*iptr != '\n' && iptr != ilim) { xpos += char_width; ! iptr++; point++; } line_continues = 0; --- 862,868 ---- while(*iptr != '\n' && iptr != ilim) { xpos += char_width; ! *iptr++; point++; } line_continues = 0; diff -c -r ups-3.33/ups/ao_ptrace.c ups-3.33.orig/ups/ao_ptrace.c *** ups-3.33/ups/ao_ptrace.c Wed Oct 7 20:50:38 1998 --- ups-3.33.orig/ups/ao_ptrace.c Mon Jul 13 19:47:05 1998 *************** *** 108,118 **** #include #endif - #ifdef OS_LINUX - #include - #include - #endif - #ifndef OS_SUNOS /* Word size (and alignment) for ptrace read/write data requests. * --- 108,113 ---- *************** *** 123,128 **** --- 118,125 ---- #if defined(OS_LINUX) /* Request values for the ptrace system call */ + #define PTRACE_PEEKUSER PTRACE_PEEKUSR + #define PTRACE_POKEUSER PTRACE_POKEUSR typedef int ptracereq_t; #elif defined (OS_BSD44) diff -c -r ups-3.33/ups/ao_symload.c ups-3.33.orig/ups/ao_symload.c *** ups-3.33/ups/ao_symload.c Thu Oct 8 12:50:22 1998 --- ups-3.33.orig/ups/ao_symload.c Fri Sep 4 16:16:04 1998 *************** *** 97,103 **** } } ! #if defined(OS_SUNOS) || defined(OS_LINUX) static stf_t * id_to_hdrstf(stf, id, symno) stf_t *stf; --- 97,103 ---- } } ! #ifdef OS_SUNOS static stf_t * id_to_hdrstf(stf, id, symno) stf_t *stf; *************** *** 381,387 **** break; getsym(symrec.symio, symrec.symno, &nm); ! #if defined(OS_SUNOS) || defined(OS_LINUX) if ((nm.n_type == N_BINCL || nm.n_type == N_EXCL) && nm.n_value != 0) { stf_t *hdrstf; --- 381,387 ---- break; getsym(symrec.symio, symrec.symno, &nm); ! #ifdef OS_SUNOS if ((nm.n_type == N_BINCL || nm.n_type == N_EXCL) && nm.n_value != 0) { stf_t *hdrstf; diff -c -r ups-3.33/ups/ao_symparse.c ups-3.33.orig/ups/ao_symparse.c *** ups-3.33/ups/ao_symparse.c Thu Oct 8 12:47:49 1998 --- ups-3.33.orig/ups/ao_symparse.c Tue Sep 1 15:12:07 1998 *************** *** 561,567 **** } else { stf_t *search_stf; ! #if defined(OS_SUNOS_5) || defined(OS_LINUX) search_stf = stf->stf_fmap[0]->hf_stf; #else search_stf = stf; --- 561,567 ---- } else { stf_t *search_stf; ! #ifdef OS_SUNOS_5 search_stf = stf->stf_fmap[0]->hf_stf; #else search_stf = stf; diff -c -r ups-3.33/ups/ao_symscan.c ups-3.33.orig/ups/ao_symscan.c *** ups-3.33/ups/ao_symscan.c Thu Oct 8 12:46:22 1998 --- ups-3.33.orig/ups/ao_symscan.c Wed Sep 30 17:36:29 1998 *************** *** 210,216 **** stf->stf_fil->fi_funclist = newlist; } ! #if defined(OS_SUNOS) || defined(OS_LINUX) /* Look up the header file entry with id id in the headers list headers. * * Used when we find a N_EXCL symbol meaning a header file excluded --- 210,216 ---- stf->stf_fil->fi_funclist = newlist; } ! #ifdef OS_SUNOS /* Look up the header file entry with id id in the headers list headers. * * Used when we find a N_EXCL symbol meaning a header file excluded *************** *** 231,237 **** return NULL; /* to keep gcc happy */ } ! #endif /* defined(OS_SUNOS) || defined(OS_LINUX) */ /* Parse a name (NAME in the grammar). * If save is non zero, return a pointer to a saved copy of the name, --- 231,237 ---- return NULL; /* to keep gcc happy */ } ! #endif /* OS_SUNOS */ /* Parse a name (NAME in the grammar). * If save is non zero, return a pointer to a saved copy of the name, *************** *** 559,565 **** { static int common_syms[] = { N_BCOMM, N_STSYM, N_GSYM, N_LCSYM, N_FUN, N_SOL, ! #if defined(OS_SUNOS) || defined(OS_LINUX) N_BINCL, N_EXCL, N_EINCL, #endif #ifdef N_XLINE --- 559,565 ---- { static int common_syms[] = { N_BCOMM, N_STSYM, N_GSYM, N_LCSYM, N_FUN, N_SOL, ! #ifdef OS_SUNOS N_BINCL, N_EXCL, N_EINCL, #endif #ifdef N_XLINE *************** *** 811,817 **** symio_t *symio; Symrec symrec; nlist_t nm; ! #if defined(OS_SUNOS) || defined(OS_LINUX) hf_t *headers, *hf; #endif #ifdef AO_ELF --- 811,817 ---- symio_t *symio; Symrec symrec; nlist_t nm; ! #ifdef OS_SUNOS hf_t *headers, *hf; #endif #ifdef AO_ELF *************** *** 852,858 **** doing_header = 0; ! #if defined(OS_SUNOS) || defined(OS_LINUX) headers = NULL; #endif --- 852,858 ---- doing_header = 0; ! #ifdef OS_SUNOS headers = NULL; #endif *************** *** 1201,1207 **** break; #endif ! #if defined(OS_SUNOS) || defined(OS_LINUX) case N_BINCL: case N_EXCL: if (stf == NULL) --- 1201,1207 ---- break; #endif ! #ifdef OS_SUNOS case N_BINCL: case N_EXCL: if (stf == NULL) *************** *** 1263,1269 **** reverse_stf_funclist(stf); break; ! #endif /* defined(OS_SUNOS) || defined(OS_LINUX) */ case N_STSYM: case N_GSYM: case N_LCSYM: --- 1263,1269 ---- reverse_stf_funclist(stf); break; ! #endif /* OS_SUNOS */ case N_STSYM: case N_GSYM: case N_LCSYM: diff -c -r ups-3.33/ups/ao_target.c ups-3.33.orig/ups/ao_target.c *** ups-3.33/ups/ao_target.c Wed Oct 7 19:31:16 1998 --- ups-3.33.orig/ups/ao_target.c Thu Jul 2 12:37:01 1998 *************** *** 20,29 **** #include #include - #ifdef OS_LINUX - #include - #endif - #ifndef OS_LINUX /* RGA linux merge */ #ifndef AO_ELF #include --- 20,25 ---- diff -c -r ups-3.33/ups/ao_text.c ups-3.33.orig/ups/ao_text.c *** ups-3.33/ups/ao_text.c Wed Oct 7 20:52:05 1998 --- ups-3.33.orig/ups/ao_text.c Fri Nov 7 13:57:20 1997 *************** *** 25,33 **** #ifdef ARCH_SUN386 #include #endif - #ifdef OS_LINUX - #include - #endif #include #include --- 25,30 ---- diff -c -r ups-3.33/ups/ci_compile.c ups-3.33.orig/ups/ci_compile.c *** ups-3.33/ups/ci_compile.c Wed Oct 7 20:47:45 1998 --- ups-3.33.orig/ups/ci_compile.c Fri Sep 9 10:17:04 1994 *************** *** 1097,1103 **** * because it starts from one (to avoid NULL valid function ptrs. */ if (tx->tx_num_funcs <= 2) { ! if ((tx->tx_max_sp & sizeof(stackword_t)) != 0) panic("misaligned stack in ci_compile"); max_stack_nwords = tx->tx_max_sp / sizeof(stackword_t) + 20; } --- 1097,1103 ---- * because it starts from one (to avoid NULL valid function ptrs. */ if (tx->tx_num_funcs <= 2) { ! if (tx->tx_max_sp & sizeof(stackword_t) != 0) panic("misaligned stack in ci_compile"); max_stack_nwords = tx->tx_max_sp / sizeof(stackword_t) + 20; } diff -c -r ups-3.33/ups/ci_func.c ups-3.33.orig/ups/ci_func.c *** ups-3.33/ups/ci_func.c Wed Oct 7 19:30:24 1998 --- ups-3.33.orig/ups/ci_func.c Mon Sep 29 14:18:05 1997 *************** *** 114,120 **** ftype = f->fu_type->ty_base; if (strcmp(f->fu_demangled_name, "$start") == 0) { ! diagf(ET_ERROR, expr != NULL ? expr->ex_lexinfo : NULL, ci_Illegal_return_from_start_message); return; } --- 114,120 ---- ftype = f->fu_type->ty_base; if (strcmp(f->fu_demangled_name, "$start") == 0) { ! diagf(ET_ERROR, (expr != NULL, "%s") ? expr->ex_lexinfo : NULL, ci_Illegal_return_from_start_message); return; } diff -c -r ups-3.33/ups/obj_misc.c ups-3.33.orig/ups/obj_misc.c *** ups-3.33/ups/obj_misc.c Wed Oct 7 19:26:38 1998 --- ups-3.33.orig/ups/obj_misc.c Fri Jun 19 18:42:14 1998 *************** *** 445,452 **** ((fil_t *)obj2)->fi_flags & FI_DUPLICATE)) return 1; if (!strs_differ && ! (((fil_t *)obj1)->fi_flags & FI_HIDE_ENTRY) == 0 && ! (((fil_t *)obj2)->fi_flags & FI_HIDE_ENTRY) == 0) ((fil_t *)obj2)->fi_flags |= FI_HIDE_ENTRY; return strs_differ; } --- 445,452 ---- ((fil_t *)obj2)->fi_flags & FI_DUPLICATE)) return 1; if (!strs_differ && ! ((fil_t *)obj1)->fi_flags & FI_HIDE_ENTRY == 0 && ! ((fil_t *)obj2)->fi_flags & FI_HIDE_ENTRY == 0) ((fil_t *)obj2)->fi_flags |= FI_HIDE_ENTRY; return strs_differ; }