@@ -71,7 +71,6 @@ private void attach(long lingeredAppPid)
71
71
cmdStringList = SATestUtils .addPrivileges (cmdStringList );
72
72
}
73
73
ProcessBuilder processBuilder = new ProcessBuilder (cmdStringList );
74
- processBuilder .redirectError (ProcessBuilder .Redirect .INHERIT );
75
74
toolProcess = processBuilder .start ();
76
75
}
77
76
@@ -91,8 +90,6 @@ private void loadCore(String coreFileName)
91
90
" and exe " + JDKToolFinder .getTestJDKTool ("java" ));
92
91
93
92
ProcessBuilder processBuilder = new ProcessBuilder (launcher .getCommand ());
94
- processBuilder .redirectError (ProcessBuilder .Redirect .INHERIT );
95
-
96
93
toolProcess = processBuilder .start ();
97
94
}
98
95
@@ -116,6 +113,17 @@ private String runCmd(List<String> commands,
116
113
throw new RuntimeException ("CLHSDB command must be provided\n " );
117
114
}
118
115
116
+ // Enable verbose exception tracing so we see the full exception backtrace
117
+ // when there is a failure. We need to insert this command into the start
118
+ // of the commands list. We can't just issue the "verbose true" command seperately
119
+ // because code below won't work correctly if all executed commands are
120
+ // not in the commands list. And since it's immutable, we need to allocate
121
+ // a mutable one.
122
+ List <String > savedCommands = commands ;
123
+ commands = new java .util .LinkedList <String >();
124
+ commands .add ("verbose true" );
125
+ commands .addAll (savedCommands );
126
+
119
127
try (OutputStream out = toolProcess .getOutputStream ()) {
120
128
for (String cmd : commands ) {
121
129
out .write ((cmd + "\n " ).getBytes ());
@@ -134,8 +142,15 @@ private String runCmd(List<String> commands,
134
142
135
143
oa .shouldHaveExitValue (0 );
136
144
output = oa .getOutput ();
145
+ System .out .println ("Output: " );
137
146
System .out .println (output );
138
147
148
+ // This will detect most SA failures, including during the attach.
149
+ oa .shouldNotMatch ("^sun.jvm.hotspot.debugger.DebuggerException:.*$" );
150
+ // This will detect unexpected exceptions, like NPEs and asserts, that are caught
151
+ // by sun.jvm.hotspot.CommandProcessor.
152
+ oa .shouldNotMatch ("^Error: .*$" );
153
+
139
154
String [] parts = output .split ("hsdb>" );
140
155
for (String cmd : commands ) {
141
156
int index = commands .indexOf (cmd ) + 1 ;
0 commit comments