Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ba3a9bd2 | 2 | * Copyright (c) 2012, 2013 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
ba3a9bd2 | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
eb1bab5b | 12 | **********************************************************************/ |
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.service; |
eb1bab5b BH |
14 | |
15 | import java.util.ArrayList; | |
bbb3538a | 16 | import java.util.Iterator; |
eb1bab5b BH |
17 | import java.util.List; |
18 | import java.util.regex.Matcher; | |
eb1bab5b BH |
19 | |
20 | import org.eclipse.core.commands.ExecutionException; | |
21 | import org.eclipse.core.runtime.IProgressMonitor; | |
22 | import org.eclipse.core.runtime.NullProgressMonitor; | |
9315aeee BH |
23 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
24 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; | |
25 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; | |
26 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; | |
d4514365 | 27 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo; |
9315aeee BH |
28 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo; |
29 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; | |
30 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; | |
31 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; | |
32 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; | |
33 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
34 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo; | |
35 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; | |
36 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo; | |
37 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo; | |
d4514365 | 38 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo; |
9315aeee BH |
39 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo; |
40 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo; | |
41 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo; | |
afe13e7a | 42 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.logging.ControlCommandLogger; |
9315aeee | 43 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
afe13e7a | 44 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.preferences.ControlPreferences; |
9315aeee BH |
45 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandResult; |
46 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandShell; | |
d4514365 | 47 | import org.osgi.framework.Version; |
4775bcbf | 48 | |
eb1bab5b | 49 | /** |
eb1bab5b BH |
50 | * <p> |
51 | * Service for sending LTTng trace control commands to remote host. | |
52 | * </p> | |
cfdb727a | 53 | * |
dbd4432d | 54 | * @author Bernd Hufmann |
eb1bab5b BH |
55 | */ |
56 | public class LTTngControlService implements ILttngControlService { | |
cfdb727a | 57 | |
eb1bab5b BH |
58 | // ------------------------------------------------------------------------ |
59 | // Attributes | |
60 | // ------------------------------------------------------------------------ | |
61 | /** | |
62 | * The command shell implementation | |
63 | */ | |
276c17e7 | 64 | protected ICommandShell fCommandShell = null; |
cfdb727a | 65 | |
c5f68877 BH |
66 | /** |
67 | * The version string. | |
68 | */ | |
d4514365 | 69 | protected Version fVersion = null; |
eb1bab5b BH |
70 | |
71 | // ------------------------------------------------------------------------ | |
72 | // Constructors | |
73 | // ------------------------------------------------------------------------ | |
74 | ||
75 | /** | |
76 | * Constructor | |
cfdb727a | 77 | * |
4775bcbf BH |
78 | * @param shell |
79 | * - the command shell implementation to use | |
eb1bab5b BH |
80 | */ |
81 | public LTTngControlService(ICommandShell shell) { | |
82 | fCommandShell = shell; | |
83 | } | |
4775bcbf | 84 | |
276c17e7 BH |
85 | // ------------------------------------------------------------------------ |
86 | // Accessors | |
87 | // ------------------------------------------------------------------------ | |
11252342 | 88 | |
276c17e7 BH |
89 | @Override |
90 | public String getVersion() { | |
d4514365 BH |
91 | if (fVersion == null) { |
92 | return "Unknown"; //$NON-NLS-1$ | |
93 | } | |
94 | return fVersion.toString(); | |
276c17e7 | 95 | } |
cfdb727a | 96 | |
c5f68877 | 97 | /** |
cfdb727a | 98 | * Sets the version of the LTTng 2.0 control service. |
c5f68877 BH |
99 | * @param version - a version to set |
100 | */ | |
276c17e7 | 101 | public void setVersion(String version) { |
d4514365 | 102 | fVersion = new Version(version); |
276c17e7 | 103 | } |
d4514365 | 104 | |
d4514365 BH |
105 | @Override |
106 | public boolean isVersionSupported(String version) { | |
107 | Version tmp = new Version(version); | |
108 | return (fVersion != null && fVersion.compareTo(tmp) >= 0) ? true : false; | |
109 | } | |
110 | ||
eb1bab5b BH |
111 | // ------------------------------------------------------------------------ |
112 | // Operations | |
4775bcbf | 113 | // ------------------------------------------------------------------------ |
cfdb727a | 114 | |
eb1bab5b BH |
115 | @Override |
116 | public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 117 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST); |
eb1bab5b | 118 | |
afe13e7a | 119 | ICommandResult result = executeCommand(command.toString(), monitor); |
4775bcbf BH |
120 | |
121 | // Output: | |
122 | // Available tracing sessions: | |
d4514365 BH |
123 | // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive] |
124 | // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive] | |
4775bcbf BH |
125 | // |
126 | // Use lttng list <session_name> for more details | |
127 | ||
128 | ArrayList<String> retArray = new ArrayList<String>(); | |
129 | int index = 0; | |
130 | while (index < result.getOutput().length) { | |
131 | String line = result.getOutput()[index]; | |
276c17e7 | 132 | Matcher matcher = LTTngControlServiceConstants.SESSION_PATTERN.matcher(line); |
4775bcbf BH |
133 | if (matcher.matches()) { |
134 | retArray.add(matcher.group(2).trim()); | |
135 | } | |
136 | index++; | |
137 | } | |
138 | return retArray.toArray(new String[retArray.size()]); | |
eb1bab5b BH |
139 | } |
140 | ||
eb1bab5b BH |
141 | @Override |
142 | public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 143 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST, sessionName); |
afe13e7a | 144 | ICommandResult result = executeCommand(command.toString(), monitor); |
eb1bab5b BH |
145 | |
146 | int index = 0; | |
147 | ||
148 | // Output: | |
4775bcbf BH |
149 | // Tracing session mysession2: [inactive] |
150 | // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330 | |
eb1bab5b BH |
151 | ISessionInfo sessionInfo = new SessionInfo(sessionName); |
152 | ||
4775bcbf BH |
153 | while (index < result.getOutput().length) { |
154 | // Tracing session mysession2: [inactive] | |
155 | // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330 | |
156 | // | |
157 | // === Domain: Kernel === | |
158 | // | |
159 | String line = result.getOutput()[index]; | |
276c17e7 | 160 | Matcher matcher = LTTngControlServiceConstants.TRACE_SESSION_PATTERN.matcher(line); |
4775bcbf BH |
161 | if (matcher.matches()) { |
162 | sessionInfo.setSessionState(matcher.group(2)); | |
163 | index++; | |
164 | continue; | |
165 | } | |
166 | ||
f3b33d40 BH |
167 | matcher = LTTngControlServiceConstants.TRACE_NETWORK_PATH_PATTERN.matcher(line); |
168 | if (matcher.matches()) { | |
169 | sessionInfo.setStreamedTrace(true); | |
170 | } | |
171 | ||
276c17e7 | 172 | matcher = LTTngControlServiceConstants.TRACE_SESSION_PATH_PATTERN.matcher(line); |
4775bcbf BH |
173 | if (matcher.matches()) { |
174 | sessionInfo.setSessionPath(matcher.group(1).trim()); | |
175 | index++; | |
176 | continue; | |
177 | } | |
eb1bab5b | 178 | |
276c17e7 | 179 | matcher = LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(line); |
4775bcbf BH |
180 | if (matcher.matches()) { |
181 | // Create Domain | |
182 | IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_KernelDomainDisplayName); | |
eb1bab5b | 183 | |
4775bcbf BH |
184 | // in domain kernel |
185 | ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>(); | |
186 | index = parseDomain(result.getOutput(), index, channels); | |
eb1bab5b | 187 | |
a30e79fe BH |
188 | if (channels.size() > 0) { |
189 | // add domain | |
190 | sessionInfo.addDomain(domainInfo); | |
cfdb727a | 191 | |
a30e79fe BH |
192 | // set channels |
193 | domainInfo.setChannels(channels); | |
194 | ||
195 | // set kernel flag | |
196 | domainInfo.setIsKernel(true); | |
197 | } | |
4775bcbf BH |
198 | continue; |
199 | } | |
eb1bab5b | 200 | |
276c17e7 | 201 | matcher = LTTngControlServiceConstants.DOMAIN_UST_GLOBAL_PATTERN.matcher(line); |
4775bcbf BH |
202 | if (matcher.matches()) { |
203 | IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName); | |
eb1bab5b | 204 | |
bbb3538a | 205 | // in domain UST |
4775bcbf BH |
206 | ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>(); |
207 | index = parseDomain(result.getOutput(), index, channels); | |
208 | ||
a30e79fe BH |
209 | if (channels.size() > 0) { |
210 | // add domain | |
211 | sessionInfo.addDomain(domainInfo); | |
212 | ||
213 | // set channels | |
214 | domainInfo.setChannels(channels); | |
cfdb727a | 215 | |
a30e79fe BH |
216 | // set kernel flag |
217 | domainInfo.setIsKernel(false); | |
218 | } | |
4775bcbf | 219 | continue; |
eb1bab5b | 220 | } |
4775bcbf BH |
221 | index++; |
222 | } | |
eb1bab5b BH |
223 | return sessionInfo; |
224 | } | |
4775bcbf | 225 | |
eb1bab5b BH |
226 | @Override |
227 | public List<IBaseEventInfo> getKernelProvider(IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 228 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_KERNEL); |
a07c7629 BH |
229 | ICommandResult result = executeCommand(command.toString(), monitor, false); |
230 | ||
231 | List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>(); | |
232 | ||
233 | if (result.getOutput() != null) { | |
234 | // Ignore the following 2 cases: | |
235 | // Spawning a session daemon | |
236 | // Error: Unable to list kernel events | |
237 | // or: | |
238 | // Error: Unable to list kernel events | |
1c5303c6 | 239 | // |
d128c979 BH |
240 | int index = 0; |
241 | while (index < result.getOutput().length) { | |
242 | String line = result.getOutput()[index]; | |
243 | Matcher matcher = LTTngControlServiceConstants.LIST_KERNEL_NO_KERNEL_PROVIDER_PATTERN.matcher(line); | |
244 | if (matcher.matches()) { | |
245 | return events; | |
246 | } | |
247 | index++; | |
a07c7629 BH |
248 | } |
249 | } | |
250 | ||
251 | if (isError(result)) { | |
252 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command.toString() + "\n" + formatOutput(result)); //$NON-NLS-1$ //$NON-NLS-2$ | |
253 | } | |
4775bcbf BH |
254 | |
255 | // Kernel events: | |
256 | // ------------- | |
257 | // sched_kthread_stop (type: tracepoint) | |
eb1bab5b BH |
258 | getProviderEventInfo(result.getOutput(), 0, events); |
259 | return events; | |
260 | } | |
261 | ||
eb1bab5b BH |
262 | @Override |
263 | public List<IUstProviderInfo> getUstProvider() throws ExecutionException { | |
264 | return getUstProvider(new NullProgressMonitor()); | |
265 | } | |
4775bcbf | 266 | |
eb1bab5b BH |
267 | @Override |
268 | public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 269 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_UST); |
eb1bab5b | 270 | |
d4514365 BH |
271 | if (isVersionSupported("2.1.0")) { //$NON-NLS-1$ |
272 | command.append(LTTngControlServiceConstants.OPTION_FIELDS); | |
273 | } | |
274 | ||
f3e2f354 BH |
275 | ICommandResult result = executeCommand(command.toString(), monitor, false); |
276 | List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>(); | |
277 | ||
278 | // Workaround for versions 2.0.x which causes a segmentation fault for this command | |
279 | // if LTTng Tools is compiled without UST support. | |
280 | if (!isVersionSupported("2.1.0") && (result.getResult() != 0)) { //$NON-NLS-1$ | |
281 | return allProviders; | |
282 | } | |
283 | ||
284 | if (result.getOutput() != null) { | |
285 | // Ignore the following 2 cases: | |
286 | // Spawning a session daemon | |
287 | // Error: Unable to list UST events: Listing UST events failed | |
288 | // or: | |
289 | // Error: Unable to list UST events: Listing UST events failed | |
290 | // | |
291 | int index = 0; | |
292 | while (index < result.getOutput().length) { | |
293 | String line = result.getOutput()[index]; | |
294 | Matcher matcher = LTTngControlServiceConstants.LIST_UST_NO_UST_PROVIDER_PATTERN.matcher(line); | |
295 | if (matcher.matches()) { | |
296 | return allProviders; | |
297 | } | |
298 | index++; | |
299 | } | |
300 | } | |
301 | ||
302 | if (isError(result)) { | |
303 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command.toString() + "\n" + formatOutput(result)); //$NON-NLS-1$ //$NON-NLS-2$ | |
304 | } | |
4775bcbf | 305 | |
d4514365 BH |
306 | // Note that field print-outs exists for version >= 2.1.0 |
307 | // | |
4775bcbf BH |
308 | // UST events: |
309 | // ------------- | |
310 | // | |
311 | // PID: 3635 - Name: | |
312 | // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello | |
313 | // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type: | |
314 | // tracepoint) | |
315 | // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint) | |
d4514365 BH |
316 | // field: doublefield (float) |
317 | // field: floatfield (float) | |
318 | // field: stringfield (string) | |
4775bcbf BH |
319 | // |
320 | // PID: 6459 - Name: | |
321 | // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello | |
322 | // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type: | |
323 | // tracepoint) | |
324 | // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint) | |
d4514365 BH |
325 | // field: doublefield (float) |
326 | // field: floatfield (float) | |
327 | // field: stringfield (string) | |
eb1bab5b | 328 | |
eb1bab5b | 329 | IUstProviderInfo provider = null; |
4775bcbf | 330 | |
eb1bab5b BH |
331 | int index = 0; |
332 | while (index < result.getOutput().length) { | |
333 | String line = result.getOutput()[index]; | |
276c17e7 | 334 | Matcher matcher = LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line); |
4775bcbf | 335 | if (matcher.matches()) { |
4775bcbf BH |
336 | provider = new UstProviderInfo(matcher.group(2).trim()); |
337 | provider.setPid(Integer.valueOf(matcher.group(1).trim())); | |
338 | List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>(); | |
339 | index = getProviderEventInfo(result.getOutput(), ++index, events); | |
340 | provider.setEvents(events); | |
341 | allProviders.add(provider); | |
eb1bab5b BH |
342 | } else { |
343 | index++; | |
344 | } | |
eb1bab5b BH |
345 | } |
346 | return allProviders; | |
347 | } | |
348 | ||
bbb3538a BH |
349 | @Override |
350 | public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException { | |
351 | ||
352 | String newName = formatParameter(sessionName); | |
353 | String newPath = formatParameter(sessionPath); | |
354 | ||
276c17e7 | 355 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName); |
c56972bb | 356 | |
bbb3538a | 357 | if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$ |
276c17e7 | 358 | command.append(LTTngControlServiceConstants.OPTION_OUTPUT_PATH); |
c56972bb | 359 | command.append(newPath); |
bbb3538a BH |
360 | } |
361 | ||
afe13e7a BH |
362 | ICommandResult result = executeCommand(command.toString(), monitor); |
363 | ||
bbb3538a BH |
364 | //Session myssession2 created. |
365 | //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418 | |
366 | String[] output = result.getOutput(); | |
cfdb727a | 367 | |
d128c979 | 368 | // Get and session name and path |
bbb3538a | 369 | String name = null; |
d128c979 | 370 | String path = null; |
bbb3538a | 371 | |
d128c979 BH |
372 | int index = 0; |
373 | while (index < output.length) { | |
374 | String line = output[index]; | |
375 | Matcher nameMatcher = LTTngControlServiceConstants.CREATE_SESSION_NAME_PATTERN.matcher(line); | |
376 | Matcher pathMatcher = LTTngControlServiceConstants.CREATE_SESSION_PATH_PATTERN.matcher(line); | |
377 | if (nameMatcher.matches()) { | |
378 | name = String.valueOf(nameMatcher.group(1).trim()); | |
379 | } else if (pathMatcher.matches()) { | |
380 | path = String.valueOf(pathMatcher.group(1).trim()); | |
381 | } | |
382 | index++; | |
bbb3538a BH |
383 | } |
384 | ||
d128c979 | 385 | // Verify session name |
f3b33d40 | 386 | if ((name == null) || (!"".equals(sessionName) && !name.equals(sessionName))) { //$NON-NLS-1$ |
bbb3538a | 387 | // Unexpected name returned |
cfdb727a AM |
388 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
389 | Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$ | |
bbb3538a | 390 | } |
cfdb727a | 391 | |
f3b33d40 BH |
392 | SessionInfo sessionInfo = new SessionInfo(name); |
393 | ||
d128c979 | 394 | // Verify session path |
a30e79fe BH |
395 | if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) { |
396 | // Unexpected path | |
397 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ | |
398 | Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$ | |
f3b33d40 | 399 | } |
d128c979 | 400 | |
a30e79fe | 401 | sessionInfo.setSessionPath(path); |
f3b33d40 BH |
402 | |
403 | return sessionInfo; | |
404 | ||
405 | } | |
406 | ||
f3b33d40 | 407 | @Override |
a30e79fe | 408 | public ISessionInfo createSession(String sessionName, String networkUrl, String controlUrl, String dataUrl, IProgressMonitor monitor) throws ExecutionException { |
f3b33d40 BH |
409 | |
410 | String newName = formatParameter(sessionName); | |
411 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION, newName); | |
412 | ||
413 | if (networkUrl != null) { | |
414 | command.append(LTTngControlServiceConstants.OPTION_NETWORK_URL); | |
415 | command.append(networkUrl); | |
416 | } else { | |
417 | command.append(LTTngControlServiceConstants.OPTION_CONTROL_URL); | |
418 | command.append(controlUrl); | |
419 | ||
420 | command.append(LTTngControlServiceConstants.OPTION_DATA_URL); | |
421 | command.append(dataUrl); | |
422 | } | |
423 | ||
f3b33d40 BH |
424 | ICommandResult result = executeCommand(command.toString(), monitor); |
425 | ||
d128c979 | 426 | // Verify output |
f3b33d40 BH |
427 | String[] output = result.getOutput(); |
428 | ||
d128c979 | 429 | // Get and session name and path |
f3b33d40 | 430 | String name = null; |
d128c979 | 431 | String path = null; |
cfdb727a | 432 | |
d128c979 BH |
433 | int index = 0; |
434 | while (index < output.length) { | |
435 | String line = output[index]; | |
436 | Matcher nameMatcher = LTTngControlServiceConstants.CREATE_SESSION_NAME_PATTERN.matcher(line); | |
437 | Matcher pathMatcher = LTTngControlServiceConstants.CREATE_SESSION_PATH_PATTERN.matcher(line); | |
438 | ||
439 | if (nameMatcher.matches()) { | |
440 | name = String.valueOf(nameMatcher.group(1).trim()); | |
441 | } else if (pathMatcher.matches() && (networkUrl != null)) { | |
442 | path = String.valueOf(pathMatcher.group(1).trim()); | |
443 | } | |
444 | index++; | |
445 | } | |
446 | ||
447 | // Verify session name | |
448 | if ((name == null) || (!"".equals(sessionName) && !name.equals(sessionName))) { //$NON-NLS-1$ | |
449 | // Unexpected name returned | |
cfdb727a | 450 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
d128c979 | 451 | Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$ |
bbb3538a | 452 | } |
cfdb727a | 453 | |
bbb3538a | 454 | SessionInfo sessionInfo = new SessionInfo(name); |
f3b33d40 | 455 | |
d128c979 BH |
456 | sessionInfo.setStreamedTrace(true); |
457 | ||
458 | // Verify session path | |
459 | if (networkUrl != null) { | |
f3b33d40 BH |
460 | if (path == null) { |
461 | // Unexpected path | |
462 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ | |
463 | Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$ | |
464 | } | |
d128c979 | 465 | |
f3b33d40 | 466 | sessionInfo.setSessionPath(path); |
d128c979 BH |
467 | |
468 | // Check file protocol | |
469 | Matcher matcher = LTTngControlServiceConstants.TRACE_FILE_PROTOCOL_PATTERN.matcher(path); | |
470 | if (matcher.matches()) { | |
471 | sessionInfo.setStreamedTrace(false); | |
472 | } | |
f3b33d40 | 473 | } |
d128c979 BH |
474 | // When using controlUrl and dataUrl the full session path is not known yet |
475 | // and will be set later on when listing the session | |
bbb3538a BH |
476 | |
477 | return sessionInfo; | |
478 | } | |
cfdb727a | 479 | |
bbb3538a BH |
480 | @Override |
481 | public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException { | |
482 | String newName = formatParameter(sessionName); | |
bbb3538a | 483 | |
276c17e7 | 484 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_DESTROY_SESSION, newName); |
afe13e7a BH |
485 | |
486 | ICommandResult result = executeCommand(command.toString(), monitor, false); | |
bbb3538a | 487 | String[] output = result.getOutput(); |
cfdb727a | 488 | |
d128c979 BH |
489 | boolean isError = isError(result); |
490 | if (isError && (output != null)) { | |
491 | int index = 0; | |
492 | while (index < output.length) { | |
493 | String line = output[index]; | |
494 | Matcher matcher = LTTngControlServiceConstants.SESSION_NOT_FOUND_ERROR_PATTERN.matcher(line); | |
495 | if (matcher.matches()) { | |
496 | // Don't treat this as an error | |
497 | isError = false; | |
498 | } | |
499 | index++; | |
500 | } | |
501 | } | |
502 | ||
503 | if (isError) { | |
504 | throw new ExecutionException(Messages.TraceControl_CommandError + " " + command.toString() + "\n" + formatOutput(result)); //$NON-NLS-1$ //$NON-NLS-2$ | |
505 | } | |
506 | ||
bbb3538a BH |
507 | //Session <sessionName> destroyed |
508 | } | |
cfdb727a | 509 | |
bbb3538a BH |
510 | @Override |
511 | public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException { | |
512 | ||
513 | String newSessionName = formatParameter(sessionName); | |
514 | ||
276c17e7 | 515 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_START_SESSION, newSessionName); |
bbb3538a | 516 | |
afe13e7a | 517 | executeCommand(command.toString(), monitor); |
bbb3538a | 518 | |
bbb3538a BH |
519 | //Session <sessionName> started |
520 | } | |
521 | ||
bbb3538a BH |
522 | @Override |
523 | public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException { | |
524 | String newSessionName = formatParameter(sessionName); | |
276c17e7 | 525 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_STOP_SESSION, newSessionName); |
bbb3538a | 526 | |
afe13e7a | 527 | executeCommand(command.toString(), monitor); |
bbb3538a | 528 | |
bbb3538a | 529 | //Session <sessionName> stopped |
cfdb727a | 530 | |
bbb3538a | 531 | } |
cfdb727a | 532 | |
bbb3538a | 533 | @Override |
498704b3 | 534 | public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException { |
bbb3538a BH |
535 | |
536 | // no channels to enable | |
c56972bb | 537 | if (channelNames.isEmpty()) { |
bbb3538a BH |
538 | return; |
539 | } | |
540 | ||
276c17e7 | 541 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_CHANNEL); |
bbb3538a BH |
542 | |
543 | for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) { | |
cfdb727a | 544 | String channel = iterator.next(); |
bbb3538a BH |
545 | command.append(channel); |
546 | if (iterator.hasNext()) { | |
c56972bb | 547 | command.append(','); |
bbb3538a BH |
548 | } |
549 | } | |
550 | ||
551 | if (isKernel) { | |
276c17e7 | 552 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
bbb3538a | 553 | } else { |
276c17e7 | 554 | command.append(LTTngControlServiceConstants.OPTION_UST); |
bbb3538a BH |
555 | } |
556 | ||
afe13e7a | 557 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 558 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
bbb3538a BH |
559 | command.append(newSessionName); |
560 | ||
561 | if (info != null) { | |
562 | // --discard Discard event when buffers are full (default) | |
bbb3538a BH |
563 | |
564 | // --overwrite Flight recorder mode | |
565 | if (info.isOverwriteMode()) { | |
276c17e7 | 566 | command.append(LTTngControlServiceConstants.OPTION_OVERWRITE); |
bbb3538a BH |
567 | } |
568 | // --subbuf-size SIZE Subbuffer size in bytes | |
569 | // (default: 4096, kernel default: 262144) | |
276c17e7 | 570 | command.append(LTTngControlServiceConstants.OPTION_SUB_BUFFER_SIZE); |
bbb3538a BH |
571 | command.append(String.valueOf(info.getSubBufferSize())); |
572 | ||
573 | // --num-subbuf NUM Number of subbufers | |
574 | // (default: 8, kernel default: 4) | |
276c17e7 | 575 | command.append(LTTngControlServiceConstants.OPTION_NUM_SUB_BUFFERS); |
bbb3538a | 576 | command.append(String.valueOf(info.getNumberOfSubBuffers())); |
cfdb727a | 577 | |
bbb3538a | 578 | // --switch-timer USEC Switch timer interval in usec (default: 0) |
276c17e7 | 579 | command.append(LTTngControlServiceConstants.OPTION_SWITCH_TIMER); |
bbb3538a BH |
580 | command.append(String.valueOf(info.getSwitchTimer())); |
581 | ||
582 | // --read-timer USEC Read timer interval in usec (default: 200) | |
276c17e7 | 583 | command.append(LTTngControlServiceConstants.OPTION_READ_TIMER); |
bbb3538a | 584 | command.append(String.valueOf(info.getReadTimer())); |
cfdb727a | 585 | } |
bbb3538a | 586 | |
afe13e7a | 587 | executeCommand(command.toString(), monitor); |
cfdb727a | 588 | |
bbb3538a BH |
589 | } |
590 | ||
bbb3538a | 591 | @Override |
498704b3 | 592 | public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException { |
cfdb727a | 593 | |
bbb3538a | 594 | // no channels to enable |
c56972bb | 595 | if (channelNames.isEmpty()) { |
bbb3538a BH |
596 | return; |
597 | } | |
598 | ||
276c17e7 | 599 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_DISABLE_CHANNEL); |
bbb3538a BH |
600 | |
601 | for (Iterator<String> iterator = channelNames.iterator(); iterator.hasNext();) { | |
cfdb727a | 602 | String channel = iterator.next(); |
bbb3538a BH |
603 | command.append(channel); |
604 | if (iterator.hasNext()) { | |
c56972bb | 605 | command.append(','); |
bbb3538a BH |
606 | } |
607 | } | |
608 | ||
609 | if (isKernel) { | |
276c17e7 | 610 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
6503ae0f | 611 | } else { |
276c17e7 | 612 | command.append(LTTngControlServiceConstants.OPTION_UST); |
6503ae0f BH |
613 | } |
614 | ||
afe13e7a | 615 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 616 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
6503ae0f BH |
617 | command.append(newSessionName); |
618 | ||
afe13e7a | 619 | executeCommand(command.toString(), monitor); |
6503ae0f | 620 | } |
cfdb727a | 621 | |
6503ae0f | 622 | @Override |
d4514365 | 623 | public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, String filterExpression, IProgressMonitor monitor) throws ExecutionException { |
6503ae0f | 624 | |
276c17e7 | 625 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT); |
6503ae0f | 626 | |
c56972bb | 627 | if (eventNames == null || eventNames.isEmpty()) { |
276c17e7 | 628 | command.append(LTTngControlServiceConstants.OPTION_ALL); |
3e91c9c0 | 629 | } else { |
3e91c9c0 | 630 | |
7a6e4bfd | 631 | StringBuffer eventNameParameter = new StringBuffer(); |
3e91c9c0 | 632 | for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) { |
cfdb727a | 633 | String event = iterator.next(); |
7a6e4bfd | 634 | eventNameParameter.append(event); |
3e91c9c0 | 635 | if (iterator.hasNext()) { |
7a6e4bfd | 636 | eventNameParameter.append(','); |
3e91c9c0 | 637 | } |
6503ae0f | 638 | } |
7a6e4bfd | 639 | command.append(formatParameter(eventNameParameter.toString())); |
6503ae0f BH |
640 | } |
641 | ||
642 | if (isKernel) { | |
276c17e7 | 643 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
bbb3538a | 644 | } else { |
276c17e7 | 645 | command.append(LTTngControlServiceConstants.OPTION_UST); |
bbb3538a BH |
646 | } |
647 | ||
afe13e7a BH |
648 | String newSessionName = formatParameter(sessionName); |
649 | ||
276c17e7 | 650 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
bbb3538a BH |
651 | command.append(newSessionName); |
652 | ||
6503ae0f | 653 | if (channelName != null) { |
276c17e7 | 654 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
6503ae0f BH |
655 | command.append(channelName); |
656 | } | |
cfdb727a | 657 | |
276c17e7 | 658 | command.append(LTTngControlServiceConstants.OPTION_TRACEPOINT); |
cfdb727a | 659 | |
d4514365 BH |
660 | if (filterExpression != null) { |
661 | command.append(LTTngControlServiceConstants.OPTION_FILTER); | |
662 | command.append('\''); | |
663 | command.append(filterExpression); | |
664 | command.append('\''); | |
665 | } | |
666 | ||
afe13e7a | 667 | executeCommand(command.toString(), monitor); |
cfdb727a | 668 | |
498704b3 | 669 | } |
6503ae0f | 670 | |
498704b3 BH |
671 | @Override |
672 | public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException { | |
afe13e7a | 673 | |
276c17e7 | 674 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT); |
498704b3 | 675 | |
276c17e7 BH |
676 | command.append(LTTngControlServiceConstants.OPTION_ALL); |
677 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); | |
498704b3 | 678 | |
afe13e7a BH |
679 | String newSessionName = formatParameter(sessionName); |
680 | ||
276c17e7 | 681 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
498704b3 BH |
682 | command.append(newSessionName); |
683 | ||
684 | if (channelName != null) { | |
276c17e7 | 685 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
498704b3 BH |
686 | command.append(channelName); |
687 | } | |
cfdb727a | 688 | |
276c17e7 | 689 | command.append(LTTngControlServiceConstants.OPTION_SYSCALL); |
cfdb727a | 690 | |
afe13e7a | 691 | executeCommand(command.toString(), monitor); |
498704b3 | 692 | } |
cfdb727a | 693 | |
498704b3 | 694 | @Override |
d132bcc7 | 695 | public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException { |
276c17e7 | 696 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT); |
498704b3 BH |
697 | |
698 | command.append(eventName); | |
276c17e7 | 699 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
498704b3 | 700 | |
afe13e7a | 701 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 702 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
498704b3 BH |
703 | command.append(newSessionName); |
704 | ||
705 | if (channelName != null) { | |
276c17e7 | 706 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
498704b3 | 707 | command.append(channelName); |
bbb3538a | 708 | } |
d132bcc7 | 709 | if (isFunction) { |
276c17e7 | 710 | command.append(LTTngControlServiceConstants.OPTION_FUNCTION_PROBE); |
d132bcc7 | 711 | } else { |
276c17e7 | 712 | command.append(LTTngControlServiceConstants.OPTION_PROBE); |
498704b3 | 713 | } |
cfdb727a | 714 | |
498704b3 | 715 | command.append(probe); |
cfdb727a | 716 | |
afe13e7a | 717 | executeCommand(command.toString(), monitor); |
498704b3 | 718 | } |
ccc66d01 | 719 | |
ccc66d01 | 720 | @Override |
d4514365 | 721 | public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExpression, IProgressMonitor monitor) throws ExecutionException { |
276c17e7 | 722 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT); |
ccc66d01 BH |
723 | |
724 | command.append(eventName); | |
276c17e7 | 725 | command.append(LTTngControlServiceConstants.OPTION_UST); |
ccc66d01 | 726 | |
afe13e7a | 727 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 728 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
ccc66d01 BH |
729 | command.append(newSessionName); |
730 | ||
731 | if (channelName != null) { | |
276c17e7 | 732 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
ccc66d01 BH |
733 | command.append(channelName); |
734 | } | |
cfdb727a | 735 | |
ccc66d01 | 736 | if (logLevelType == LogLevelType.LOGLEVEL) { |
276c17e7 | 737 | command.append(LTTngControlServiceConstants.OPTION_LOGLEVEL); |
ccc66d01 | 738 | } else if (logLevelType == LogLevelType.LOGLEVEL_ONLY) { |
276c17e7 | 739 | command.append(LTTngControlServiceConstants.OPTION_LOGLEVEL_ONLY); |
cfdb727a | 740 | |
ccc66d01 BH |
741 | } else { |
742 | return; | |
743 | } | |
744 | command.append(level.getInName()); | |
cfdb727a | 745 | |
afe13e7a | 746 | executeCommand(command.toString(), monitor); |
ccc66d01 BH |
747 | } |
748 | ||
6503ae0f BH |
749 | @Override |
750 | public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 751 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_DISABLE_EVENT); |
6503ae0f | 752 | |
3e91c9c0 | 753 | if (eventNames == null) { |
276c17e7 | 754 | command.append(LTTngControlServiceConstants.OPTION_ALL); |
3e91c9c0 | 755 | } else { |
7a6e4bfd | 756 | // no events to disable |
c56972bb | 757 | if (eventNames.isEmpty()) { |
3e91c9c0 BH |
758 | return; |
759 | } | |
6503ae0f | 760 | |
7a6e4bfd | 761 | StringBuffer eventNameParameter = new StringBuffer(); |
3e91c9c0 | 762 | for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) { |
cfdb727a | 763 | String event = iterator.next(); |
7a6e4bfd | 764 | eventNameParameter.append(event); |
3e91c9c0 | 765 | if (iterator.hasNext()) { |
7a6e4bfd | 766 | eventNameParameter.append(','); |
3e91c9c0 | 767 | } |
6503ae0f | 768 | } |
7a6e4bfd | 769 | command.append(formatParameter(eventNameParameter.toString())); |
6503ae0f BH |
770 | } |
771 | ||
772 | if (isKernel) { | |
276c17e7 | 773 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
6503ae0f | 774 | } else { |
276c17e7 | 775 | command.append(LTTngControlServiceConstants.OPTION_UST); |
6503ae0f BH |
776 | } |
777 | ||
afe13e7a | 778 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 779 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
6503ae0f BH |
780 | command.append(newSessionName); |
781 | ||
782 | if (channelName != null) { | |
276c17e7 | 783 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
6503ae0f BH |
784 | command.append(channelName); |
785 | } | |
786 | ||
afe13e7a | 787 | executeCommand(command.toString(), monitor); |
6503ae0f | 788 | } |
b793fbe1 | 789 | |
b793fbe1 BH |
790 | @Override |
791 | public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException { | |
792 | ||
276c17e7 | 793 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ADD_CONTEXT, LTTngControlServiceConstants.OPTION_HELP); |
b793fbe1 | 794 | |
afe13e7a | 795 | ICommandResult result = executeCommand(command.toString(), monitor); |
b793fbe1 | 796 | |
cfdb727a AM |
797 | String[] output = result.getOutput(); |
798 | ||
b793fbe1 | 799 | List<String> contexts = new ArrayList<String>(0); |
cfdb727a | 800 | |
b793fbe1 BH |
801 | int index = 0; |
802 | boolean inList = false; | |
803 | while (index < output.length) { | |
804 | String line = result.getOutput()[index]; | |
cfdb727a | 805 | |
276c17e7 BH |
806 | Matcher startMatcher = LTTngControlServiceConstants.ADD_CONTEXT_HELP_CONTEXTS_INTRO.matcher(line); |
807 | Matcher endMatcher = LTTngControlServiceConstants.ADD_CONTEXT_HELP_CONTEXTS_END_LINE.matcher(line); | |
b793fbe1 BH |
808 | |
809 | if (startMatcher.matches()) { | |
810 | inList = true; | |
811 | } else if (endMatcher.matches()) { | |
812 | break; | |
813 | } else if (inList == true) { | |
814 | String[] tmp = line.split(","); //$NON-NLS-1$ | |
815 | for (int i = 0; i < tmp.length; i++) { | |
816 | contexts.add(tmp[i].trim()); | |
817 | } | |
818 | } | |
819 | index++; | |
820 | } | |
821 | return contexts; | |
822 | } | |
823 | ||
b793fbe1 BH |
824 | @Override |
825 | public void addContexts(String sessionName, String channelName, String eventName, boolean isKernel, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException { | |
276c17e7 | 826 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ADD_CONTEXT); |
b793fbe1 | 827 | |
afe13e7a | 828 | String newSessionName = formatParameter(sessionName); |
276c17e7 | 829 | command.append(LTTngControlServiceConstants.OPTION_SESSION); |
b793fbe1 | 830 | command.append(newSessionName); |
cfdb727a | 831 | |
b793fbe1 | 832 | if (channelName != null) { |
276c17e7 | 833 | command.append(LTTngControlServiceConstants.OPTION_CHANNEL); |
b793fbe1 BH |
834 | command.append(channelName); |
835 | } | |
836 | ||
837 | if (eventName != null) { | |
276c17e7 | 838 | command.append(LTTngControlServiceConstants.OPTION_EVENT); |
b793fbe1 BH |
839 | command.append(eventName); |
840 | } | |
841 | ||
842 | if (isKernel) { | |
276c17e7 | 843 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
b793fbe1 | 844 | } else { |
276c17e7 | 845 | command.append(LTTngControlServiceConstants.OPTION_UST); |
b793fbe1 | 846 | } |
cfdb727a | 847 | |
b793fbe1 | 848 | for (Iterator<String> iterator = contextNames.iterator(); iterator.hasNext();) { |
cfdb727a | 849 | String context = iterator.next(); |
276c17e7 | 850 | command.append(LTTngControlServiceConstants.OPTION_CONTEXT_TYPE); |
b793fbe1 BH |
851 | command.append(context); |
852 | } | |
853 | ||
afe13e7a | 854 | executeCommand(command.toString(), monitor); |
cfdb727a | 855 | |
b793fbe1 BH |
856 | } |
857 | ||
b720ac44 BH |
858 | @Override |
859 | public void calibrate(boolean isKernel, IProgressMonitor monitor) throws ExecutionException { | |
860 | // String newSessionName = formatParameter(sessionName); | |
276c17e7 | 861 | StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_CALIBRATE); |
b720ac44 BH |
862 | // |
863 | // command.append(OPTION_SESSION); | |
864 | // command.append(newSessionName); | |
865 | ||
866 | if (isKernel) { | |
276c17e7 | 867 | command.append(LTTngControlServiceConstants.OPTION_KERNEL); |
b720ac44 | 868 | } else { |
276c17e7 | 869 | command.append(LTTngControlServiceConstants.OPTION_UST); |
b720ac44 BH |
870 | } |
871 | ||
276c17e7 | 872 | command.append(LTTngControlServiceConstants.OPTION_FUNCTION_PROBE); |
b720ac44 | 873 | |
afe13e7a | 874 | executeCommand(command.toString(), monitor); |
b720ac44 | 875 | } |
cfdb727a | 876 | |
eb1bab5b BH |
877 | // ------------------------------------------------------------------------ |
878 | // Helper methods | |
879 | // ------------------------------------------------------------------------ | |
11252342 | 880 | |
eb1bab5b BH |
881 | /** |
882 | * Checks if command result is an error result. | |
cfdb727a | 883 | * |
4775bcbf BH |
884 | * @param result |
885 | * - the command result to check | |
eb1bab5b BH |
886 | * @return true if error else false |
887 | */ | |
276c17e7 | 888 | protected boolean isError(ICommandResult result) { |
d128c979 BH |
889 | // Check return code and length of returned strings |
890 | if ((result.getResult()) != 0 || (result.getOutput().length < 1)) { | |
eb1bab5b BH |
891 | return true; |
892 | } | |
d128c979 BH |
893 | |
894 | // Look for error pattern | |
895 | int index = 0; | |
896 | while (index < result.getOutput().length) { | |
897 | String line = result.getOutput()[index]; | |
898 | Matcher matcher = LTTngControlServiceConstants.ERROR_PATTERN.matcher(line); | |
899 | if (matcher.matches()) { | |
900 | return true; | |
901 | } | |
902 | index++; | |
903 | } | |
904 | ||
eb1bab5b BH |
905 | return false; |
906 | } | |
4775bcbf | 907 | |
eb1bab5b BH |
908 | /** |
909 | * Formats the output string as single string. | |
cfdb727a | 910 | * |
ea21cd65 | 911 | * @param result |
4775bcbf | 912 | * - output array |
eb1bab5b BH |
913 | * @return - the formatted output |
914 | */ | |
7a6e4bfd | 915 | public static String formatOutput(ICommandResult result) { |
afe13e7a | 916 | if ((result == null) || result.getOutput() == null || result.getOutput().length == 0) { |
eb1bab5b BH |
917 | return ""; //$NON-NLS-1$ |
918 | } | |
afe13e7a | 919 | String[] output = result.getOutput(); |
eb1bab5b | 920 | StringBuffer ret = new StringBuffer(); |
afe13e7a BH |
921 | ret.append("Return Value: "); //$NON-NLS-1$ |
922 | ret.append(result.getResult()); | |
923 | ret.append("\n"); //$NON-NLS-1$ | |
eb1bab5b BH |
924 | for (int i = 0; i < output.length; i++) { |
925 | ret.append(output[i] + "\n"); //$NON-NLS-1$ | |
926 | } | |
927 | return ret.toString(); | |
928 | } | |
4775bcbf | 929 | |
eb1bab5b BH |
930 | /** |
931 | * Parses the domain information. | |
cfdb727a | 932 | * |
4775bcbf BH |
933 | * @param output |
934 | * - a command output array | |
935 | * @param currentIndex | |
936 | * - current index in command output array | |
937 | * @param channels | |
938 | * - list for returning channel information | |
939 | * @return the new current index in command output array | |
eb1bab5b | 940 | */ |
276c17e7 | 941 | protected int parseDomain(String[] output, int currentIndex, List<IChannelInfo> channels) { |
eb1bab5b BH |
942 | int index = currentIndex; |
943 | ||
4775bcbf BH |
944 | // Channels: |
945 | // ------------- | |
946 | // - channnel1: [enabled] | |
947 | // | |
948 | // Attributes: | |
949 | // overwrite mode: 0 | |
950 | // subbufers size: 262144 | |
951 | // number of subbufers: 4 | |
952 | // switch timer interval: 0 | |
953 | // read timer interval: 200 | |
954 | // output: splice() | |
955 | ||
eb1bab5b BH |
956 | while (index < output.length) { |
957 | String line = output[index]; | |
4775bcbf | 958 | |
276c17e7 | 959 | Matcher outerMatcher = LTTngControlServiceConstants.CHANNELS_SECTION_PATTERN.matcher(line); |
a30e79fe BH |
960 | Matcher noKernelChannelMatcher = LTTngControlServiceConstants.DOMAIN_NO_KERNEL_CHANNEL_PATTERN.matcher(line); |
961 | Matcher noUstChannelMatcher = LTTngControlServiceConstants.DOMAIN_NO_UST_CHANNEL_PATTERN.matcher(line); | |
4775bcbf | 962 | if (outerMatcher.matches()) { |
eb1bab5b BH |
963 | IChannelInfo channelInfo = null; |
964 | while (index < output.length) { | |
965 | String subLine = output[index]; | |
4775bcbf | 966 | |
276c17e7 | 967 | Matcher innerMatcher = LTTngControlServiceConstants.CHANNEL_PATTERN.matcher(subLine); |
4775bcbf | 968 | if (innerMatcher.matches()) { |
eb1bab5b | 969 | channelInfo = new ChannelInfo(""); //$NON-NLS-1$ |
4775bcbf BH |
970 | // get channel name |
971 | channelInfo.setName(innerMatcher.group(1)); | |
972 | ||
973 | // get channel enablement | |
974 | channelInfo.setState(innerMatcher.group(2)); | |
975 | ||
976 | // add channel | |
977 | channels.add(channelInfo); | |
978 | ||
276c17e7 | 979 | } else if (LTTngControlServiceConstants.OVERWRITE_MODE_ATTRIBUTE.matcher(subLine).matches()) { |
eb1bab5b | 980 | String value = getAttributeValue(subLine); |
64636df8 BH |
981 | if (channelInfo != null) { |
982 | channelInfo.setOverwriteMode(!LTTngControlServiceConstants.OVERWRITE_MODE_ATTRIBUTE_FALSE.equals(value)); | |
983 | } | |
276c17e7 | 984 | } else if (LTTngControlServiceConstants.SUBBUFFER_SIZE_ATTRIBUTE.matcher(subLine).matches()) { |
64636df8 BH |
985 | if (channelInfo != null) { |
986 | channelInfo.setSubBufferSize(Long.valueOf(getAttributeValue(subLine))); | |
987 | } | |
4775bcbf | 988 | |
276c17e7 | 989 | } else if (LTTngControlServiceConstants.NUM_SUBBUFFERS_ATTRIBUTE.matcher(subLine).matches()) { |
64636df8 BH |
990 | if (channelInfo != null) { |
991 | channelInfo.setNumberOfSubBuffers(Integer.valueOf(getAttributeValue(subLine))); | |
992 | } | |
4775bcbf | 993 | |
276c17e7 | 994 | } else if (LTTngControlServiceConstants.SWITCH_TIMER_ATTRIBUTE.matcher(subLine).matches()) { |
64636df8 BH |
995 | if (channelInfo != null) { |
996 | channelInfo.setSwitchTimer(Long.valueOf(getAttributeValue(subLine))); | |
997 | } | |
4775bcbf | 998 | |
276c17e7 | 999 | } else if (LTTngControlServiceConstants.READ_TIMER_ATTRIBUTE.matcher(subLine).matches()) { |
64636df8 BH |
1000 | if (channelInfo != null) { |
1001 | channelInfo.setReadTimer(Long.valueOf(getAttributeValue(subLine))); | |
1002 | } | |
4775bcbf | 1003 | |
276c17e7 | 1004 | } else if (LTTngControlServiceConstants.OUTPUT_ATTRIBUTE.matcher(subLine).matches()) { |
64636df8 BH |
1005 | if (channelInfo != null) { |
1006 | channelInfo.setOutputType(getAttributeValue(subLine)); | |
1007 | } | |
4775bcbf | 1008 | |
276c17e7 | 1009 | } else if (LTTngControlServiceConstants.EVENT_SECTION_PATTERN.matcher(subLine).matches()) { |
4775bcbf | 1010 | List<IEventInfo> events = new ArrayList<IEventInfo>(); |
eb1bab5b | 1011 | index = parseEvents(output, index, events); |
64636df8 BH |
1012 | if (channelInfo != null) { |
1013 | channelInfo.setEvents(events); | |
1014 | } | |
4775bcbf BH |
1015 | // we want to stay at the current index to be able to |
1016 | // exit the domain | |
eb1bab5b | 1017 | continue; |
276c17e7 | 1018 | } else if (LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(subLine).matches()) { |
eb1bab5b BH |
1019 | return index; |
1020 | ||
276c17e7 | 1021 | } else if (LTTngControlServiceConstants.DOMAIN_UST_GLOBAL_PATTERN.matcher(subLine).matches()) { |
eb1bab5b BH |
1022 | return index; |
1023 | } | |
1024 | index++; | |
1025 | } | |
a30e79fe BH |
1026 | } else if (noKernelChannelMatcher.matches() || noUstChannelMatcher.matches()) { |
1027 | // domain indicates that no channels were found -> return | |
1028 | index++; | |
1029 | return index; | |
eb1bab5b BH |
1030 | } |
1031 | index++; | |
1032 | } | |
1033 | return index; | |
1034 | } | |
1035 | ||
1036 | /** | |
1037 | * Parses the event information within a domain. | |
cfdb727a | 1038 | * |
4775bcbf BH |
1039 | * @param output |
1040 | * - a command output array | |
1041 | * @param currentIndex | |
1042 | * - current index in command output array | |
1043 | * @param events | |
1044 | * - list for returning event information | |
eb1bab5b | 1045 | * @return the new current index in command output array |
eb1bab5b | 1046 | */ |
276c17e7 | 1047 | protected int parseEvents(String[] output, int currentIndex, List<IEventInfo> events) { |
eb1bab5b BH |
1048 | int index = currentIndex; |
1049 | ||
1050 | while (index < output.length) { | |
1051 | String line = output[index]; | |
276c17e7 | 1052 | if (LTTngControlServiceConstants.CHANNEL_PATTERN.matcher(line).matches()) { |
eb1bab5b BH |
1053 | // end of channel |
1054 | return index; | |
276c17e7 | 1055 | } else if (LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(line).matches()) { |
eb1bab5b BH |
1056 | // end of domain |
1057 | return index; | |
276c17e7 | 1058 | } else if (LTTngControlServiceConstants.DOMAIN_UST_GLOBAL_PATTERN.matcher(line).matches()) { |
eb1bab5b BH |
1059 | // end of domain |
1060 | return index; | |
cfdb727a | 1061 | } |
4775bcbf | 1062 | |
276c17e7 BH |
1063 | Matcher matcher = LTTngControlServiceConstants.EVENT_PATTERN.matcher(line); |
1064 | Matcher matcher2 = LTTngControlServiceConstants.WILDCARD_EVENT_PATTERN.matcher(line); | |
4775bcbf BH |
1065 | |
1066 | if (matcher.matches()) { | |
1067 | IEventInfo eventInfo = new EventInfo(matcher.group(1).trim()); | |
1068 | eventInfo.setLogLevel(matcher.group(2).trim()); | |
1069 | eventInfo.setEventType(matcher.group(3).trim()); | |
1070 | eventInfo.setState(matcher.group(4)); | |
d4514365 BH |
1071 | String filter = matcher.group(5); |
1072 | if (filter != null) { | |
1073 | filter = filter.substring(1, filter.length() - 1); // remove '[' and ']' | |
1074 | eventInfo.setFilterExpression(filter); | |
1075 | } | |
4775bcbf | 1076 | events.add(eventInfo); |
d132bcc7 | 1077 | index++; |
4775bcbf BH |
1078 | } else if (matcher2.matches()) { |
1079 | IEventInfo eventInfo = new EventInfo(matcher2.group(1).trim()); | |
1080 | eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN); | |
1081 | eventInfo.setEventType(matcher2.group(2).trim()); | |
1082 | eventInfo.setState(matcher2.group(3)); | |
d4514365 BH |
1083 | String filter = matcher2.group(4); |
1084 | if (filter != null) { | |
1085 | filter = filter.substring(1, filter.length() - 1); // remove '[' and ']' | |
1086 | eventInfo.setFilterExpression(filter); | |
1087 | } | |
cfdb727a | 1088 | |
d132bcc7 BH |
1089 | if (eventInfo.getEventType() == TraceEventType.PROBE) { |
1090 | IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName()); | |
1091 | probeEvent.setLogLevel(eventInfo.getLogLevel()); | |
1092 | probeEvent.setEventType(eventInfo.getEventType()); | |
1093 | probeEvent.setState(eventInfo.getState()); | |
1094 | ||
1095 | // Overwrite eventinfo | |
1096 | eventInfo = probeEvent; | |
1097 | ||
1098 | // myevent2 (type: probe) [enabled] | |
1099 | // addr: 0xc0101340 | |
1100 | // myevent0 (type: probe) [enabled] | |
1101 | // offset: 0x0 | |
1102 | // symbol: init_post | |
1103 | index++; | |
1104 | while (index < output.length) { | |
1105 | String probeLine = output[index]; | |
1106 | // parse probe | |
276c17e7 BH |
1107 | Matcher addrMatcher = LTTngControlServiceConstants.PROBE_ADDRESS_PATTERN.matcher(probeLine); |
1108 | Matcher offsetMatcher = LTTngControlServiceConstants.PROBE_OFFSET_PATTERN.matcher(probeLine); | |
1109 | Matcher symbolMatcher = LTTngControlServiceConstants.PROBE_SYMBOL_PATTERN.matcher(probeLine); | |
d132bcc7 BH |
1110 | if (addrMatcher.matches()) { |
1111 | String addr = addrMatcher.group(2).trim(); | |
1112 | probeEvent.setAddress(addr); | |
1113 | } else if (offsetMatcher.matches()) { | |
1114 | String offset = offsetMatcher.group(2).trim(); | |
1115 | probeEvent.setOffset(offset); | |
1116 | } else if (symbolMatcher.matches()) { | |
1117 | String symbol = symbolMatcher.group(2).trim(); | |
1118 | probeEvent.setSymbol(symbol); | |
276c17e7 | 1119 | } else if ((LTTngControlServiceConstants.EVENT_PATTERN.matcher(probeLine).matches()) || (LTTngControlServiceConstants.WILDCARD_EVENT_PATTERN.matcher(probeLine).matches())) { |
d132bcc7 | 1120 | break; |
276c17e7 | 1121 | } else if (LTTngControlServiceConstants.CHANNEL_PATTERN.matcher(probeLine).matches()) { |
d132bcc7 | 1122 | break; |
276c17e7 | 1123 | } else if (LTTngControlServiceConstants.DOMAIN_KERNEL_PATTERN.matcher(probeLine).matches()) { |
d132bcc7 BH |
1124 | // end of domain |
1125 | break; | |
276c17e7 | 1126 | } else if (LTTngControlServiceConstants.DOMAIN_UST_GLOBAL_PATTERN.matcher(probeLine).matches()) { |
d132bcc7 BH |
1127 | // end of domain |
1128 | break; | |
1129 | } | |
1130 | index++; | |
1131 | } | |
1132 | events.add(eventInfo); | |
1133 | } else { | |
1134 | events.add(eventInfo); | |
1135 | index++; | |
1136 | continue; | |
1137 | } | |
1138 | } else { | |
1139 | index++; | |
eb1bab5b BH |
1140 | } |
1141 | // else if (line.matches(EVENT_NONE_PATTERN)) { | |
1142 | // do nothing | |
cfdb727a | 1143 | // } else |
d132bcc7 | 1144 | |
eb1bab5b BH |
1145 | } |
1146 | ||
1147 | return index; | |
1148 | } | |
1149 | ||
1150 | /** | |
1151 | * Parses a line with attributes: <attribute Name>: <attribute value> | |
cfdb727a | 1152 | * |
4775bcbf BH |
1153 | * @param line |
1154 | * - attribute line to parse | |
eb1bab5b | 1155 | * @return the attribute value as string |
eb1bab5b | 1156 | */ |
276c17e7 | 1157 | protected String getAttributeValue(String line) { |
eb1bab5b BH |
1158 | String[] temp = line.split("\\: "); //$NON-NLS-1$ |
1159 | return temp[1]; | |
1160 | } | |
1161 | ||
1162 | /** | |
4775bcbf | 1163 | * Parses the event information within a provider. |
cfdb727a | 1164 | * |
4775bcbf BH |
1165 | * @param output |
1166 | * - a command output array | |
1167 | * @param currentIndex | |
1168 | * - current index in command output array | |
1169 | * @param events | |
1170 | * - list for returning event information | |
eb1bab5b BH |
1171 | * @return the new current index in command output array |
1172 | */ | |
276c17e7 | 1173 | protected int getProviderEventInfo(String[] output, int currentIndex, List<IBaseEventInfo> events) { |
eb1bab5b | 1174 | int index = currentIndex; |
d4514365 | 1175 | IBaseEventInfo eventInfo = null; |
eb1bab5b BH |
1176 | while (index < output.length) { |
1177 | String line = output[index]; | |
276c17e7 | 1178 | Matcher matcher = LTTngControlServiceConstants.PROVIDER_EVENT_PATTERN.matcher(line); |
4775bcbf | 1179 | if (matcher.matches()) { |
d4514365 BH |
1180 | // sched_kthread_stop (loglevel: TRACE_EMERG0) (type: tracepoint) |
1181 | eventInfo = new BaseEventInfo(matcher.group(1).trim()); | |
4775bcbf BH |
1182 | eventInfo.setLogLevel(matcher.group(2).trim()); |
1183 | eventInfo.setEventType(matcher.group(3).trim()); | |
1184 | events.add(eventInfo); | |
d4514365 BH |
1185 | index++; |
1186 | } else if (LTTngControlServiceConstants.EVENT_FIELD_PATTERN.matcher(line).matches()) { | |
1187 | if (eventInfo != null) { | |
1188 | List<IFieldInfo> fields = new ArrayList<IFieldInfo>(); | |
1189 | index = getFieldInfo(output, index, fields); | |
1190 | eventInfo.setFields(fields); | |
1191 | } else { | |
1192 | index++; | |
1193 | } | |
1194 | } | |
1195 | else if (LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line).matches()) { | |
1196 | return index; | |
1197 | } else { | |
1198 | index++; | |
1199 | } | |
1200 | } | |
1201 | return index; | |
1202 | } | |
1203 | ||
1204 | ||
7050e327 AM |
1205 | /** |
1206 | * Parse a field's information. | |
1207 | * | |
1208 | * @param output | |
1209 | * A command output array | |
1210 | * @param currentIndex | |
1211 | * The current index in the command output array | |
1212 | * @param fields | |
1213 | * List for returning the field information | |
1214 | * @return The new current index in the command output array | |
1215 | */ | |
d4514365 BH |
1216 | protected int getFieldInfo(String[] output, int currentIndex, List<IFieldInfo> fields) { |
1217 | int index = currentIndex; | |
1218 | IFieldInfo fieldInfo = null; | |
1219 | while (index < output.length) { | |
1220 | String line = output[index]; | |
1221 | Matcher matcher = LTTngControlServiceConstants.EVENT_FIELD_PATTERN.matcher(line); | |
1222 | if (matcher.matches()) { | |
1223 | // field: content (string) | |
1224 | fieldInfo = new FieldInfo(matcher.group(2).trim()); | |
1225 | fieldInfo.setFieldType(matcher.group(3).trim()); | |
1226 | fields.add(fieldInfo); | |
1227 | } else if (LTTngControlServiceConstants.PROVIDER_EVENT_PATTERN.matcher(line).matches()) { | |
1228 | return index; | |
276c17e7 | 1229 | } else if (LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line).matches()) { |
eb1bab5b BH |
1230 | return index; |
1231 | } | |
1232 | index++; | |
1233 | } | |
1234 | return index; | |
1235 | } | |
1236 | ||
bbb3538a | 1237 | /** |
cfdb727a | 1238 | * Formats a command parameter for the command execution i.e. adds quotes |
bbb3538a BH |
1239 | * at the beginning and end if necessary. |
1240 | * @param parameter - parameter to format | |
1241 | * @return formated parameter | |
1242 | */ | |
276c17e7 | 1243 | protected String formatParameter(String parameter) { |
bbb3538a | 1244 | if (parameter != null) { |
c56972bb BH |
1245 | StringBuffer newString = new StringBuffer(); |
1246 | newString.append(parameter); | |
bbb3538a | 1247 | |
7a6e4bfd | 1248 | if (parameter.contains(" ") || parameter.contains("*")) { //$NON-NLS-1$ //$NON-NLS-2$ |
c56972bb BH |
1249 | newString.insert(0, "\""); //$NON-NLS-1$ |
1250 | newString.append("\""); //$NON-NLS-1$ | |
bbb3538a | 1251 | } |
c56972bb | 1252 | return newString.toString(); |
bbb3538a BH |
1253 | } |
1254 | return null; | |
1255 | } | |
afe13e7a BH |
1256 | |
1257 | /** | |
1258 | * @param strings array of string that makes up a command line | |
1259 | * @return string buffer with created command line | |
1260 | */ | |
276c17e7 | 1261 | protected StringBuffer createCommand(String... strings) { |
afe13e7a | 1262 | StringBuffer command = new StringBuffer(); |
276c17e7 | 1263 | command.append(LTTngControlServiceConstants.CONTROL_COMMAND); |
afe13e7a BH |
1264 | command.append(getTracingGroupOption()); |
1265 | command.append(getVerboseOption()); | |
1266 | for (String string : strings) { | |
1267 | command.append(string); | |
1268 | } | |
1269 | return command; | |
1270 | } | |
1271 | ||
1272 | /** | |
1273 | * @return the tracing group option if configured in the preferences | |
1274 | */ | |
276c17e7 | 1275 | protected String getTracingGroupOption() { |
afe13e7a | 1276 | if (!ControlPreferences.getInstance().isDefaultTracingGroup() && !ControlPreferences.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$ |
276c17e7 | 1277 | return LTTngControlServiceConstants.OPTION_TRACING_GROUP + ControlPreferences.getInstance().getTracingGroup(); |
afe13e7a BH |
1278 | } |
1279 | return ""; //$NON-NLS-1$ | |
1280 | } | |
1281 | ||
1282 | /** | |
1283 | * @return the verbose option as configured in the preferences | |
1284 | */ | |
276c17e7 | 1285 | protected String getVerboseOption() { |
afe13e7a BH |
1286 | if (ControlPreferences.getInstance().isLoggingEnabled()) { |
1287 | String level = ControlPreferences.getInstance().getVerboseLevel(); | |
1288 | if (ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_VERBOSE.equals(level)) { | |
276c17e7 | 1289 | return LTTngControlServiceConstants.OPTION_VERBOSE; |
afe13e7a BH |
1290 | } |
1291 | if (ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_VERBOSE.equals(level)) { | |
276c17e7 | 1292 | return LTTngControlServiceConstants.OPTION_VERY_VERBOSE; |
cfdb727a | 1293 | } |
afe13e7a | 1294 | if (ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE.equals(level)) { |
276c17e7 | 1295 | return LTTngControlServiceConstants.OPTION_VERY_VERY_VERBOSE; |
afe13e7a BH |
1296 | } |
1297 | } | |
1298 | return ""; //$NON-NLS-1$ | |
1299 | } | |
1300 | ||
1301 | /** | |
cfdb727a AM |
1302 | * Method that logs the command and command result if logging is enabled as |
1303 | * well as forwards the command execution to the shell. | |
1304 | * | |
1305 | * @param command | |
1306 | * - the command to execute | |
1307 | * @param monitor | |
1308 | * - a progress monitor | |
afe13e7a BH |
1309 | * @return the command result |
1310 | * @throws ExecutionException | |
6f4e8ec0 | 1311 | * If the command fails |
afe13e7a | 1312 | */ |
cfdb727a AM |
1313 | protected ICommandResult executeCommand(String command, |
1314 | IProgressMonitor monitor) throws ExecutionException { | |
afe13e7a BH |
1315 | return executeCommand(command, monitor, true); |
1316 | } | |
cfdb727a | 1317 | |
afe13e7a | 1318 | /** |
cfdb727a AM |
1319 | * Method that logs the command and command result if logging is enabled as |
1320 | * well as forwards the command execution to the shell. | |
1321 | * | |
1322 | * @param command | |
1323 | * - the command to execute | |
1324 | * @param monitor | |
1325 | * - a progress monitor | |
1326 | * @param checkForError | |
1327 | * - true to verify command result, else false | |
afe13e7a | 1328 | * @return the command result |
cfdb727a AM |
1329 | * @throws ExecutionException |
1330 | * in case of error result | |
afe13e7a | 1331 | */ |
cfdb727a AM |
1332 | protected ICommandResult executeCommand(String command, |
1333 | IProgressMonitor monitor, boolean checkForError) | |
1334 | throws ExecutionException { | |
afe13e7a BH |
1335 | if (ControlPreferences.getInstance().isLoggingEnabled()) { |
1336 | ControlCommandLogger.log(command); | |
1337 | } | |
1338 | ||
cfdb727a AM |
1339 | ICommandResult result = fCommandShell.executeCommand( |
1340 | command.toString(), monitor); | |
1341 | ||
afe13e7a BH |
1342 | if (ControlPreferences.getInstance().isLoggingEnabled()) { |
1343 | ControlCommandLogger.log(formatOutput(result)); | |
1344 | } | |
1345 | ||
a07c7629 | 1346 | if (checkForError && isError(result)) { |
cfdb727a AM |
1347 | throw new ExecutionException(Messages.TraceControl_CommandError |
1348 | + " " + command.toString() + "\n" + formatOutput(result)); //$NON-NLS-1$ //$NON-NLS-2$ | |
afe13e7a | 1349 | } |
cfdb727a | 1350 | |
afe13e7a BH |
1351 | return result; |
1352 | } | |
eb1bab5b | 1353 | } |