8201242: Include source file/line number when reporting native call stack on supported platforms
authorzgu
Mon, 09 Apr 2018 08:19:26 -0400
changeset 49721 ea0cc7c74e75
parent 49720 96afaacb6b48
child 49722 a47d1e21b3f1
8201242: Include source file/line number when reporting native call stack on supported platforms Summary: Added source file/line number to native call stack reporting on supported platforms Reviewed-by: adinn, stuefe, dcubed
src/hotspot/share/utilities/nativeCallStack.cpp
--- a/src/hotspot/share/utilities/nativeCallStack.cpp	Mon Apr 09 13:38:45 2018 +0200
+++ b/src/hotspot/share/utilities/nativeCallStack.cpp	Mon Apr 09 08:19:26 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "runtime/os.hpp"
+#include "utilities/decoder.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/nativeCallStack.hpp"
 
@@ -102,6 +103,7 @@
   address pc;
   char    buf[1024];
   int     offset;
+  int     line_no;
   if (is_empty()) {
     for (int index = 0; index < indent; index ++) out->print(" ");
     out->print("[BOOTSTRAP]");
@@ -112,10 +114,15 @@
       // Print indent
       for (int index = 0; index < indent; index ++) out->print(" ");
       if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
-        out->print_cr("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset);
+        out->print("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset);
       } else {
-        out->print_cr("[" PTR_FORMAT "]", p2i(pc));
+        out->print("[" PTR_FORMAT "]", p2i(pc));
       }
+
+      if (Decoder::get_source_info(pc, buf, sizeof(buf), &line_no)) {
+        out->print("  (%s:%d)", buf, line_no);
+      }
+      out->cr();
     }
   }
 }