public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dave Korn <dave.korn.cygwin@googlemail.com>
To: java@gcc.gnu.org
Cc: Dave Korn <dave.korn.cygwin@googlemail.com>
Subject: Re: Question about a comment in _Jv_StackTrace::UnwindTraceFn
Date: Fri, 22 May 2009 01:12:00 -0000	[thread overview]
Message-ID: <4A15FE9C.1040801@gmail.com> (raw)
In-Reply-To: <4A158C3A.7000705@redhat.com>

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

  reply	other threads:[~2009-05-22  1:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21 16:50 Dave Korn
2009-05-21 17:15 ` Andrew Haley
2009-05-22  1:12   ` Dave Korn [this message]
2009-05-21 17:17 ` Bryce McKinlay
2009-05-21 18:53   ` Dave Korn
2009-05-21 19:13     ` Dave Korn
2009-05-21 20:36     ` Dave Korn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A15FE9C.1040801@gmail.com \
    --to=dave.korn.cygwin@googlemail.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).