From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1035 invoked by alias); 22 May 2009 01:12:16 -0000 Received: (qmail 1017 invoked by uid 22791); 22 May 2009 01:12:14 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_50,SPF_PASS,WEIRD_PORT X-Spam-Check-By: sourceware.org Received: from mail-ew0-f157.google.com (HELO mail-ew0-f157.google.com) (209.85.219.157) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 May 2009 01:12:08 +0000 Received: by ewy1 with SMTP id 1so1725296ewy.8 for ; Thu, 21 May 2009 18:12:05 -0700 (PDT) Received: by 10.210.39.2 with SMTP id m2mr131706ebm.26.1242954725739; Thu, 21 May 2009 18:12:05 -0700 (PDT) Received: from ?192.168.2.99? (cpc2-cmbg8-0-0-cust61.cmbg.cable.ntl.com [82.6.108.62]) by mx.google.com with ESMTPS id 28sm5106325eyg.24.2009.05.21.18.12.05 (version=SSLv3 cipher=RC4-MD5); Thu, 21 May 2009 18:12:05 -0700 (PDT) Message-ID: <4A15FE9C.1040801@gmail.com> Date: Fri, 22 May 2009 01:12:00 -0000 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: java@gcc.gnu.org CC: Dave Korn Subject: Re: Question about a comment in _Jv_StackTrace::UnwindTraceFn References: <4A15890E.30001@gmail.com> <4A158C3A.7000705@redhat.com> In-Reply-To: <4A158C3A.7000705@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00060.txt.bz2 Andrew Haley wrote: > Dave Korn wrote: >> 124 // the java code and not the interpreter itself. This assumes a 1:1 >> 125 // correspondance between call frames in the interpreted stack and >> occurances >> 126 // of _Jv_InterpMethod::run() on the native stack. >> 127 #ifdef INTERPRETER >> 128 void *interp_run = NULL; >> 129 >> 130 if (::gnu::classpath::jdwp::Jdwp::isDebugging) >> (gdb) >> 131 interp_run = (void *) &_Jv_InterpMethod::run_debug; >> 132 else >> 133 interp_run = (void *) &_Jv_InterpMethod::run; >> 134 >> 135 if (func_addr == UNWRAP_FUNCTION_DESCRIPTOR (interp_run)) >> 136 { >> 137 state->frames[pos].type = frame_interpreter; >> 138 _Jv_Frame *frame = static_cast<_Jv_Frame *> (state->interp_frame); >> 139 state->frames[pos].interp.meth >> 140 = static_cast<_Jv_InterpMethod *> (frame->self); > #23 0x0043e86b in _Jv_Linker::resolve_pool_entry (klass=0x294d4c0, index=97, > lazy=false) at /gnu/gcc/gcc-patched/libjava/link.cc:440 > #24 0x0044e695 in _Jv_InterpMethod::run (retp=0x22cb40, args=0x22cb60, > meth=0x292e870) at /gnu/gcc/gcc-patched/libjava/interpret-run.cc:2385 > #25 0x00780c45 in ffi_closure_raw_SYSV () > at /gnu/gcc/gcc-patched/libffi/src/x86/win32.S:338 > #26 0x0044836c in java::lang::Class::initializeClass (this=0x294d4c0) >> ... there is a single call to _Jv_InterpMethod::run, at frame #24, coming from >> a call to ffi_closure_raw_SYSV. And that's where it goes wrong. _Unwind_Backtrace happily unwinds the stack all the way down through _Jv_Linker::resolve_pool_entry calling the unwind hook, which does nothing in each case. It unwinds one more frame level, reaching _Jv_InterpMethod::run, and calls the hook, which this time pops the (one and only) interpreter frame. _Unwind_Backtrace unwinds one more level and then calls the hook again - but the _Unwind_Context it passes is still the same as last time - it has not been updated, and still points at _Jv_InterpMethod::run. So the hook attempts to pop another interpreter frame, and that's when it falls off the end of the linklist and dies. I think the explanation why _Unwind_Backtrace fails to update the context and calls the stack trace hook with the same context for the run method twice is pretty simple: there's no eh_frame data for the calling function ffi_closure_raw_SYSV. All the other .S files in libffi/src/$arch/ have a hand-written .eh_frame section, but x86/win32.S is lacking one. The solution is now obvious, but not easy. I'll be off in the corner with a copy of the Dwarf spec for a while, learning how to hand-craft CIEs and FDEs and all those things. If anyone knows of a handy tool or shortcut that can help me with that task, please drop me a reply, because I don't know of any option apart from doing it manually. cheers, DaveK