This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [MinGW] RFC/RFA: Get Partial Stack Traces on Windows
- From: Andrew Haley <aph at redhat dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: GCJ Patches <java-patches at gcc dot gnu dot org>, mckinlay at redhat dot com
- Date: Mon, 26 Jun 2006 20:05:44 +0100
- Subject: Re: [MinGW] RFC/RFA: Get Partial Stack Traces on Windows
- References: <44A02481.207@gmail.com>
Ranjit Mathew writes:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> [Bryce, CC-ing you explicitly to get your opinion on the
> fallback_backtrace() changes.]
>
> iD8DBQFEoCSBYb1hx2wRS48RAqBeAJ4+nJapJ8bjLC3WS8v2YiM0UHHXRQCgiC4o
> Iay49ETYGKAZocPmjAmujvo=
> =mGTH
> -----END PGP SIGNATURE-----
> Index: ChangeLog
> from Ranjit Mathew <rmathew@gcc.gnu.org>
>
> * sysdep/i386/backtrace.h (fallback_backtrace): Check that a potential
> frame pointer value is 32-bit word-aligned. Use operand of the CALL
> instruction calling the current function to find its starting address.
> * stacktrace.cc: Include platform.h.
> (_Jv_StackTrace::getLineNumberForFrame): Use VirtualQuery() trick on
> Windows to find the module containing a given address.
> (_Jv_StackTrace::GetStackTraceElements): Use nCodeMap even for Windows.
> (_Jv_StackTrace::GetClassContext): Use fallback_backtrace() for
> targets with SJLJ exceptions instead of using _Unwind_Backtrace().
> (_Jv_StackTrace::GetFirstNonSystemClassLoader): Likewise.
What happens with -findirect-dispatch?
> Index: sysdep/i386/backtrace.h
> ===================================================================
> --- sysdep/i386/backtrace.h (revision 114838)
> +++ sysdep/i386/backtrace.h (working copy)
> @@ -1,6 +1,6 @@
> // backtrace.h - Fallback backtrace implementation. i386 implementation.
>
> -/* Copyright (C) 2005 Free Software Foundation
> +/* Copyright (C) 2005, 2006 Free Software Foundation
>
> This file is part of libgcj.
>
> @@ -29,12 +29,37 @@ fallback_backtrace (_Jv_UnwindState *sta
> rfp && i < state->length;
> rfp = *(unsigned int **)rfp)
> {
> + /* Sanity checks to eliminate dubious-looking frame pointer chains.
> + The frame pointer should be a 32-bit word-aligned stack address.
> + Since the stack grows downwards on x86, the frame pointer must have
> + a value greater than the current value of the stack pointer, it
> + should not be below the supposed next frame pointer and it should
> + not be too far off from the supposed next frame pointer. */
> int diff = *rfp - (unsigned int)rfp;
> - if ((void*)rfp < _esp || diff > 4 * 1024 || diff < 0)
> + if (((unsigned int)rfp & 0x00000003) != 0 || (void*)rfp < _esp
Don't use unsigned int for a pointer; instead use
int __attribute__((mode(pointer))). This is an int that is exactly the
same size as a pointer.
Andrew.