Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.debug/src/com/oracle/graal/debug/Debug.java @ 5059:ed559a528128
Perform renames on files.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 17:57:30 +0100 |
parents | graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java@e3cc0d407bc6 |
children | 4ed4295ce15f |
rev | line source |
---|---|
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.max.graal.debug; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
25 import com.oracle.max.graal.debug.internal.*; |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
26 import java.util.*; |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
27 import java.util.concurrent.*; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
28 |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
29 public class Debug { |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
31 private static boolean ENABLED = false; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
32 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
33 public static void enable() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
34 ENABLED = true; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
35 DebugScope.initialize(); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
36 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
38 public static boolean isEnabled() { |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
39 return ENABLED; |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
40 } |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
41 |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
42 public static boolean isDumpEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
43 return ENABLED && DebugScope.getInstance().isDumpEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
44 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
45 |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
46 public static boolean isMeterEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
47 return ENABLED && DebugScope.getInstance().isMeterEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
48 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
49 |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
50 public static boolean isTimeEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
51 return ENABLED && DebugScope.getInstance().isTimeEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
52 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
53 |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
54 public static boolean isLogEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
55 return ENABLED && DebugScope.getInstance().isLogEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
56 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
57 |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
58 public static void sandbox(String name, Runnable runnable) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
59 if (ENABLED) { |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
60 DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
61 } else { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
62 runnable.run(); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
63 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
64 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
65 |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
66 public static void scope(String name, Runnable runnable) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
67 scope(name, new Object[0], runnable); |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
68 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
69 |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
70 public static <T> T scope(String name, Callable<T> callable) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
71 return scope(name, new Object[0], callable); |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
72 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
73 |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
74 public static void scope(String name, Object context, Runnable runnable) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
75 scope(name, new Object[] {context}, runnable); |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
76 } |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
77 |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
78 public static void scope(String name, Object[] context, Runnable runnable) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
79 if (ENABLED) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
80 DebugScope.getInstance().scope(name, runnable, null, false, context); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 } else { |
4346
ee5fbfca6612
more work on debug project; removed CiStatistics
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4345
diff
changeset
|
82 runnable.run(); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
86 public static String currentScope() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
87 if (ENABLED) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
88 return DebugScope.getInstance().getQualifiedName(); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
89 } else { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
90 return ""; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
91 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
92 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
93 |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
94 public static <T> T scope(String name, Object context, Callable<T> callable) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
95 return scope(name, new Object[] {context}, callable); |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
96 } |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
97 |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
98 public static <T> T scope(String name, Object[] context, Callable<T> callable) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
99 if (ENABLED) { |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
100 return DebugScope.getInstance().scope(name, null, callable, false, context); |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
101 } else { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
102 return DebugScope.call(callable); |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
103 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
104 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
105 |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
106 public static void log(String msg, Object... args) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
107 if (ENABLED && DebugScope.getInstance().isLogEnabled()) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
108 DebugScope.getInstance().log(msg, args); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
109 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
110 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
111 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
112 public static void dump(Object object, String msg, Object... args) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
113 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
114 DebugScope.getInstance().dump(object, msg, args); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
115 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
116 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
117 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
118 public static Iterable<Object> context() { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
119 if (ENABLED) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
120 return DebugScope.getInstance().getCurrentContext(); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
121 } else { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
122 return Collections.emptyList(); |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
123 } |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
124 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
126 @SuppressWarnings("unchecked") |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
127 public static <T> List<T> contextSnapshot(Class<T> clazz) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
128 if (ENABLED) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
129 List<T> result = new ArrayList<>(); |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
130 for (Object o : context()) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
131 if (clazz.isInstance(o)) { |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
132 result.add((T) o); |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
133 } |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
134 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
135 return result; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
136 } else { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
137 return Collections.emptyList(); |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
138 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
139 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
140 |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
141 @SuppressWarnings("unchecked") |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
142 public static <T> T contextLookup(Class<T> clazz) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
143 if (ENABLED) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
144 for (Object o : context()) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
145 if (clazz.isInstance(o)) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
146 return ((T) o); |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
147 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
148 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
149 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
150 return null; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
151 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
152 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
153 public static DebugMetric metric(String name) { |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
154 if (ENABLED) { |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
155 return new MetricImpl(name); |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
156 } else { |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
157 return VOID_METRIC; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
161 public static void setConfig(DebugConfig config) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
162 if (ENABLED) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
163 DebugScope.getInstance().setConfig(config); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
164 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
165 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
166 |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4477
diff
changeset
|
167 public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isTimerEnabled, final Collection<? extends DebugDumpHandler> dumpHandlers) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
168 return new DebugConfig() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
169 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
170 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
171 public boolean isLogEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
172 return isLogEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
173 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
174 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
175 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
176 public boolean isMeterEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
177 return isMeterEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
178 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
179 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
180 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
181 public boolean isDumpEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
182 return isDumpEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
183 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
184 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
185 @Override |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
186 public boolean isTimeEnabled() { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
187 return isTimerEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
188 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
189 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
190 @Override |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
191 public RuntimeException interceptException(Throwable e) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
192 return null; |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
193 } |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
194 |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
195 @Override |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
196 public Collection< ? extends DebugDumpHandler> dumpHandlers() { |
4428
0bb7ab1add7e
enable dumping graphs upon exception, new constructor for NodeInputList, initialize debug system for non-compiler threads
Lukas Stadler <lukas.stadler@jku.at>
parents:
4406
diff
changeset
|
197 return dumpHandlers; |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
198 } |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
199 }; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
200 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
201 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
202 private static final DebugMetric VOID_METRIC = new DebugMetric() { |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
203 |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
204 public void increment() { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
205 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
206 |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
207 public void add(int value) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
208 } |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
209 }; |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
210 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
211 public static DebugTimer timer(String name) { |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
212 if (ENABLED) { |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
213 return new TimerImpl(name); |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
214 } else { |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
215 return VOID_TIMER; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
219 private static final DebugTimer VOID_TIMER = new DebugTimer() { |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
220 |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
221 public TimerCloseable start() { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
222 return TimerImpl.VOID_CLOSEABLE; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
223 } |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
224 }; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 } |