1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 * Simon Delisle - Updated for support of LTTng Tools 2.2
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
;
16 import java
.util
.ArrayList
;
17 import java
.util
.Iterator
;
18 import java
.util
.List
;
19 import java
.util
.regex
.Matcher
;
21 import org
.eclipse
.core
.commands
.ExecutionException
;
22 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
23 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IProbeEventInfo
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.BaseEventInfo
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.BufferTypeConstants
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ChannelInfo
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.DomainInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.EventInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.FieldInfo
;
41 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.ProbeEventInfo
;
42 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.SessionInfo
;
43 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.UstProviderInfo
;
44 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.logging
.ControlCommandLogger
;
45 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
46 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.preferences
.ControlPreferences
;
47 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.remote
.ICommandResult
;
48 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.remote
.ICommandShell
;
52 * Service for sending LTTng trace control commands to remote host.
55 * @author Bernd Hufmann
57 public class LTTngControlService
implements ILttngControlService
{
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
63 * The command shell implementation
65 private final ICommandShell fCommandShell
;
70 private LttngVersion fVersion
= null;
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
80 * - the command shell implementation to use
82 public LTTngControlService(ICommandShell shell
) {
83 fCommandShell
= shell
;
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 public String
getVersion() {
92 if (fVersion
== null) {
93 return "Unknown"; //$NON-NLS-1$
95 return fVersion
.toString();
99 * Sets the version of the LTTng 2.0 control service.
100 * @param version - a version to set
102 public void setVersion(String version
) {
103 fVersion
= new LttngVersion(version
);
107 public boolean isVersionSupported(String version
) {
108 LttngVersion tmp
= new LttngVersion(version
);
109 return (fVersion
!= null && fVersion
.compareTo(tmp
) >= 0) ?
true : false;
113 * Returns the command shell implementation.
115 * @return the command shell implementation
117 protected ICommandShell
getCommandShell() {
118 return fCommandShell
;
121 // ------------------------------------------------------------------------
123 // ------------------------------------------------------------------------
126 public String
[] getSessionNames(IProgressMonitor monitor
) throws ExecutionException
{
127 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_LIST
);
129 ICommandResult result
= executeCommand(command
.toString(), monitor
);
132 // Available tracing sessions:
133 // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
134 // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
136 // Use lttng list <session_name> for more details
138 ArrayList
<String
> retArray
= new ArrayList
<String
>();
140 while (index
< result
.getOutput().length
) {
141 String line
= result
.getOutput()[index
];
142 Matcher matcher
= LTTngControlServiceConstants
.SESSION_PATTERN
.matcher(line
);
143 if (matcher
.matches()) {
144 retArray
.add(matcher
.group(2).trim());
148 return retArray
.toArray(new String
[retArray
.size()]);
152 public ISessionInfo
getSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
153 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_LIST
, sessionName
);
154 ICommandResult result
= executeCommand(command
.toString(), monitor
);
159 // Tracing session mysession2: [inactive]
160 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
161 ISessionInfo sessionInfo
= new SessionInfo(sessionName
);
163 while (index
< result
.getOutput().length
) {
164 // Tracing session mysession2: [inactive]
165 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
167 // === Domain: Kernel ===
169 String line
= result
.getOutput()[index
];
170 Matcher matcher
= LTTngControlServiceConstants
.TRACE_SESSION_PATTERN
.matcher(line
);
171 if (matcher
.matches()) {
172 sessionInfo
.setSessionState(matcher
.group(2));
177 matcher
= LTTngControlServiceConstants
.TRACE_NETWORK_PATH_PATTERN
.matcher(line
);
178 if (matcher
.matches()) {
179 sessionInfo
.setStreamedTrace(true);
182 matcher
= LTTngControlServiceConstants
.TRACE_SESSION_PATH_PATTERN
.matcher(line
);
183 if (matcher
.matches()) {
184 sessionInfo
.setSessionPath(matcher
.group(1).trim());
189 matcher
= LTTngControlServiceConstants
.DOMAIN_KERNEL_PATTERN
.matcher(line
);
190 if (matcher
.matches()) {
192 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_KernelDomainDisplayName
);
195 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
196 index
= parseDomain(result
.getOutput(), index
, channels
, domainInfo
);
198 if (channels
.size() > 0) {
200 sessionInfo
.addDomain(domainInfo
);
203 domainInfo
.setChannels(channels
);
206 domainInfo
.setIsKernel(true);
211 matcher
= LTTngControlServiceConstants
.DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
);
212 if (matcher
.matches()) {
213 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_UstGlobalDomainDisplayName
);
216 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
217 index
= parseDomain(result
.getOutput(), index
, channels
, domainInfo
);
219 if (channels
.size() > 0) {
221 sessionInfo
.addDomain(domainInfo
);
224 domainInfo
.setChannels(channels
);
227 domainInfo
.setIsKernel(false);
237 public List
<IBaseEventInfo
> getKernelProvider(IProgressMonitor monitor
) throws ExecutionException
{
238 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_LIST_KERNEL
);
239 ICommandResult result
= executeCommand(command
.toString(), monitor
, false);
241 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
243 if (result
.getOutput() != null) {
244 // Ignore the following 2 cases:
245 // Spawning a session daemon
246 // Error: Unable to list kernel events
248 // Error: Unable to list kernel events
251 while (index
< result
.getOutput().length
) {
252 String line
= result
.getOutput()[index
];
253 Matcher matcher
= LTTngControlServiceConstants
.LIST_KERNEL_NO_KERNEL_PROVIDER_PATTERN
.matcher(line
);
254 if (matcher
.matches()) {
261 if (isError(result
)) {
262 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
.toString() + "\n" + formatOutput(result
)); //$NON-NLS-1$ //$NON-NLS-2$
267 // sched_kthread_stop (type: tracepoint)
268 getProviderEventInfo(result
.getOutput(), 0, events
);
273 public List
<IUstProviderInfo
> getUstProvider() throws ExecutionException
{
274 return getUstProvider(new NullProgressMonitor());
278 public List
<IUstProviderInfo
> getUstProvider(IProgressMonitor monitor
) throws ExecutionException
{
279 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_LIST_UST
);
281 if (isVersionSupported("2.1.0")) { //$NON-NLS-1$
282 command
.append(LTTngControlServiceConstants
.OPTION_FIELDS
);
285 ICommandResult result
= executeCommand(command
.toString(), monitor
, false);
286 List
<IUstProviderInfo
> allProviders
= new ArrayList
<IUstProviderInfo
>();
288 // Workaround for versions 2.0.x which causes a segmentation fault for this command
289 // if LTTng Tools is compiled without UST support.
290 if (!isVersionSupported("2.1.0") && (result
.getResult() != 0)) { //$NON-NLS-1$
294 if (result
.getOutput() != null) {
295 // Ignore the following 2 cases:
296 // Spawning a session daemon
297 // Error: Unable to list UST events: Listing UST events failed
299 // Error: Unable to list UST events: Listing UST events failed
302 while (index
< result
.getOutput().length
) {
303 String line
= result
.getOutput()[index
];
304 Matcher matcher
= LTTngControlServiceConstants
.LIST_UST_NO_UST_PROVIDER_PATTERN
.matcher(line
);
305 if (matcher
.matches()) {
312 if (isError(result
)) {
313 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
.toString() + "\n" + formatOutput(result
)); //$NON-NLS-1$ //$NON-NLS-2$
316 // Note that field print-outs exists for version >= 2.1.0
322 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
323 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
325 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
326 // field: doublefield (float)
327 // field: floatfield (float)
328 // field: stringfield (string)
331 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
332 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
334 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
335 // field: doublefield (float)
336 // field: floatfield (float)
337 // field: stringfield (string)
339 IUstProviderInfo provider
= null;
342 while (index
< result
.getOutput().length
) {
343 String line
= result
.getOutput()[index
];
344 Matcher matcher
= LTTngControlServiceConstants
.UST_PROVIDER_PATTERN
.matcher(line
);
345 if (matcher
.matches()) {
346 provider
= new UstProviderInfo(matcher
.group(2).trim());
347 provider
.setPid(Integer
.valueOf(matcher
.group(1).trim()));
348 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
349 index
= getProviderEventInfo(result
.getOutput(), ++index
, events
);
350 provider
.setEvents(events
);
351 allProviders
.add(provider
);
360 public ISessionInfo
createSession(String sessionName
, String sessionPath
, IProgressMonitor monitor
) throws ExecutionException
{
362 String newName
= formatParameter(sessionName
);
363 String newPath
= formatParameter(sessionPath
);
365 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_CREATE_SESSION
, newName
);
367 if (newPath
!= null && !"".equals(newPath
)) { //$NON-NLS-1$
368 command
.append(LTTngControlServiceConstants
.OPTION_OUTPUT_PATH
);
369 command
.append(newPath
);
372 ICommandResult result
= executeCommand(command
.toString(), monitor
);
374 //Session myssession2 created.
375 //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
376 String
[] output
= result
.getOutput();
378 // Get and session name and path
383 while (index
< output
.length
) {
384 String line
= output
[index
];
385 Matcher nameMatcher
= LTTngControlServiceConstants
.CREATE_SESSION_NAME_PATTERN
.matcher(line
);
386 Matcher pathMatcher
= LTTngControlServiceConstants
.CREATE_SESSION_PATH_PATTERN
.matcher(line
);
387 if (nameMatcher
.matches()) {
388 name
= String
.valueOf(nameMatcher
.group(1).trim());
389 } else if (pathMatcher
.matches()) {
390 path
= String
.valueOf(pathMatcher
.group(1).trim());
395 // Verify session name
396 if ((name
== null) || (!"".equals(sessionName
) && !name
.equals(sessionName
))) { //$NON-NLS-1$
397 // Unexpected name returned
398 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
399 Messages
.TraceControl_UnexpectedNameError
+ ": " + name
); //$NON-NLS-1$
402 SessionInfo sessionInfo
= new SessionInfo(name
);
404 // Verify session path
405 if ((path
== null) || ((sessionPath
!= null) && (!path
.contains(sessionPath
)))) {
407 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
408 Messages
.TraceControl_UnexpectedPathError
+ ": " + name
); //$NON-NLS-1$
411 sessionInfo
.setSessionPath(path
);
418 public ISessionInfo
createSession(String sessionName
, String networkUrl
, String controlUrl
, String dataUrl
, IProgressMonitor monitor
) throws ExecutionException
{
420 String newName
= formatParameter(sessionName
);
421 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_CREATE_SESSION
, newName
);
423 if (networkUrl
!= null) {
424 command
.append(LTTngControlServiceConstants
.OPTION_NETWORK_URL
);
425 command
.append(networkUrl
);
427 command
.append(LTTngControlServiceConstants
.OPTION_CONTROL_URL
);
428 command
.append(controlUrl
);
430 command
.append(LTTngControlServiceConstants
.OPTION_DATA_URL
);
431 command
.append(dataUrl
);
434 ICommandResult result
= executeCommand(command
.toString(), monitor
);
437 String
[] output
= result
.getOutput();
439 // Get and session name and path
444 while (index
< output
.length
) {
445 String line
= output
[index
];
446 Matcher nameMatcher
= LTTngControlServiceConstants
.CREATE_SESSION_NAME_PATTERN
.matcher(line
);
447 Matcher pathMatcher
= LTTngControlServiceConstants
.CREATE_SESSION_PATH_PATTERN
.matcher(line
);
449 if (nameMatcher
.matches()) {
450 name
= String
.valueOf(nameMatcher
.group(1).trim());
451 } else if (pathMatcher
.matches() && (networkUrl
!= null)) {
452 path
= String
.valueOf(pathMatcher
.group(1).trim());
457 // Verify session name
458 if ((name
== null) || (!"".equals(sessionName
) && !name
.equals(sessionName
))) { //$NON-NLS-1$
459 // Unexpected name returned
460 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
461 Messages
.TraceControl_UnexpectedNameError
+ ": " + name
); //$NON-NLS-1$
464 SessionInfo sessionInfo
= new SessionInfo(name
);
466 sessionInfo
.setStreamedTrace(true);
468 // Verify session path
469 if (networkUrl
!= null) {
472 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
473 Messages
.TraceControl_UnexpectedPathError
+ ": " + name
); //$NON-NLS-1$
476 sessionInfo
.setSessionPath(path
);
478 // Check file protocol
479 Matcher matcher
= LTTngControlServiceConstants
.TRACE_FILE_PROTOCOL_PATTERN
.matcher(path
);
480 if (matcher
.matches()) {
481 sessionInfo
.setStreamedTrace(false);
484 // When using controlUrl and dataUrl the full session path is not known yet
485 // and will be set later on when listing the session
491 public void destroySession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
492 String newName
= formatParameter(sessionName
);
494 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_DESTROY_SESSION
, newName
);
496 ICommandResult result
= executeCommand(command
.toString(), monitor
, false);
497 String
[] output
= result
.getOutput();
499 boolean isError
= isError(result
);
500 if (isError
&& (output
!= null)) {
502 while (index
< output
.length
) {
503 String line
= output
[index
];
504 Matcher matcher
= LTTngControlServiceConstants
.SESSION_NOT_FOUND_ERROR_PATTERN
.matcher(line
);
505 if (matcher
.matches()) {
506 // Don't treat this as an error
514 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
.toString() + "\n" + formatOutput(result
)); //$NON-NLS-1$ //$NON-NLS-2$
517 //Session <sessionName> destroyed
521 public void startSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
523 String newSessionName
= formatParameter(sessionName
);
525 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_START_SESSION
, newSessionName
);
527 executeCommand(command
.toString(), monitor
);
529 //Session <sessionName> started
533 public void stopSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
534 String newSessionName
= formatParameter(sessionName
);
535 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_STOP_SESSION
, newSessionName
);
537 executeCommand(command
.toString(), monitor
);
539 //Session <sessionName> stopped
544 public void enableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
546 // no channels to enable
547 if (channelNames
.isEmpty()) {
551 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ENABLE_CHANNEL
);
553 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
554 String channel
= iterator
.next();
555 command
.append(channel
);
556 if (iterator
.hasNext()) {
562 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
564 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
567 String newSessionName
= formatParameter(sessionName
);
568 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
569 command
.append(newSessionName
);
572 // --discard Discard event when buffers are full (default)
574 // --overwrite Flight recorder mode
575 if (info
.isOverwriteMode()) {
576 command
.append(LTTngControlServiceConstants
.OPTION_OVERWRITE
);
578 // --subbuf-size SIZE Subbuffer size in bytes
579 // (default: 4096, kernel default: 262144)
580 if (info
.getSubBufferSize() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
581 command
.append(LTTngControlServiceConstants
.OPTION_SUB_BUFFER_SIZE
);
582 command
.append(String
.valueOf(info
.getSubBufferSize()));
585 // --num-subbuf NUM Number of subbufers
586 if (info
.getNumberOfSubBuffers() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
587 command
.append(LTTngControlServiceConstants
.OPTION_NUM_SUB_BUFFERS
);
588 command
.append(String
.valueOf(info
.getNumberOfSubBuffers()));
591 // --switch-timer USEC Switch timer interval in usec
592 if (info
.getSwitchTimer() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
593 command
.append(LTTngControlServiceConstants
.OPTION_SWITCH_TIMER
);
594 command
.append(String
.valueOf(info
.getSwitchTimer()));
597 // --read-timer USEC Read timer interval in usec
598 if (info
.getReadTimer() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
599 command
.append(LTTngControlServiceConstants
.OPTION_READ_TIMER
);
600 command
.append(String
.valueOf(info
.getReadTimer()));
603 if (isVersionSupported("2.2.0")) { //$NON-NLS-1$
604 // --buffer-uid Every application sharing the same UID use the same buffers
605 if (!isKernel
&& info
.isBuffersUID()) {
606 command
.append(LTTngControlServiceConstants
.OPTION_PER_UID_BUFFERS
);
609 // -C SIZE Maximum size of trace files in bytes
610 if (info
.getMaxSizeTraceFiles() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
611 command
.append(LTTngControlServiceConstants
.OPTION_MAX_SIZE_TRACE_FILES
);
612 command
.append(String
.valueOf(info
.getMaxSizeTraceFiles()));
615 // -W NUM Maximum number of trace files
616 if (info
.getMaxNumberTraceFiles() != LTTngControlServiceConstants
.UNUSED_VALUE
) {
617 command
.append(LTTngControlServiceConstants
.OPTION_MAX_TRACE_FILES
);
618 command
.append(String
.valueOf(info
.getMaxNumberTraceFiles()));
623 executeCommand(command
.toString(), monitor
);
628 public void disableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
630 // no channels to enable
631 if (channelNames
.isEmpty()) {
635 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_DISABLE_CHANNEL
);
637 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
638 String channel
= iterator
.next();
639 command
.append(channel
);
640 if (iterator
.hasNext()) {
646 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
648 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
651 String newSessionName
= formatParameter(sessionName
);
652 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
653 command
.append(newSessionName
);
655 executeCommand(command
.toString(), monitor
);
659 public void enableEvents(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
661 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ENABLE_EVENT
);
663 if (eventNames
== null || eventNames
.isEmpty()) {
664 command
.append(LTTngControlServiceConstants
.OPTION_ALL
);
667 StringBuffer eventNameParameter
= new StringBuffer();
668 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
669 String event
= iterator
.next();
670 eventNameParameter
.append(event
);
671 if (iterator
.hasNext()) {
672 eventNameParameter
.append(',');
675 command
.append(formatParameter(eventNameParameter
.toString()));
679 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
681 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
684 String newSessionName
= formatParameter(sessionName
);
686 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
687 command
.append(newSessionName
);
689 if (channelName
!= null) {
690 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
691 command
.append(channelName
);
694 command
.append(LTTngControlServiceConstants
.OPTION_TRACEPOINT
);
696 if (filterExpression
!= null) {
697 command
.append(LTTngControlServiceConstants
.OPTION_FILTER
);
698 command
.append('\'');
699 command
.append(filterExpression
);
700 command
.append('\'');
703 executeCommand(command
.toString(), monitor
);
708 public void enableSyscalls(String sessionName
, String channelName
, IProgressMonitor monitor
) throws ExecutionException
{
710 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ENABLE_EVENT
);
712 command
.append(LTTngControlServiceConstants
.OPTION_ALL
);
713 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
715 String newSessionName
= formatParameter(sessionName
);
717 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
718 command
.append(newSessionName
);
720 if (channelName
!= null) {
721 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
722 command
.append(channelName
);
725 command
.append(LTTngControlServiceConstants
.OPTION_SYSCALL
);
727 executeCommand(command
.toString(), monitor
);
731 public void enableProbe(String sessionName
, String channelName
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
732 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ENABLE_EVENT
);
734 command
.append(eventName
);
735 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
737 String newSessionName
= formatParameter(sessionName
);
738 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
739 command
.append(newSessionName
);
741 if (channelName
!= null) {
742 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
743 command
.append(channelName
);
746 command
.append(LTTngControlServiceConstants
.OPTION_FUNCTION_PROBE
);
748 command
.append(LTTngControlServiceConstants
.OPTION_PROBE
);
751 command
.append(probe
);
753 executeCommand(command
.toString(), monitor
);
757 public void enableLogLevel(String sessionName
, String channelName
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
758 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ENABLE_EVENT
);
760 command
.append(eventName
);
761 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
763 String newSessionName
= formatParameter(sessionName
);
764 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
765 command
.append(newSessionName
);
767 if (channelName
!= null) {
768 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
769 command
.append(channelName
);
772 if (logLevelType
== LogLevelType
.LOGLEVEL
) {
773 command
.append(LTTngControlServiceConstants
.OPTION_LOGLEVEL
);
774 } else if (logLevelType
== LogLevelType
.LOGLEVEL_ONLY
) {
775 command
.append(LTTngControlServiceConstants
.OPTION_LOGLEVEL_ONLY
);
780 command
.append(level
.getInName());
782 executeCommand(command
.toString(), monitor
);
786 public void disableEvent(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
787 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_DISABLE_EVENT
);
789 if (eventNames
== null) {
790 command
.append(LTTngControlServiceConstants
.OPTION_ALL
);
792 // no events to disable
793 if (eventNames
.isEmpty()) {
797 StringBuffer eventNameParameter
= new StringBuffer();
798 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
799 String event
= iterator
.next();
800 eventNameParameter
.append(event
);
801 if (iterator
.hasNext()) {
802 eventNameParameter
.append(',');
805 command
.append(formatParameter(eventNameParameter
.toString()));
809 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
811 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
814 String newSessionName
= formatParameter(sessionName
);
815 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
816 command
.append(newSessionName
);
818 if (channelName
!= null) {
819 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
820 command
.append(channelName
);
823 executeCommand(command
.toString(), monitor
);
827 public List
<String
> getContextList(IProgressMonitor monitor
) throws ExecutionException
{
829 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ADD_CONTEXT
, LTTngControlServiceConstants
.OPTION_HELP
);
831 ICommandResult result
= executeCommand(command
.toString(), monitor
);
833 String
[] output
= result
.getOutput();
835 List
<String
> contexts
= new ArrayList
<String
>(0);
838 boolean inList
= false;
839 while (index
< output
.length
) {
840 String line
= result
.getOutput()[index
];
842 Matcher startMatcher
= LTTngControlServiceConstants
.ADD_CONTEXT_HELP_CONTEXTS_INTRO
.matcher(line
);
843 Matcher endMatcher
= LTTngControlServiceConstants
.ADD_CONTEXT_HELP_CONTEXTS_END_LINE
.matcher(line
);
845 if (startMatcher
.matches()) {
847 } else if (endMatcher
.matches()) {
849 } else if (inList
== true) {
850 String
[] tmp
= line
.split(","); //$NON-NLS-1$
851 for (int i
= 0; i
< tmp
.length
; i
++) {
852 contexts
.add(tmp
[i
].trim());
861 public void addContexts(String sessionName
, String channelName
, String eventName
, boolean isKernel
, List
<String
> contextNames
, IProgressMonitor monitor
) throws ExecutionException
{
862 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_ADD_CONTEXT
);
864 String newSessionName
= formatParameter(sessionName
);
865 command
.append(LTTngControlServiceConstants
.OPTION_SESSION
);
866 command
.append(newSessionName
);
868 if (channelName
!= null) {
869 command
.append(LTTngControlServiceConstants
.OPTION_CHANNEL
);
870 command
.append(channelName
);
873 if (eventName
!= null) {
874 command
.append(LTTngControlServiceConstants
.OPTION_EVENT
);
875 command
.append(eventName
);
879 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
881 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
884 for (Iterator
<String
> iterator
= contextNames
.iterator(); iterator
.hasNext();) {
885 String context
= iterator
.next();
886 command
.append(LTTngControlServiceConstants
.OPTION_CONTEXT_TYPE
);
887 command
.append(context
);
890 executeCommand(command
.toString(), monitor
);
895 public void calibrate(boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
896 StringBuffer command
= createCommand(LTTngControlServiceConstants
.COMMAND_CALIBRATE
);
899 command
.append(LTTngControlServiceConstants
.OPTION_KERNEL
);
901 command
.append(LTTngControlServiceConstants
.OPTION_UST
);
904 command
.append(LTTngControlServiceConstants
.OPTION_FUNCTION_PROBE
);
906 executeCommand(command
.toString(), monitor
);
909 // ------------------------------------------------------------------------
911 // ------------------------------------------------------------------------
914 * Checks if command result is an error result.
917 * - the command result to check
918 * @return true if error else false
920 protected boolean isError(ICommandResult result
) {
921 // Check return code and length of returned strings
922 if ((result
.getResult()) != 0 || (result
.getOutput().length
< 1)) {
926 // Look for error pattern
928 while (index
< result
.getOutput().length
) {
929 String line
= result
.getOutput()[index
];
930 Matcher matcher
= LTTngControlServiceConstants
.ERROR_PATTERN
.matcher(line
);
931 if (matcher
.matches()) {
941 * Formats the output string as single string.
945 * @return - the formatted output
947 public static String
formatOutput(ICommandResult result
) {
948 if ((result
== null) || result
.getOutput() == null || result
.getOutput().length
== 0) {
949 return ""; //$NON-NLS-1$
951 String
[] output
= result
.getOutput();
952 StringBuffer ret
= new StringBuffer();
953 ret
.append("Return Value: "); //$NON-NLS-1$
954 ret
.append(result
.getResult());
955 ret
.append("\n"); //$NON-NLS-1$
956 for (int i
= 0; i
< output
.length
; i
++) {
957 ret
.append(output
[i
]).append("\n"); //$NON-NLS-1$
959 return ret
.toString();
963 * Parses the domain information.
966 * - a command output array
967 * @param currentIndex
968 * - current index in command output array
970 * - list for returning channel information
972 * - The domain information
973 * @return the new current index in command output array
975 protected int parseDomain(String
[] output
, int currentIndex
, List
<IChannelInfo
> channels
, IDomainInfo domainInfo
) {
976 int index
= currentIndex
;
980 // - channnel1: [enabled]
984 // subbufers size: 262144
985 // number of subbufers: 4
986 // switch timer interval: 0
987 // read timer interval: 200
990 while (index
< output
.length
) {
991 String line
= output
[index
];
993 if (isVersionSupported("2.2.0")) { //$NON-NLS-1$
994 Matcher bufferTypeMatcher
= LTTngControlServiceConstants
.BUFFER_TYPE_PATTERN
.matcher(line
);
995 if (bufferTypeMatcher
.matches()) {
996 domainInfo
.setBufferType(getAttributeValue(line
));
999 domainInfo
.setBufferType(BufferTypeConstants
.BUFFER_TYPE_UNKNOWN
);
1001 Matcher outerMatcher
= LTTngControlServiceConstants
.CHANNELS_SECTION_PATTERN
.matcher(line
);
1002 Matcher noKernelChannelMatcher
= LTTngControlServiceConstants
.DOMAIN_NO_KERNEL_CHANNEL_PATTERN
.matcher(line
);
1003 Matcher noUstChannelMatcher
= LTTngControlServiceConstants
.DOMAIN_NO_UST_CHANNEL_PATTERN
.matcher(line
);
1004 if (outerMatcher
.matches()) {
1005 IChannelInfo channelInfo
= null;
1006 while (index
< output
.length
) {
1007 String subLine
= output
[index
];
1009 Matcher innerMatcher
= LTTngControlServiceConstants
.CHANNEL_PATTERN
.matcher(subLine
);
1010 if (innerMatcher
.matches()) {
1011 channelInfo
= new ChannelInfo(""); //$NON-NLS-1$
1013 channelInfo
.setName(innerMatcher
.group(1));
1015 // get channel enablement
1016 channelInfo
.setState(innerMatcher
.group(2));
1019 channels
.add(channelInfo
);
1021 } else if (LTTngControlServiceConstants
.OVERWRITE_MODE_ATTRIBUTE
.matcher(subLine
).matches()) {
1022 String value
= getAttributeValue(subLine
);
1023 if (channelInfo
!= null) {
1024 channelInfo
.setOverwriteMode(!LTTngControlServiceConstants
.OVERWRITE_MODE_ATTRIBUTE_FALSE
.equals(value
));
1026 } else if (LTTngControlServiceConstants
.SUBBUFFER_SIZE_ATTRIBUTE
.matcher(subLine
).matches()) {
1027 if (channelInfo
!= null) {
1028 channelInfo
.setSubBufferSize(Long
.valueOf(getAttributeValue(subLine
)));
1031 } else if (LTTngControlServiceConstants
.NUM_SUBBUFFERS_ATTRIBUTE
.matcher(subLine
).matches()) {
1032 if (channelInfo
!= null) {
1033 channelInfo
.setNumberOfSubBuffers(Integer
.valueOf(getAttributeValue(subLine
)));
1036 } else if (LTTngControlServiceConstants
.SWITCH_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1037 if (channelInfo
!= null) {
1038 channelInfo
.setSwitchTimer(Long
.valueOf(getAttributeValue(subLine
)));
1041 } else if (LTTngControlServiceConstants
.READ_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1042 if (channelInfo
!= null) {
1043 channelInfo
.setReadTimer(Long
.valueOf(getAttributeValue(subLine
)));
1046 } else if (LTTngControlServiceConstants
.OUTPUT_ATTRIBUTE
.matcher(subLine
).matches()) {
1047 if (channelInfo
!= null) {
1048 channelInfo
.setOutputType(getAttributeValue(subLine
));
1051 } else if (LTTngControlServiceConstants
.EVENT_SECTION_PATTERN
.matcher(subLine
).matches()) {
1052 List
<IEventInfo
> events
= new ArrayList
<IEventInfo
>();
1053 index
= parseEvents(output
, index
, events
);
1054 if (channelInfo
!= null) {
1055 channelInfo
.setEvents(events
);
1057 // we want to stay at the current index to be able to
1060 } else if (LTTngControlServiceConstants
.DOMAIN_KERNEL_PATTERN
.matcher(subLine
).matches()) {
1063 } else if (LTTngControlServiceConstants
.DOMAIN_UST_GLOBAL_PATTERN
.matcher(subLine
).matches()) {
1068 } else if (noKernelChannelMatcher
.matches() || noUstChannelMatcher
.matches()) {
1069 // domain indicates that no channels were found -> return
1079 * Parses the event information within a domain.
1082 * - a command output array
1083 * @param currentIndex
1084 * - current index in command output array
1086 * - list for returning event information
1087 * @return the new current index in command output array
1089 protected int parseEvents(String
[] output
, int currentIndex
, List
<IEventInfo
> events
) {
1090 int index
= currentIndex
;
1092 while (index
< output
.length
) {
1093 String line
= output
[index
];
1094 if (LTTngControlServiceConstants
.CHANNEL_PATTERN
.matcher(line
).matches()) {
1097 } else if (LTTngControlServiceConstants
.DOMAIN_KERNEL_PATTERN
.matcher(line
).matches()) {
1100 } else if (LTTngControlServiceConstants
.DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
).matches()) {
1105 Matcher matcher
= LTTngControlServiceConstants
.EVENT_PATTERN
.matcher(line
);
1106 Matcher matcher2
= LTTngControlServiceConstants
.WILDCARD_EVENT_PATTERN
.matcher(line
);
1108 if (matcher
.matches()) {
1109 IEventInfo eventInfo
= new EventInfo(matcher
.group(1).trim());
1110 eventInfo
.setLogLevel(matcher
.group(2).trim());
1111 eventInfo
.setEventType(matcher
.group(3).trim());
1112 eventInfo
.setState(matcher
.group(4));
1113 String filter
= matcher
.group(5);
1114 if (filter
!= null) {
1115 filter
= filter
.substring(1, filter
.length() - 1); // remove '[' and ']'
1116 eventInfo
.setFilterExpression(filter
);
1118 events
.add(eventInfo
);
1120 } else if (matcher2
.matches()) {
1121 IEventInfo eventInfo
= new EventInfo(matcher2
.group(1).trim());
1122 eventInfo
.setLogLevel(TraceLogLevel
.LEVEL_UNKNOWN
);
1123 eventInfo
.setEventType(matcher2
.group(2).trim());
1124 eventInfo
.setState(matcher2
.group(3));
1125 String filter
= matcher2
.group(4);
1126 if (filter
!= null) {
1127 filter
= filter
.substring(1, filter
.length() - 1); // remove '[' and ']'
1128 eventInfo
.setFilterExpression(filter
);
1131 if (eventInfo
.getEventType() == TraceEventType
.PROBE
) {
1132 IProbeEventInfo probeEvent
= new ProbeEventInfo(eventInfo
.getName());
1133 probeEvent
.setLogLevel(eventInfo
.getLogLevel());
1134 probeEvent
.setEventType(eventInfo
.getEventType());
1135 probeEvent
.setState(eventInfo
.getState());
1137 // Overwrite eventinfo
1138 eventInfo
= probeEvent
;
1140 // myevent2 (type: probe) [enabled]
1142 // myevent0 (type: probe) [enabled]
1144 // symbol: init_post
1146 while (index
< output
.length
) {
1147 String probeLine
= output
[index
];
1149 Matcher addrMatcher
= LTTngControlServiceConstants
.PROBE_ADDRESS_PATTERN
.matcher(probeLine
);
1150 Matcher offsetMatcher
= LTTngControlServiceConstants
.PROBE_OFFSET_PATTERN
.matcher(probeLine
);
1151 Matcher symbolMatcher
= LTTngControlServiceConstants
.PROBE_SYMBOL_PATTERN
.matcher(probeLine
);
1152 if (addrMatcher
.matches()) {
1153 String addr
= addrMatcher
.group(2).trim();
1154 probeEvent
.setAddress(addr
);
1155 } else if (offsetMatcher
.matches()) {
1156 String offset
= offsetMatcher
.group(2).trim();
1157 probeEvent
.setOffset(offset
);
1158 } else if (symbolMatcher
.matches()) {
1159 String symbol
= symbolMatcher
.group(2).trim();
1160 probeEvent
.setSymbol(symbol
);
1161 } else if ((LTTngControlServiceConstants
.EVENT_PATTERN
.matcher(probeLine
).matches()) || (LTTngControlServiceConstants
.WILDCARD_EVENT_PATTERN
.matcher(probeLine
).matches())) {
1163 } else if (LTTngControlServiceConstants
.CHANNEL_PATTERN
.matcher(probeLine
).matches()) {
1165 } else if (LTTngControlServiceConstants
.DOMAIN_KERNEL_PATTERN
.matcher(probeLine
).matches()) {
1168 } else if (LTTngControlServiceConstants
.DOMAIN_UST_GLOBAL_PATTERN
.matcher(probeLine
).matches()) {
1174 events
.add(eventInfo
);
1176 events
.add(eventInfo
);
1189 * Parses a line with attributes: <attribute Name>: <attribute value>
1192 * - attribute line to parse
1193 * @return the attribute value as string
1195 protected String
getAttributeValue(String line
) {
1196 String
[] temp
= line
.split("\\: "); //$NON-NLS-1$
1201 * Parses the event information within a provider.
1204 * - a command output array
1205 * @param currentIndex
1206 * - current index in command output array
1208 * - list for returning event information
1209 * @return the new current index in command output array
1211 protected int getProviderEventInfo(String
[] output
, int currentIndex
, List
<IBaseEventInfo
> events
) {
1212 int index
= currentIndex
;
1213 IBaseEventInfo eventInfo
= null;
1214 while (index
< output
.length
) {
1215 String line
= output
[index
];
1216 Matcher matcher
= LTTngControlServiceConstants
.PROVIDER_EVENT_PATTERN
.matcher(line
);
1217 if (matcher
.matches()) {
1218 // sched_kthread_stop (loglevel: TRACE_EMERG0) (type: tracepoint)
1219 eventInfo
= new BaseEventInfo(matcher
.group(1).trim());
1220 eventInfo
.setLogLevel(matcher
.group(2).trim());
1221 eventInfo
.setEventType(matcher
.group(3).trim());
1222 events
.add(eventInfo
);
1224 } else if (LTTngControlServiceConstants
.EVENT_FIELD_PATTERN
.matcher(line
).matches()) {
1225 if (eventInfo
!= null) {
1226 List
<IFieldInfo
> fields
= new ArrayList
<IFieldInfo
>();
1227 index
= getFieldInfo(output
, index
, fields
);
1228 eventInfo
.setFields(fields
);
1233 else if (LTTngControlServiceConstants
.UST_PROVIDER_PATTERN
.matcher(line
).matches()) {
1244 * Parse a field's information.
1247 * A command output array
1248 * @param currentIndex
1249 * The current index in the command output array
1251 * List for returning the field information
1252 * @return The new current index in the command output array
1254 protected int getFieldInfo(String
[] output
, int currentIndex
, List
<IFieldInfo
> fields
) {
1255 int index
= currentIndex
;
1256 IFieldInfo fieldInfo
= null;
1257 while (index
< output
.length
) {
1258 String line
= output
[index
];
1259 Matcher matcher
= LTTngControlServiceConstants
.EVENT_FIELD_PATTERN
.matcher(line
);
1260 if (matcher
.matches()) {
1261 // field: content (string)
1262 fieldInfo
= new FieldInfo(matcher
.group(2).trim());
1263 fieldInfo
.setFieldType(matcher
.group(3).trim());
1264 fields
.add(fieldInfo
);
1265 } else if (LTTngControlServiceConstants
.PROVIDER_EVENT_PATTERN
.matcher(line
).matches()) {
1267 } else if (LTTngControlServiceConstants
.UST_PROVIDER_PATTERN
.matcher(line
).matches()) {
1276 * Formats a command parameter for the command execution i.e. adds quotes
1277 * at the beginning and end if necessary.
1278 * @param parameter - parameter to format
1279 * @return formated parameter
1281 protected String
formatParameter(String parameter
) {
1282 if (parameter
!= null) {
1283 StringBuffer newString
= new StringBuffer();
1284 newString
.append(parameter
);
1286 if (parameter
.contains(" ") || parameter
.contains("*")) { //$NON-NLS-1$ //$NON-NLS-2$
1287 newString
.insert(0, "\""); //$NON-NLS-1$
1288 newString
.append("\""); //$NON-NLS-1$
1290 return newString
.toString();
1296 * @param strings array of string that makes up a command line
1297 * @return string buffer with created command line
1299 protected StringBuffer
createCommand(String
... strings
) {
1300 StringBuffer command
= new StringBuffer();
1301 command
.append(LTTngControlServiceConstants
.CONTROL_COMMAND
);
1302 command
.append(getTracingGroupOption());
1303 command
.append(getVerboseOption());
1304 for (String string
: strings
) {
1305 command
.append(string
);
1311 * @return the tracing group option if configured in the preferences
1313 protected String
getTracingGroupOption() {
1314 if (!ControlPreferences
.getInstance().isDefaultTracingGroup() && !ControlPreferences
.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$
1315 return LTTngControlServiceConstants
.OPTION_TRACING_GROUP
+ ControlPreferences
.getInstance().getTracingGroup();
1317 return ""; //$NON-NLS-1$
1321 * @return the verbose option as configured in the preferences
1323 protected String
getVerboseOption() {
1324 if (ControlPreferences
.getInstance().isLoggingEnabled()) {
1325 String level
= ControlPreferences
.getInstance().getVerboseLevel();
1326 if (ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_VERBOSE
.equals(level
)) {
1327 return LTTngControlServiceConstants
.OPTION_VERBOSE
;
1329 if (ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_VERBOSE
.equals(level
)) {
1330 return LTTngControlServiceConstants
.OPTION_VERY_VERBOSE
;
1332 if (ControlPreferences
.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE
.equals(level
)) {
1333 return LTTngControlServiceConstants
.OPTION_VERY_VERY_VERBOSE
;
1336 return ""; //$NON-NLS-1$
1340 * Method that logs the command and command result if logging is enabled as
1341 * well as forwards the command execution to the shell.
1344 * - the command to execute
1346 * - a progress monitor
1347 * @return the command result
1348 * @throws ExecutionException
1349 * If the command fails
1351 protected ICommandResult
executeCommand(String command
,
1352 IProgressMonitor monitor
) throws ExecutionException
{
1353 return executeCommand(command
, monitor
, true);
1357 * Method that logs the command and command result if logging is enabled as
1358 * well as forwards the command execution to the shell.
1361 * - the command to execute
1363 * - a progress monitor
1364 * @param checkForError
1365 * - true to verify command result, else false
1366 * @return the command result
1367 * @throws ExecutionException
1368 * in case of error result
1370 protected ICommandResult
executeCommand(String command
,
1371 IProgressMonitor monitor
, boolean checkForError
)
1372 throws ExecutionException
{
1373 if (ControlPreferences
.getInstance().isLoggingEnabled()) {
1374 ControlCommandLogger
.log(command
);
1377 ICommandResult result
= fCommandShell
.executeCommand(
1378 command
.toString(), monitor
);
1380 if (ControlPreferences
.getInstance().isLoggingEnabled()) {
1381 ControlCommandLogger
.log(formatOutput(result
));
1384 if (checkForError
&& isError(result
)) {
1385 throw new ExecutionException(Messages
.TraceControl_CommandError
1386 + " " + command
.toString() + "\n" + formatOutput(result
)); //$NON-NLS-1$ //$NON-NLS-2$