Mercurial > hg > truffle
annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java @ 13163:1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 Nov 2013 18:42:51 +0100 |
parents | 401830ff96f4 |
children | 8569b9e047cd |
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 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.debug.internal; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
24 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
25 import java.io.*; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
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.*; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.debug.*; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
30 |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
31 public final class DebugScope implements AutoCloseable { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
32 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
33 private final class IndentImpl implements Indent { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
34 |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
35 private static final String INDENTATION_INCREMENT = " "; |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
36 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
37 final String indent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
38 boolean enabled; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
39 final IndentImpl parentIndent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
40 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
41 IndentImpl(IndentImpl parentIndent, boolean enabled) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
42 this.parentIndent = parentIndent; |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
43 this.indent = (parentIndent == null ? "" : parentIndent.indent + INDENTATION_INCREMENT); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
44 this.enabled = enabled; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
45 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
46 |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
47 private void printScopeName() { |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
48 if (logScopeName) { |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
49 if (parentIndent != null) { |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
50 parentIndent.printScopeName(); |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
51 } |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
52 output.println(indent + "[thread:" + Thread.currentThread().getId() + "] scope: " + qualifiedName); |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
53 logScopeName = false; |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
54 } |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
55 } |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
56 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
57 @Override |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
58 public void log(String msg, Object... args) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
59 if (enabled) { |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
60 printScopeName(); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
61 output.println(indent + String.format(msg, args)); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
62 lastUsedIndent = this; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
63 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
64 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
65 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
66 @Override |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
67 public void setEnabled(boolean enabled) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
68 this.enabled = enabled; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
69 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
70 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
71 @Override |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
72 public Indent indent() { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
73 lastUsedIndent = new IndentImpl(this, enabled); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
74 return lastUsedIndent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
75 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
76 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
77 @Override |
13142
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
78 public Indent logAndIndent(String msg, Object... args) { |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
79 log(msg, args); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
80 return indent(); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
81 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
82 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
83 @Override |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
84 public Indent outdent() { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
85 if (parentIndent != null) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
86 lastUsedIndent = parentIndent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
87 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
88 return lastUsedIndent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
89 } |
13142
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
90 |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
91 @Override |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
92 public void close() { |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
93 outdent(); |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
94 } |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
95 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
96 |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
97 private static ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>(); |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
98 private static ThreadLocal<DebugConfig> configTL = new ThreadLocal<>(); |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
99 private static ThreadLocal<Throwable> lastExceptionThrownTL = new ThreadLocal<>(); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
100 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
101 private final DebugScope parent; |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
102 private final DebugConfig parentConfig; |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
103 private final boolean sandbox; |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
104 private IndentImpl lastUsedIndent; |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
105 private boolean logScopeName; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
106 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
107 private Object[] context; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
108 |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
109 private final DebugValueMap valueMap; |
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
110 private final String qualifiedName; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
111 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
112 private static final char SCOPE_SEP = '.'; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
113 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
114 private boolean meterEnabled; |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4392
diff
changeset
|
115 private boolean timeEnabled; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
116 private boolean dumpEnabled; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
5302
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5134
diff
changeset
|
118 private PrintStream output; |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5134
diff
changeset
|
119 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
120 public static DebugScope getInstance() { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
121 DebugScope result = instanceTL.get(); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
122 if (result == null) { |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
123 DebugScope topLevelDebugScope = new DebugScope(Thread.currentThread().getName(), "", null, false); |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
124 instanceTL.set(topLevelDebugScope); |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
125 DebugValueMap.registerTopLevel(topLevelDebugScope.getValueMap()); |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
126 return topLevelDebugScope; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
127 } else { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
128 return result; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
129 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
130 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
131 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
132 public static DebugConfig getConfig() { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
133 return configTL.get(); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
134 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
135 |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
136 private DebugScope(String name, String qualifiedName, DebugScope parent, boolean sandbox, Object... context) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
137 this.parent = parent; |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
138 this.sandbox = sandbox; |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
139 this.parentConfig = getConfig(); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
140 this.context = context; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
141 this.qualifiedName = qualifiedName; |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
142 if (parent != null) { |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
143 lastUsedIndent = new IndentImpl(parent.lastUsedIndent, parent.isLogEnabled()); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
144 logScopeName = !parent.qualifiedName.equals(qualifiedName); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
145 } else { |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
146 lastUsedIndent = new IndentImpl(null, false); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
147 logScopeName = true; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
148 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
149 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
150 // Be pragmatic: provide a default log stream to prevent a crash if the stream is not |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
151 // set while logging |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
152 this.output = System.out; |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4477
diff
changeset
|
153 assert context != null; |
5134
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
154 |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
155 if (parent != null) { |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
156 for (DebugValueMap child : parent.getValueMap().getChildren()) { |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
157 if (child.getName().equals(name)) { |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
158 this.valueMap = child; |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
159 return; |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
160 } |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
161 } |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
162 this.valueMap = new DebugValueMap(name); |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
163 parent.getValueMap().addChild(this.valueMap); |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
164 } else { |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
165 this.valueMap = new DebugValueMap(name); |
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
166 } |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
167 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
168 |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
169 public void close() { |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
170 context = null; |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
171 instanceTL.set(parent); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
172 setConfig(parentConfig); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
173 } |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
174 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
175 public boolean isDumpEnabled() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
176 return dumpEnabled; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
177 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
178 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
179 public boolean isLogEnabled() { |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
180 return lastUsedIndent.enabled; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
181 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
182 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
183 public void setLogEnabled(boolean enabled) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
184 lastUsedIndent.setEnabled(enabled); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
185 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
186 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
187 public boolean isMeterEnabled() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
188 return meterEnabled; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
189 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
190 |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4392
diff
changeset
|
191 public boolean isTimeEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4392
diff
changeset
|
192 return timeEnabled; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
193 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
195 public void log(String msg, Object... args) { |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
196 lastUsedIndent.log(msg, args); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
197 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
198 |
10923 | 199 public void printf(String msg, Object... args) { |
200 if (isLogEnabled()) { | |
11400
37446655527c
changed log indentation increment to 2 spaces
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
201 lastUsedIndent.printScopeName(); |
10923 | 202 output.printf(msg, args); |
203 } | |
204 } | |
205 | |
4362
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
206 public void dump(Object object, String formatString, Object[] args) { |
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
207 if (isDumpEnabled()) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4362
diff
changeset
|
208 DebugConfig config = getConfig(); |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4362
diff
changeset
|
209 if (config != null) { |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4362
diff
changeset
|
210 String message = String.format(formatString, args); |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4362
diff
changeset
|
211 for (DebugDumpHandler dumpHandler : config.dumpHandlers()) { |
4362
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
212 dumpHandler.dump(object, message); |
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
213 } |
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
214 } |
ed69fd347566
Added DebugDumpHandler interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
215 } |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
216 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
217 |
6570
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
218 /** |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
219 * This method exists mainly to allow a debugger (e.g., Eclipse) to force dump a graph. |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
220 */ |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
221 public static void dump(Object object, String message) { |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
222 DebugConfig config = getConfig(); |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
223 if (config != null) { |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
224 for (DebugDumpHandler dumpHandler : config.dumpHandlers()) { |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
225 dumpHandler.dump(object, message); |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
226 } |
11733
cb5df1879500
added warning about ignored forced graph dump
Doug Simon <doug.simon@oracle.com>
parents:
11616
diff
changeset
|
227 } else { |
cb5df1879500
added warning about ignored forced graph dump
Doug Simon <doug.simon@oracle.com>
parents:
11616
diff
changeset
|
228 PrintStream out = System.out; |
cb5df1879500
added warning about ignored forced graph dump
Doug Simon <doug.simon@oracle.com>
parents:
11616
diff
changeset
|
229 out.println("Forced dump ignored because debugging is disabled - use -G:Dump=xxx option"); |
6570
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
230 } |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
231 } |
d4f5301e9c7b
added method to DebugScope to simplify dumping of a graph from with Eclipse
Doug Simon <doug.simon@oracle.com>
parents:
5856
diff
changeset
|
232 |
9199
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
233 /** |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
234 * Runs a task in a new debug scope which is either a child of the current scope or a disjoint |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
235 * top level scope. |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
236 * |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
237 * @param newName the name of the new scope |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
238 * @param runnable the task to run (must be null iff {@code callable} is not null) |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
239 * @param callable the task to run (must be null iff {@code runnable} is not null) |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
240 * @param sandboxConfig if non-null, a new top level scope is entered with this configuration |
9199
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
241 * @param newContext context objects of the new scope |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
242 * @return the value returned by the task |
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
243 */ |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
244 public <T> T scope(String newName, Runnable runnable, Callable<T> callable, DebugConfig sandboxConfig, Object[] newContext) { |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
245 try (DebugScope s = openScope(newName, sandboxConfig, newContext)) { |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
246 return executeScope(runnable, callable); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
247 } |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
248 } |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
249 |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
250 public DebugScope openScope(String newName, DebugConfig sandboxConfig, Object... newContext) { |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
251 DebugScope newScope = null; |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
252 if (sandboxConfig != null) { |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
253 newScope = new DebugScope(newName, newName, this, true, newContext); |
9199
2ff3499d408e
enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
254 setConfig(sandboxConfig); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
255 } else { |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
256 newScope = this.createChild(newName, newContext); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
258 instanceTL.set(newScope); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
259 newScope.setLogEnabled(this.isLogEnabled()); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
260 newScope.updateFlags(); |
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
261 return newScope; |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
262 } |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
263 |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
264 private <T> T executeScope(Runnable runnable, Callable<T> callable) { |
5134
4eb9895d9afe
Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
265 |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
266 try { |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
267 if (runnable != null) { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
268 runnable.run(); |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
269 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
270 if (callable != null) { |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
271 return call(callable); |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
272 } |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
273 } catch (Throwable e) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
274 if (e == lastExceptionThrownTL.get()) { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
275 throw e; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
276 } else { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
277 RuntimeException newException = interceptException(e); |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
278 if (newException == null) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
279 lastExceptionThrownTL.set(e); |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
280 throw e; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
281 } else { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
282 lastExceptionThrownTL.set(newException); |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
283 throw newException; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
284 } |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
285 } |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
286 } |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
287 return null; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
288 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
289 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
290 private void updateFlags() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
291 DebugConfig config = getConfig(); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
292 if (config == null) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
293 meterEnabled = false; |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4392
diff
changeset
|
294 timeEnabled = false; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
295 dumpEnabled = false; |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
296 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
297 // Be pragmatic: provide a default log stream to prevent a crash if the stream is not |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
298 // set while logging |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
299 output = System.out; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
300 } else { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
301 meterEnabled = config.isMeterEnabled(); |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4392
diff
changeset
|
302 timeEnabled = config.isTimeEnabled(); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
303 dumpEnabled = config.isDumpEnabled(); |
5302
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5134
diff
changeset
|
304 output = config.output(); |
13142
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
305 if (config.isLogEnabled()) { |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
306 setLogEnabled(true); |
401830ff96f4
some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents:
11733
diff
changeset
|
307 } |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
308 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
309 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
310 |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
311 private RuntimeException interceptException(final Throwable e) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
312 final DebugConfig config = getConfig(); |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
313 if (config != null) { |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
314 return scope("InterceptException", null, new Callable<RuntimeException>() { |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
315 |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
316 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
317 public RuntimeException call() throws Exception { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
318 try { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
319 return config.interceptException(e); |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
320 } catch (Throwable t) { |
4612
d8ff6f2bcabd
Use parameters in graph group names for the visualizer so that successive compilation of methods with same name but different signature don't get fused
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4484
diff
changeset
|
321 return new RuntimeException("Exception while intercepting exception", t); |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
322 } |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4394
diff
changeset
|
323 } |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
324 }, null, new Object[]{e}); |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
325 } |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4437
diff
changeset
|
326 return null; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
329 private DebugValueMap getValueMap() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
330 return valueMap; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
331 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
332 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
333 long getCurrentValue(int index) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
334 return getValueMap().getCurrentValue(index); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
335 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
336 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
337 void setCurrentValue(int index, long l) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
338 getValueMap().setCurrentValue(index, l); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
339 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
340 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
341 private DebugScope createChild(String newName, Object[] newContext) { |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
342 String newQualifiedName = newName; |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
343 if (this.qualifiedName.length() > 0) { |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
344 newQualifiedName = this.qualifiedName + SCOPE_SEP + newName; |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
345 } |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
346 DebugScope result = new DebugScope(newName, newQualifiedName, this, false, newContext); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
347 return result; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
350 public Iterable<Object> getCurrentContext() { |
5856
a3e7b8320165
Fix compiler warning.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5307
diff
changeset
|
351 final DebugScope scope = this; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
352 return new Iterable<Object>() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
353 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
354 @Override |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
355 public Iterator<Object> iterator() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
356 return new Iterator<Object>() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
357 |
5856
a3e7b8320165
Fix compiler warning.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5307
diff
changeset
|
358 DebugScope currentScope = scope; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
359 int objectIndex; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
360 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
361 @Override |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
362 public boolean hasNext() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
363 selectScope(); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
364 return currentScope != null; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
365 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
366 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
367 private void selectScope() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
368 while (currentScope != null && currentScope.context.length <= objectIndex) { |
13163
1baa169508f5
made DebugScope be AutoCloseable so that try-with-resource can be used to more cleanly manage scopes
Doug Simon <doug.simon@oracle.com>
parents:
13142
diff
changeset
|
369 currentScope = currentScope.sandbox ? null : currentScope.parent; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
370 objectIndex = 0; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
371 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
372 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
373 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
374 @Override |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
375 public Object next() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
376 selectScope(); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
377 if (currentScope != null) { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
378 return currentScope.context[objectIndex++]; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
379 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
380 throw new IllegalStateException("May only be called if there is a next element."); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
381 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
382 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
383 @Override |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
384 public void remove() { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
385 throw new UnsupportedOperationException("This iterator is read only."); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
386 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
387 }; |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
388 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4346
diff
changeset
|
389 }; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 } |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
391 |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
392 public static <T> T call(Callable<T> callable) { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
393 try { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
394 return callable.call(); |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
395 } catch (Exception e) { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
396 if (e instanceof RuntimeException) { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
397 throw (RuntimeException) e; |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
398 } else { |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
399 throw new RuntimeException(e); |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
400 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
401 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
402 } |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
403 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
404 public void setConfig(DebugConfig newConfig) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
405 configTL.set(newConfig); |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
406 updateFlags(); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
407 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
408 |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
409 public String getQualifiedName() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
410 return qualifiedName; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
411 } |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
412 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
413 public Indent pushIndentLogger() { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
414 lastUsedIndent = (IndentImpl) lastUsedIndent.indent(); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
415 return lastUsedIndent; |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
416 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 } |