Patch: FYI: stacktrace.cc fixlet

Tom Tromey tromey@redhat.com
Sun May 15 17:05:00 GMT 2005


I'm checking this in on the trunk.

Without this patch, gcjappletviewer crashes if an exception is
thrown, since _Jv_argv is NULL.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* stacktrace.cc (getLineNumberForFrame): Use _Jv_GetSafeArg.

Index: stacktrace.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/stacktrace.cc,v
retrieving revision 1.6
diff -u -r1.6 stacktrace.cc
--- stacktrace.cc 24 Mar 2005 00:04:02 -0000 1.6
+++ stacktrace.cc 15 May 2005 17:04:42 -0000
@@ -184,13 +184,13 @@
 #endif
   // Use dladdr() to determine in which binary the address IP resides.
 #if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
-  extern char **_Jv_argv;
   Dl_info info;
   jstring binaryName = NULL;
+  const char *argv0 = _Jv_GetSafeArg(0);
 
   void *ip = frame->ip;
   _Unwind_Ptr offset = 0;
-  
+
   if (dladdr (ip, &info))
     {
       if (info.dli_fname)
@@ -199,7 +199,7 @@
         return;
 
       // addr2line expects relative addresses for shared libraries.
-      if (strcmp (info.dli_fname, _Jv_argv[0]) == 0)
+      if (strcmp (info.dli_fname, argv0) == 0)
         offset = (_Unwind_Ptr) ip;
       else
         offset = (_Unwind_Ptr) ip - (_Unwind_Ptr) info.dli_fbase;



More information about the Java-patches mailing list