简体   繁体   English

强制Java / Eclipse在堆栈跟踪中提供更多信息

[英]Force Java/Eclipse to provide more information in a stack trace

While debugging a plugin in Eclipse, I see this exception: 在Eclipse中调试插件时,我看到以下异常:

!ENTRY org.eclipse.ui.monitoring 2 0 2016-02-16 10:43:21.573
!MESSAGE UI freeze of 0.63s at 10:43:20.943
!SUBENTRY 1 org.eclipse.ui.monitoring 1 0 2016-02-16 10:43:21.573
!MESSAGE Sample at 10:43:21.278 (+0.335s)
Thread 'main' tid=1 (RUNNABLE)
!STACK 0
java.lang.Exception: Stack Trace
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$1400(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:686)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:420)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at org.eclipse.osgi.storage.bundlefile.ZipBundleEntry$ZipBundleEntryInputStream.read(ZipBundleEntry.java:156)
    at org.eclipse.osgi.storage.StorageUtil.getBytes(StorageUtil.java:195)
    at org.eclipse.osgi.storage.bundlefile.BundleEntry.getBytes(BundleEntry.java:94)`
    ...

Given the nature of the code and the rest of the stack trace, I suspect Eclipse is having trouble reading a JAR archive on the file system. 考虑到代码的性质以及其余的堆栈跟踪,我怀疑Eclipse在读取文件系统上的JAR归档文件时遇到了麻烦。 There are many of these and I'd like to know which one. 其中有很多,我想知道是哪一个。 However the exception doesn't offer me that information. 但是,例外情况并未向我提供该信息。 This all happens inside Eclipse and JDK code (ie hasn't hit my plugin yet.) 所有这一切都发生在Eclipse和JDK代码内(即,还没有打我的插件。)

Is there some clever way I can hook into the relevant code to see which file it's trying to read and failing? 我可以通过某种巧妙的方法插入相关代码,以查看它尝试读取哪个文件并失败吗? I've set breakpoints at various locations. 我已经在各个位置设置了断点。 However it appears that Eclipse uses this same code to load hundreds of files or more, so clicking through each one is extremely tedious. 但是,看来Eclipse使用相同的代码来加载数百个或更多文件,因此单击每个文件都非常繁琐。

If you start Eclipse specifying -debug <path of debug file> on the command (or in the eclipse.ini) you can enable many debug options by setting values in the debug file. 如果您在命令中(或在eclipse.ini中)指定-debug <path of debug file>来启动Eclipse,则可以通过在调试文件中设置值来启用许多调试选项。

Many of the core Eclipse plugins have long lists of things you can turn on. 许多核心Eclipse插件都有很长的清单,您可以打开它们。 For the org.eclipse.osgi plugin shown in your log the options are: 对于日志中显示的org.eclipse.osgi插件,选项为:

#### Debugging options for org.eclipse.osgi

# Turn on general debugging for org.eclipse.osgi
org.eclipse.osgi/debug=false
# Prints out location debug information
org.eclipse.osgi/debug/location = false
# Prints out class loading debug information
org.eclipse.osgi/debug/loader=false
# Prints out event (FrameworkEvent/BundleEvent/ServiceEvent) and listener debug information
org.eclipse.osgi/debug/events=false
# Prints out OSGi service debug information (registration/getting/ungetting etc.)
org.eclipse.osgi/debug/services=false
# Prints out bundle manifest parsing debug information
org.eclipse.osgi/debug/manifest=false
# Prints out LDAP filter debug information
org.eclipse.osgi/debug/filter=false
# Prints out security (PermissionAdmin service) debug information
org.eclipse.osgi/debug/security=false
# Prints out start level service debug information
org.eclipse.osgi/debug/startlevel=false
# Prints out package admin service debug information
org.eclipse.osgi/debug/packageadmin=false
# Prints out timing information for bundle activation
org.eclipse.osgi/debug/bundleTime=false
# Debug the loading of message bundles
org.eclipse.osgi/debug/messageBundles=false
# Debug the object pool additions
org.eclipse.osgi/debug/objectPool/adds=false
# Debug the object pool duplications
org.eclipse.osgi/debug/objectPool/dups=false
# Debug the caching of bundle headers
org.eclipse.osgi/debug/cachedmanifest = false

# Eclipse adaptor options
org.eclipse.osgi/eclipseadaptor/debug = false
org.eclipse.osgi/eclipseadaptor/debug/platformadmin=false
org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver=false
org.eclipse.osgi/eclipseadaptor/converter/debug = false

### OSGi resolver options
# General debug option for the resolver. Enabling this option is equivalent to 
# enabling all other resolver debug options. 
org.eclipse.osgi/resolver = false
# Displays the current root bundle which is being resolved
org.eclipse.osgi/resolver/roots=false
# Displays information about matching capabilities returned to the resolver and
# why any were filtered out.
org.eclipse.osgi/resolver/providers = false
# Displays information about capabilities or resources that were filtered by 
# resolver hooks.
org.eclipse.osgi/resolver/hooks = false
# Displays information about uses constraint violations.
org.eclipse.osgi/resolver/uses = false
# Displays wiring information after the resolve process completes.
org.eclipse.osgi/resolver/wiring = false
# Displays the resolution report information.
org.eclipse.osgi/resolver/report = false


#### Monitoring settings

# monitor eager bundle activation
org.eclipse.osgi/monitor/activation=false
# monitor lazy bundle activation
org.eclipse.osgi/monitor/lazy=false

To enable any of the options you must always set 要启用任何选项,您必须始终设置

org.eclipse.osgi/debug=true

and then set the other options you want to true 然后将其他选项设置为true

Recent releases of Eclipse also provide the 'General > Tracing' page in the Preferences to set these values. Eclipse的最新发行版还在“首选项”中提供了“常规>跟踪”页面来设置这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM