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 to execute calibrate command to quantify LTTng overhead
108 private final static String COMMAND_CALIBRATE
= CONTROL_COMMAND
+ " calibrate "; //$NON-NLS-1$
110 // Command options constants
112 * Command line option for output path.
114 private final static String OPTION_OUTPUT_PATH
= " -o "; //$NON-NLS-1$
116 * Command line option for kernel tracer.
118 private final static String OPTION_KERNEL
= " -k "; //$NON-NLS-1$
120 * Command line option for UST tracer.
122 private final static String OPTION_UST
= " -u "; //$NON-NLS-1$
124 * Command line option for specifying a session.
126 private final static String OPTION_SESSION
= " -s "; //$NON-NLS-1$
128 * Command line option for specifying a channel.
130 private final static String OPTION_CHANNEL
= " -c "; //$NON-NLS-1$
132 * Command line option for specifying a event.
134 private final static String OPTION_EVENT
= " -e "; //$NON-NLS-1$
136 * Command line option for specifying all events.
138 private final static String OPTION_ALL
= " -a "; //$NON-NLS-1$
140 * Command line option for specifying a context.
142 private final static String OPTION_CONTEXT_TYPE
= " -t "; //$NON-NLS-1$
144 * Command line option for specifying tracepoint events.
146 private final static String OPTION_TRACEPOINT
= " --tracepoint "; //$NON-NLS-1$
148 * Command line option for specifying syscall events.
150 private final static String OPTION_SYSCALL
= " --syscall "; //$NON-NLS-1$
152 * Command line option for specifying a dynamic probe.
154 private final static String OPTION_PROBE
= " --probe "; //$NON-NLS-1$
156 * Command line option for specifying a dynamic function entry/return probe.
158 private final static String OPTION_FUNCTION_PROBE
= " --function "; //$NON-NLS-1$
160 * Command line option for specifying a log level range.
162 private final static String OPTION_LOGLEVEL
= " --loglevel "; //$NON-NLS-1$
164 * Command line option for specifying a specific log level.
166 private final static String OPTION_LOGLEVEL_ONLY
= " --loglevel-only "; //$NON-NLS-1$
168 * Optional command line option for configuring a channel's overwrite mode.
170 private final static String OPTION_OVERWRITE
= " --overwrite "; //$NON-NLS-1$
172 * Optional command line option for configuring a channel's number of sub buffers.
174 private final static String OPTION_NUM_SUB_BUFFERS
= " --num-subbuf "; //$NON-NLS-1$
176 * Optional command line option for configuring a channel's sub buffer size.
178 private final static String OPTION_SUB_BUFFER_SIZE
= " --subbuf-size "; //$NON-NLS-1$
180 * Optional command line option for configuring a channel's switch timer interval.
182 private final static String OPTION_SWITCH_TIMER
= " --switch-timer "; //$NON-NLS-1$
184 * Optional command line option for configuring a channel's read timer interval.
186 private final static String OPTION_READ_TIMER
= " --read-timer "; //$NON-NLS-1$
188 * Command line option for printing the help of a specif command
190 private final static String OPTION_HELP
= " -h "; //$NON-NLS-1$
194 * Pattern to match for error output
196 private final static Pattern ERROR_PATTERN
= Pattern
.compile("\\s*Error\\:.*"); //$NON-NLS-1$
198 * Pattern to match for session information (lttng list)
200 private final static Pattern SESSION_PATTERN
= Pattern
.compile("\\s+(\\d+)\\)\\s+(.*)\\s+\\((.*)\\)\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
202 * Pattern to match for session information (lttng list <session>)
204 private final static Pattern TRACE_SESSION_PATTERN
= Pattern
.compile("\\s*Tracing\\s+session\\s+(.*)\\:\\s+\\[(active|inactive)\\].*"); //$NON-NLS-1$
206 * Pattern to match for session path information (lttng list <session>)
208 private final static Pattern TRACE_SESSION_PATH_PATTERN
= Pattern
.compile("\\s*Trace\\s+path\\:\\s+(.*)"); //$NON-NLS-1$
210 * Pattern to match for kernel domain information (lttng list <session>)
212 private final static Pattern DOMAIN_KERNEL_PATTERN
= Pattern
.compile("=== Domain: Kernel ==="); //$NON-NLS-1$
214 * Pattern to match for ust domain information (lttng list <session>)
216 private final static Pattern DOMAIN_UST_GLOBAL_PATTERN
= Pattern
.compile("=== Domain: UST global ==="); //$NON-NLS-1$
218 * Pattern to match for channels section (lttng list <session>)
220 private final static Pattern CHANNELS_SECTION_PATTERN
= Pattern
.compile("\\s*Channels\\:"); //$NON-NLS-1$
222 * Pattern to match for channel information (lttng list <session>)
224 private final static Pattern CHANNEL_PATTERN
= Pattern
.compile("\\s*-\\s+(.*)\\:\\s+\\[(enabled|disabled)\\]"); //$NON-NLS-1$
226 * Pattern to match for events section information (lttng list <session>)
228 private final static Pattern EVENT_SECTION_PATTERN
= Pattern
.compile("\\s*Events\\:"); //$NON-NLS-1$
230 * Pattern to match for event information (no enabled events) (lttng list <session>)
232 // private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
234 * Pattern to match for event information (lttng list <session>)
236 private final static Pattern EVENT_PATTERN
= Pattern
.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
238 * Pattern to match a wildcarded event information (lttng list <session>)
240 private final static Pattern WILDCARD_EVENT_PATTERN
= Pattern
.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
242 * Pattern to match a probe address information (lttng list <session>)
244 private final static Pattern PROBE_ADDRESS_PATTERN
= Pattern
.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
246 * Pattern to match a probe OFFSET information (lttng list <session>)
248 private final static Pattern PROBE_OFFSET_PATTERN
= Pattern
.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
250 * Pattern to match a probe SYMBOL information (lttng list <session>)
252 private final static Pattern PROBE_SYMBOL_PATTERN
= Pattern
.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
254 * Pattern to match for channel (overwite mode) information (lttng list
257 private final static Pattern OVERWRITE_MODE_ATTRIBUTE
= Pattern
.compile("\\s+overwrite\\s+mode\\:.*"); //$NON-NLS-1$
259 * Pattern to match indicating false for overwrite mode
261 private final static String OVERWRITE_MODE_ATTRIBUTE_FALSE
= "0"; //$NON-NLS-1$
263 * Pattern to match for channel (sub-buffer size) information (lttng list
266 private final static Pattern SUBBUFFER_SIZE_ATTRIBUTE
= Pattern
.compile("\\s+subbufers\\s+size\\:.*"); //$NON-NLS-1$
268 * Pattern to match for channel (number of sub-buffers) information (lttng
271 private final static Pattern NUM_SUBBUFFERS_ATTRIBUTE
= Pattern
.compile("\\s+number\\s+of\\s+subbufers\\:.*"); //$NON-NLS-1$
273 * Pattern to match for channel (switch timer) information (lttng list
276 private final static Pattern SWITCH_TIMER_ATTRIBUTE
= Pattern
.compile("\\s+switch\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
278 * Pattern to match for channel (read timer) information (lttng list
281 private final static Pattern READ_TIMER_ATTRIBUTE
= Pattern
.compile("\\s+read\\s+timer\\s+interval\\:.*"); //$NON-NLS-1$
283 * Pattern to match for channel (output type) information (lttng list
286 private final static Pattern OUTPUT_ATTRIBUTE
= Pattern
.compile("\\s+output\\:.*"); //$NON-NLS-1$
288 * Pattern to match for provider information (lttng list -k/-u)
290 private final static Pattern PROVIDER_EVENT_PATTERN
= Pattern
.compile("\\s*(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)"); //$NON-NLS-1$
292 * Pattern to match for UST provider information (lttng list -u)
294 private final static Pattern UST_PROVIDER_PATTERN
= Pattern
.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
296 * Pattern to match for session information (lttng create <session name>)
298 private final static Pattern CREATE_SESSION_NAME_PATTERN
= Pattern
.compile("\\s*Session\\s+(.*)\\s+created\\."); //$NON-NLS-1$
300 * Pattern to match for session path information (lttng create <session name>)
302 private final static Pattern CREATE_SESSION_PATH_PATTERN
= Pattern
.compile("\\s*Traces\\s+will\\s+be\\s+written\\s+in\\s+(.*).*"); //$NON-NLS-1$
304 * Pattern to match for session command output for "session name not found".
306 private final static Pattern SESSION_NOT_FOUND_ERROR_PATTERN
= Pattern
.compile("\\s*Error:\\s+Session\\s+name\\s+not\\s+found"); //$NON-NLS-1$
308 * Pattern to match introduction line of context list.
310 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$
313 * Pattern to match introduction line of context list.
315 private final static Pattern ADD_CONTEXT_HELP_CONTEXTS_END_LINE
= Pattern
.compile("\\s*Example.*"); //$NON-NLS-1$
317 // ------------------------------------------------------------------------
319 // ------------------------------------------------------------------------
321 * The command shell implementation
323 private ICommandShell fCommandShell
= null;
325 // ------------------------------------------------------------------------
327 // ------------------------------------------------------------------------
333 * - the command shell implementation to use
335 public LTTngControlService(ICommandShell shell
) {
336 fCommandShell
= shell
;
339 // ------------------------------------------------------------------------
341 // ------------------------------------------------------------------------
347 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
348 * #getSessionNames(org.eclipse.core.runtime.IProgressMonitor)
351 public String
[] getSessionNames(IProgressMonitor monitor
) throws ExecutionException
{
353 String command
= COMMAND_LIST
;
354 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
356 if (isError(result
)) {
357 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
361 // Available tracing sessions:
362 // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928)
364 // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318)
367 // Use lttng list <session_name> for more details
369 ArrayList
<String
> retArray
= new ArrayList
<String
>();
371 while (index
< result
.getOutput().length
) {
372 String line
= result
.getOutput()[index
];
373 Matcher matcher
= SESSION_PATTERN
.matcher(line
);
374 if (matcher
.matches()) {
375 retArray
.add(matcher
.group(2).trim());
379 return retArray
.toArray(new String
[retArray
.size()]);
386 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
387 * #getSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
390 public ISessionInfo
getSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
392 String command
= COMMAND_LIST
+ sessionName
;
393 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
395 if (isError(result
)) {
396 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
402 // Tracing session mysession2: [inactive]
403 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
404 ISessionInfo sessionInfo
= new SessionInfo(sessionName
);
406 while (index
< result
.getOutput().length
) {
407 // Tracing session mysession2: [inactive]
408 // Trace path: /home/eedbhu/lttng-traces/mysession2-20120123-110330
410 // === Domain: Kernel ===
412 String line
= result
.getOutput()[index
];
413 Matcher matcher
= TRACE_SESSION_PATTERN
.matcher(line
);
414 if (matcher
.matches()) {
415 sessionInfo
.setSessionState(matcher
.group(2));
420 matcher
= TRACE_SESSION_PATH_PATTERN
.matcher(line
);
421 if (matcher
.matches()) {
422 sessionInfo
.setSessionPath(matcher
.group(1).trim());
427 matcher
= DOMAIN_KERNEL_PATTERN
.matcher(line
);
428 if (matcher
.matches()) {
430 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_KernelDomainDisplayName
);
431 sessionInfo
.addDomain(domainInfo
);
434 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
435 index
= parseDomain(result
.getOutput(), index
, channels
);
438 domainInfo
.setChannels(channels
);
441 domainInfo
.setIsKernel(true);
445 matcher
= DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
);
446 if (matcher
.matches()) {
447 IDomainInfo domainInfo
= new DomainInfo(Messages
.TraceControl_UstGlobalDomainDisplayName
);
448 sessionInfo
.addDomain(domainInfo
);
451 ArrayList
<IChannelInfo
> channels
= new ArrayList
<IChannelInfo
>();
452 index
= parseDomain(result
.getOutput(), index
, channels
);
455 domainInfo
.setChannels(channels
);
458 domainInfo
.setIsKernel(false);
470 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
471 * #getKernelProvider(org.eclipse.core.runtime.IProgressMonitor)
474 public List
<IBaseEventInfo
> getKernelProvider(IProgressMonitor monitor
) throws ExecutionException
{
475 String command
= COMMAND_LIST_KERNEL
;
476 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
477 if (isError(result
)) {
478 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
483 // sched_kthread_stop (type: tracepoint)
484 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
485 getProviderEventInfo(result
.getOutput(), 0, events
);
493 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
497 public List
<IUstProviderInfo
> getUstProvider() throws ExecutionException
{
498 return getUstProvider(new NullProgressMonitor());
505 * org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService
506 * #getUstProvider(org.eclipse.core.runtime.IProgressMonitor)
509 public List
<IUstProviderInfo
> getUstProvider(IProgressMonitor monitor
) throws ExecutionException
{
510 String command
= COMMAND_LIST_UST
;
511 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
513 if (isError(result
)) {
514 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
521 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
522 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
524 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
527 // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
528 // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
530 // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
532 List
<IUstProviderInfo
> allProviders
= new ArrayList
<IUstProviderInfo
>();
533 IUstProviderInfo provider
= null;
536 while (index
< result
.getOutput().length
) {
537 String line
= result
.getOutput()[index
];
538 Matcher matcher
= UST_PROVIDER_PATTERN
.matcher(line
);
539 if (matcher
.matches()) {
541 provider
= new UstProviderInfo(matcher
.group(2).trim());
542 provider
.setPid(Integer
.valueOf(matcher
.group(1).trim()));
543 List
<IBaseEventInfo
> events
= new ArrayList
<IBaseEventInfo
>();
544 index
= getProviderEventInfo(result
.getOutput(), ++index
, events
);
545 provider
.setEvents(events
);
546 allProviders
.add(provider
);
558 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
561 public ISessionInfo
createSession(String sessionName
, String sessionPath
, IProgressMonitor monitor
) throws ExecutionException
{
563 String newName
= formatParameter(sessionName
);
564 String newPath
= formatParameter(sessionPath
);
566 StringBuffer command
= new StringBuffer();
567 command
.append(COMMAND_CREATE_SESSION
);
568 command
.append(newName
);
570 if (newPath
!= null && !"".equals(newPath
)) { //$NON-NLS-1$
571 command
.append(OPTION_OUTPUT_PATH
);
572 command
.append(newPath
);
575 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
577 if (isError(result
)) {
578 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
580 //Session myssession2 created.
581 //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
582 String
[] output
= result
.getOutput();
584 // Get and verify session name
585 Matcher matcher
= CREATE_SESSION_NAME_PATTERN
.matcher(output
[0]);
588 if (matcher
.matches()) {
589 name
= String
.valueOf(matcher
.group(1).trim());
591 // Output format not expected
592 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
593 Messages
.TraceControl_UnexpectedCommnadOutputFormat
+ ":\n" + //$NON-NLS-1$
594 formatOutput(result
.getOutput()));
597 if ((name
== null) || (!name
.equals(sessionName
))) {
598 // Unexpected name returned
599 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
600 Messages
.TraceControl_UnexpectedNameError
+ ": " + name
); //$NON-NLS-1$
603 // Get and verify session path
604 matcher
= CREATE_SESSION_PATH_PATTERN
.matcher(output
[1]);
607 if (matcher
.matches()) {
608 path
= String
.valueOf(matcher
.group(1).trim());
610 // Output format not expected
611 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
612 Messages
.TraceControl_UnexpectedCommnadOutputFormat
+ ":\n" + //$NON-NLS-1$
613 formatOutput(result
.getOutput()));
616 if ((path
== null) || ((sessionPath
!= null) && (!path
.contains(sessionPath
)))) {
618 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + //$NON-NLS-1$ //$NON-NLS-2$
619 Messages
.TraceControl_UnexpectedPathError
+ ": " + name
); //$NON-NLS-1$
622 SessionInfo sessionInfo
= new SessionInfo(name
);
623 sessionInfo
.setSessionPath(path
);
629 public void destroySession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
630 String newName
= formatParameter(sessionName
);
631 String command
= COMMAND_DESTROY_SESSION
+ newName
;
633 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
634 String
[] output
= result
.getOutput();
636 if (isError(result
) && ((output
== null) || (!SESSION_NOT_FOUND_ERROR_PATTERN
.matcher(output
[0]).matches()))) {
637 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
639 //Session <sessionName> destroyed
644 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
647 public void startSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
649 String newSessionName
= formatParameter(sessionName
);
651 String command
= COMMAND_START_SESSION
+ newSessionName
;
653 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
655 if (isError(result
)) {
656 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
658 //Session <sessionName> started
663 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
666 public void stopSession(String sessionName
, IProgressMonitor monitor
) throws ExecutionException
{
667 String newSessionName
= formatParameter(sessionName
);
668 String command
= COMMAND_STOP_SESSION
+ newSessionName
;
670 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
672 if (isError(result
)) {
673 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
675 //Session <sessionName> stopped
681 * @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)
684 public void enableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
686 // no channels to enable
687 if (channelNames
.isEmpty()) {
691 String newSessionName
= formatParameter(sessionName
);
693 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_CHANNEL
);
695 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
696 String channel
= (String
) iterator
.next();
697 command
.append(channel
);
698 if (iterator
.hasNext()) {
704 command
.append(OPTION_KERNEL
);
706 command
.append(OPTION_UST
);
709 command
.append(OPTION_SESSION
);
710 command
.append(newSessionName
);
713 // --discard Discard event when buffers are full (default)
715 // --overwrite Flight recorder mode
716 if (info
.isOverwriteMode()) {
717 command
.append(OPTION_OVERWRITE
);
719 // --subbuf-size SIZE Subbuffer size in bytes
720 // (default: 4096, kernel default: 262144)
721 command
.append(OPTION_SUB_BUFFER_SIZE
);
722 command
.append(String
.valueOf(info
.getSubBufferSize()));
724 // --num-subbuf NUM Number of subbufers
725 // (default: 8, kernel default: 4)
726 command
.append(OPTION_NUM_SUB_BUFFERS
);
727 command
.append(String
.valueOf(info
.getNumberOfSubBuffers()));
729 // --switch-timer USEC Switch timer interval in usec (default: 0)
730 command
.append(OPTION_SWITCH_TIMER
);
731 command
.append(String
.valueOf(info
.getSwitchTimer()));
733 // --read-timer USEC Read timer interval in usec (default: 200)
734 command
.append(OPTION_READ_TIMER
);
735 command
.append(String
.valueOf(info
.getReadTimer()));
738 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
740 if (isError(result
)) {
741 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
747 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
750 public void disableChannels(String sessionName
, List
<String
> channelNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
752 // no channels to enable
753 if (channelNames
.isEmpty()) {
757 String newSessionName
= formatParameter(sessionName
);
759 StringBuffer command
= new StringBuffer(COMMAND_DISABLE_CHANNEL
);
761 for (Iterator
<String
> iterator
= channelNames
.iterator(); iterator
.hasNext();) {
762 String channel
= (String
) iterator
.next();
763 command
.append(channel
);
764 if (iterator
.hasNext()) {
770 command
.append(OPTION_KERNEL
);
772 command
.append(OPTION_UST
);
775 command
.append(OPTION_SESSION
);
776 command
.append(newSessionName
);
778 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
780 if (isError(result
)) {
781 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
787 * @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)
790 public void enableEvents(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
792 String newSessionName
= formatParameter(sessionName
);
794 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
796 if (eventNames
== null || eventNames
.isEmpty()) {
797 command
.append(OPTION_ALL
);
800 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
801 String event
= (String
) iterator
.next();
802 command
.append(event
);
803 if (iterator
.hasNext()) {
810 command
.append(OPTION_KERNEL
);
812 command
.append(OPTION_UST
);
815 command
.append(OPTION_SESSION
);
816 command
.append(newSessionName
);
818 if (channelName
!= null) {
819 command
.append(OPTION_CHANNEL
);
820 command
.append(channelName
);
823 command
.append(OPTION_TRACEPOINT
);
825 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
827 if (isError(result
)) {
828 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
834 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
837 public void enableSyscalls(String sessionName
, String channelName
, IProgressMonitor monitor
) throws ExecutionException
{
838 String newSessionName
= formatParameter(sessionName
);
840 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
842 command
.append(OPTION_ALL
);
843 command
.append(OPTION_KERNEL
);
845 command
.append(OPTION_SESSION
);
846 command
.append(newSessionName
);
848 if (channelName
!= null) {
849 command
.append(OPTION_CHANNEL
);
850 command
.append(channelName
);
853 command
.append(OPTION_SYSCALL
);
855 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
857 if (isError(result
)) {
858 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
864 * @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)
867 public void enableProbe(String sessionName
, String channelName
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
868 String newSessionName
= formatParameter(sessionName
);
870 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
872 command
.append(eventName
);
873 command
.append(OPTION_KERNEL
);
875 command
.append(OPTION_SESSION
);
876 command
.append(newSessionName
);
878 if (channelName
!= null) {
879 command
.append(OPTION_CHANNEL
);
880 command
.append(channelName
);
883 command
.append(OPTION_FUNCTION_PROBE
);
885 command
.append(OPTION_PROBE
);
888 command
.append(probe
);
890 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
892 if (isError(result
)) {
893 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
899 * @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)
902 public void enableLogLevel(String sessionName
, String channelName
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
903 String newSessionName
= formatParameter(sessionName
);
905 StringBuffer command
= new StringBuffer(COMMAND_ENABLE_EVENT
);
907 command
.append(eventName
);
908 command
.append(OPTION_UST
);
910 command
.append(OPTION_SESSION
);
911 command
.append(newSessionName
);
913 if (channelName
!= null) {
914 command
.append(OPTION_CHANNEL
);
915 command
.append(channelName
);
918 if (logLevelType
== LogLevelType
.LOGLEVEL
) {
919 command
.append(OPTION_LOGLEVEL
);
920 } else if (logLevelType
== LogLevelType
.LOGLEVEL_ONLY
) {
921 command
.append(OPTION_LOGLEVEL_ONLY
);
926 command
.append(level
.getInName());
928 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
930 if (isError(result
)) {
931 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
937 * @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)
940 public void disableEvent(String sessionName
, String channelName
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
941 String newSessionName
= formatParameter(sessionName
);
943 StringBuffer command
= new StringBuffer(COMMAND_DISABLE_EVENT
);
944 if (eventNames
== null) {
945 command
.append(OPTION_ALL
);
947 // no events to enable
948 if (eventNames
.isEmpty()) {
952 for (Iterator
<String
> iterator
= eventNames
.iterator(); iterator
.hasNext();) {
953 String event
= (String
) iterator
.next();
954 command
.append(event
);
955 if (iterator
.hasNext()) {
962 command
.append(OPTION_KERNEL
);
964 command
.append(OPTION_UST
);
967 command
.append(OPTION_SESSION
);
968 command
.append(newSessionName
);
970 if (channelName
!= null) {
971 command
.append(OPTION_CHANNEL
);
972 command
.append(channelName
);
975 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
977 if (isError(result
)) {
978 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
984 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#getContexts(org.eclipse.core.runtime.IProgressMonitor)
987 public List
<String
> getContextList(IProgressMonitor monitor
) throws ExecutionException
{
989 String command
= COMMAND_ADD_CONTEXT
+ OPTION_HELP
;
991 ICommandResult result
= fCommandShell
.executeCommand(command
, monitor
);
993 if (isError(result
)) {
994 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
997 String
[] output
= result
.getOutput();
999 List
<String
> contexts
= new ArrayList
<String
>(0);
1002 boolean inList
= false;
1003 while (index
< output
.length
) {
1004 String line
= result
.getOutput()[index
];
1006 Matcher startMatcher
= ADD_CONTEXT_HELP_CONTEXTS_INTRO
.matcher(line
);
1007 Matcher endMatcher
= ADD_CONTEXT_HELP_CONTEXTS_END_LINE
.matcher(line
);
1009 if (startMatcher
.matches()) {
1011 } else if (endMatcher
.matches()) {
1013 } else if (inList
== true) {
1014 String
[] tmp
= line
.split(","); //$NON-NLS-1$
1015 for (int i
= 0; i
< tmp
.length
; i
++) {
1016 contexts
.add(tmp
[i
].trim());
1026 * @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)
1029 public void addContexts(String sessionName
, String channelName
, String eventName
, boolean isKernel
, List
<String
> contextNames
, IProgressMonitor monitor
) throws ExecutionException
{
1031 String newSessionName
= formatParameter(sessionName
);
1032 StringBuffer command
= new StringBuffer(COMMAND_ADD_CONTEXT
);
1034 command
.append(OPTION_SESSION
);
1035 command
.append(newSessionName
);
1037 if (channelName
!= null) {
1038 command
.append(OPTION_CHANNEL
);
1039 command
.append(channelName
);
1042 if (eventName
!= null) {
1043 command
.append(OPTION_EVENT
);
1044 command
.append(eventName
);
1048 command
.append(OPTION_KERNEL
);
1050 command
.append(OPTION_UST
);
1053 for (Iterator
<String
> iterator
= contextNames
.iterator(); iterator
.hasNext();) {
1054 String context
= (String
) iterator
.next();
1055 command
.append(OPTION_CONTEXT_TYPE
);
1056 command
.append(context
);
1059 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
1061 if (isError(result
)) {
1062 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
1068 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#calibrate(boolean, org.eclipse.core.runtime.IProgressMonitor)
1071 public void calibrate(boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
1072 // String newSessionName = formatParameter(sessionName);
1073 StringBuffer command
= new StringBuffer(COMMAND_CALIBRATE
);
1075 // command.append(OPTION_SESSION);
1076 // command.append(newSessionName);
1079 command
.append(OPTION_KERNEL
);
1081 command
.append(OPTION_UST
);
1084 command
.append(OPTION_FUNCTION_PROBE
);
1086 ICommandResult result
= fCommandShell
.executeCommand(command
.toString(), monitor
);
1088 if (isError(result
)) {
1089 throw new ExecutionException(Messages
.TraceControl_CommandError
+ " " + command
+ "\n" + formatOutput(result
.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
1093 // ------------------------------------------------------------------------
1095 // ------------------------------------------------------------------------
1097 * Checks if command result is an error result.
1100 * - the command result to check
1101 * @return true if error else false
1103 private boolean isError(ICommandResult result
) {
1104 if ((result
.getResult()) != 0 || (result
.getOutput().length
< 1 || ERROR_PATTERN
.matcher(result
.getOutput()[0]).matches())) {
1111 * Formats the output string as single string.
1115 * @return - the formatted output
1117 private String
formatOutput(String
[] output
) {
1118 if (output
== null || output
.length
== 0) {
1119 return ""; //$NON-NLS-1$
1122 StringBuffer ret
= new StringBuffer();
1123 for (int i
= 0; i
< output
.length
; i
++) {
1124 ret
.append(output
[i
] + "\n"); //$NON-NLS-1$
1126 return ret
.toString();
1130 * Parses the domain information.
1133 * - a command output array
1134 * @param currentIndex
1135 * - current index in command output array
1137 * - list for returning channel information
1138 * @return the new current index in command output array
1140 private int parseDomain(String
[] output
, int currentIndex
, List
<IChannelInfo
> channels
) {
1141 int index
= currentIndex
;
1145 // - channnel1: [enabled]
1148 // overwrite mode: 0
1149 // subbufers size: 262144
1150 // number of subbufers: 4
1151 // switch timer interval: 0
1152 // read timer interval: 200
1155 while (index
< output
.length
) {
1156 String line
= output
[index
];
1158 Matcher outerMatcher
= CHANNELS_SECTION_PATTERN
.matcher(line
);
1159 if (outerMatcher
.matches()) {
1160 IChannelInfo channelInfo
= null;
1161 while (index
< output
.length
) {
1162 String subLine
= output
[index
];
1164 Matcher innerMatcher
= CHANNEL_PATTERN
.matcher(subLine
);
1165 if (innerMatcher
.matches()) {
1166 channelInfo
= new ChannelInfo(""); //$NON-NLS-1$
1168 channelInfo
.setName(innerMatcher
.group(1));
1170 // get channel enablement
1171 channelInfo
.setState(innerMatcher
.group(2));
1174 channels
.add(channelInfo
);
1176 } else if (OVERWRITE_MODE_ATTRIBUTE
.matcher(subLine
).matches()) {
1177 String value
= getAttributeValue(subLine
);
1178 channelInfo
.setOverwriteMode(!OVERWRITE_MODE_ATTRIBUTE_FALSE
.equals(value
));
1179 } else if (SUBBUFFER_SIZE_ATTRIBUTE
.matcher(subLine
).matches()) {
1180 channelInfo
.setSubBufferSize(Long
.valueOf(getAttributeValue(subLine
)));
1182 } else if (NUM_SUBBUFFERS_ATTRIBUTE
.matcher(subLine
).matches()) {
1183 channelInfo
.setNumberOfSubBuffers(Integer
.valueOf(getAttributeValue(subLine
)));
1185 } else if (SWITCH_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1186 channelInfo
.setSwitchTimer(Long
.valueOf(getAttributeValue(subLine
)));
1188 } else if (READ_TIMER_ATTRIBUTE
.matcher(subLine
).matches()) {
1189 channelInfo
.setReadTimer(Long
.valueOf(getAttributeValue(subLine
)));
1191 } else if (OUTPUT_ATTRIBUTE
.matcher(subLine
).matches()) {
1192 channelInfo
.setOutputType(getAttributeValue(subLine
));
1194 } else if (EVENT_SECTION_PATTERN
.matcher(subLine
).matches()) {
1195 List
<IEventInfo
> events
= new ArrayList
<IEventInfo
>();
1196 index
= parseEvents(output
, index
, events
);
1197 channelInfo
.setEvents(events
);
1198 // we want to stay at the current index to be able to
1201 } else if (DOMAIN_KERNEL_PATTERN
.matcher(subLine
).matches()) {
1204 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(subLine
).matches()) {
1216 * Parses the event information within a domain.
1219 * - a command output array
1220 * @param currentIndex
1221 * - current index in command output array
1223 * - list for returning event information
1224 * @return the new current index in command output array
1226 private int parseEvents(String
[] output
, int currentIndex
, List
<IEventInfo
> events
) {
1227 int index
= currentIndex
;
1229 while (index
< output
.length
) {
1230 String line
= output
[index
];
1231 if (CHANNEL_PATTERN
.matcher(line
).matches()) {
1234 } else if (DOMAIN_KERNEL_PATTERN
.matcher(line
).matches()) {
1237 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(line
).matches()) {
1242 Matcher matcher
= EVENT_PATTERN
.matcher(line
);
1243 Matcher matcher2
= WILDCARD_EVENT_PATTERN
.matcher(line
);
1245 if (matcher
.matches()) {
1246 IEventInfo eventInfo
= new EventInfo(matcher
.group(1).trim());
1247 eventInfo
.setLogLevel(matcher
.group(2).trim());
1248 eventInfo
.setEventType(matcher
.group(3).trim());
1249 eventInfo
.setState(matcher
.group(4));
1250 events
.add(eventInfo
);
1252 } else if (matcher2
.matches()) {
1253 IEventInfo eventInfo
= new EventInfo(matcher2
.group(1).trim());
1254 eventInfo
.setLogLevel(TraceLogLevel
.LEVEL_UNKNOWN
);
1255 eventInfo
.setEventType(matcher2
.group(2).trim());
1256 eventInfo
.setState(matcher2
.group(3));
1258 if (eventInfo
.getEventType() == TraceEventType
.PROBE
) {
1259 IProbeEventInfo probeEvent
= new ProbeEventInfo(eventInfo
.getName());
1260 probeEvent
.setLogLevel(eventInfo
.getLogLevel());
1261 probeEvent
.setEventType(eventInfo
.getEventType());
1262 probeEvent
.setState(eventInfo
.getState());
1264 // Overwrite eventinfo
1265 eventInfo
= probeEvent
;
1267 // myevent2 (type: probe) [enabled]
1269 // myevent0 (type: probe) [enabled]
1271 // symbol: init_post
1273 while (index
< output
.length
) {
1274 String probeLine
= output
[index
];
1276 Matcher addrMatcher
= PROBE_ADDRESS_PATTERN
.matcher(probeLine
);
1277 Matcher offsetMatcher
= PROBE_OFFSET_PATTERN
.matcher(probeLine
);
1278 Matcher symbolMatcher
= PROBE_SYMBOL_PATTERN
.matcher(probeLine
);
1279 if (addrMatcher
.matches()) {
1280 String addr
= addrMatcher
.group(2).trim();
1281 probeEvent
.setAddress(addr
);
1282 } else if (offsetMatcher
.matches()) {
1283 String offset
= offsetMatcher
.group(2).trim();
1284 probeEvent
.setOffset(offset
);
1285 } else if (symbolMatcher
.matches()) {
1286 String symbol
= symbolMatcher
.group(2).trim();
1287 probeEvent
.setSymbol(symbol
);
1288 } else if ((EVENT_PATTERN
.matcher(probeLine
).matches()) || (WILDCARD_EVENT_PATTERN
.matcher(probeLine
).matches())) {
1290 } else if (CHANNEL_PATTERN
.matcher(probeLine
).matches()) {
1292 } else if (DOMAIN_KERNEL_PATTERN
.matcher(probeLine
).matches()) {
1295 } else if (DOMAIN_UST_GLOBAL_PATTERN
.matcher(probeLine
).matches()) {
1301 events
.add(eventInfo
);
1303 events
.add(eventInfo
);
1310 // else if (line.matches(EVENT_NONE_PATTERN)) {
1320 * Parses a line with attributes: <attribute Name>: <attribute value>
1323 * - attribute line to parse
1324 * @return the attribute value as string
1326 private String
getAttributeValue(String line
) {
1327 String
[] temp
= line
.split("\\: "); //$NON-NLS-1$
1332 * Parses the event information within a provider.
1335 * - a command output array
1336 * @param currentIndex
1337 * - current index in command output array
1339 * - list for returning event information
1340 * @return the new current index in command output array
1342 private int getProviderEventInfo(String
[] output
, int currentIndex
, List
<IBaseEventInfo
> events
) {
1343 int index
= currentIndex
;
1344 while (index
< output
.length
) {
1345 String line
= output
[index
];
1346 Matcher matcher
= PROVIDER_EVENT_PATTERN
.matcher(line
);
1347 if (matcher
.matches()) {
1348 // sched_kthread_stop (loglevel: TRACE_EMERG0) (type:
1350 IBaseEventInfo eventInfo
= new BaseEventInfo(matcher
.group(1).trim());
1351 eventInfo
.setLogLevel(matcher
.group(2).trim());
1352 eventInfo
.setEventType(matcher
.group(3).trim());
1353 events
.add(eventInfo
);
1354 } else if (UST_PROVIDER_PATTERN
.matcher(line
).matches()) {
1363 * Formats a command parameter for the command execution i.e. adds quotes
1364 * at the beginning and end if necessary.
1365 * @param parameter - parameter to format
1366 * @return formated parameter
1368 private String
formatParameter(String parameter
) {
1369 if (parameter
!= null) {
1370 StringBuffer newString
= new StringBuffer();
1371 newString
.append(parameter
);
1373 if (parameter
.contains(" ")) { //$NON-NLS-1$
1374 newString
.insert(0, "\""); //$NON-NLS-1$
1375 newString
.append("\""); //$NON-NLS-1$
1377 return newString
.toString();