3

我的设置:

  • Windows 64 位
  • Java 应用程序加载 32 位原生模块
  • 可以使用 32 位 Java (jdk1.6.0_29) 和以下命令行在调试器外正常运行 - “-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug ...”(为简洁起见)

如果我想调试本机模块,问题就开始了。因此,我使用以下 powershell 命令行启动了我的 windbg 64 位:

windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;bu $entry;g;g" "$env:JAVA_HOME\bin\java.exe" $Params

$Params用于在调试器之外运行它的完全相同的参数在哪里。

调试器启动,但会话非常短:

Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: "c:\Program Files (x86)\Java\jdk1.6.0_29\bin\java.exe" "-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper"
Symbol search path is: C:\dev\shunra\DriverProxy\CloudAPI\CLOUDAPI\Profile\Stratus;C:\dev\shunra\DriverProxy\LocalDriverProxy\Profile;C:\dev\shunra\SharedModules\cJSON\lib\win32\Profile;C:\dev\shunra\SharedModules\curl\lib\win32\Profile;C:\dev\shunra\SharedModules\DataStruct\lib\win32\profile;C:\dev\shunra\SharedModules\GraphSetup\lib\win32\profile;C:\dev\shunra\SharedModules\multikey_lookup\lib\win32\profile;C:\dev\shunra\SharedModules\ShunraAPICommon\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIEmulation\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIParsers\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIRest\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraUtils\lib\win32\profile;C:\dev\shunra\SharedModules\ShunraXercesUtils\lib\win32\profile;C:\dev\shunra\SharedModules\SNetXMLBuilder\lib\win32\profile;C:\dev\shunra\SharedModules\StormEngine\lib\win32\profile;C:\dev\shunra\SharedModules\xerces-c-2.80\Build\Win32\VC10\Profile;C:\dev\shunra\SharedModules\XMLControl\lib\win32\profile;srv*Z:\Symbols*http://msdl.microsoft.com/download/symbols
Executable search path is: 
ModLoad: 00000000`00400000 00000000`00424000   java.exe
ModLoad: 00000000`77540000 00000000`776e9000   ntdll.dll
ModLoad: 00000000`77720000 00000000`778a0000   ntdll32.dll
ModLoad: 00000000`74da0000 00000000`74ddf000   C:\Windows\SYSTEM32\wow64.dll
ModLoad: 00000000`74d40000 00000000`74d9c000   C:\Windows\SYSTEM32\wow64win.dll
ModLoad: 00000000`74d30000 00000000`74d38000   C:\Windows\SYSTEM32\wow64cpu.dll
(684.e30): Break instruction exception - code 80000003 (first chance)
Processing initial command '!sw;bu LocalDriverProxy!Java_com_shunra_vcat_core_emulation_LocalDriverProxy_StartEmulation;g;g'
ntdll!LdrpDoDebuggerBreak+0x30:
00000000`775ecb60 cc              int     3
0:000> !sw;bu LocalDriverProxy!Java_com_shunra_vcat_core_emulation_LocalDriverProxy_StartEmulation;g;g
Switched to 32bit mode
ModLoad: 76e60000 76f7f000   WOW64_IMAGE_SECTION
ModLoad: 00000000`75300000 00000000`75410000   WOW64_IMAGE_SECTION
ModLoad: 00000000`76e60000 00000000`76f7f000   NOT_AN_IMAGE
ModLoad: 00000000`77190000 00000000`7728a000   NOT_AN_IMAGE
ModLoad: 00000000`75300000 00000000`75410000   C:\Windows\syswow64\kernel32.dll
ModLoad: 00000000`752b0000 00000000`752f7000   C:\Windows\syswow64\KERNELBASE.dll
ModLoad: 00000000`769a0000 00000000`76a40000   C:\Windows\syswow64\ADVAPI32.dll
ModLoad: 00000000`76710000 00000000`767bc000   C:\Windows\syswow64\msvcrt.dll
ModLoad: 00000000`76390000 00000000`763a9000   C:\Windows\SysWOW64\sechost.dll
ModLoad: 00000000`75410000 00000000`75500000   C:\Windows\syswow64\RPCRT4.dll
ModLoad: 00000000`74e00000 00000000`74e60000   C:\Windows\syswow64\SspiCli.dll
ModLoad: 00000000`74df0000 00000000`74dfc000   C:\Windows\syswow64\CRYPTBASE.dll
(684.e30): WOW64 breakpoint - code 4000001f (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
ModLoad: 74860000 748ac000   C:\Windows\SysWOW64\apphelp.dll
ModLoad: 00000000`7c340000 00000000`7c396000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\msvcr71.dll
ModLoad: 00000000`6d8a0000 00000000`6db4f000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\client\jvm.dll
ModLoad: 00000000`76610000 00000000`76710000   C:\Windows\syswow64\USER32.dll
ModLoad: 00000000`76c20000 00000000`76cb0000   C:\Windows\syswow64\GDI32.dll
ModLoad: 00000000`74ee0000 00000000`74eea000   C:\Windows\syswow64\LPK.dll
ModLoad: 00000000`76190000 00000000`7622d000   C:\Windows\syswow64\USP10.dll
ModLoad: 00000000`747e0000 00000000`74812000   C:\Windows\SysWOW64\WINMM.dll
ModLoad: 00000000`76af0000 00000000`76b50000   C:\Windows\SysWOW64\IMM32.DLL
ModLoad: 00000000`76b50000 00000000`76c1c000   C:\Windows\syswow64\MSCTF.dll
ModLoad: 00000000`74860000 00000000`748ac000   C:\Windows\SysWOW64\apphelp.dll
ModLoad: 00000000`6d850000 00000000`6d85c000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\verify.dll
ModLoad: 00000000`6d3d0000 00000000`6d3ef000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\java.dll
ntdll!NtTerminateProcess+0xa:
00000000`775915da c3              ret

菲尼托!Java 终止在控制台窗口中打印此短消息:

Invalid initial heap size: -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file
:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper
Could not create the Java virtual machine.

任何人都可以对此有所了解吗?

编辑

在下面的一些评论之后,我倾向于认为我的 powershell 脚本有问题。

事实上,正如 Jon Skeet 所建议的那样,我尝试使用相同的 -XYZ 参数从调试器中运行 HelloWorld Java 应用程序,并且它有效。然后是 Codo 的评论,这让我觉得我的 powershell 代码有问题。

这里是:

$env:JAVA_HOME='c:\Program Files (x86)\Java\jdk1.6.0_29'
$Params="-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper"
windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" $Params

$Params似乎作为单个字符串传递给java进程。好的,所以我扩展它:

windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper

现在我得到一个由 java 打印出的不同的致命错误:

Exception in thread "main" java.lang.NoClassDefFoundError: /debug
Caused by: java.lang.ClassNotFoundException: .debug
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: .debug.  Program will exit.

它想从我的生活中得到什么?

编辑2

根据 Codo 的建议更改了命令行:

windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug=true -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper

现在错误是:

Exception in thread "main" java.lang.NoClassDefFoundError: /debug=true
Caused by: java.lang.ClassNotFoundException: .debug=true
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: .debug=true.  Program will exit.

这意味着-Dlog4j.debug=true被解释为类名,而不是 JVM 选项。我不明白发生了什么事。

4

0 回答 0