summaryrefslogtreecommitdiff
path: root/test/StackWalk2/StackWalk2.java
diff options
context:
space:
mode:
author Shih-wei Liao <sliao@google.com> 2011-09-16 10:36:43 -0700
committer Shih-wei Liao <sliao@google.com> 2011-09-25 23:34:37 -0700
commit9407c60800c95902fba0b3c3265520d47c1e7052 (patch)
treede5f2f0cc2d7840da217ec70c04644f4a6f38b53 /test/StackWalk2/StackWalk2.java
parent4681c809ba35d50fab92c592ce8d2c7f8b2731f7 (diff)
Stack scanning: Find RegisterMap and unit-test it. Add decoding of the map.
Tests disabled, because there is a bug in System's LoadLibrary. Change-Id: Ied3f4a31ce454f37c4d0f9caacd4ba03c4adb493
Diffstat (limited to 'test/StackWalk2/StackWalk2.java')
-rw-r--r--test/StackWalk2/StackWalk2.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/StackWalk2/StackWalk2.java b/test/StackWalk2/StackWalk2.java
new file mode 100644
index 0000000000..7d8c17723e
--- /dev/null
+++ b/test/StackWalk2/StackWalk2.java
@@ -0,0 +1,49 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+package com.example.StackWalk2;
+
+public class StackWalk2 {
+ // use v1 for this
+
+ String str = new String(); // use v0 for str in <init>
+
+ int f() {
+ g(1); // use v0 for 1, v1 for this
+ g(2); // use v0 for 2, v1 for this
+ strTest(); // use v1 for this
+ return 0;
+ }
+
+ void g(int num_calls) throws RuntimeException {
+ if (num_calls == 1) { // use v0 for 1, v3 for num_calls
+ System.logI("1st call"); // use v0 for PrintStream, v1 for "1st call"
+ refmap2(24); // use v0 for 24, v2 for this
+ } else if (num_calls == 2) { // use v0 for 2, v3 for num_calls
+ System.logI("2nd call"); // use v0 for PrintStream, v1 for "2nd call"
+ refmap2(25); // use v0 for 24, v2 for this
+ }
+ throw new RuntimeException(); // use v0 for new RuntimeException
+ }
+
+ void strTest() {
+ System.logI(str); // use v1 for PrintStream, v2, v3 for str
+ str = null; // use v1 for null, v3 for str
+ str = new String("ya"); // use v2 for "ya", v1 for new String
+ String s = str; // use v0, v1, v3
+ System.logI(str); // use v1 for PrintStream, v2, v3 for str
+ System.logI(s); // use v1 for PrintStream, v0 for s
+ s = null; // use v0
+ System.logI(s); // use v1 for PrintStream, v0 for s
+ }
+
+ native int refmap2(int x);
+
+ static {
+ System.loadLibrary("arttest");
+ }
+
+ public static void main(String[] args) {
+ StackWalk2 st = new StackWalk2();
+ st.f();
+ }
+}