4343 * resulting {@link datadog.crashtracking.dto.CrashLog} will be marked {@code incomplete}.
4444 */
4545public final class HotspotCrashLogParser {
46+ private static final String HOTSPOT_JVM_ARGS_PREFIX = "jvm_args:" ;
4647 private static final DateTimeFormatter ZONED_DATE_TIME_FORMATTER =
4748 DateTimeFormatter .ofPattern ("EEE MMM ppd HH:mm:ss yyyy zzz" , Locale .getDefault ());
4849 private static final DateTimeFormatter OFFSET_DATE_TIME_FORMATTER =
@@ -62,7 +63,8 @@ enum State {
6263 THREAD ,
6364 STACKTRACE ,
6465 REGISTERS ,
65- SEEK_DYNAMIC_LIBRARIES ,
66+ PROCESS ,
67+ VM_ARGUMENTS ,
6668 DYNAMIC_LIBRARIES ,
6769 SYSTEM ,
6870 DONE
@@ -332,6 +334,13 @@ static String parseCurrentThreadName(String line) {
332334 return threadDescriptor ;
333335 }
334336
337+ private static List <String > parseHotspotJvmArgs (String line ) {
338+ if (line == null || !line .startsWith (HOTSPOT_JVM_ARGS_PREFIX )) {
339+ return null ;
340+ }
341+ return RuntimeArgs .parseVmArgs (line .substring (HOTSPOT_JVM_ARGS_PREFIX .length ()));
342+ }
343+
335344 public CrashLog parse (String uuid , String crashLog ) {
336345 SigInfo sigInfo = null ;
337346 String pid = null ;
@@ -342,6 +351,7 @@ public CrashLog parse(String uuid, String crashLog) {
342351 boolean incomplete = false ;
343352 String oomMessage = null ;
344353 Map <String , String > registers = null ;
354+ List <String > runtimeArgs = null ;
345355 List <String > dynamicLibraryLines = null ;
346356 String dynamicLibraryKey = null ;
347357
@@ -420,7 +430,7 @@ public CrashLog parse(String uuid, String crashLog) {
420430 registers = new LinkedHashMap <>();
421431 state = State .REGISTERS ;
422432 } else if (line .contains ("P R O C E S S" )) {
423- state = State .SEEK_DYNAMIC_LIBRARIES ;
433+ state = State .PROCESS ;
424434 } else {
425435 // Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
426436 final StackFrame frame = parseLine (line );
@@ -440,18 +450,27 @@ public CrashLog parse(String uuid, String crashLog) {
440450 }
441451 }
442452 break ;
443- case SEEK_DYNAMIC_LIBRARIES :
444- if (line .startsWith ("Dynamic libraries:" )) {
453+ case PROCESS :
454+ if (runtimeArgs == null && line .startsWith ("VM Arguments:" )) {
455+ state = State .VM_ARGUMENTS ;
456+ } else if (line .startsWith ("Dynamic libraries:" )) {
445457 state = State .DYNAMIC_LIBRARIES ;
446458 } else if (line .contains ("S Y S T E M" )) {
447459 state = State .SYSTEM ;
448460 } else if (line .equals ("END." )) {
449461 state = State .DONE ;
450462 }
451463 break ;
464+ case VM_ARGUMENTS :
465+ if (line .isEmpty ()) {
466+ state = State .PROCESS ;
467+ } else if (runtimeArgs == null && line .startsWith (HOTSPOT_JVM_ARGS_PREFIX )) {
468+ runtimeArgs = parseHotspotJvmArgs (line );
469+ }
470+ break ;
452471 case DYNAMIC_LIBRARIES :
453472 if (line .isEmpty ()) {
454- state = State .SEEK_DYNAMIC_LIBRARIES ;
473+ state = State .PROCESS ;
455474 } else {
456475 if (dynamicLibraryKey == null ) {
457476 dynamicLibraryKey = detectDynamicLibrariesKey (line );
@@ -491,8 +510,8 @@ public CrashLog parse(String uuid, String crashLog) {
491510 }
492511 }
493512
494- // SEEK_DYNAMIC_LIBRARIES and SYSTEM sections are late enough that all critical data is captured
495- if (state != State .DONE && state != State .SEEK_DYNAMIC_LIBRARIES && state != State .SYSTEM ) {
513+ // PROCESS and SYSTEM sections are late enough that all critical data is captured
514+ if (state != State .DONE && state != State .PROCESS && state != State .SYSTEM ) {
496515 // incomplete crash log
497516 incomplete = true ;
498517 }
@@ -553,7 +572,10 @@ public CrashLog parse(String uuid, String crashLog) {
553572 Integer parsedPid = safelyParseInt (pid );
554573 ProcInfo procInfo = parsedPid != null ? new ProcInfo (parsedPid ) : null ;
555574 Experimental experimental =
556- (registers != null && !registers .isEmpty ()) ? new Experimental (registers ) : null ;
575+ (registers != null && !registers .isEmpty ())
576+ || (runtimeArgs != null && !runtimeArgs .isEmpty ())
577+ ? new Experimental (registers , runtimeArgs )
578+ : null ;
557579 DynamicLibs files =
558580 (dynamicLibraryLines != null && !dynamicLibraryLines .isEmpty ())
559581 ? new DynamicLibs (dynamicLibraryKey , dynamicLibraryLines )
0 commit comments