lttng.control: Add support for enabling syscall by name
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / dialogs / EnableKernelEventComposite.java
CommitLineData
ccc66d01 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 Ericsson
cfdb727a 3 *
ccc66d01
BH
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
cfdb727a
AM
8 *
9 * Contributors:
ccc66d01 10 * Bernd Hufmann - Initial API and implementation
d4489ec9 11 * Marc-Andre Laperle - Add filtering textbox
ccc66d01 12 **********************************************************************/
9bc60be7 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
ccc66d01
BH
14
15import java.util.ArrayList;
aa2c8e1a 16import java.util.Arrays;
ccc66d01 17import java.util.List;
aa2c8e1a 18import java.util.stream.Collectors;
ccc66d01
BH
19
20import org.eclipse.jface.dialogs.MessageDialog;
21import org.eclipse.jface.viewers.CheckStateChangedEvent;
22import org.eclipse.jface.viewers.CheckboxTreeViewer;
23import org.eclipse.jface.viewers.ICheckStateListener;
d4489ec9 24import org.eclipse.jface.viewers.TreeViewer;
ccc66d01
BH
25import org.eclipse.swt.SWT;
26import org.eclipse.swt.events.SelectionAdapter;
27import org.eclipse.swt.events.SelectionEvent;
28import org.eclipse.swt.graphics.Image;
29import org.eclipse.swt.layout.GridData;
30import org.eclipse.swt.layout.GridLayout;
31import org.eclipse.swt.widgets.Button;
32import org.eclipse.swt.widgets.Composite;
33import org.eclipse.swt.widgets.Group;
34import org.eclipse.swt.widgets.Label;
35import org.eclipse.swt.widgets.Text;
1bc37054 36import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
207ff523 37import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
9bc60be7
AM
38import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
39import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
40import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.BaseEventComponent;
41import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.KernelProviderComponent;
42import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlContentProvider;
43import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlLabelProvider;
44import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
d4489ec9
MAL
45import org.eclipse.ui.dialogs.FilteredTree;
46import org.eclipse.ui.dialogs.PatternFilter;
ccc66d01
BH
47
48/**
ccc66d01
BH
49 * <p>
50 * A composite for collecting information about kernel events to be enabled.
51 * </p>
cfdb727a 52 *
dbd4432d 53 * @author Bernd Hufmann
ccc66d01
BH
54 */
55public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents {
56
57 // ------------------------------------------------------------------------
58 // Constants
59 // ------------------------------------------------------------------------
9ee91a86 60 private enum KernelGroupEnum { ALL, TRACEPOINTS, SYSCALLS, PROBE, FUNCTION }
ccc66d01
BH
61
62 // ------------------------------------------------------------------------
63 // Attributes
64 // ------------------------------------------------------------------------
65
9ee91a86
BH
66 /**
67 * A button to enable/disable the all tracepoints&sycalls group
68 */
69 private Button fAllActivateButton;
ccc66d01
BH
70 /**
71 * A button to enable/disable the tracepoints group
72 */
73 private Button fTracepointsActivateButton;
74 /**
75 * A tree viewer for displaying and selection of available tracepoints.
76 */
77 private CheckboxTreeViewer fTracepointsViewer;
207ff523
BR
78 /**
79 * A tree viewer for displaying and selection of available syscalls.
80 */
81 private CheckboxTreeViewer fSyscallsViewer;
ccc66d01
BH
82 /**
83 * A button to enable/disable the syscalls group
84 */
207ff523 85 private Button fSyscallsActivateButton;
aa2c8e1a
BR
86 /**
87 * A Text field for the specific event name.
88 */
89 private Text fSpecificEventText;
ccc66d01
BH
90 /**
91 * A button to enable or disable the dynamic probe group.
92 */
93 private Button fProbeActivateButton;
94 /**
cfdb727a 95 * The text field for the event name for the dynamic probe.
ccc66d01
BH
96 */
97 private Text fProbeEventNameText;
98 /**
99 * The text field for the dynamic probe.
100 */
101 private Text fProbeText;
102 /**
103 * A button to enable or disable the dynamic function probe group.
104 */
105 private Button fFunctionActivateButton;
106 /**
cfdb727a 107 * The text field for the event name for the dynamic probe.
ccc66d01
BH
108 */
109 private Text fFunctionEventNameText;
110 /**
111 * The text field for the dynamic function entry/return probe.
112 */
113 private Text fFunctionText;
f0584d20
BH
114 /**
115 * The filter text
116 */
117 private Text fFilterText;
ccc66d01 118 /**
cfdb727a 119 * The referenced trace provider group containing the kernel provider
ccc66d01
BH
120 * component which contains a list of available tracepoints.
121 */
cfdb727a 122 private final TraceProviderGroup fProviderGroup;
9ee91a86
BH
123 /**
124 * The flag indicating that all tracepoints/syscalls are selected.
125 */
126 private boolean fIsAllTracepointsAndSyscalls;
ccc66d01
BH
127 /**
128 * The flag indicating that tracepoints are selected.
129 */
130 private boolean fIsTracepoints;
131 /**
132 * The flag indicating that all tracepoints are selected.
133 */
134 private boolean fIsAllTracepoints;
135 /**
136 * The flag indicating that syscalls are selected.
137 */
207ff523
BR
138 private boolean fIsSyscalls;
139 /**
140 * The flag indicating that all syscalls are selected.
141 */
142 private boolean fIsAllSyscalls;
ccc66d01
BH
143 /**
144 * The list of tracepoints to be enabled.
145 */
146 private List<String> fSelectedEvents;
147 /**
148 * The flag indicating that dynamic probe is selected.
149 */
150 private boolean fIsDynamicProbe;
151 /**
cfdb727a 152 * The event name of the dynamic probe.
ccc66d01
BH
153 */
154 private String fProbeEventName;
155 /**
156 * The dynamic probe.
157 */
158 private String fProbeString;
159 /**
160 * The flag indicating that the dynamic function probe is selected.
161 */
162 private boolean fIsDynamicFunctionProbe;
163 /**
164 * The event name of the dynamic function entry/return probe.
165 */
166 private String fFunctionEventName;
167 /**
168 * The dynamic function entry/return probe.
169 */
170 private String fFunctionString;
f0584d20
BH
171 /**
172 * The filter expression
173 */
174 private String fFilterExpression;
ccc66d01
BH
175
176 // ------------------------------------------------------------------------
177 // Constructors
178 // ------------------------------------------------------------------------
179
cfdb727a
AM
180 /**
181 * Constructor
182 *
183 * @param parent
184 * The parent composite
185 * @param style
186 * The index of the style for this event composite
187 * @param providerGroup
188 * The trace provider group
189 */
ccc66d01
BH
190 public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
191 super(parent, style);
192 fProviderGroup = providerGroup;
193 }
194
195 // ------------------------------------------------------------------------
196 // Acessors
197 // ------------------------------------------------------------------------
9ee91a86
BH
198 @Override
199 public boolean isAllEvents() {
200 return fIsAllTracepointsAndSyscalls;
201 }
ccc66d01
BH
202 @Override
203 public boolean isTracepoints() {
204 return fIsTracepoints;
205 }
cfdb727a 206
ccc66d01
BH
207 @Override
208 public boolean isAllTracePoints() {
209 return fIsAllTracepoints;
210 }
cfdb727a 211
ccc66d01 212 @Override
207ff523
BR
213 public boolean isSyscalls() {
214 return fIsSyscalls;
ccc66d01 215 }
cfdb727a 216
ccc66d01 217 @Override
207ff523
BR
218 public boolean isAllSyscalls() {
219 return fIsAllSyscalls;
ccc66d01 220 }
cfdb727a 221
ccc66d01
BH
222 @Override
223 public List<String> getEventNames() {
e0838ca1 224 return new ArrayList<>(fSelectedEvents);
ccc66d01 225 }
11252342 226
ccc66d01
BH
227 @Override
228 public boolean isDynamicProbe() {
229 return fIsDynamicProbe;
230 }
cfdb727a 231
ccc66d01
BH
232 @Override
233 public String getProbeName() {
234 return fProbeString;
235 }
cfdb727a 236
ccc66d01
BH
237 @Override
238 public String getProbeEventName() {
239 return fProbeEventName;
240 }
cfdb727a 241
ccc66d01
BH
242 @Override
243 public boolean isDynamicFunctionProbe() {
244 return fIsDynamicFunctionProbe;
245 }
cfdb727a 246
ccc66d01
BH
247 @Override
248 public String getFunctionEventName() {
249 return fFunctionEventName;
250 }
cfdb727a 251
ccc66d01
BH
252 @Override
253 public String getFunction() {
254 return fFunctionString;
255 }
256
f0584d20
BH
257 @Override
258 public String getFilterExpression() {
259 return fFilterExpression;
260 }
261
ccc66d01
BH
262 // ------------------------------------------------------------------------
263 // Operations
264 // ------------------------------------------------------------------------
11252342 265
ccc66d01
BH
266 /**
267 * Creates the composite content
268 */
269 public void createContent() {
cfdb727a 270
9ee91a86
BH
271 // All Tracepoints/syscalls Group
272 createAllTracepointsSyscallGroup();
273
cfdb727a 274 // Tracepoints Group
ccc66d01
BH
275 createTracepointsGroup();
276
cfdb727a 277 // Syscalls Group
207ff523 278 createSyscallsGroup();
cfdb727a
AM
279
280 // Dynamic Probe Group
ccc66d01
BH
281 createDynamicProbeGroup();
282
cfdb727a 283 // Dynamic Function Probe Group
ccc66d01 284 createDynamicFunctionPropeGroup();
cfdb727a 285
f0584d20
BH
286 // Filter Group
287 createFilterGroup();
288
ccc66d01 289 // Set default enablements
9ee91a86 290 setKernelEnablements(KernelGroupEnum.ALL);
ccc66d01 291 }
cfdb727a 292
ccc66d01
BH
293 /**
294 * Validates the kernel composite input data.
295 * @return true if configured data is valid and can be retrieved.
296 */
297 public boolean isValid() {
9ee91a86 298 fIsAllTracepointsAndSyscalls = fAllActivateButton.getSelection();
ccc66d01 299 fIsTracepoints = fTracepointsActivateButton.getSelection();
207ff523 300 fIsSyscalls = fSyscallsActivateButton.getSelection();
ccc66d01
BH
301 fIsDynamicProbe = fProbeActivateButton.getSelection();
302 fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection();
303
5f1f22f8
BH
304 // initialize tracepoint fields
305 fIsAllTracepoints = false;
e0838ca1 306 fSelectedEvents = new ArrayList<>();
5f1f22f8
BH
307
308 if (fIsTracepoints) {
5f1f22f8
BH
309 Object[] checkedElements = fTracepointsViewer.getCheckedElements();
310 for (int i = 0; i < checkedElements.length; i++) {
311 ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
312 if (component instanceof BaseEventComponent) {
313 fSelectedEvents.add(component.getName());
314 }
ccc66d01 315 }
579acd01
BH
316 // verify if all events are selected
317 int nbEvents = 0;
318 List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
319 for (ITraceControlComponent comp : comps) {
207ff523
BR
320 for (ITraceControlComponent event : comp.getChildren()) {
321 if (event instanceof BaseEventComponent && ((BaseEventComponent) event).getEventType() == TraceEventType.TRACEPOINT) {
322 nbEvents++;
323 }
324 }
579acd01
BH
325 }
326 fIsAllTracepoints = (nbEvents == fSelectedEvents.size());
aa2c8e1a
BR
327 String tmpSpecificEvent = fSpecificEventText.getText();
328 if (!fIsAllTracepoints && !tmpSpecificEvent.trim().isEmpty()) {
329 // Format the text to a List<String>
330 // Removing all non visible characters
331 tmpSpecificEvent = tmpSpecificEvent.replaceAll("\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$
332 // Splitting the different events that are separated by commas
333 List<String> list = Arrays.asList(tmpSpecificEvent.split(",")); //$NON-NLS-1$
334 fSelectedEvents.addAll(list);
335 fSelectedEvents = fSelectedEvents.stream().distinct().collect(Collectors.toList());
336 }
ccc66d01 337 }
5f1f22f8 338
207ff523
BR
339 fIsAllSyscalls = false;
340
341 if (fIsSyscalls) {
342 if (fSyscallsViewer != null) {
343 Object[] checkedElements = fSyscallsViewer.getCheckedElements();
344 for (int i = 0; i < checkedElements.length; i++) {
345 ITraceControlComponent component = (ITraceControlComponent)checkedElements[i];
346 if (component instanceof BaseEventComponent) {
347 fSelectedEvents.add(component.getName());
348 }
349 }
350 // verify if all events are selected
351 int nbSyscalls = 0;
352 List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
353 for (ITraceControlComponent comp : comps) {
354 for (ITraceControlComponent syscall : comp.getChildren()) {
355 if (syscall instanceof BaseEventComponent && ((BaseEventComponent) syscall).getEventType() == TraceEventType.SYSCALL) {
356 nbSyscalls++;
357 }
358 }
359 }
360 fIsAllSyscalls = (nbSyscalls == fSelectedEvents.size());
361 if (!fIsAllSyscalls) {
362 fSelectedEvents = fSelectedEvents.stream().distinct().collect(Collectors.toList());
363 }
364 } else {
365 // for version < LTTng 2.6.0 only all syscalls could be enabled
366 fIsAllSyscalls = true;
367 }
368 }
369
5f1f22f8
BH
370 if (fIsDynamicProbe) {
371 String temp = fProbeEventNameText.getText();
4bd5ece2 372 if (temp.trim().isEmpty() ||
c371fa43 373 (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
5f1f22f8
BH
374 MessageDialog.openError(getShell(),
375 Messages.TraceControl_EnableEventsDialogTitle,
376 Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
377
378 return false;
379 }
380
c371fa43
BH
381 fProbeEventName = temp;
382 // fProbeString will be validated by lttng-tools
383 fProbeString = fProbeText.getText();
ccc66d01 384 }
ccc66d01
BH
385
386 // initialize function string
387 fFunctionEventName = null;
388 fFunctionString = null;
5f1f22f8
BH
389 if (fIsDynamicFunctionProbe) {
390 String functionTemp = fFunctionEventNameText.getText();
4bd5ece2 391 if (functionTemp.trim().isEmpty() ||
c371fa43 392 (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
5f1f22f8
BH
393 MessageDialog.openError(getShell(),
394 Messages.TraceControl_EnableEventsDialogTitle,
395 Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
ccc66d01 396
5f1f22f8
BH
397 return false;
398 }
ccc66d01 399
c371fa43
BH
400 fFunctionEventName = functionTemp;
401 // fFunctionString will be validated by lttng-tools
402 fFunctionString = fFunctionText.getText();
ccc66d01
BH
403 }
404
f0584d20
BH
405 // initialize filter with null
406 fFilterExpression = null;
1bc37054 407 if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) {
f0584d20
BH
408 String tempFilter = fFilterText.getText();
409
4bd5ece2 410 if(!tempFilter.trim().isEmpty()) {
f0584d20
BH
411 fFilterExpression = tempFilter;
412 }
413 }
414
ccc66d01
BH
415 return true;
416 }
cfdb727a 417
9ee91a86
BH
418 /**
419 * Creates all tracepoints/syscalls group.
420 */
421 private void createAllTracepointsSyscallGroup() {
9ee91a86
BH
422 GridLayout layout;
423 GridData data;
424 Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
425 tpMainGroup.setText(Messages.TraceControl_EnableEventsAllEventsLabel);
426 layout = new GridLayout(2, false);
427 tpMainGroup.setLayout(layout);
428 data = new GridData(GridData.FILL_HORIZONTAL);
429 tpMainGroup.setLayoutData(data);
430
431 Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
432 layout = new GridLayout(1, true);
433 buttonComposite.setLayout(layout);
434 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
435 buttonComposite.setLayoutData(data);
436
437 fAllActivateButton = new Button(buttonComposite, SWT.RADIO);
438 fAllActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
439 fAllActivateButton.setToolTipText(Messages.TraceControl_EnableEventsAllEventsTooltip);
440 data = new GridData(GridData.FILL_HORIZONTAL);
441 fAllActivateButton.setLayoutData(data);
442 fAllActivateButton.addSelectionListener(new SelectionAdapter() {
443 @Override
444 public void widgetSelected(SelectionEvent e) {
445 setKernelEnablements(KernelGroupEnum.ALL);
446 }
447 });
448 }
449
ccc66d01
BH
450 /**
451 * Creates tracepoints group.
452 */
453 private void createTracepointsGroup() {
ccc66d01
BH
454 GridLayout layout;
455 GridData data;
456 Group tpMainGroup = new Group(this, SWT.SHADOW_NONE);
457 tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName);
458 layout = new GridLayout(2, false);
459 tpMainGroup.setLayout(layout);
460 data = new GridData(GridData.FILL_BOTH);
461 tpMainGroup.setLayoutData(data);
462
463 Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE);
464 layout = new GridLayout(1, true);
465 buttonComposite.setLayout(layout);
466 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
467 buttonComposite.setLayoutData(data);
468
469 fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO);
470 fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
471 data = new GridData(GridData.FILL_HORIZONTAL);
472 fTracepointsActivateButton.setLayoutData(data);
473 fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() {
474 @Override
475 public void widgetSelected(SelectionEvent e) {
476 setKernelEnablements(KernelGroupEnum.TRACEPOINTS);
477 }
478 });
479
480 Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE);
481 layout = new GridLayout(1, true);
482 tracepointsGroup.setLayout(layout);
483 data = new GridData(GridData.FILL_BOTH);
484 tracepointsGroup.setLayoutData(data);
485
d4489ec9
MAL
486 new FilteredTree(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) {
487 @Override
488 protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
489 fTracepointsViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
490 fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip);
ccc66d01 491
207ff523 492 fTracepointsViewer.setContentProvider(new KernelContentProvider(TraceEventType.TRACEPOINT));
d4489ec9 493 fTracepointsViewer.setLabelProvider(new KernelLabelProvider());
207ff523 494 fTracepointsViewer.addCheckStateListener(new KernelCheckListener(fTracepointsViewer));
d4489ec9 495 fTracepointsViewer.setInput(fProviderGroup);
ccc66d01 496
d4489ec9
MAL
497 fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
498 return fTracepointsViewer;
499 }
ad9972cc
PJPG
500
501 @Override
502 protected void updateToolbar(boolean visible) {
503 super.updateToolbar(visible);
504 treeViewer.expandAll();
505 }
d4489ec9 506 };
aa2c8e1a
BR
507
508 Group specificEventGroup = new Group(tracepointsGroup, SWT.SHADOW_NONE);
509 specificEventGroup.setText(Messages.TraceControl_EnableEventsSpecificEventGroupName);
510 layout = new GridLayout(4, true);
511 specificEventGroup.setLayout(layout);
512 specificEventGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
513
514 Label specificEventLabel = new Label(specificEventGroup, SWT.LEFT);
e010f47b 515 specificEventLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
aa2c8e1a
BR
516 data = new GridData(GridData.FILL_HORIZONTAL);
517 data.horizontalSpan = 1;
518 specificEventLabel.setLayoutData(data);
519
520 fSpecificEventText = new Text(specificEventGroup, SWT.LEFT);
521 fSpecificEventText.setToolTipText(Messages.TraceControl_EnableEventsSpecificEventTooltip);
522 data = new GridData(GridData.FILL_HORIZONTAL);
523 data.horizontalSpan = 3;
524 fSpecificEventText.setLayoutData(data);
ccc66d01
BH
525 }
526
527 /**
528 * Creates syscalls group.
529 */
207ff523 530 private void createSyscallsGroup() {
ccc66d01
BH
531 GridLayout layout;
532 GridData data;
207ff523
BR
533 Group syscallMainGroup = new Group(this, SWT.SHADOW_NONE);
534 syscallMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName);
ccc66d01 535 layout = new GridLayout(2, false);
207ff523
BR
536 syscallMainGroup.setLayout(layout);
537 data = new GridData(GridData.FILL_BOTH);
538 syscallMainGroup.setLayoutData(data);
ccc66d01 539
207ff523
BR
540 Composite buttonComposite = new Composite(syscallMainGroup, SWT.NONE);
541 layout = new GridLayout(1, true);
ccc66d01
BH
542 buttonComposite.setLayout(layout);
543 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
544 buttonComposite.setLayoutData(data);
545
207ff523
BR
546 fSyscallsActivateButton = new Button(buttonComposite, SWT.RADIO);
547 fSyscallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
548 fSyscallsActivateButton.setSelection(false);
ccc66d01 549 data = new GridData(GridData.FILL_HORIZONTAL);
207ff523
BR
550 fSyscallsActivateButton.setLayoutData(data);
551 fSyscallsActivateButton.addSelectionListener(new SelectionAdapter() {
ccc66d01
BH
552 @Override
553 public void widgetSelected(SelectionEvent e) {
554 setKernelEnablements(KernelGroupEnum.SYSCALLS);
555 }
556 });
207ff523
BR
557
558 if (fProviderGroup.isPerSyscallEventsSupported()) {
559 Group syscallGroup = new Group(syscallMainGroup, SWT.SHADOW_NONE);
560 layout = new GridLayout(1, true);
561 syscallGroup.setLayout(layout);
562 data = new GridData(GridData.FILL_BOTH);
563 syscallGroup.setLayoutData(data);
564
565 new FilteredTree(syscallGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) {
566 @Override
567 protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
568 fSyscallsViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
569 fSyscallsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip);
570
571 fSyscallsViewer.setContentProvider(new KernelContentProvider(TraceEventType.SYSCALL));
572 fSyscallsViewer.setLabelProvider(new KernelLabelProvider());
573 fSyscallsViewer.addCheckStateListener(new KernelCheckListener(fSyscallsViewer));
574 fSyscallsViewer.setInput(fProviderGroup);
575
576 fSyscallsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
577
578 return fSyscallsViewer;
579 }
580
581 @Override
582 protected void updateToolbar(boolean visible) {
583 super.updateToolbar(visible);
584 treeViewer.expandAll();
585 }
586 };
587 }
ccc66d01
BH
588 }
589
590 /**
591 * Creates dynamic probe group.
592 */
593 private void createDynamicProbeGroup() {
594 GridLayout layout;
595 GridData data;
596 Group probeMainGroup = new Group(this, SWT.SHADOW_NONE);
597 probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName);
598 layout = new GridLayout(2, false);
599 probeMainGroup.setLayout(layout);
600 data = new GridData(GridData.FILL_HORIZONTAL);
601 probeMainGroup.setLayoutData(data);
602
603 Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE);
604 layout = new GridLayout(1, false);
605 buttonComposite.setLayout(layout);
606 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
607 buttonComposite.setLayoutData(data);
608
609 fProbeActivateButton = new Button(buttonComposite, SWT.RADIO);
610 fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
611 fProbeActivateButton.setSelection(false);
612 data = new GridData(GridData.FILL_HORIZONTAL);
613 fProbeActivateButton.setLayoutData(data);
614 fProbeActivateButton.addSelectionListener(new SelectionAdapter() {
615 @Override
616 public void widgetSelected(SelectionEvent e) {
617 setKernelEnablements(KernelGroupEnum.PROBE);
618 }
619 });
620
621 Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE);
622 layout = new GridLayout(4, true);
623 probeGroup.setLayout(layout);
624 probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
625
626 Label probeNameLabel = new Label(probeGroup, SWT.LEFT);
627 probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
628 data = new GridData(GridData.FILL_BOTH);
629 data.horizontalSpan = 1;
630 probeNameLabel.setLayoutData(data);
631
632 fProbeEventNameText = new Text(probeGroup, SWT.LEFT);
633 fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip);
634
635 data = new GridData(GridData.FILL_BOTH);
636 data.horizontalSpan = 3;
637 fProbeEventNameText.setLayoutData(data);
638
639 Label probeLabel = new Label(probeGroup, SWT.LEFT);
640 probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel);
641 data = new GridData(GridData.FILL_BOTH);
642 data.horizontalSpan = 1;
643 probeLabel.setLayoutData(data);
644
645 fProbeText = new Text(probeGroup, SWT.LEFT);
646 fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
647 data = new GridData(GridData.FILL_BOTH);
648 data.horizontalSpan = 3;
649 fProbeText.setLayoutData(data);
650 }
651
652 /**
653 * Creates dynamic function entry/return probe group.
654 */
655 private void createDynamicFunctionPropeGroup() {
656 GridLayout layout;
657 GridData data;
658 Group functionMainGroup = new Group(this, SWT.SHADOW_NONE);
659 functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName);
660 layout = new GridLayout(2, false);
661 functionMainGroup.setLayout(layout);
662 data = new GridData(GridData.FILL_HORIZONTAL);
663 functionMainGroup.setLayoutData(data);
664
665 Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE);
666 layout = new GridLayout(1, false);
667 buttonComposite.setLayout(layout);
668 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
669 buttonComposite.setLayoutData(data);
670
671 fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO);
672 fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
673 fFunctionActivateButton.setSelection(false);
674 data = new GridData(GridData.FILL_HORIZONTAL);
675 fFunctionActivateButton.setLayoutData(data);
676 fFunctionActivateButton.addSelectionListener(new SelectionAdapter() {
677 @Override
678 public void widgetSelected(SelectionEvent e) {
679 setKernelEnablements(KernelGroupEnum.FUNCTION);
680 }
681 });
682
683 Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE);
684 layout = new GridLayout(4, true);
685 functionGroup.setLayout(layout);
686 functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
687
688 Label functionNameLabel = new Label(functionGroup, SWT.LEFT);
689 functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
690 data = new GridData(GridData.FILL_BOTH);
691 data.horizontalSpan = 1;
692 functionNameLabel.setLayoutData(data);
693
694 fFunctionEventNameText = new Text(functionGroup, SWT.LEFT);
695 fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip);
696 data = new GridData(GridData.FILL_BOTH);
697 data.horizontalSpan = 3;
698 fFunctionEventNameText.setLayoutData(data);
699
700 Label functionLabel = new Label(functionGroup, SWT.LEFT);
701 functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel);
702 data = new GridData(GridData.FILL_BOTH);
703 data.horizontalSpan = 1;
704 functionLabel.setLayoutData(data);
705
706 fFunctionText = new Text(functionGroup, SWT.LEFT);
707 fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip);
708 data = new GridData(GridData.FILL_BOTH);
709 data.horizontalSpan = 3;
710 fFunctionText.setLayoutData(data);
711 }
712
713 /**
714 * Enable/selects widgets depending on the group specified.
715 * @param group - group to enable.
716 */
717 private void setKernelEnablements(KernelGroupEnum group) {
9ee91a86 718 fAllActivateButton.setSelection(group == KernelGroupEnum.ALL);
ccc66d01
BH
719 fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS);
720 fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS);
aa2c8e1a 721 fSpecificEventText.setEnabled(group == KernelGroupEnum.TRACEPOINTS);
ccc66d01 722
207ff523
BR
723 fSyscallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS);
724 if (fProviderGroup.isPerSyscallEventsSupported()) {
725 fSyscallsViewer.getTree().setEnabled(group == KernelGroupEnum.SYSCALLS);
726 }
ccc66d01
BH
727
728 fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE);
729 fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE);
730 fProbeText.setEnabled(group == KernelGroupEnum.PROBE);
731
732 fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION);
733 fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION);
734 fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION);
735 }
736
f0584d20 737 private void createFilterGroup() {
1bc37054 738 if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) {
f0584d20
BH
739 Group filterMainGroup = new Group(this, SWT.SHADOW_NONE);
740 filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName);
741 GridLayout layout = new GridLayout(3, false);
742 filterMainGroup.setLayout(layout);
743 GridData data = new GridData(GridData.FILL_HORIZONTAL);
744 filterMainGroup.setLayoutData(data);
745
746 fFilterText = new Text(filterMainGroup, SWT.LEFT);
747 fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip);
748 data = new GridData(GridData.FILL_HORIZONTAL);
749 fFilterText.setLayoutData(data);
750 }
751 }
752
ccc66d01
BH
753 // ------------------------------------------------------------------------
754 // Local classes
755 // ------------------------------------------------------------------------
756 /**
207ff523 757 * Content provider for the tracepoints and syscalls tree.
ccc66d01 758 */
77735e82 759 public static final class KernelContentProvider extends TraceControlContentProvider {
207ff523
BR
760 /**
761 * The type of event ({@link TraceEventType})
762 */
763 private final TraceEventType fEventType;
764
765 /**
766 * Constructor
767 *
768 * @param eventType
769 * the type of event ({@link TraceEventType})
770 */
771 public KernelContentProvider(TraceEventType eventType) {
772 fEventType = eventType;
773 }
774
ccc66d01
BH
775 @Override
776 public Object[] getChildren(Object parentElement) {
777 if (parentElement instanceof TraceProviderGroup) {
778 List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class);
cfdb727a 779 return children.toArray(new ITraceControlComponent[children.size()]);
ccc66d01
BH
780 }
781 if (parentElement instanceof ITraceControlComponent) {
207ff523
BR
782 List<ITraceControlComponent> events = new ArrayList<>();
783 for (ITraceControlComponent event : ((ITraceControlComponent)parentElement).getChildren()) {
784 if (event instanceof BaseEventComponent && ((BaseEventComponent) event).getEventType() == fEventType) {
785 events.add(event);
786 }
787 }
788 return events.toArray(new ITraceControlComponent[events.size()]);
ccc66d01
BH
789 }
790 return new Object[0];
791 }
792 }
cfdb727a 793
ccc66d01 794 /**
207ff523 795 * Content label for the tracepoints and syscalls tree.
ccc66d01 796 */
77735e82 797 public static final class KernelLabelProvider extends TraceControlLabelProvider {
ccc66d01
BH
798 @Override
799 public Image getImage(Object element) {
800 return null;
801 }
207ff523 802
ccc66d01
BH
803 @Override
804 public String getText(Object element) {
805 if ((element != null) && (element instanceof KernelProviderComponent)) {
207ff523 806 return Messages.TraceControl_EnableEventsTreeAllLabel;
ccc66d01
BH
807 }
808 return super.getText(element);
809 }
810 }
cfdb727a 811
ccc66d01 812 /**
207ff523 813 * Check state listener for the tracepoints and syscalls tree.
ccc66d01 814 */
77735e82 815 public final class KernelCheckListener implements ICheckStateListener {
207ff523
BR
816 /**
817 * The check box tree viewer.
818 */
819 private final CheckboxTreeViewer fCheckBoxTreeViewer;
820
821 /**
822 * Constructor
823 *
824 * @param checkBoxTreeViewer
825 * the check box tree viewer.
826 */
827 public KernelCheckListener(CheckboxTreeViewer checkBoxTreeViewer) {
828 fCheckBoxTreeViewer = checkBoxTreeViewer;
829 }
830
ccc66d01
BH
831 @Override
832 public void checkStateChanged(CheckStateChangedEvent event) {
833 if (event.getChecked()) {
834 if (event.getElement() instanceof KernelProviderComponent) {
207ff523 835 fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), true);
cfdb727a
AM
836 }
837 } else {
ccc66d01 838 if (event.getElement() instanceof KernelProviderComponent) {
207ff523 839 fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), false);
ccc66d01
BH
840 } else {
841 ITraceControlComponent component = (ITraceControlComponent) event.getElement();
207ff523 842 fCheckBoxTreeViewer.setChecked(component.getParent(), false);
ccc66d01
BH
843 }
844 }
845 }
846 }
847}
This page took 0.150912 seconds and 5 git commands to generate.