From 283a159fe38e477d93b189d43888f1e42043c0af Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Mon, 17 Jan 2000 15:45:24 +0000 Subject: [PATCH] natThrowable.cc: New file. 2000-01-14 Andrew Haley * java/lang/natThrowable.cc: New file. * java/lang/Throwable.java (fillInStackTrace): Make native. (printStackTrace): Call native method to do this. (Throwable): Call fillInStackTrace. (stackTrace): New variable. * include/jvm.h: Add _Jv_ThisExecutable functions. * prims.cc: (_Jv_execName): New variable. (catch_segv): Call fillInStackTrace. (catch_fpe): Ditto. (_Jv_ThisExecutable): New functions. (JvRunMain): Set the name of this executable. * Makefile.am: Add java/lang/natThrowable.cc. Add name-finder.cc. * Makefile.in: Rebuilt. * acconfig.h: Add HAVE_PROC_SELF_EXE. * configure.in: Force link with __frame_state_for in FORCELIBGCCSPEC. Add new checks for backtrace. * include/config.h.in: Rebuilt. * name-finder.cc: New file. * include/name-finder.h: New file. From-SVN: r31460 --- libjava/ChangeLog | 30 +++ libjava/Makefile.am | 3 +- libjava/Makefile.in | 9 +- libjava/acconfig.h | 3 + libjava/configure | 369 ++++++++++++++++++++---------- libjava/configure.in | 6 +- libjava/include/config.h.in | 22 ++ libjava/include/jvm.h | 4 + libjava/include/name-finder.h | 69 ++++++ libjava/java/lang/Throwable.java | 69 +++--- libjava/java/lang/natThrowable.cc | 95 ++++++++ libjava/name-finder.cc | 180 +++++++++++++++ libjava/prims.cc | 35 ++- 13 files changed, 732 insertions(+), 162 deletions(-) create mode 100644 libjava/include/name-finder.h create mode 100644 libjava/java/lang/natThrowable.cc create mode 100644 libjava/name-finder.cc diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 8db6f2fd7db7..53f778822b03 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,33 @@ +2000-01-14 Andrew Haley + + * java/lang/natThrowable.cc: New file. + + * java/lang/Throwable.java (fillInStackTrace): Make native. + (printStackTrace): Call native method to do this. + (Throwable): Call fillInStackTrace. + (stackTrace): New variable. + + * include/jvm.h: Add _Jv_ThisExecutable functions. + + * prims.cc: (_Jv_execName): New variable. + (catch_segv): Call fillInStackTrace. + (catch_fpe): Ditto. + (_Jv_ThisExecutable): New functions. + (JvRunMain): Set the name of this executable. + + * Makefile.am: Add java/lang/natThrowable.cc. + Add name-finder.cc. + * Makefile.in: Rebuilt. + + * acconfig.h: Add HAVE_PROC_SELF_EXE. + + * configure.in: Force link with __frame_state_for in + FORCELIBGCCSPEC. Add new checks for backtrace. + * include/config.h.in: Rebuilt. + + * name-finder.cc: New file. + * include/name-finder.h: New file. + 2000-01-16 Anthony Green * java/lang/StringBuffer.java (StringBuffer): Don't special case diff --git a/libjava/Makefile.am b/libjava/Makefile.am index d15784dfb421..bc828ce498f0 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -112,7 +112,7 @@ javao_files = $(java_source_files:.java=.lo) \ libffi_files = `$(AR) t ../libffi/.libs/libffi.a 2>/dev/null | sed 's/\.o/\.lo/g' | sed 's/^/..\/libffi\//g'` libgcj_la_SOURCES = prims.cc jni.cc exception.cc \ - resolve.cc defineclass.cc interpret.cc + resolve.cc defineclass.cc interpret.cc name-finder.cc EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \ $(c_source_files) $(java_source_files) $(built_java_source_files) libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) $(nat_files) \ @@ -804,6 +804,7 @@ java/lang/natRuntime.cc \ java/lang/natString.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ +java/lang/natThrowable.cc \ java/lang/reflect/natArray.cc \ java/lang/reflect/natConstructor.cc \ java/lang/reflect/natField.cc \ diff --git a/libjava/Makefile.in b/libjava/Makefile.in index feb516de38de..26ee2e3076f9 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -184,7 +184,7 @@ javao_files = $(java_source_files:.java=.lo) \ libffi_files = `$(AR) t ../libffi/.libs/libffi.a 2>/dev/null | sed 's/\.o/\.lo/g' | sed 's/^/..\/libffi\//g'` libgcj_la_SOURCES = prims.cc jni.cc exception.cc \ - resolve.cc defineclass.cc interpret.cc + resolve.cc defineclass.cc interpret.cc name-finder.cc EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \ $(c_source_files) $(java_source_files) $(built_java_source_files) @@ -618,6 +618,7 @@ java/lang/natRuntime.cc \ java/lang/natString.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ +java/lang/natThrowable.cc \ java/lang/reflect/natArray.cc \ java/lang/reflect/natConstructor.cc \ java/lang/reflect/natField.cc \ @@ -699,7 +700,7 @@ libgcjdata_a_LIBADD = LTLIBRARIES = $(toolexeclib_LTLIBRARIES) libgcj_la_OBJECTS = prims.lo jni.lo exception.lo resolve.lo \ -defineclass.lo interpret.lo +defineclass.lo interpret.lo name-finder.lo @NATIVE_TRUE@bin_PROGRAMS = jv-convert$(EXEEXT) gij$(EXEEXT) @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \ @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS$(EXEEXT) @@ -923,8 +924,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/util/zip/ZipException.P .deps/java/util/zip/ZipFile.P \ .deps/java/util/zip/ZipInputStream.P \ .deps/java/util/zip/ZipOutputStream.P .deps/jni.P .deps/libgcjdata.P \ -.deps/no-threads.P .deps/nogc.P .deps/posix-threads.P .deps/prims.P \ -.deps/resolve.P +.deps/name-finder.P .deps/no-threads.P .deps/nogc.P \ +.deps/posix-threads.P .deps/prims.P .deps/resolve.P SOURCES = $(libgcjdata_a_SOURCES) $(libgcj_la_SOURCES) $(EXTRA_libgcj_la_SOURCES) $(jv_convert_SOURCES) $(EXTRA_jv_convert_SOURCES) $(gij_SOURCES) $(EXTRA_gij_SOURCES) $(gen_from_JIS_SOURCES) $(EXTRA_gen_from_JIS_SOURCES) OBJECTS = $(libgcjdata_a_OBJECTS) $(libgcj_la_OBJECTS) $(jv_convert_OBJECTS) $(gij_OBJECTS) $(gen_from_JIS_OBJECTS) diff --git a/libjava/acconfig.h b/libjava/acconfig.h index ef2c513f533e..75931b7ef6f7 100644 --- a/libjava/acconfig.h +++ b/libjava/acconfig.h @@ -120,5 +120,8 @@ /* Define if using setjmp/longjmp exceptions. */ #undef SJLJ_EXCEPTIONS +/* Define if you have /proc/self/exe */ +#undef HAVE_PROC_SELF_EXE + /* Define if getuid() and friends are missing. */ #undef NO_GETUID diff --git a/libjava/configure b/libjava/configure index 602829bf8dc1..56183b82feb3 100755 --- a/libjava/configure +++ b/libjava/configure @@ -2456,7 +2456,7 @@ fi FORCELIBGCCSPEC= if test "$ac_cv_prog_gnu_ld" = yes; then - FORCELIBGCCSPEC="-u __rethrow -lgcc" + FORCELIBGCCSPEC="-u __rethrow -u __frame_state_for -lgcc" fi echo $ac_n "checking for data_start""... $ac_c" 1>&6 @@ -3224,16 +3224,15 @@ else fi done - - for ac_func in gethostbyname_r + for ac_func in backtrace fork execvp pipe do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3232: checking for $ac_func" >&5 +echo "configure:3231: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + for ac_hdr in execinfo.h unistd.h dlfcn.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:3287: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:3297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + for ac_file in /proc/self/exe +do + +ac_safe=`echo "$ac_file" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_file""... $ac_c" 1>&6 +echo "configure:3328: checking for $ac_file" >&5 +if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: Cannot check for file existence when cross compiling" 1>&2; exit 1; } +else + if test -r $ac_file; then + eval "ac_cv_file_$ac_safe=yes" + else + eval "ac_cv_file_$ac_safe=no" + fi +fi +fi +if eval "test \"`echo '$ac_cv_file_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_file=HAVE_`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_PROC_SELF_EXE 1 +EOF + +else + echo "$ac_t""no" 1>&6 + +fi +done + + + for ac_func in gethostbyname_r +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:3363: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3283,7 +3414,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext < EOF @@ -3303,7 +3434,7 @@ rm -f conftest* *" -D_REENTRANT "*) ;; *) echo $ac_n "checking whether gethostbyname_r declaration requires -D_REENTRANT""... $ac_c" 1>&6 -echo "configure:3307: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5 +echo "configure:3438: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5 if eval "test \"`echo '$''{'libjava_cv_gethostbyname_r_needs_reentrant'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3316,14 +3447,14 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < int main() { gethostbyname_r("", 0, 0); ; return 0; } EOF -if { (eval echo configure:3327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_gethostbyname_r_needs_reentrant=no else @@ -3333,14 +3464,14 @@ else CPPFLAGS_SAVE="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_REENTRANT" cat > conftest.$ac_ext < int main() { gethostbyname_r("", 0, 0); ; return 0; } EOF -if { (eval echo configure:3344: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3475: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_gethostbyname_r_needs_reentrant=yes else @@ -3375,12 +3506,12 @@ EOF esac echo $ac_n "checking for struct hostent_data""... $ac_c" 1>&6 -echo "configure:3379: checking for struct hostent_data" >&5 +echo "configure:3510: checking for struct hostent_data" >&5 if eval "test \"`echo '$''{'libjava_cv_struct_hostent_data'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_struct_hostent_data=yes else @@ -3420,12 +3551,12 @@ done for ac_func in gethostbyaddr_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3424: checking for $ac_func" >&5 +echo "configure:3555: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3475,7 +3606,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext < EOF @@ -3499,12 +3630,12 @@ done for ac_func in gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3503: checking for $ac_func" >&5 +echo "configure:3634: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3551,7 +3682,7 @@ EOF EOF cat > conftest.$ac_ext < EOF @@ -3582,12 +3713,12 @@ done for ac_func in pthread_mutexattr_settype pthread_mutexattr_setkind_np do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3586: checking for $ac_func" >&5 +echo "configure:3717: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3640,12 +3771,12 @@ done for ac_func in sched_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3644: checking for $ac_func" >&5 +echo "configure:3775: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3690,7 +3821,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6 -echo "configure:3694: checking for sched_yield in -lrt" >&5 +echo "configure:3825: checking for sched_yield in -lrt" >&5 ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3698,7 +3829,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lrt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3735,7 +3866,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 -echo "configure:3739: checking for sched_yield in -lposix4" >&5 +echo "configure:3870: checking for sched_yield in -lposix4" >&5 ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3743,7 +3874,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3790,7 +3921,7 @@ done # We can save a little space at runtime if the mutex has m_count # or __m_count. This is a nice hack for Linux. cat > conftest.$ac_ext < int main() { @@ -3799,7 +3930,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:3803: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3934: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define PTHREAD_MUTEX_HAVE_M_COUNT 1 @@ -3811,7 +3942,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < int main() { @@ -3820,7 +3951,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:3824: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3955: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define PTHREAD_MUTEX_HAVE___M_COUNT 1 @@ -3840,12 +3971,12 @@ rm -f conftest* for ac_func in gettimeofday time ftime do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3844: checking for $ac_func" >&5 +echo "configure:3975: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3899,12 +4030,12 @@ done for ac_func in memmove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3903: checking for $ac_func" >&5 +echo "configure:4034: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3957,12 +4088,12 @@ done for ac_func in memcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3961: checking for $ac_func" >&5 +echo "configure:4092: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4033,7 +4164,7 @@ done #-------------------------------------------------------------------- echo $ac_n "checking for socket libraries""... $ac_c" 1>&6 -echo "configure:4037: checking for socket libraries" >&5 +echo "configure:4168: checking for socket libraries" >&5 if eval "test \"`echo '$''{'gcj_cv_lib_sockets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4041,12 +4172,12 @@ else gcj_checkBoth=0 unset ac_cv_func_connect echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:4045: checking for connect" >&5 +echo "configure:4176: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -4092,7 +4223,7 @@ fi if test "$gcj_checkSocket" = 1; then unset ac_cv_func_connect echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:4096: checking for main in -lsocket" >&5 +echo "configure:4227: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4100,14 +4231,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4134,12 +4265,12 @@ fi LIBS="$LIBS -lsocket -lnsl" unset ac_cv_func_accept echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:4138: checking for accept" >&5 +echo "configure:4269: checking for accept" >&5 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_accept=yes" else @@ -4189,12 +4320,12 @@ fi gcj_oldLibs=$LIBS LIBS="$LIBS $gcj_cv_lib_sockets" echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:4193: checking for gethostbyname" >&5 +echo "configure:4324: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -4235,7 +4366,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:4239: checking for main in -lnsl" >&5 +echo "configure:4370: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4243,14 +4374,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4282,7 +4413,7 @@ echo "$ac_t""$gcj_cv_lib_sockets" 1>&6 if test "$with_system_zlib" = yes; then echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:4286: checking for deflate in -lz" >&5 +echo "configure:4417: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4290,7 +4421,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4330,7 +4461,7 @@ fi # requires -ldl. if test "$GC" = boehm; then echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 -echo "configure:4334: checking for main in -ldl" >&5 +echo "configure:4465: checking for main in -ldl" >&5 ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4338,14 +4469,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4465,7 +4596,7 @@ EOF # See if gcj supports -fuse-divide-subroutine. gcc 2.95 does not, and # we want to continue to support that version. echo $ac_n "checking whether gcj supports -fuse-divide-subroutine""... $ac_c" 1>&6 -echo "configure:4469: checking whether gcj supports -fuse-divide-subroutine" >&5 +echo "configure:4600: checking whether gcj supports -fuse-divide-subroutine" >&5 cat > conftest.java << 'END' public class conftest { } END @@ -4485,17 +4616,17 @@ for ac_hdr in unistd.h bstring.h sys/time.h sys/types.h fcntl.h sys/ioctl.h sys/ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4489: checking for $ac_hdr" >&5 +echo "configure:4620: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4630: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4525,17 +4656,17 @@ for ac_hdr in dirent.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4529: checking for $ac_hdr" >&5 +echo "configure:4660: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4539: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4670: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4563,12 +4694,12 @@ done echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:4567: checking for ANSI C header files" >&5 +echo "configure:4698: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4576,7 +4707,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4580: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4593,7 +4724,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -4611,7 +4742,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -4632,7 +4763,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -4643,7 +4774,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:4647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -4667,12 +4798,12 @@ EOF fi echo $ac_n "checking for ssize_t""... $ac_c" 1>&6 -echo "configure:4671: checking for ssize_t" >&5 +echo "configure:4802: checking for ssize_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -4701,9 +4832,9 @@ fi echo $ac_n "checking for in_addr_t""... $ac_c" 1>&6 -echo "configure:4705: checking for in_addr_t" >&5 +echo "configure:4836: checking for in_addr_t" >&5 cat > conftest.$ac_ext < #if STDC_HEADERS @@ -4717,7 +4848,7 @@ int main() { in_addr_t foo; ; return 0; } EOF -if { (eval echo configure:4721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4852: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_IN_ADDR_T 1 @@ -4733,16 +4864,16 @@ fi rm -f conftest* echo $ac_n "checking whether struct ip_mreq is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:4737: checking whether struct ip_mreq is in netinet/in.h" >&5 +echo "configure:4868: checking whether struct ip_mreq is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct ip_mreq mreq; ; return 0; } EOF -if { (eval echo configure:4746: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_STRUCT_IP_MREQ 1 @@ -4758,16 +4889,16 @@ fi rm -f conftest* echo $ac_n "checking whether struct sockaddr_in6 is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:4762: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 +echo "configure:4893: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct sockaddr_in6 addr6; ; return 0; } EOF -if { (eval echo configure:4771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_INET6 1 @@ -4783,16 +4914,16 @@ fi rm -f conftest* echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6 -echo "configure:4787: checking for socklen_t in sys/socket.h" >&5 +echo "configure:4918: checking for socklen_t in sys/socket.h" >&5 cat > conftest.$ac_ext < int main() { socklen_t x = 5; ; return 0; } EOF -if { (eval echo configure:4796: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4927: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_SOCKLEN_T 1 @@ -4808,16 +4939,16 @@ fi rm -f conftest* echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6 -echo "configure:4812: checking for tm_gmtoff in struct tm" >&5 +echo "configure:4943: checking for tm_gmtoff in struct tm" >&5 cat > conftest.$ac_ext < int main() { struct tm tim; tim.tm_gmtoff = 0; ; return 0; } EOF -if { (eval echo configure:4821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4952: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define STRUCT_TM_HAS_GMTOFF 1 @@ -4830,16 +4961,16 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking for global timezone variable""... $ac_c" 1>&6 -echo "configure:4834: checking for global timezone variable" >&5 +echo "configure:4965: checking for global timezone variable" >&5 cat > conftest.$ac_ext < int main() { long z2 = timezone; ; return 0; } EOF -if { (eval echo configure:4843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4974: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_TIMEZONE 1 @@ -4859,19 +4990,19 @@ rm -f conftest* # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:4863: checking for working alloca.h" >&5 +echo "configure:4994: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -4892,12 +5023,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4896: checking for alloca" >&5 +echo "configure:5027: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -4957,12 +5088,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4961: checking whether alloca needs Cray hooks" >&5 +echo "configure:5092: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4991: checking for $ac_func" >&5 +echo "configure:5122: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5042,7 +5173,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:5046: checking stack direction for C alloca" >&5 +echo "configure:5177: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5050,7 +5181,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -5096,7 +5227,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5100: checking for $ac_word" >&5 +echo "configure:5231: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/libjava/configure.in b/libjava/configure.in index 080146ae7166..612b30fa59c2 100644 --- a/libjava/configure.in +++ b/libjava/configure.in @@ -86,7 +86,7 @@ fi FORCELIBGCCSPEC= dnl Work around libgcc design flaw. if test "$ac_cv_prog_gnu_ld" = yes; then - FORCELIBGCCSPEC="-u __rethrow -lgcc" + FORCELIBGCCSPEC="-u __rethrow -u __frame_state_for -lgcc" fi AC_MSG_CHECKING([for data_start]) @@ -360,6 +360,10 @@ else AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath) AC_CHECK_FUNCS(inet_aton inet_addr, break) AC_CHECK_FUNCS(inet_pton uname inet_ntoa) + AC_CHECK_FUNCS(backtrace fork execvp pipe) + AC_CHECK_HEADERS(execinfo.h unistd.h dlfcn.h) + AC_CHECK_FILES(/proc/self/exe, [ + AC_DEFINE(HAVE_PROC_SELF_EXE)]) AC_CHECK_FUNCS(gethostbyname_r, [ AC_DEFINE(HAVE_GETHOSTBYNAME_R) diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in index 8dbdc5d4e67f..c636c93f2102 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -135,12 +135,25 @@ /* Define if using setjmp/longjmp exceptions. */ #undef SJLJ_EXCEPTIONS +/* Define if you have /proc/self/exe */ +#undef HAVE_PROC_SELF_EXE + + /* Define if getuid() and friends are missing. */ #undef NO_GETUID /* Define if you have the access function. */ #undef HAVE_ACCESS +/* Define if you have the backtrace function. */ +#undef HAVE_BACKTRACE + +/* Define if you have the execvp function. */ +#undef HAVE_EXECVP + +/* Define if you have the fork function. */ +#undef HAVE_FORK + /* Define if you have the fstat function. */ #undef HAVE_FSTAT @@ -201,6 +214,9 @@ /* Define if you have the open function. */ #undef HAVE_OPEN +/* Define if you have the pipe function. */ +#undef HAVE_PIPE + /* Define if you have the pthread_mutexattr_setkind_np function. */ #undef HAVE_PTHREAD_MUTEXATTR_SETKIND_NP @@ -252,6 +268,12 @@ /* Define if you have the header file. */ #undef HAVE_DIRENT_H +/* Define if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define if you have the header file. */ +#undef HAVE_EXECINFO_H + /* Define if you have the header file. */ #undef HAVE_FCNTL_H diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index 3b59b8dfe7c3..49fc47b0b9ed 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -182,4 +182,8 @@ extern "C" jlong _Jv_remJ (jlong, jlong); } +/* get/set the name of the running executable. */ +extern char *_Jv_ThisExecutable (void); +extern void _Jv_ThisExecutable (const char *); + #endif /* __JAVA_JVM_H__ */ diff --git a/libjava/include/name-finder.h b/libjava/include/name-finder.h new file mode 100644 index 000000000000..9a1d7dfdaac2 --- /dev/null +++ b/libjava/include/name-finder.h @@ -0,0 +1,69 @@ +// name-finder.h - Convert addresses to names + +/* Copyright (C) 2000 Red Hat Inc + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/** + * @author Andrew Haley + * @date Jan 6 2000 + */ + +#include +#include + +#include + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +/* _Jv_name_finder is a class wrapper around a mechanism that can + convert addresses of methods to their names and the names of files + in which they appear. */ + +class _Jv_name_finder +{ +public: + _Jv_name_finder (char *executable); + ~_Jv_name_finder () + { +#if defined (HAVE_PIPE) && defined (HAVE_FORK) + close (f_pipe[1]); + fclose (b_pipe_fd); +#endif + } + +/* Given a pointer to a function or method, try to convert it into a + name and the appropriate line and source file. The caller passes + the code pointer in p. + + Returns false if the lookup fails. Even if this happens, the field + hex will have been correctly filled in with the pointer. + + The other fields are method_name and file_name, which lookup will + attempt to fill appropriately. If the lookup has failed, these + fields contain garbage.*/ + bool lookup (void *p); + + char method_name[1024]; + char file_name[1024]; + char hex[sizeof (void *) * 2 + 5]; + +private: + void toHex (void *p); +#if defined (HAVE_PIPE) && defined (HAVE_FORK) + int pid; + int f_pipe[2], b_pipe[2]; + FILE *b_pipe_fd; + int error; +#endif +}; + diff --git a/libjava/java/lang/Throwable.java b/libjava/java/lang/Throwable.java index 5ae39ae25944..faba2be1aa72 100644 --- a/libjava/java/lang/Throwable.java +++ b/libjava/java/lang/Throwable.java @@ -12,6 +12,7 @@ package java.lang; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Serializable; +import java.io.OutputStreamWriter; /** * @author Tom Tromey @@ -26,55 +27,51 @@ import java.io.Serializable; public class Throwable implements Serializable { - public Throwable fillInStackTrace () - { - return this; - } + public native Throwable fillInStackTrace (); public String getLocalizedMessage () - { - return getMessage (); - } + { + return getMessage (); + } public String getMessage () - { - return detailMessage; - } + { + return detailMessage; + } public void printStackTrace () - { - printStackTrace (System.err); - } - - public void printStackTrace (PrintStream s) - { - // No stack trace, but we can still print this object. - s.println(toString ()); - } - - public void printStackTrace (PrintWriter wr) - { - // No stack trace, but we can still print this object. - wr.println(toString ()); - } + { + printStackTrace (System.err); + } + public void printStackTrace (PrintStream ps) + { + printStackTrace (new PrintWriter(new OutputStreamWriter(ps))); + } + + public native void printStackTrace (PrintWriter wr); + public Throwable () - { - detailMessage = null; - } + { + detailMessage = null; + fillInStackTrace (); + } public Throwable (String message) - { - detailMessage = message; - } + { + detailMessage = message; + fillInStackTrace (); + } public String toString () - { - return ((detailMessage == null) - ? getClass().getName() - : getClass().getName() + ": " + getMessage ()); - } + { + return ((detailMessage == null) + ? getClass().getName() + : getClass().getName() + ": " + getMessage ()); + } // Name of this field comes from serialization spec. private String detailMessage; + + private byte stackTrace[]; } diff --git a/libjava/java/lang/natThrowable.cc b/libjava/java/lang/natThrowable.cc new file mode 100644 index 000000000000..2227e7d35d17 --- /dev/null +++ b/libjava/java/lang/natThrowable.cc @@ -0,0 +1,95 @@ +// natThrowable.cc - Superclass for all exceptions. + +/* Copyright (C) 2000 Red Hat Inc + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/** + * @author Andrew Haley + * @date Jan 6 2000 + */ + +#include + +#include + +#pragma implementation "Throwable.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#ifdef HAVE_EXECINFO_H +#include +#endif + +#include + +/* FIXME: size of the stack trace is limited to 128 elements. It's + undoubtedly sensible to limit the stack trace, but 128 is rather + arbitrary. It may be better to configure this. */ + +java::lang::Throwable * +java::lang::Throwable::fillInStackTrace (void) +{ +#ifdef HAVE_BACKTRACE + void *p[128]; + + // We subtract 1 from the number of elements because we don't want + // to include the call to fillInStackTrace in the trace. + int n = backtrace (p, 128) - 1; + + // ??? Might this cause a problem if the byte array isn't aligned? + stackTrace = JvNewByteArray (n * sizeof p[0]); + memcpy (elements (stackTrace), p+1, (n * sizeof p[0])); + + return this; +#endif +} + +void +java::lang::Throwable::printStackTrace (java::io::PrintWriter *wr) +{ + wr->println (toString ()); +#ifdef HAVE_BACKTRACE + if (!stackTrace) + return; + + void **p = (void **)elements (stackTrace); + int depth = stackTrace->length / sizeof p[0]; + + _Jv_name_finder finder (_Jv_ThisExecutable ()); + + for (int i = 0; i < depth; i++) + { + bool found = finder.lookup (p[i]); + wr->print (JvNewStringLatin1 (" at ")); + wr->print (JvNewStringLatin1 (finder.hex)); + if (found) + { + wr->print (JvNewStringLatin1 (": ")); + wr->print (JvNewStringLatin1 (finder.method_name)); + wr->print (JvNewStringLatin1 (" (")); + wr->print (JvNewStringLatin1 (finder.file_name)); + wr->print (JvNewStringLatin1 (")")); + } + wr->println (); + } +#endif /* HAVE_BACKTRACE */ +} + diff --git a/libjava/name-finder.cc b/libjava/name-finder.cc new file mode 100644 index 000000000000..ba8a5ae73844 --- /dev/null +++ b/libjava/name-finder.cc @@ -0,0 +1,180 @@ +// name-finder.cc - Convert addresses to names + +/* Copyright (C) 2000 Red Hat Inc + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/** + * @author Andrew Haley + * @date Jan 6 2000 + */ + +/* _Jv_name_finder is a class wrapper around a mechanism that can + convert address of methods to their names and the names of files in + which they appear. + + Right now, the only implementation of this involves running a copy + of addr2line, but at some point it is worth building this + functionality into libgcj, if only for embedded systems. */ + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_DLFCN_H +#include +#endif + +#include + +/* Create a new name finder which will perform address lookups on an + executable. */ + +_Jv_name_finder::_Jv_name_finder (char *executable) +{ +#if defined (HAVE_PIPE) && defined (HAVE_FORK) && defined (HAVE_EXECVP) + error = 0; + + char *argv[6]; + { + int arg = 0; + argv[arg++] = "addr2line"; + argv[arg++] = "-C"; + argv[arg++] = "-f"; + argv[arg++] = "-e"; + argv[arg++] = executable; + argv[arg] = NULL; + } + + error |= pipe (f_pipe) < 0; + error |= pipe (b_pipe) < 0; + + if (error) + return; + + pid = fork (); + if (pid == 0) + { + close (f_pipe[1]); + close (b_pipe[0]); + dup2 (f_pipe[0], fileno (stdin)); + dup2 (b_pipe[1], fileno (stdout)); + execvp (argv[0], argv); + _exit (127); + } + + close (f_pipe [0]); + close (b_pipe [1]); + + if (pid < 0) + { + error |= 1; + return; + } + + b_pipe_fd = fdopen (b_pipe[0], "r"); + error |= !b_pipe_fd; +#endif +} + +/* Convert a pointer to hex. */ + +void +_Jv_name_finder::toHex (void *p) +{ + unsigned long long n = (unsigned long long)p; + int digits = sizeof (void *) * 2; + + strcpy (hex, "0x"); + for (int i = digits - 1; i >= 0; i--) + { + int digit = n % 16; + + n /= 16; + hex[i+2] = digit > 9 ? 'a' + digit - 10 : '0' + digit; + } + hex [digits+2] = 0; +} + +/* Given a pointer to a function or method, try to convert it into a + name and the appropriate line and source file. The caller passes + the code pointer in p. + + Returns false if the lookup fails. Even if this happens, the field + he will have been correctly filled in with the pointer. */ + +bool +_Jv_name_finder::lookup (void *p) +{ + toHex (p); + +#ifdef HAVE_DLFCN_H + { + Dl_info dl_info; + + if (dladdr (p, &dl_info)) + { + strncpy (file_name, dl_info.dli_fname, sizeof file_name); + strncpy (method_name, dl_info.dli_sname, sizeof method_name); + return true; + } + } +#endif + +#if defined (HAVE_PIPE) && defined (HAVE_FORK) && defined (HAVE_EXECVP) + if (error) + return false; + + error |= write (f_pipe[1], hex, strlen (hex)) < 0; + if (error) + return false; + error |= write (f_pipe[1], "\n", 1) < 0; + if (error) + return false; + + error |= (fgets (method_name, sizeof method_name, b_pipe_fd) == NULL); + if (error) + return false; + error |= (fgets (file_name, sizeof file_name, b_pipe_fd) == NULL); + if (error) + return false; + + char *newline = strchr (method_name, '\n'); + if (newline) + *newline = 0; + newline = strchr (file_name, '\n'); + if (newline) + *newline = 0; + + return true; + +#else + return false; +#endif /* defined (HAVE_PIPE) && defined (HAVE_FORK) && defined (HAVE_EXECVP) */ +} diff --git a/libjava/prims.cc b/libjava/prims.cc index 2a413ae34036..f427a5adf369 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -16,6 +16,10 @@ details. */ #include #include +#ifdef HAVE_UNISTD_H +#include +#endif + #include #include #include @@ -68,6 +72,10 @@ const char **_Jv_Compiler_Properties; // Property key/value pairs. property_pair *_Jv_Environment_Properties; #endif + +// The name of this executable. +static char * _Jv_execName; + #ifdef HANDLE_SEGV @@ -75,6 +83,7 @@ static java::lang::NullPointerException *nullp; SIGNAL_HANDLER (catch_segv) { MAKE_THROW_FRAME; + nullp->fillInStackTrace (); _Jv_Throw (nullp); } #endif @@ -89,6 +98,7 @@ SIGNAL_HANDLER (catch_fpe) #else MAKE_THROW_FRAME; #endif + arithexception->fillInStackTrace (); _Jv_Throw (arithexception); } #endif @@ -638,8 +648,24 @@ static java::lang::ThreadGroup *main_group; // The primary thread. static java::lang::Thread *main_thread; +char * +_Jv_ThisExecutable (void) +{ + return _Jv_execName; +} + +void +_Jv_ThisExecutable (const char *name) +{ + if (name) + { + _Jv_execName = new char[strlen (name) + 1]; + strcpy (_Jv_execName, name); + } +} + static void -main_init (void) +main_init () { INIT_SEGV; #ifdef HANDLE_FPE @@ -812,6 +838,13 @@ JvRunMain (jclass klass, int argc, const char **argv) PROCESS_GCJ_PROPERTIES; main_init (); +#ifdef HAVE_PROC_SELF_EXE + char exec_name[20]; + sprintf (exec_name, "/proc/%d/exe", getpid ()); + _Jv_ThisExecutable (exec_name); +#else + _Jv_ThisExecutable (argv[0]); +#endif arg_vec = JvConvertArgv (argc - 1, argv + 1); main_group = new java::lang::ThreadGroup (23);