[aarch64-port-dev ] Update debug code to unwind correctly through C2-compiled frames

Andrew Haley aph at redhat.com
Mon Dec 9 08:48:03 PST 2013


simpf and nextpf needed updating to cope with C2-compiled code.
Fixed thusly.

Andrew.



# HG changeset patch
# User aph
# Date 1386606626 0
# Node ID bd1555e15374799485450f990aa4b042c9a875c3
# Parent  cf547fab864b015510686c9a8cebe5b00828ab1b
Update debug code to unwind correctly through C2-compiled frames.

diff -r cf547fab864b -r bd1555e15374 src/cpu/aarch64/vm/frame_aarch64.cpp
--- a/src/cpu/aarch64/vm/frame_aarch64.cpp	Mon Dec 09 16:28:31 2013 +0000
+++ b/src/cpu/aarch64/vm/frame_aarch64.cpp	Mon Dec 09 16:30:26 2013 +0000
@@ -782,15 +782,26 @@
       printf("not a Method\n");
   } else {
     CodeBlob *cb = CodeCache::find_blob((address)pc);
-    if (cb != NULL && cb->is_nmethod()) {
-      ResourceMark rm;
-      nmethod* nm = (nmethod*)cb;
-      printf("nmethod %s\n", nm->method()->name_and_sig_as_C_string());
+    if (cb != NULL) {
+      if (cb->is_nmethod()) {
+	ResourceMark rm;
+	nmethod* nm = (nmethod*)cb;
+	printf("nmethod %s\n", nm->method()->name_and_sig_as_C_string());
+      } else if (cb->name()) {
+	printf("CodeBlob %s\n", cb->name());
+      }
     }
   }
 }

 extern "C" void npf() {
+  CodeBlob *cb = CodeCache::find_blob((address)nextpc);
+  // C2 does not always chain the frame pointers when it can, instead
+  // preferring to use fixed offsets from SP, so a simple leave() does
+  // not work.  Instead, it adds the frame size to SP then pops FP and
+  // LR.  We have to do the same thing to get a good call chain.
+  if (cb)
+    nextfp = nextsp + wordSize * (cb->frame_size() - 2);
   internal_pf (nextsp, nextfp, nextpc, -1);
 }

@@ -801,6 +812,11 @@
     reg_map = (RegisterMap*)new char[sizeof map];
   }
   memcpy(reg_map, &map, sizeof map);
+  {
+    CodeBlob *cb = CodeCache::find_blob((address)pc);
+    if (cb)
+      fp = sp + wordSize * (cb->frame_size() - 2);
+  }
   internal_pf(sp, fp, pc, bcx);
 }




More information about the aarch64-port-dev mailing list