This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't reference main() in stacktrace.cc on MinGW


Aaron W. LaFramboise wrote:
The generic i386 fall-back unwinder has logic to stop early at main(). However, on Windows, main() isn't always available, primarily when we're in a shared library (DLL). Also, when libgcj is linked as a DLL (patch coming soon), the 'main' symbol doesn't have the proper dynamic linkage to get the one we want, so things won't work.

This patch fixes this issue by removing this stopping condition on Windows.

I tested this by building a static libjava on i386-pc-mingw32.

OK to commit?

Patch attached.


2008-08-21  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>

	* sysdep/i386/backtrace.h (DONT_REFERENCE_MAIN) [_WIN32]: New.
	(fallback_backtrace) [DONT_REFERENCE_MAIN]: Don't generate references to main().

Index: sysdep/i386/backtrace.h
===================================================================
--- sysdep/i386/backtrace.h	(revision 139186)
+++ sysdep/i386/backtrace.h	(working copy)
@@ -13,7 +13,13 @@ details.  */
 
 #include <java-stack.h>
 
+#ifdef _WIN32
+#define DONT_REFERENCE_MAIN
+#endif
+
+#ifndef DONT_REFERENCE_MAIN
 extern int main (int, char **);
+#endif
 
 /* The context used to keep track of our position while unwinding through
    the call stack.  */
@@ -104,7 +110,10 @@ fallback_backtrace (_Unwind_Trace_Fn tra
                             const char **, bool))_Jv_RunMain;
       if (ctx.meth_addr == (_Jv_uintptr_t)jv_runmain
           || ctx.meth_addr == (_Jv_uintptr_t)_Jv_ThreadStart
-          || (ctx.meth_addr - (_Jv_uintptr_t)main) < 16)
+#ifndef DONT_REFERENCE_MAIN
+          || (ctx.meth_addr - (_Jv_uintptr_t)main) < 16
+#endif
+          )
         break;
     }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]