import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.DomainInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ProbeEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.SessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderInfo;
*/
private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
/**
- * Command to destroy a session.
+ * Command to disable a channel.
*/
private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
+ /**
+ * Command to enable a event.
+ */
+ private final static String COMMAND_ENABLE_EVENT = CONTROL_COMMAND + " enable-event "; //$NON-NLS-1$
+ /**
+ * Command to disable a event.
+ */
+ private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
+ // Command options constants
+ /**
+ * Command line option for kernel tracer.
+ */
+ private final static String OPTION_KERNEL = " -k "; //$NON-NLS-1$
+ /**
+ * Command line option for UST tracer.
+ */
+ private final static String OPTION_UST = " -u "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a session.
+ */
+ private final static String OPTION_SESSION = " -s "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a channel.
+ */
+ private final static String OPTION_CHANNEL = " -c "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying all events.
+ */
+ private final static String OPTION_ALL = " -a "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying tracepoint events.
+ */
+ private final static String OPTION_TRACEPOINT = " --tracepoint "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying syscall events.
+ */
+ private final static String OPTION_SYSCALL = " --syscall "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a dynamic probe.
+ */
+ private final static String OPTION_PROBE = " --probe "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a dynamic function entry/return probe.
+ */
+ private final static String OPTION_FUNCTION_PROBE = " --function "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a log level range.
+ */
+ private final static String OPTION_LOGLEVEL = " --loglevel "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a specific log level.
+ */
+ private final static String OPTION_LOGLEVEL_ONLY = " --loglevel-only "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's overwrite mode.
+ */
+ private final static String OPTION_OVERWRITE = " --overwrite "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's number of sub buffers.
+ */
+ private final static String OPTION_NUM_SUB_BUFFERS = " --num-subbuf "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's sub buffer size.
+ */
+ private final static String OPTION_SUB_BUFFER_SIZE = " --subbuf-size "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's switch timer interval.
+ */
+ private final static String OPTION_SWITCH_TIMER = " --switch-timer "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's read timer interval.
+ */
+ private final static String OPTION_READ_TIMER = " --read-timer "; //$NON-NLS-1$
+
// Parsing constants
/**
* Pattern to match for error output
*/
private final static Pattern EVENT_SECTION_PATTERN = Pattern.compile("\\s*Events\\:"); //$NON-NLS-1$
/**
- * Pattern to match for event information (no enabled events) (lttng list
- * <session>)
+ * Pattern to match for event information (no enabled events) (lttng list <session>)
*/
// private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
/**
* Pattern to match a wildcarded event information (lttng list <session>)
*/
private final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe address information (lttng list <session>)
+ */
+ private final static Pattern PROBE_ADDRESS_PATTERN = Pattern.compile("\\s+(addr)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe OFFSET information (lttng list <session>)
+ */
+ private final static Pattern PROBE_OFFSET_PATTERN = Pattern.compile("\\s+(offset)\\:\\s+(0x[0-9a-fA-F]{1,8})"); //$NON-NLS-1$
+ /**
+ * Pattern to match a probe SYMBOL information (lttng list <session>)
+ */
+ private final static Pattern PROBE_SYMBOL_PATTERN = Pattern.compile("\\s+(symbol)\\:\\s+(.+)"); //$NON-NLS-1$
/**
* Pattern to match for channel (overwite mode) information (lttng list
* <session>)
*/
@Override
public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
String command = COMMAND_LIST + sessionName;
ICommandResult result = fCommandShell.executeCommand(command, monitor);
-
+
+
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
* @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void enableChannel(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
+ public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
// no channels to enable
if (channelNames.size() == 0) {
}
if (isKernel) {
- command.append(" -k ");
+ command.append(OPTION_KERNEL);
} else {
- command.append(" -u ");
+ command.append(OPTION_UST);
}
- command.append(" -s "); //$NON-NLS-1$
+ command.append(OPTION_SESSION);
command.append(newSessionName);
if (info != null) {
// --discard Discard event when buffers are full (default)
- // TODO discard
// --overwrite Flight recorder mode
if (info.isOverwriteMode()) {
- command.append(" --overwrite ");
+ command.append(OPTION_OVERWRITE);
}
// --subbuf-size SIZE Subbuffer size in bytes
// (default: 4096, kernel default: 262144)
- command.append(" --subbuf-size ");
+ command.append(OPTION_SUB_BUFFER_SIZE);
command.append(String.valueOf(info.getSubBufferSize()));
// --num-subbuf NUM Number of subbufers
// (default: 8, kernel default: 4)
- command.append(" --num-subbuf ");
+ command.append(OPTION_NUM_SUB_BUFFERS);
command.append(String.valueOf(info.getNumberOfSubBuffers()));
// --switch-timer USEC Switch timer interval in usec (default: 0)
- command.append(" --switch-timer ");
+ command.append(OPTION_SWITCH_TIMER);
command.append(String.valueOf(info.getSwitchTimer()));
// --read-timer USEC Read timer interval in usec (default: 200)
- command.append(" --read-timer ");
+ command.append(OPTION_READ_TIMER);
command.append(String.valueOf(info.getReadTimer()));
}
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
-
}
/*
* @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void disableChannel(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException{
+ public void disableChannels(String sessionName, List<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
// no channels to enable
if (channelNames.size() == 0) {
}
if (isKernel) {
- command.append(" -k ");
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ if (eventNames == null || eventNames.size() == 0) {
+ command.append(OPTION_ALL);
+ } else {
+
+ for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
} else {
- command.append(" -u ");
+ command.append(OPTION_UST);
}
- command.append(" -s "); //$NON-NLS-1$
+ command.append(OPTION_SESSION);
command.append(newSessionName);
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ command.append(OPTION_TRACEPOINT);
+
ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
if (isError(result)) {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableSyscalls(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableSyscalls(String sessionName, String channelName, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(OPTION_ALL);
+ command.append(OPTION_KERNEL);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ command.append(OPTION_SYSCALL);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableProbe(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableProbe(String sessionName, String channelName, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(eventName);
+ command.append(OPTION_KERNEL);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+ if (isFunction) {
+ command.append(OPTION_FUNCTION_PROBE);
+ } else {
+ command.append(OPTION_PROBE);
+ }
+
+ command.append(probe);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ command.append(eventName);
+ command.append(OPTION_UST);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ if (logLevelType == LogLevelType.LOGLEVEL) {
+ command.append(OPTION_LOGLEVEL);
+ } else if (logLevelType == LogLevelType.LOGLEVEL_ONLY) {
+ command.append(OPTION_LOGLEVEL_ONLY);
+
+ } else {
+ return;
+ }
+ command.append(level.getInName());
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_DISABLE_EVENT);
+ if (eventNames == null) {
+ command.append(OPTION_ALL);
+ } else {
+ // no events to enable
+ if (eventNames.size() == 0) {
+ return;
+ }
+
+ for (Iterator<String> iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
eventInfo.setEventType(matcher.group(3).trim());
eventInfo.setState(matcher.group(4));
events.add(eventInfo);
+ index++;
} else if (matcher2.matches()) {
IEventInfo eventInfo = new EventInfo(matcher2.group(1).trim());
eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN);
eventInfo.setEventType(matcher2.group(2).trim());
eventInfo.setState(matcher2.group(3));
- events.add(eventInfo);
+
+ if (eventInfo.getEventType() == TraceEventType.PROBE) {
+ IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName());
+ probeEvent.setLogLevel(eventInfo.getLogLevel());
+ probeEvent.setEventType(eventInfo.getEventType());
+ probeEvent.setState(eventInfo.getState());
+
+ // Overwrite eventinfo
+ eventInfo = probeEvent;
+
+ // myevent2 (type: probe) [enabled]
+ // addr: 0xc0101340
+ // myevent0 (type: probe) [enabled]
+ // offset: 0x0
+ // symbol: init_post
+ index++;
+ while (index < output.length) {
+ String probeLine = output[index];
+ // parse probe
+ Matcher addrMatcher = PROBE_ADDRESS_PATTERN.matcher(probeLine);
+ Matcher offsetMatcher = PROBE_OFFSET_PATTERN.matcher(probeLine);
+ Matcher symbolMatcher = PROBE_SYMBOL_PATTERN.matcher(probeLine);
+ if (addrMatcher.matches()) {
+ String addr = addrMatcher.group(2).trim();
+ probeEvent.setAddress(addr);
+ } else if (offsetMatcher.matches()) {
+ String offset = offsetMatcher.group(2).trim();
+ probeEvent.setOffset(offset);
+ } else if (symbolMatcher.matches()) {
+ String symbol = symbolMatcher.group(2).trim();
+ probeEvent.setSymbol(symbol);
+ } else if ((EVENT_PATTERN.matcher(probeLine).matches()) || (WILDCARD_EVENT_PATTERN.matcher(probeLine).matches())) {
+ break;
+ } else if (CHANNEL_PATTERN.matcher(probeLine).matches()) {
+ break;
+ } else if (DOMAIN_KERNEL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ } else if (DOMAIN_UST_GLOBAL_PATTERN.matcher(probeLine).matches()) {
+ // end of domain
+ break;
+ }
+ index++;
+ }
+ events.add(eventInfo);
+ } else {
+ events.add(eventInfo);
+ index++;
+ continue;
+ }
+ } else {
+ index++;
}
// else if (line.matches(EVENT_NONE_PATTERN)) {
// do nothing
// } else
- index++;
+
}
return index;