summaryrefslogtreecommitdiff
path: root/test/1917-get-stack-frame
diff options
context:
space:
mode:
Diffstat (limited to 'test/1917-get-stack-frame')
-rw-r--r--[-rwxr-xr-x]test/1917-get-stack-frame/run.py (renamed from test/1917-get-stack-frame/run)6
-rw-r--r--test/1917-get-stack-frame/src/Main.java6
-rw-r--r--test/1917-get-stack-frame/src/art/Test1917.java218
3 files changed, 116 insertions, 114 deletions
diff --git a/test/1917-get-stack-frame/run b/test/1917-get-stack-frame/run.py
index 51875a7e86..ce3a55a474 100755..100644
--- a/test/1917-get-stack-frame/run
+++ b/test/1917-get-stack-frame/run.py
@@ -14,5 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Ask for stack traces to be dumped to a file rather than to stdout.
-./default-run "$@" --jvmti
+
+def run(ctx, args):
+ # Ask for stack traces to be dumped to a file rather than to stdout.
+ ctx.default_run(args, jvmti=True)
diff --git a/test/1917-get-stack-frame/src/Main.java b/test/1917-get-stack-frame/src/Main.java
index c055a5c540..c6f0853d44 100644
--- a/test/1917-get-stack-frame/src/Main.java
+++ b/test/1917-get-stack-frame/src/Main.java
@@ -15,7 +15,7 @@
*/
public class Main {
- public static void main(String[] args) throws Exception {
- art.Test1917.run();
- }
+ public static void main(String[] args) throws Exception {
+ art.Test1917.run();
+ }
}
diff --git a/test/1917-get-stack-frame/src/art/Test1917.java b/test/1917-get-stack-frame/src/art/Test1917.java
index 75af43bea3..47b06cfa21 100644
--- a/test/1917-get-stack-frame/src/art/Test1917.java
+++ b/test/1917-get-stack-frame/src/art/Test1917.java
@@ -34,124 +34,124 @@ import java.util.function.Supplier;
import java.util.function.Consumer;
public class Test1917 {
- public final static boolean TEST_PRINT_ALL = false;
-
- public static class ThreadPauser implements Runnable {
- public Semaphore sem_wakeup_main = new Semaphore(0);
- public Semaphore sem_wait = new Semaphore(0);
-
- public void run() {
- try {
- sem_wakeup_main.release();
- sem_wait.acquire();
- } catch (Exception e) {
- throw new Error("Error with semaphores!", e);
- }
- }
+ public final static boolean TEST_PRINT_ALL = false;
+
+ public static class ThreadPauser implements Runnable {
+ public Semaphore sem_wakeup_main = new Semaphore(0);
+ public Semaphore sem_wait = new Semaphore(0);
+
+ public void run() {
+ try {
+ sem_wakeup_main.release();
+ sem_wait.acquire();
+ } catch (Exception e) {
+ throw new Error("Error with semaphores!", e);
+ }
+ }
- public void waitForOtherThreadToPause() throws Exception {
- sem_wakeup_main.acquire();
- while (!sem_wait.hasQueuedThreads()) {}
- }
+ public void waitForOtherThreadToPause() throws Exception {
+ sem_wakeup_main.acquire();
+ while (!sem_wait.hasQueuedThreads()) {}
+ }
- public void wakeupOtherThread() throws Exception {
- sem_wait.release();
- }
- }
-
- public static class StackTraceGenerator implements Runnable {
- private final Thread thr;
- private final Consumer<StackTrace.StackFrameData> con;
- public StackTraceGenerator(Thread thr, Consumer<StackTrace.StackFrameData> con) {
- this.thr = thr;
- this.con = con;
+ public void wakeupOtherThread() throws Exception {
+ sem_wait.release();
+ }
}
- public StackTraceGenerator(Consumer<StackTrace.StackFrameData> con) {
- this(null, con);
- }
+ public static class StackTraceGenerator implements Runnable {
+ private final Thread thr;
+ private final Consumer<StackTrace.StackFrameData> con;
+ public StackTraceGenerator(Thread thr, Consumer<StackTrace.StackFrameData> con) {
+ this.thr = thr;
+ this.con = con;
+ }
- public Thread getThread() {
- if (thr == null) {
- return Thread.currentThread();
- } else {
- return thr;
- }
- }
- public void run() {
- for (StackTrace.StackFrameData s : StackTrace.GetStackTrace(getThread())) {
- con.accept(s);
- }
+ public StackTraceGenerator(Consumer<StackTrace.StackFrameData> con) {
+ this(null, con);
+ }
+
+ public Thread getThread() {
+ if (thr == null) {
+ return Thread.currentThread();
+ } else {
+ return thr;
+ }
+ }
+ public void run() {
+ for (StackTrace.StackFrameData s : StackTrace.GetStackTrace(getThread())) {
+ con.accept(s);
+ }
+ }
}
- }
-
- public static class RecurCount implements Runnable {
- private final int cnt;
- private final Runnable then;
- public RecurCount(int cnt, Runnable then) {
- this.cnt = cnt;
- this.then = then;
+
+ public static class RecurCount implements Runnable {
+ private final int cnt;
+ private final Runnable then;
+ public RecurCount(int cnt, Runnable then) {
+ this.cnt = cnt;
+ this.then = then;
+ }
+
+ public void run() {
+ doRecur(0);
+ }
+
+ public void doRecur(int n) {
+ if (n < cnt) {
+ doRecur(n + 1);
+ } else {
+ then.run();
+ }
+ }
}
- public void run() {
- doRecur(0);
+ public static Consumer<StackTrace.StackFrameData> makePrintStackFramesConsumer()
+ throws Exception {
+ final Method end_method = Test1917.class.getDeclaredMethod("run");
+ return new Consumer<StackTrace.StackFrameData>() {
+ public void accept(StackTrace.StackFrameData data) {
+ if (TEST_PRINT_ALL) {
+ System.out.println(data);
+ } else {
+ Package p = data.method.getDeclaringClass().getPackage();
+ // Filter out anything to do with the testing harness.
+ if (p != null && p.equals(Test1917.class.getPackage())) {
+ System.out.printf("'%s' line: %d\n",
+ data.method,
+ Breakpoint.locationToLine(data.method, data.current_location));
+ } else if (data.method.getDeclaringClass().equals(Semaphore.class)) {
+ System.out.printf("'%s' line: <NOT-DETERMINISTIC>\n", data.method);
+ }
+ }
+ }
+ };
}
- public void doRecur(int n) {
- if (n < cnt) {
- doRecur(n + 1);
- } else {
- then.run();
- }
+ public static void run() throws Exception {
+ System.out.println("Recurring 5 times");
+ new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())).run();
+
+ System.out.println("Recurring 5 times on another thread");
+ Thread thr = new Thread(
+ Thread.currentThread().getThreadGroup(),
+ new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())),
+ "Recurring Thread 1",
+ 10*1000000 /* 10 mb*/);
+ thr.start();
+ thr.join();
+
+ System.out.println("Recurring 5 times on another thread. Stack trace from main thread!");
+ ThreadPauser pause = new ThreadPauser();
+ Thread thr2 = new Thread(
+ Thread.currentThread().getThreadGroup(),
+ new RecurCount(5, pause),
+ "Recurring Thread 2",
+ 10*1000000 /* 10 mb*/);
+ thr2.start();
+ pause.waitForOtherThreadToPause();
+ new StackTraceGenerator(thr2, makePrintStackFramesConsumer()).run();
+ pause.wakeupOtherThread();
+ thr2.join();
}
- }
-
- public static Consumer<StackTrace.StackFrameData> makePrintStackFramesConsumer()
- throws Exception {
- final Method end_method = Test1917.class.getDeclaredMethod("run");
- return new Consumer<StackTrace.StackFrameData>() {
- public void accept(StackTrace.StackFrameData data) {
- if (TEST_PRINT_ALL) {
- System.out.println(data);
- } else {
- Package p = data.method.getDeclaringClass().getPackage();
- // Filter out anything to do with the testing harness.
- if (p != null && p.equals(Test1917.class.getPackage())) {
- System.out.printf("'%s' line: %d\n",
- data.method,
- Breakpoint.locationToLine(data.method, data.current_location));
- } else if (data.method.getDeclaringClass().equals(Semaphore.class)) {
- System.out.printf("'%s' line: <NOT-DETERMINISTIC>\n", data.method);
- }
- }
- }
- };
- }
-
- public static void run() throws Exception {
- System.out.println("Recurring 5 times");
- new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())).run();
-
- System.out.println("Recurring 5 times on another thread");
- Thread thr = new Thread(
- Thread.currentThread().getThreadGroup(),
- new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())),
- "Recurring Thread 1",
- 10*1000000 /* 10 mb*/);
- thr.start();
- thr.join();
-
- System.out.println("Recurring 5 times on another thread. Stack trace from main thread!");
- ThreadPauser pause = new ThreadPauser();
- Thread thr2 = new Thread(
- Thread.currentThread().getThreadGroup(),
- new RecurCount(5, pause),
- "Recurring Thread 2",
- 10*1000000 /* 10 mb*/);
- thr2.start();
- pause.waitForOtherThreadToPause();
- new StackTraceGenerator(thr2, makePrintStackFramesConsumer()).run();
- pause.wakeupOtherThread();
- thr2.join();
- }
}