Translate between managaed java and unmanaged jvm

Discussion in 'Java' started by JR, May 13, 2010.

  1. JR

    JR Guest

    Hello All -
    When I debug .net ihave the docs and automated tool to interpret .net
    managed objects from unmanaged code. So when i dump a native callstack
    and see mscorwks.dll->CallMethDesc, i know that that is the native
    code used to call into the .net managed code. I can then translate
    mscorwks.dll->CallMethDesc to myclass->myNetFunction with one command.
    This way i can debug mixed managed and unmanaged code very easily. I
    assumed Java would be similiar but i have ben unabale to find tools or
    documents that explain what method(s) in jvm.dll actually invoke the
    managed java methods and how to get that info. For example, I have
    this stack


    08c3faac 7c827d0b 77e61d1e 000005ec 00000000 ntdll!KiFastSystemCallRet
    08c3fab0 77e61d1e 000005ec 00000000 00000000 ntdll!
    NtWaitForSingleObject+0xc
    08c3fb20 77e61c8d 000005ec ffffffff 00000000 kernel32!
    WaitForSingleObjectEx+0xac
    08c3fb34 080a686e 000005ec ffffffff 0334b7e0 kernel32!
    WaitForSingleObject+0x12
    08c3fb70 080c119d 0334b660 1e20dd80 0334b660 jvm!JVM_FindSignal
    +0x19be2
    08c3fb90 0806aee5 0334b7e0 08c3fbc4 0334b660 jvm!
    JVM_RegisterPerfMethods+0x13126
    08c3fbb0 00887a7e 0334b660 08c3fbc4 00887a52 jvm+0x6aee5
    08c3fbe8 00882c03 00000000 00000000 103f98f8 0x887a7e
    08c3fc1c 00882c03 00000000 103f98f8 103f9558 0x882c03
    08c3fc50 00882cda 103f9558 1e20de20 08c3fc60 0x882c03
    08c3fd64 08070c8a 08c3fd98 08c3ff3c 0000000a 0x882cda
    08c3fde4 080aab6d 0000000a 00000000 08c3fe94 jvm+0x70c8a
    08c3fe20 08070b97 08070b9c 08c3ff34 08c3fe48 jvm!JVM_FindSignal
    +0x1dee1
    08c3fe3c 08070893 08c3ff34 0334b7dc 08c3fe94 jvm+0x70b97

    i know this is executing a managed function but don't know how to get
    that data. Does anyone know the tools or methods used to do this? It
    looks like the jvm!JVM_FindSignal function is responsible for setting
    up and calling managed java code but i am not sure.
    JR, May 13, 2010
    #1
    1. Advertising

  2. JR

    Arne Vajhøj Guest

    On 13-05-2010 17:46, JR wrote:
    > When I debug .net ihave the docs and automated tool to interpret .net
    > managed objects from unmanaged code. So when i dump a native callstack
    > and see mscorwks.dll->CallMethDesc, i know that that is the native
    > code used to call into the .net managed code. I can then translate
    > mscorwks.dll->CallMethDesc to myclass->myNetFunction with one command.
    > This way i can debug mixed managed and unmanaged code very easily. I
    > assumed Java would be similiar but i have ben unabale to find tools or
    > documents that explain what method(s) in jvm.dll actually invoke the
    > managed java methods and how to get that info.


    managed-unmanaged is not prioritized as high i Java as
    in .NET, so I am not surprised that the tool support is
    not as good.

    But somewhere there must be some map for jvm.dll.

    The extreme solution for you would be to get OpenJDK
    and build it with the options to debug it.

    Arne
    Arne Vajhøj, May 14, 2010
    #2
    1. Advertising

  3. JR

    Lew Guest

    JR wrote:
    > When I debug .net i [sic]have the docs and automated tool to interpret .net
    > managed objects from unmanaged code. So when i [sic] dump a native callstack
    > and see mscorwks.dll->CallMethDesc, i [sic] know that that is the native
    > code used to call into the .net managed code. I can then translate
    > mscorwks.dll->CallMethDesc to myclass->myNetFunction with one command.
    > This way i [sic] can debug mixed managed and unmanaged code very easily. I
    > assumed Java would be similiar but i [sic] have ben unabale to find tools or
    > documents that explain what method(s) in jvm.dll actually invoke the
    > managed java [sic] methods and how to get that info. For example, I have
    > this stack
    >
    >
    > 08c3faac 7c827d0b 77e61d1e 000005ec 00000000 ntdll!KiFastSystemCallRet
    > 08c3fab0 77e61d1e 000005ec 00000000 00000000 ntdll!
    > NtWaitForSingleObject+0xc
    > 08c3fb20 77e61c8d 000005ec ffffffff 00000000 kernel32!
    > WaitForSingleObjectEx+0xac
    > 08c3fb34 080a686e 000005ec ffffffff 0334b7e0 kernel32!
    > WaitForSingleObject+0x12
    > 08c3fb70 080c119d 0334b660 1e20dd80 0334b660 jvm!JVM_FindSignal
    > +0x19be2
    > 08c3fb90 0806aee5 0334b7e0 08c3fbc4 0334b660 jvm!
    > JVM_RegisterPerfMethods+0x13126
    > 08c3fbb0 00887a7e 0334b660 08c3fbc4 00887a52 jvm+0x6aee5
    > 08c3fbe8 00882c03 00000000 00000000 103f98f8 0x887a7e
    > 08c3fc1c 00882c03 00000000 103f98f8 103f9558 0x882c03
    > 08c3fc50 00882cda 103f9558 1e20de20 08c3fc60 0x882c03
    > 08c3fd64 08070c8a 08c3fd98 08c3ff3c 0000000a 0x882cda
    > 08c3fde4 080aab6d 0000000a 00000000 08c3fe94 jvm+0x70c8a
    > 08c3fe20 08070b97 08070b9c 08c3ff34 08c3fe48 jvm!JVM_FindSignal
    > +0x1dee1
    > 08c3fe3c 08070893 08c3ff34 0334b7dc 08c3fe94 jvm+0x70b97
    >
    > i [sic] know this is executing a managed function but don't know how to get
    > that data. Does anyone know the tools or methods used to do this? It
    > looks like the jvm!JVM_FindSignal function is responsible for setting
    > up and calling managed java [sic] code but i [sic] am not sure.


    Don't do that.

    The word "managed" has no relevance in Java because the word "unmanaged" has
    no meaning. Everything is "managed". There is no "managed function", just
    "method".

    --
    Lew
    Lew, May 14, 2010
    #3
  4. JR

    JR Guest

    On May 13, 6:26 pm, Lew <> wrote:
    > JR wrote:
    > > When I debug .net i [sic]have the docs and automated tool to interpret ..net
    > > managed objects from unmanaged code. So when i [sic] dump a native callstack
    > > and see mscorwks.dll->CallMethDesc, i [sic] know that that is the native
    > > code used to call into the .net managed code. I can then translate
    > > mscorwks.dll->CallMethDesc to myclass->myNetFunction with one command.
    > > This way i [sic] can debug mixed managed and unmanaged code very easily.. I
    > > assumed Java would be similiar but i [sic] have ben unabale to find tools or
    > > documents that explain what method(s) in jvm.dll actually invoke the
    > > managed java [sic] methods and how to get that info. For example, I have
    > > this stack

    >
    > > 08c3faac 7c827d0b 77e61d1e 000005ec 00000000 ntdll!KiFastSystemCallRet
    > > 08c3fab0 77e61d1e 000005ec 00000000 00000000 ntdll!
    > > NtWaitForSingleObject+0xc
    > > 08c3fb20 77e61c8d 000005ec ffffffff 00000000 kernel32!
    > > WaitForSingleObjectEx+0xac
    > > 08c3fb34 080a686e 000005ec ffffffff 0334b7e0 kernel32!
    > > WaitForSingleObject+0x12
    > > 08c3fb70 080c119d 0334b660 1e20dd80 0334b660 jvm!JVM_FindSignal
    > > +0x19be2
    > > 08c3fb90 0806aee5 0334b7e0 08c3fbc4 0334b660 jvm!
    > > JVM_RegisterPerfMethods+0x13126
    > > 08c3fbb0 00887a7e 0334b660 08c3fbc4 00887a52 jvm+0x6aee5
    > > 08c3fbe8 00882c03 00000000 00000000 103f98f8 0x887a7e
    > > 08c3fc1c 00882c03 00000000 103f98f8 103f9558 0x882c03
    > > 08c3fc50 00882cda 103f9558 1e20de20 08c3fc60 0x882c03
    > > 08c3fd64 08070c8a 08c3fd98 08c3ff3c 0000000a 0x882cda
    > > 08c3fde4 080aab6d 0000000a 00000000 08c3fe94 jvm+0x70c8a
    > > 08c3fe20 08070b97 08070b9c 08c3ff34 08c3fe48 jvm!JVM_FindSignal
    > > +0x1dee1
    > > 08c3fe3c 08070893 08c3ff34 0334b7dc 08c3fe94 jvm+0x70b97

    >
    > > i [sic] know this is executing a managed function but don't know how to get
    > > that data. Does anyone know the tools or methods used to do this? It
    > > looks like the jvm!JVM_FindSignal function is responsible for setting
    > > up and calling managed java [sic] code but i [sic] am not sure.

    >
    > Don't do that.
    >
    > The word "managed" has no relevance in Java because the word "unmanaged" has
    > no meaning.  Everything is "managed". There is no "managed function", just
    > "method".
    >
    > --
    > Lew- Hide quoted text -
    >
    > - Show quoted text -


    consider it native code run by cpu vs byte code run by jvm.

    You understand what im getting at though right?
    JR, May 14, 2010
    #4
  5. On 13-05-2010 19:26, Lew wrote:
    > The word "managed" has no relevance in Java because the word "unmanaged"
    > has no meaning. Everything is "managed". There is no "managed function",
    > just "method".


    It is .NET terminology.

    Translation to Java:

    managed = Java code
    unmanaged = native code

    Arne
    Arne Vajhøj, May 14, 2010
    #5
  6. JR

    JR Guest

    On May 13, 6:46 pm, Arne Vajhøj <> wrote:
    > On 13-05-2010 19:26, Lew wrote:
    >
    > > The word "managed" has no relevance in Java because the word "unmanaged"
    > > has no meaning. Everything is "managed". There is no "managed function",
    > > just "method".

    >
    > It is .NET terminology.
    >
    > Translation to Java:
    >
    > managed = Java code
    > unmanaged = native code
    >
    > Arne


    k, so given a windows crash dump how would one determine what java
    code was being run by the jvm?
    JR, May 14, 2010
    #6
  7. JR

    Lew Guest

    Lew wrote:
    >> The word "managed" has no relevance in Java because the word "unmanaged"
    >> has no meaning. Everything is "managed". There is no "managed function",
    >> just "method".


    Arne Vajhøj wrote:
    > It is .NET terminology.
    >
    > Translation to Java:
    >
    > managed = Java code
    > unmanaged = native code


    That is instructive. I thought "unmanaged" code in .Net (with which I'm
    barely passingly familiar) meant high-level code still (e.g., C#), but without
    the memory-management features (GC).

    --
    Lew
    Lew, May 14, 2010
    #7
  8. JR

    Lew Guest

    JR wrote:
    > consider it native code run by cpu vs byte code run by jvm.
    >
    > You understand what im [sic] getting at though right?


    Now I do, thanks to your and Arne's explanations. I don't get why you need
    that information.

    Also, the native code run in the JVM changes during execution, at least with
    the Hotspot compiler, as optimizations come and go.

    Much more convenient that non-portably hacking the JVM, I'd think, would be
    using the inbuilt debugging facilities of the JVM, which explicitly provide
    for peering into the methods and data in use by a program.

    --
    Lew
    Lew, May 14, 2010
    #8
  9. On 13-05-2010 20:31, Lew wrote:
    > Lew wrote:
    >>> The word "managed" has no relevance in Java because the word "unmanaged"
    >>> has no meaning. Everything is "managed". There is no "managed function",
    >>> just "method".

    >
    > Arne Vajhøj wrote:
    >> It is .NET terminology.
    >>
    >> Translation to Java:
    >>
    >> managed = Java code
    >> unmanaged = native code

    >
    > That is instructive. I thought "unmanaged" code in .Net (with which I'm
    > barely passingly familiar) meant high-level code still (e.g., C#), but
    > without the memory-management features (GC).


    The very short version is that:

    managed code = C# code

    unmanaged code = C/C++ code called via one of DllImport, COM interop or
    mixed mode C++.

    Arne
    Arne Vajhøj, May 14, 2010
    #9
  10. JR

    Arne Vajhøj Guest

    On 13-05-2010 20:37, Thomas Pornin wrote:
    > According to Lew<>:
    >> That is instructive. I thought "unmanaged" code in .Net (with which
    >> I'm barely passingly familiar) meant high-level code still (e.g., C#),
    >> but without the memory-management features (GC).

    >
    > Well, C# has that, too. C# syntax tends to agglomerate features quite
    > fast. You can have "unmanaged" C# code, with C-like things like explicit
    > pointer arithmetic. But the term "unmanaged" is also used to describe
    > native code. Basically, in the .NET world, "managed" means "code where
    > types, array accesses, memory management,... is under strict control of
    > the VM" and "unmanaged" means "whatever is not managed".


    Unmanaged code is native code. You can not produce that with
    Microsofts C# compiler. C# code does not become unmanaged just
    by using unsafe features.

    C# managed code can somewhat work with unmanaged data though
    interop classes.

    Arne
    Arne Vajhøj, May 14, 2010
    #10
  11. Thomas Pornin wrote:
    > According to Lew <>:
    >> That is instructive. I thought "unmanaged" code in .Net (with which
    >> I'm barely passingly familiar) meant high-level code still (e.g.,
    >> C#), but without the memory-management features (GC).

    >
    > Well, C# has that, too. C# syntax tends to agglomerate features quite
    > fast. You can have "unmanaged" C# code, with C-like things like
    > explicit pointer arithmetic.


    That's "unsafe" code. "Unmanaged" code means code that's not produced from
    ..NET IL.
    Mike Schilling, May 14, 2010
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Hooke

    Re: Handling both MS JVM and Sun JVM

    Kevin Hooke, Aug 26, 2003, in forum: Java
    Replies:
    2
    Views:
    873
  2. Lasse
    Replies:
    1
    Views:
    698
    Jon A. Cruz
    Jan 5, 2004
  3. Young-Jin Lee

    MS JVM and Sun JVM problem

    Young-Jin Lee, Jan 20, 2004, in forum: Java
    Replies:
    3
    Views:
    571
    Mickey Segal
    Jan 21, 2004
  4. Replies:
    9
    Views:
    510
    Chris Uppal
    Jan 4, 2005
  5. Satya
    Replies:
    1
    Views:
    1,237
    jmcgill
    May 16, 2006
Loading...

Share This Page