1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.service
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
17 import java
.util
.regex
.Matcher
;
18 import java
.util
.regex
.Pattern
;
20 import org
.eclipse
.core
.commands
.ExecutionException
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IBaseEventInfo
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IChannelInfo
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IDomainInfo
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IEventInfo
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IProbeEventInfo
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ISessionInfo
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IUstProviderInfo
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.LogLevelType
;
32 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEventType
;
33 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
34 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.BaseEventInfo
;
35 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.ChannelInfo
;
36 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.DomainInfo
;
37 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.EventInfo
;
38 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.ProbeEventInfo
;
39 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.SessionInfo
;
40 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.UstProviderInfo
;
43 * <b><u>LTTngControlService</u></b>
45 * Service for sending LTTng trace control commands to remote host.
48 public class LTTngControlService
implements ILttngControlService
{
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
54 * The lttng tools command.
56 private final static String CONTROL_COMMAND
= "lttng"; //$NON-NLS-1$
58 * Command: lttng list.
60 private final static String COMMAND_LIST
= CONTROL_COMMAND
+ " list "; //$NON-NLS-1$
62 * Command to list kernel tracer information.
64 private final static String COMMAND_LIST_KERNEL
= COMMAND_LIST
+ "-k"; //$NON-NLS-1$
66 * Command to list user space trace information.
68 private final static String COMMAND_LIST_UST
= COMMAND_LIST
+ "-u"; //$NON-NLS-1$
70 * Command to create a session.
72 private final static String COMMAND_CREATE_SESSION
= CONTROL_COMMAND
+ " create "; //$NON-NLS-1$
74 * Command to destroy a session.
76 private final static String COMMAND_DESTROY_SESSION
= CONTROL_COMMAND
+ " destroy "; //$NON-NLS-1$
78 * Command to destroy a session.
80 private final static String COMMAND_START_SESSION
= CONTROL_COMMAND
+ " start "; //$NON-NLS-1$
82 * Command to destroy a session.
84 private final static String COMMAND_STOP_SESSION
= CONTROL_COMMAND
+ " stop "; //$NON-NLS-1$
86 * Command to enable a channel.
88 private final static String COMMAND_ENABLE_CHANNEL
= CONTROL_COMMAND
+ " enable-channel "; //$NON-NLS-1$
90 * Command to disable a channel.
92 private final static String COMMAND_DISABLE_CHANNEL
= CONTROL_COMMAND
+ " disable-channel "; //$NON-NLS-1$
94 * Command to enable a event.
96 private final static String COMMAND_ENABLE_EVENT
= CONTROL_COMMAND
+ " enable-event "; //$NON-NLS-1$
98 * Command to disable a event.
100 private final static String COMMAND_DISABLE_EVENT
= CONTROL_COMMAND
+ " disable-event "; //$NON-NLS-1$
102 * Command to add a context to channels and/or events
104 private final static String COMMAND_ADD_CONTEXT
= CONTROL_COMMAND
+ " add-context "; //$NON-NLS-1$
106 // Command options constants
108 * Command line option for output path.
110 private final static String OPTION_OUTPUT_PATH
= " -o "; //$NON-NLS-1$
112 * Command line option for kernel tracer.
114 private final static String OPTION_KERNEL
= " -k "; //$NON-NLS-1$
116 * Command line option for UST tracer.
118 private final static String OPTION_UST
= " -u "; //$NON-NLS-1$
120 * Command line option for specifying a session.
122 private final static String OPTION_SESSION
= " -s "; //$NON-NLS-1$
124 * Command line option for specifying a channel.
126 private final static String OPTION_CHANNEL
= " -c "; //$NON-NLS-1$
128 * Command line option for specifying a event.
130 private final static String OPTION_EVENT
= " -e "; //$NON-NLS-1$
132 * Command line option for specifying all events.
134 private final static String OPTION_ALL
= " -a "; //$NON-NLS-1$
136 * Command line option for specifying a context.
138 private final static String OPTION_CONTEXT_TYPE
= " -t "; //$NON-NLS-1$
140 * Command line option for specifying tracepoint events.
142 private final static String OPTION_TRACEPOINT
= " --tracepoint "; //$NON-NLS-1$
144 * Command line option for specifying syscall events.
146 private final static String OPTION_SYSCALL
= " --syscall "; //$NON-NLS-1$
148 * Command line option for specifying a dynamic probe.
150 private final static String OPTION_PROBE
= " --probe "; //$NON-NLS-1$
152 * Command line option for specifying a dynamic function entry/return probe.
154 private final static String OPTION_FUNCTION_PROBE
= " --function "; //$NON-NLS-1$
156 * Command line option for specifying a log level range.
158 private final static String OPTION_LOGLEVEL
= " --loglevel "; //$NON-NLS-1$
160 * Command line option for specifying a specific log level.
162 private final static String OPTION_LOGLEVEL_ONLY
= " --loglevel-only "; //$NON-NLS-1$
164 * Optional command line option for configuring a channel's overwrite mode.
166 private final static String OPTION_OVERWRITE
= " --overwrite "; //$NON-NLS-1$
168 * Optional command line option for configuring a channel's number of sub buffers.
170 private final static String OPTION_NUM_SUB_BUFFERS
= " --num-subbuf "; //$NON-NLS-1$
172 * Optional command line option for configuring a channel's sub buffer size.
174 private final static String OPTION_SUB_BUFFER_SIZE
= " --subbuf-size "; //$NON-NLS-1$
176 * Optional command line option for configuring a channel's switch timer interval.
178 private final static String OPTION_SWITCH_TIMER
= " --switch-timer "; //$NON-NLS-1$
180 * Optional command line option for configuring a channel's read timer interval.
182 private final static String OPTION_READ_TIMER
= " --read-timer "; //$NON-NLS-1$
184 * Command line option for printing the help of a specif command
186 private final static String OPTION_HELP
= " -h "; //$NON-NLS-1$
190 * Pattern to match for error output
192 private final static Pattern ERROR_PATTERN
= Pattern
.compile("\\s*Error\\:.*"); //$NON-NLS-1$
194 * Pattern to match for session information (lttng list)
196 private final static Pattern SESSION_PATTERN
= Pattern
.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
198 * Pattern to match for session information (lttng list <session>)
200 private final static Pattern TRACE_SESSION_PATTERN
= Pattern
.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
202 * Pattern to match for session path information (lttng list <session>)
204 private final static Pattern TRACE_SESSION_PATH_PATTERN
= Pattern
.compile("\\s*Trace\\s+path\\:\\s+(.*)"); //$NON-NLS-1$
206 * Pattern to match for kernel domain information (lttng list <session>)
208 private final static Pattern DOMAIN_KERNEL_PATTERN
= Pattern
.compile("=== Domain: Kernel ==="); //$NON-NLS-1$
210 * Pattern to match for ust domain information (lttng list <session>)
212 private final static Pattern DOMAIN_UST_GLOBAL_PATTERN
= Pattern
.compile("=== Domain: UST global ==="); //$NON-NLS-1$
214 * Pattern to match for channels section (lttng list <session>)
216 private final static Pattern CHANNELS_SECTION_PATTERN
= Pattern
.compile("\\s*Channels\\:"); //$NON-NLS-1$
218 * Pattern to match for channel information (lttng list <session>)
220 private final static Pattern CHANNEL_PATTERN
= Pattern
.compile("\\s*-\\s+(.*)\\:\\s+\\[(enabled|disabled)\\]"); //$NON-NLS-1$
222 * Pattern to match for events section information (lttng list <session>)
224 private final static Pattern EVENT_SECTION_PATTERN
= Pattern
.compile("\\s*Events\\:"); //$NON-NLS-1$
226 * Pattern to match for event information (no enabled events) (lttng list <session>)
228 // private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
230 * Pattern to match for event information (lttng list <session>)
232 private final static Pattern EVENT_PATTERN
= Pattern
.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
234 * Pattern to match a wildcarded event information (lttng list <session>)
236 private final static Pattern WILDCARD_EVENT_PATTERN
= Pattern
.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
238 * Pattern to match a probe address information (lttng list <session>)
240 private final static Pattern PROBE_ADDRESS_PATTERN
= Pattern
.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
242 * Pattern to match a probe OFFSET information (lttng list <session>)
244 private final static Pattern PROBE_OFFSET_PATTERN
= Pattern
.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
246 * Pattern to match a probe SYMBOL information (lttng list <session>)
248 private final static Pattern PROBE_SYMBOL_PATTERN
= Pattern
.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
250 * Pattern to match for channel (overwite mode) information (lttng list
253 private final static Pattern OVERWRITE_MODE_ATTRIBUTE
= Pattern
.compile("\\s+overwrite\\s+mode\\:.*"); //$NON-NLS-1$
255 * Pattern to match indicating false for overwrite mode
257 private final static String OVERWRITE_MODE_ATTRIBUTE_FALSE
= "0"; //$NON-NLS-1$
259 * Pattern to match for channel (sub-buffer size) information (lttng list
262 private final static Pattern SUBBUFFER_SIZE_ATTRIBUTE
= Pattern
.compile("\\s+subbufers\\s+size\\:.*"); //$NON-NLS-1$
264 * Pattern to match for channel (number of sub-buffers) information (lttng
267 private final static Pattern NUM_SUBBUFFERS_ATTRIBUTE
= Pattern
.compile("\\s+number\\s+of\\s+subbufers\\:.*"); //$NON-NLS-1$
269 * Pattern to match for channel (switch timer) information (lttng list
272 private final static Pattern SWITCH_TIMER_ATTRIBUTE
= Pattern
.compile("\\s+switch\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
274 * Pattern to match for channel (read timer) information (lttng list
277 private final static Pattern READ_TIMER_ATTRIBUTE
= Pattern
.compile("\\s+read\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
279 * Pattern to match for channel (output type) information (lttng list
282 private final static Pattern OUTPUT_ATTRIBUTE
= Pattern
.compile("\\s+output\\:.*"); //$NON-NLS-1$
284 * Pattern to match for provider information (lttng list -k/-u)
286 private final static Pattern PROVIDER_EVENT_PATTERN
= Pattern
.compile("\\s*(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)"); //$NON-NLS-1$
288 * Pattern to match for UST provider information (lttng list -u)
290 private final static Pattern UST_PROVIDER_PATTERN
= Pattern
.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
292 * Pattern to match for session information (lttng create <session name>)
294 private final static Pattern CREATE_SESSION_NAME_PATTERN
= Pattern
.compile("\\s*Session\\s+(.*)\\s+created\\."); //$NON-NLS-1$
296 * Pattern to match for session path information (lttng create <session name>)
298 private final static Pattern CREATE_SESSION_PATH_PATTERN
= Pattern
.compile("\\s*Traces\\s+will\\s+be\\s+written\\s+in\\s+(.*).*"); //$NON-NLS-1$
300 * Pattern to match for session command output for "session name not found".
302 private final static Pattern SESSION_NOT_FOUND_ERROR_PATTERN
= Pattern
.compile("\\s*Error:\\s+Session\\s+name\\s+not\\s+found"); //$NON-NLS-1$
304 * Pattern to match introduction line of context list.
306 private final static Pattern ADD_CONTEXT_HELP_CONTEXTS_INTRO
= Pattern
.compile("\\s*TYPE can\\s+be\\s+one\\s+of\\s+the\\s+strings\\s+below.*"); //$NON-NLS-1$
309 * Pattern to match introduction line of context list.
311 private final static Pattern ADD_CONTEXT_HELP_CONTEXTS_END_LINE
= Pattern
.compile("\\s*Example.*"); //$NON-NLS-1$
313 // ------------------------------------------------------------------------
315 // ------------------------------------------------------------------------
317 * The command shell implementation
319 private ICommandShell fCommandShell
= null;
321 // ------------------------------------------------------------------------
323 // ------------------------------------------------------------------------
329 * - the command shell implementation to use
331 public LTTngControlService(ICommandShell shell
) {
332 fCommandShell
= shell
;
335 // ------------------------------------------------------------------------
337 // ------------------------------------------------------------------------
343 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
344 * #getSessionNames(org.eclipse.core.runtime.IProgressMonitor)
347 public String
[] getSessionNames(IProgressMonitor monitor
) throws ExecutionException
{
349 String command
= COMMAND_LIST
;
350 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
352 if (isError(result
)) {
353 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
357 // Available tracing sessions:
358 // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928)
360 // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318)
363 // Use lttng list <session_name> for more details
365 ArrayList
<String
> retArray
= new ArrayList
<String
>();
367 while (index
< result
.getOutput().length
) {
368 String line
= result
.getOutput()[index
];
369 Matcher matcher
= SESSION_PATTERN
.matcher(line
);
370 if (matcher
.matches()) {
371 retArray
.add(matcher
.group(2).trim());
375 return retArray
.toArray(new String
[retArray
.size()]);
382 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
383 * #getSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
386 public ISessionInfo
getSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
388 String command
= COMMAND_LIST
+ sessionName
;
389 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
391 if (isError(result
)) {
392 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
398 // Tracing session mysession2: [inactive]
399 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
400 ISessionInfo sessionInfo
= new SessionInfo(sessionName
);
402 while (index
< result
.getOutput().length
) {
403 // Tracing session mysession2: [inactive]
404 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
406 // === Domain: Kernel ===
408 String line
= result
.getOutput()[index
];
409 Matcher matcher
= TRACE_SESSION_PATTERN
.matcher(line
);
410 if (matcher
.matches()) {
411 sessionInfo
.setSessionState(matcher
.group(2));
416 matcher
= TRACE_SESSION_PATH_PATTERN
.matcher(line
);
417 if (matcher
.matches()) {
418 sessionInfo
.setSessionPath(matcher
.group(1).trim());
423 matcher
= DOMAIN_KERNEL_PATTERN
.matcher(line
);
424 if (matcher
.matches()) {
426 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_KernelDomainDisplayName
);
427 sessionInfo
.addDomain(domainInfo
);
430 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
431 index
= parseDomain(result
.getOutput(), index
, channels
);
434 domainInfo
.setChannels(channels
);
437 domainInfo
.setIsKernel(true);
441 matcher
= DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
);
442 if (matcher
.matches()) {
443 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_UstGlobalDomainDisplayName
);
444 sessionInfo
.addDomain(domainInfo
);
447 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
448 index
= parseDomain(result
.getOutput(), index
, channels
);
451 domainInfo
.setChannels(channels
);
454 domainInfo
.setIsKernel(false);
466 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
467 * #getKernelProvider(org.eclipse.core.runtime.IProgressMonitor)
470 public List
<IBaseEventInfo
> getKernelProvider(IProgressMonitor monitor
) throws ExecutionException
{
471 String command
= COMMAND_LIST_KERNEL
;
472 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
473 if (isError(result
)) {
474 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
479 // sched_kthread_stop (type: tracepoint)
480 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
481 getProviderEventInfo(result
.getOutput(), 0, events
);
489 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
493 public List
<IUstProviderInfo
> getUstProvider() throws ExecutionException
{
494 return getUstProvider(new NullProgressMonitor());
501 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
502 * #getUstProvider(org.eclipse.core.runtime.IProgressMonitor)
505 public List
<IUstProviderInfo
> getUstProvider(IProgressMonitor monitor
) throws ExecutionException
{
506 String command
= COMMAND_LIST_UST
;
507 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
509 if (isError(result
)) {
510 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
517 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
518 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
520 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
523 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
524 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
526 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
528 List
<IUstProviderInfo
> allProviders
= new ArrayList
<IUstProviderInfo
>();
529 IUstProviderInfo provider
= null;
532 while (index
< result
.getOutput().length
) {
533 String line
= result
.getOutput()[index
];
534 Matcher matcher
= UST_PROVIDER_PATTERN
.matcher(line
);
535 if (matcher
.matches()) {
537 provider
= new UstProviderInfo(matcher
.group(2).trim());
538 provider
.setPid(Integer
.valueOf(matcher
.group(1).trim()));
539 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
540 index
= getProviderEventInfo(result
.getOutput(), ++index
, events
);
541 provider
.setEvents(events
);
542 allProviders
.add(provider
);
554 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
557 public ISessionInfo
createSession(String sessionName
, String sessionPath
, IProgressMonitor monitor
) throws ExecutionException
{
559 String newName
= formatParameter(sessionName
);
560 String newPath
= formatParameter(sessionPath
);
562 StringBuffer command
= new StringBuffer();
563 command
.append(COMMAND_CREATE_SESSION
);
564 command
.append(newName
);
566 if (newPath
!= null && !"".equals(newPath
)) { //$NON-NLS-1$
567 command
.append(OPTION_OUTPUT_PATH
);
568 command
.append(newPath
);
571 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
573 if (isError(result
)) {
574 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
576 //Session myssession2 created.
577 //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
578 String
[] output
= result
.getOutput();
580 // Get and verify session name
581 Matcher matcher
= CREATE_SESSION_NAME_PATTERN
.matcher(output
[0]);
584 if (matcher
.matches()) {
585 name
= String
.valueOf(matcher
.group(1).trim());
587 // Output format not expected
588 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
589 Messages
.TraceControl_UnexpectedCommnadOutputFormat
+ ":\n" + //$NON-NLS-1$
590 formatOutput(result
.getOutput()));
593 if ((name
== null) || (!name
.equals(sessionName
))) {
594 // Unexpected name returned
595 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
596 Messages
.TraceControl_UnexpectedNameError
+ ": " + name
); //$NON-NLS-1$
599 // Get and verify session path
600 matcher
= CREATE_SESSION_PATH_PATTERN
.matcher(output
[1]);
603 if (matcher
.matches()) {
604 path
= String
.valueOf(matcher
.group(1).trim());
606 // Output format not expected
607 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
608 Messages
.TraceControl_UnexpectedCommnadOutputFormat
+ ":\n" + //$NON-NLS-1$
609 formatOutput(result
.getOutput()));
612 if ((path
== null) || ((sessionPath
!= null) && (!path
.contains(sessionPath
)))) {
614 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
615 Messages
.TraceControl_UnexpectedPathError
+ ": " + name
); //$NON-NLS-1$
618 SessionInfo sessionInfo
= new SessionInfo(name
);
619 sessionInfo
.setSessionPath(path
);
625 public void destroySession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
626 String newName
= formatParameter(sessionName
);
627 String command
= COMMAND_DESTROY_SESSION
+ newName
;
629 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
630 String
[] output
= result
.getOutput();
632 if (isError(result
) && ((output
== null) || (!SESSION_NOT_FOUND_ERROR_PATTERN
.matcher(output
[0]).matches()))) {
633 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
635 //Session <sessionName> destroyed
640 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
643 public void startSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
645 String newSessionName
= formatParameter(sessionName
);
647 String command
= COMMAND_START_SESSION
+ newSessionName
;
649 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
651 if (isError(result
)) {
652 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
654 //Session <sessionName> started
659 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
662 public void stopSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
663 String newSessionName
= formatParameter(sessionName
);
664 String command
= COMMAND_STOP_SESSION
+ newSessionName
;
666 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
668 if (isError(result
)) {
669 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
671 //Session <sessionName> stopped
677 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
680 public void enableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
682 // no channels to enable
683 if (channelNames
.isEmpty()) {
687 String newSessionName
= formatParameter(sessionName
);
689 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_CHANNEL
);
691 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
692 String channel
= (String
) iterator
.next();
693 command
.append(channel
);
694 if (iterator
.hasNext()) {
700 command
.append(OPTION_KERNEL
);
702 command
.append(OPTION_UST
);
705 command
.append(OPTION_SESSION
);
706 command
.append(newSessionName
);
709 // --discard Discard event when buffers are full (default)
711 // --overwrite Flight recorder mode
712 if (info
.isOverwriteMode()) {
713 command
.append(OPTION_OVERWRITE
);
715 // --subbuf-size SIZE Subbuffer size in bytes
716 // (default: 4096, kernel default: 262144)
717 command
.append(OPTION_SUB_BUFFER_SIZE
);
718 command
.append(String
.valueOf(info
.getSubBufferSize()));
720 // --num-subbuf NUM Number of subbufers
721 // (default: 8, kernel default: 4)
722 command
.append(OPTION_NUM_SUB_BUFFERS
);
723 command
.append(String
.valueOf(info
.getNumberOfSubBuffers()));
725 // --switch-timer USEC Switch timer interval in usec (default: 0)
726 command
.append(OPTION_SWITCH_TIMER
);
727 command
.append(String
.valueOf(info
.getSwitchTimer()));
729 // --read-timer USEC Read timer interval in usec (default: 200)
730 command
.append(OPTION_READ_TIMER
);
731 command
.append(String
.valueOf(info
.getReadTimer()));
734 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
736 if (isError(result
)) {
737 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
743 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
746 public void disableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
748 // no channels to enable
749 if (channelNames
.isEmpty()) {
753 String newSessionName
= formatParameter(sessionName
);
755 StringBuffer command
= new StringBuffer(COMMAND_DISABLE_CHANNEL
);
757 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
758 String channel
= (String
) iterator
.next();
759 command
.append(channel
);
760 if (iterator
.hasNext()) {
766 command
.append(OPTION_KERNEL
);
768 command
.append(OPTION_UST
);
771 command
.append(OPTION_SESSION
);
772 command
.append(newSessionName
);
774 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
776 if (isError(result
)) {
777 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
783 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
786 public void enableEvents(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
788 String newSessionName
= formatParameter(sessionName
);
790 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
792 if (eventNames
== null || eventNames
.isEmpty()) {
793 command
.append(OPTION_ALL
);
796 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
797 String event
= (String
) iterator
.next();
798 command
.append(event
);
799 if (iterator
.hasNext()) {
806 command
.append(OPTION_KERNEL
);
808 command
.append(OPTION_UST
);
811 command
.append(OPTION_SESSION
);
812 command
.append(newSessionName
);
814 if (channelName
!= null) {
815 command
.append(OPTION_CHANNEL
);
816 command
.append(channelName
);
819 command
.append(OPTION_TRACEPOINT
);
821 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
823 if (isError(result
)) {
824 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
830 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
833 public void enableSyscalls(String sessionName
, String channelName
, IProgressMonitor monitor
) throws ExecutionException
{
834 String newSessionName
= formatParameter(sessionName
);
836 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
838 command
.append(OPTION_ALL
);
839 command
.append(OPTION_KERNEL
);
841 command
.append(OPTION_SESSION
);
842 command
.append(newSessionName
);
844 if (channelName
!= null) {
845 command
.append(OPTION_CHANNEL
);
846 command
.append(channelName
);
849 command
.append(OPTION_SYSCALL
);
851 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
853 if (isError(result
)) {
854 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
860 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
863 public void enableProbe(String sessionName
, String channelName
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
864 String newSessionName
= formatParameter(sessionName
);
866 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
868 command
.append(eventName
);
869 command
.append(OPTION_KERNEL
);
871 command
.append(OPTION_SESSION
);
872 command
.append(newSessionName
);
874 if (channelName
!= null) {
875 command
.append(OPTION_CHANNEL
);
876 command
.append(channelName
);
879 command
.append(OPTION_FUNCTION_PROBE
);
881 command
.append(OPTION_PROBE
);
884 command
.append(probe
);
886 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
888 if (isError(result
)) {
889 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
895 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
898 public void enableLogLevel(String sessionName
, String channelName
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
899 String newSessionName
= formatParameter(sessionName
);
901 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
903 command
.append(eventName
);
904 command
.append(OPTION_UST
);
906 command
.append(OPTION_SESSION
);
907 command
.append(newSessionName
);
909 if (channelName
!= null) {
910 command
.append(OPTION_CHANNEL
);
911 command
.append(channelName
);
914 if (logLevelType
== LogLevelType
.LOGLEVEL
) {
915 command
.append(OPTION_LOGLEVEL
);
916 } else if (logLevelType
== LogLevelType
.LOGLEVEL_ONLY
) {
917 command
.append(OPTION_LOGLEVEL_ONLY
);
922 command
.append(level
.getInName());
924 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
926 if (isError(result
)) {
927 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
933 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
936 public void disableEvent(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
937 String newSessionName
= formatParameter(sessionName
);
939 StringBuffer command
= new StringBuffer(COMMAND_DISABLE_EVENT
);
940 if (eventNames
== null) {
941 command
.append(OPTION_ALL
);
943 // no events to enable
944 if (eventNames
.isEmpty()) {
948 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
949 String event
= (String
) iterator
.next();
950 command
.append(event
);
951 if (iterator
.hasNext()) {
958 command
.append(OPTION_KERNEL
);
960 command
.append(OPTION_UST
);
963 command
.append(OPTION_SESSION
);
964 command
.append(newSessionName
);
966 if (channelName
!= null) {
967 command
.append(OPTION_CHANNEL
);
968 command
.append(channelName
);
971 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
973 if (isError(result
)) {
974 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
980 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#getContexts(org.eclipse.core.runtime.IProgressMonitor)
983 public List
<String
> getContextList(IProgressMonitor monitor
) throws ExecutionException
{
985 String command
= COMMAND_ADD_CONTEXT
+ OPTION_HELP
;
987 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
989 if (isError(result
)) {
990 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
993 String
[] output
= result
.getOutput();
995 List
<String
> contexts
= new ArrayList
<String
>(0);
998 boolean inList
= false;
999 while (index
< output
.length
) {
1000 String line
= result
.getOutput()[index
];
1002 Matcher startMatcher
= ADD_CONTEXT_HELP_CONTEXTS_INTRO
.matcher(line
);
1003 Matcher endMatcher
= ADD_CONTEXT_HELP_CONTEXTS_END_LINE
.matcher(line
);
1005 if (startMatcher
.matches()) {
1007 } else if (endMatcher
.matches()) {
1009 } else if (inList
== true) {
1010 String
[] tmp
= line
.split(","); //$NON-NLS-1$
1011 for (int i
= 0; i
< tmp
.length
; i
++) {
1012 contexts
.add(tmp
[i
].trim());
1022 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#addContexts(java.lang.String, java.lang.String, java.lang.String, boolean, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
1025 public void addContexts(String sessionName
, String channelName
, String eventName
, boolean isKernel
, List
<String
> contextNames
, IProgressMonitor monitor
) throws ExecutionException
{
1027 String newSessionName
= formatParameter(sessionName
);
1028 StringBuffer command
= new StringBuffer(COMMAND_ADD_CONTEXT
);
1030 command
.append(OPTION_SESSION
);
1031 command
.append(newSessionName
);
1033 if (channelName
!= null) {
1034 command
.append(OPTION_CHANNEL
);
1035 command
.append(channelName
);
1038 if (eventName
!= null) {
1039 command
.append(OPTION_EVENT
);
1040 command
.append(eventName
);
1044 command
.append(OPTION_KERNEL
);
1046 command
.append(OPTION_UST
);
1049 for (Iterator
<String
> iterator
= contextNames
.iterator(); iterator
.hasNext();) {
1050 String context
= (String
) iterator
.next();
1051 command
.append(OPTION_CONTEXT_TYPE
);
1052 command
.append(context
);
1055 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
1057 if (isError(result
)) {
1058 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
1062 // ------------------------------------------------------------------------
1064 // ------------------------------------------------------------------------
1066 * Checks if command result is an error result.
1069 * - the command result to check
1070 * @return true if error else false
1072 private boolean isError(ICommandResult result
) {
1073 if ((result
.getResult()) != 0 || (result
.getOutput().length
< 1 || ERROR_PATTERN
.matcher(result
.getOutput()[0]).matches())) {
1080 * Formats the output string as single string.
1084 * @return - the formatted output
1086 private String
formatOutput(String
[] output
) {
1087 if (output
== null || output
.length
== 0) {
1088 return ""; //$NON-NLS-1$
1091 StringBuffer ret
= new StringBuffer();
1092 for (int i
= 0; i
< output
.length
; i
++) {
1093 ret
.append(output
[i
] + "\n"); //$NON-NLS-1$
1095 return ret
.toString();
1099 * Parses the domain information.
1102 * - a command output array
1103 * @param currentIndex
1104 * - current index in command output array
1106 * - list for returning channel information
1107 * @return the new current index in command output array
1109 private int parseDomain(String
[] output
, int currentIndex
, List
<IChannelInfo
> channels
) {
1110 int index
= currentIndex
;
1114 // - channnel1: [enabled]
1117 // overwrite mode: 0
1118 // subbufers size: 262144
1119 // number of subbufers: 4
1120 // switch timer interval: 0
1121 // read timer interval: 200
1124 while (index
< output
.length
) {
1125 String line
= output
[index
];
1127 Matcher outerMatcher
= CHANNELS_SECTION_PATTERN
.matcher(line
);
1128 if (outerMatcher
.matches()) {
1129 IChannelInfo channelInfo
= null;
1130 while (index
< output
.length
) {
1131 String subLine
= output
[index
];
1133 Matcher innerMatcher
= CHANNEL_PATTERN
.matcher(subLine
);
1134 if (innerMatcher
.matches()) {
1135 channelInfo
= new ChannelInfo(""); //$NON-NLS-1$
1137 channelInfo
.setName(innerMatcher
.group(1));
1139 // get channel enablement
1140 channelInfo
.setState(innerMatcher
.group(2));
1143 channels
.add(channelInfo
);
1145 } else if (OVERWRITE_MODE_ATTRIBUTE
.matcher(subLine
).matches()) {
1146 String value
= getAttributeValue(subLine
);
1147 channelInfo
.setOverwriteMode(!OVERWRITE_MODE_ATTRIBUTE_FALSE
.equals(value
));
1148 } else if (SUBBUFFER_SIZE_ATTRIBUTE
.matcher(subLine
).matches()) {
1149 channelInfo
.setSubBufferSize(Long
.valueOf(getAttributeValue(subLine
)));
1151 } else if (NUM_SUBBUFFERS_ATTRIBUTE
.matcher(subLine
).matches()) {
1152 channelInfo
.setNumberOfSubBuffers(Integer
.valueOf(getAttributeValue(subLine
)));
1154 } else if (SWITCH_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1155 channelInfo
.setSwitchTimer(Long
.valueOf(getAttributeValue(subLine
)));
1157 } else if (READ_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1158 channelInfo
.setReadTimer(Long
.valueOf(getAttributeValue(subLine
)));
1160 } else if (OUTPUT_ATTRIBUTE
.matcher(subLine
).matches()) {
1161 channelInfo
.setOutputType(getAttributeValue(subLine
));
1163 } else if (EVENT_SECTION_PATTERN
.matcher(subLine
).matches()) {
1164 List
<IEventInfo
> events
= new ArrayList
<IEventInfo
>();
1165 index
= parseEvents(output
, index
, events
);
1166 channelInfo
.setEvents(events
);
1167 // we want to stay at the current index to be able to
1170 } else if (DOMAIN_KERNEL_PATTERN
.matcher(subLine
).matches()) {
1173 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(subLine
).matches()) {
1185 * Parses the event information within a domain.
1188 * - a command output array
1189 * @param currentIndex
1190 * - current index in command output array
1192 * - list for returning event information
1193 * @return the new current index in command output array
1195 private int parseEvents(String
[] output
, int currentIndex
, List
<IEventInfo
> events
) {
1196 int index
= currentIndex
;
1198 while (index
< output
.length
) {
1199 String line
= output
[index
];
1200 if (CHANNEL_PATTERN
.matcher(line
).matches()) {
1203 } else if (DOMAIN_KERNEL_PATTERN
.matcher(line
).matches()) {
1206 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
).matches()) {
1211 Matcher matcher
= EVENT_PATTERN
.matcher(line
);
1212 Matcher matcher2
= WILDCARD_EVENT_PATTERN
.matcher(line
);
1214 if (matcher
.matches()) {
1215 IEventInfo eventInfo
= new EventInfo(matcher
.group(1).trim());
1216 eventInfo
.setLogLevel(matcher
.group(2).trim());
1217 eventInfo
.setEventType(matcher
.group(3).trim());
1218 eventInfo
.setState(matcher
.group(4));
1219 events
.add(eventInfo
);
1221 } else if (matcher2
.matches()) {
1222 IEventInfo eventInfo
= new EventInfo(matcher2
.group(1).trim());
1223 eventInfo
.setLogLevel(TraceLogLevel
.LEVEL_UNKNOWN
);
1224 eventInfo
.setEventType(matcher2
.group(2).trim());
1225 eventInfo
.setState(matcher2
.group(3));
1227 if (eventInfo
.getEventType() == TraceEventType
.PROBE
) {
1228 IProbeEventInfo probeEvent
= new ProbeEventInfo(eventInfo
.getName());
1229 probeEvent
.setLogLevel(eventInfo
.getLogLevel());
1230 probeEvent
.setEventType(eventInfo
.getEventType());
1231 probeEvent
.setState(eventInfo
.getState());
1233 // Overwrite eventinfo
1234 eventInfo
= probeEvent
;
1236 // myevent2 (type: probe) [enabled]
1238 // myevent0 (type: probe) [enabled]
1240 // symbol: init_post
1242 while (index
< output
.length
) {
1243 String probeLine
= output
[index
];
1245 Matcher addrMatcher
= PROBE_ADDRESS_PATTERN
.matcher(probeLine
);
1246 Matcher offsetMatcher
= PROBE_OFFSET_PATTERN
.matcher(probeLine
);
1247 Matcher symbolMatcher
= PROBE_SYMBOL_PATTERN
.matcher(probeLine
);
1248 if (addrMatcher
.matches()) {
1249 String addr
= addrMatcher
.group(2).trim();
1250 probeEvent
.setAddress(addr
);
1251 } else if (offsetMatcher
.matches()) {
1252 String offset
= offsetMatcher
.group(2).trim();
1253 probeEvent
.setOffset(offset
);
1254 } else if (symbolMatcher
.matches()) {
1255 String symbol
= symbolMatcher
.group(2).trim();
1256 probeEvent
.setSymbol(symbol
);
1257 } else if ((EVENT_PATTERN
.matcher(probeLine
).matches()) || (WILDCARD_EVENT_PATTERN
.matcher(probeLine
).matches())) {
1259 } else if (CHANNEL_PATTERN
.matcher(probeLine
).matches()) {
1261 } else if (DOMAIN_KERNEL_PATTERN
.matcher(probeLine
).matches()) {
1264 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(probeLine
).matches()) {
1270 events
.add(eventInfo
);
1272 events
.add(eventInfo
);
1279 // else if (line.matches(EVENT_NONE_PATTERN)) {
1289 * Parses a line with attributes: <attribute Name>: <attribute value>
1292 * - attribute line to parse
1293 * @return the attribute value as string
1295 private String
getAttributeValue(String line
) {
1296 String
[] temp
= line
.split("\\: "); //$NON-NLS-1$
1301 * Parses the event information within a provider.
1304 * - a command output array
1305 * @param currentIndex
1306 * - current index in command output array
1308 * - list for returning event information
1309 * @return the new current index in command output array
1311 private int getProviderEventInfo(String
[] output
, int currentIndex
, List
<IBaseEventInfo
> events
) {
1312 int index
= currentIndex
;
1313 while (index
< output
.length
) {
1314 String line
= output
[index
];
1315 Matcher matcher
= PROVIDER_EVENT_PATTERN
.matcher(line
);
1316 if (matcher
.matches()) {
1317 // sched_kthread_stop (loglevel: TRACE_EMERG0) (type:
1319 IBaseEventInfo eventInfo
= new BaseEventInfo(matcher
.group(1).trim());
1320 eventInfo
.setLogLevel(matcher
.group(2).trim());
1321 eventInfo
.setEventType(matcher
.group(3).trim());
1322 events
.add(eventInfo
);
1323 } else if (UST_PROVIDER_PATTERN
.matcher(line
).matches()) {
1332 * Formats a command parameter for the command execution i.e. adds quotes
1333 * at the beginning and end if necessary.
1334 * @param parameter - parameter to format
1335 * @return formated parameter
1337 private String
formatParameter(String parameter
) {
1338 if (parameter
!= null) {
1339 StringBuffer newString
= new StringBuffer();
1340 newString
.append(parameter
);
1342 if (parameter
.contains(" ")) { //$NON-NLS-1$
1343 newString
.insert(0, "\""); //$NON-NLS-1$
1344 newString
.append("\""); //$NON-NLS-1$
1346 return newString
.toString();