From c40c538ac64b02a7f87ad2adcb7b6ed4f50d4ad6 Mon Sep 17 00:00:00 2001 From: Sharath Ballal Date: Fri, 2 Jun 2017 12:31:28 +0530 Subject: [PATCH] 6760477: Update SA to include stack traces in the heap dump Update SA to include HPROF_TRACE and HPROF_FRAME records in the heap dump Reviewed-by: dsamersoff --- jdk/test/sun/tools/jhsdb/HeapDumpTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java index bc1d6553885..a36179eaaec 100644 --- a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java +++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ import jdk.testlibrary.OutputAnalyzer; import jdk.testlibrary.ProcessTools; import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.Platform; +import jdk.test.lib.hprof.parser.HprofReader; public class HeapDumpTest { @@ -93,6 +94,17 @@ public class HeapDumpTest { launch(expectedMessage, Arrays.asList(toolArgs)); } + public static void printStackTraces(String file) throws IOException { + try { + String output = HprofReader.getStack(file, 0); + if (!output.contains("LingeredAppWithExtendedChars.main")) { + throw new RuntimeException("'LingeredAppWithExtendedChars.main' missing from stdout/stderr"); + } + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } + } + public static void testHeapDump() throws IOException { File dump = new File("jhsdb.jmap.heap." + System.currentTimeMillis() + ".hprof"); @@ -106,6 +118,8 @@ public class HeapDumpTest { assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath()); + printStackTraces(dump.getAbsolutePath()); + dump.delete(); }