IBM JDK生成Javacore的方法

什么是IBM SDK, Java Technology Edition

    IBM SDK, Java Technology Edition是IBM对Java标准的实现。如下图所展示的JDK,JRE,JVM和JIT之间的关系,Java实现“Write once, run anywhere”,是因为JVM处理了不同硬件平台的差异。IBM有自己独特的操作系统,AIX,Z/OS,因此有必要在此之上实现自己的JVM。另一方面,IBM的中间件WebSphere Application Server基于IBM自有的JDK,Oracle JDK的目标是即面向桌面应用也面向企业应用、甚至包括移动应用,IBM自有的JDK主要面向企业应用,针对企业应用的特性做了优化,也形成了自己独特的竞争优势。

如何生成javacore

    javacore在诊断Java相关的问题时非常重要。根据IBM JDK的文档,有以下的方法可以选择生成Javacore:
1. JVM执行异常时,自动生成Javacore
1.1 发生了引起JVM停止运行的本地错误时,会自动产生Javacore文件
1.2 JVM内存不足时,会自动产生Javacore文件
2. 触发JVM生成JDK
2.1 (常用)从命令行中发出kill -3 <pid>指令,生成Javacore
2.2 在应用中调用com.ibm.jvm.Dump.JavaDump()方法,生成Javacore
2.3 使用WAS wsadmin utility命令生成Javacore, 以Jython语言为例:
jvm = AdminControl.completeObjectName('type=JVM,process=server1,*')
AdminControl.invoke(jvm, 'dumpThreads')
2.4 可以配置dump agent触发生成Javacore
dump agent提供了一些可配置的选项,详细见文档
生成Javacore可以响应的事件列表如下:
  • gpf: A General Protection Fault (GPF) occurs.
  • user: The JVM receives the SIGQUIT (Linux, AIX®, z/OS®, and i5/OS™) or SIGBREAK (Windows) signal from the operating system.
  • abort: The JVM receives the SIGABRT signal from the operating system.
  • vmstart: The virtual machine is started.
  • vmstop: The virtual machine stops.
  • load: A class is loaded.
  • unload: A class is unloaded.
  • throw: An exception is thrown.
  • catch: An exception is caught.
  • uncaught: A Java™ exception is not caught by the application.
  • systhrow: A Java exception is about to be thrown by the JVM. This is different from the 'throw' event because it is only triggered for error conditions detected internally in the JVM.
  • thrstart: A new thread is started.A new thread is started.
  • blocked: A thread becomes blocked.
  • thrstop: thrstopA thread stops.
  • fullgc: A garbage collection cycle is started.
  • slow: A thread takes longer than 50ms to respond to an internal JVM request.
  • allocation: A Java object is allocated with a size matching the given filter specification
  • traceassert: An internal error occurs in the JVM

2.5 可以使用trigger trace选项生成Javacore

例如:-Xtrace:trigger=method{java/lang/String.substring,javadump}
Trace trigger的配置是 -Xtrace:trigger=trigger=<clause>[,<clause>][,<clause>]...
条件可以是:
method{<methodspec>[,<entryAction>[,<exitAction>[,<delayCount>[,<matchcount>]]]]}
On entering a method that matches <methodspec>, the specified <entryAction> is run. On leaving a method that matches <methodspec>, the specified <exitAction> is run. If you specify a <delayCount>, the actions are performed only after a matching <methodspec> has been entered that many times. If you specify a <matchCount>, <entryAction> and <exitAction> are performed at most that many times.
group{<groupname>,<action>[,<delayCount>[,<matchcount>]]}
On finding any active tracepoint that is defined as being in trace group <groupname>, for example Entry or Exit, the specified action is run. If you specify a <delayCount>, the action is performed only after that many active tracepoints from group <groupname> have been found. If you specify a <matchCount>, <action> is performed at most that many times.
tpnid{<tpnid>|<tpnidRange>,<action>[,<delayCount>[,<matchcount>]]}
On finding the specified active <tpnid> (tracepoint ID) or a <tpnid> that falls inside the specified <tpnidRange>, the specified action is run. If you specify a <delayCount>, the action is performed only after the JVM finds such an active <tpnid> that many times. If you specify a <matchCount>, <action> is performed at most that many times.

参考文献

1. IBM SDK, Java Technology Edition, Version 6官方文档

2. https://javapapers.com/core-java/differentiate-jvm-jre-jdk-jit/

猜你喜欢

转载自blog.csdn.net/gongxsh00/article/details/80863172