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
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 * Marc-Andre Laperle - Add filtering textbox
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
14
15 import java.util.ArrayList;
16 import java.util.Arrays;
17 import java.util.List;
18 import java.util.stream.Collectors;
19
20 import org.eclipse.jface.dialogs.MessageDialog;
21 import org.eclipse.jface.viewers.CheckStateChangedEvent;
22 import org.eclipse.jface.viewers.CheckboxTreeViewer;
23 import org.eclipse.jface.viewers.ICheckStateListener;
24 import org.eclipse.jface.viewers.TreeViewer;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.events.SelectionAdapter;
27 import org.eclipse.swt.events.SelectionEvent;
28 import org.eclipse.swt.graphics.Image;
29 import org.eclipse.swt.layout.GridData;
30 import org.eclipse.swt.layout.GridLayout;
31 import org.eclipse.swt.widgets.Button;
32 import org.eclipse.swt.widgets.Composite;
33 import org.eclipse.swt.widgets.Group;
34 import org.eclipse.swt.widgets.Label;
35 import org.eclipse.swt.widgets.Text;
36 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
37 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
38 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
39 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
40 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.BaseEventComponent;
41 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.KernelProviderComponent;
42 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlContentProvider;
43 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlLabelProvider;
44 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
45 import org.eclipse.ui.dialogs.FilteredTree;
46 import org.eclipse.ui.dialogs.PatternFilter;
47
48 /**
49 * <p>
50 * A composite for collecting information about kernel events to be enabled.
51 * </p>
52 *
53 * @author Bernd Hufmann
54 */
55 public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents {
56
57 // ------------------------------------------------------------------------
58 // Constants
59 // ------------------------------------------------------------------------
60 private enum KernelGroupEnum { ALL, TRACEPOINTS, SYSCALLS, PROBE, FUNCTION }
61
62 // ------------------------------------------------------------------------
63 // Attributes
64 // ------------------------------------------------------------------------
65
66 /**
67 * A button to enable/disable the all tracepoints&sycalls group
68 */
69 private Button fAllActivateButton;
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;
78 /**
79 * A tree viewer for displaying and selection of available syscalls.
80 */
81 private CheckboxTreeViewer fSyscallsViewer;
82 /**
83 * A button to enable/disable the syscalls group
84 */
85 private Button fSyscallsActivateButton;
86 /**
87 * A Text field for the specific event name.
88 */
89 private Text fSpecificEventText;
90 /**
91 * A button to enable or disable the dynamic probe group.
92 */
93 private Button fProbeActivateButton;
94 /**
95 * The text field for the event name for the dynamic probe.
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 /**
107 * The text field for the event name for the dynamic probe.
108 */
109 private Text fFunctionEventNameText;
110 /**
111 * The text field for the dynamic function entry/return probe.
112 */
113 private Text fFunctionText;
114 /**
115 * The filter text
116 */
117 private Text fFilterText;
118 /**
119 * The referenced trace provider group containing the kernel provider
120 * component which contains a list of available tracepoints.
121 */
122 private final TraceProviderGroup fProviderGroup;
123 /**
124 * The flag indicating that all tracepoints/syscalls are selected.
125 */
126 private boolean fIsAllTracepointsAndSyscalls;
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 */
138 private boolean fIsSyscalls;
139 /**
140 * The flag indicating that all syscalls are selected.
141 */
142 private boolean fIsAllSyscalls;
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 /**
152 * The event name of the dynamic probe.
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;
171 /**
172 * The filter expression
173 */
174 private String fFilterExpression;
175
176 // ------------------------------------------------------------------------
177 // Constructors
178 // ------------------------------------------------------------------------
179
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 */
190 public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) {
191 super(parent, style);
192 fProviderGroup = providerGroup;
193 }
194
195 // ------------------------------------------------------------------------
196 // Acessors
197 // ------------------------------------------------------------------------
198 @Override
199 public boolean isAllEvents() {
200 return fIsAllTracepointsAndSyscalls;
201 }
202 @Override
203 public boolean isTracepoints() {
204 return fIsTracepoints;
205 }
206
207 @Override
208 public boolean isAllTracePoints() {
209 return fIsAllTracepoints;
210 }
211
212 @Override
213 public boolean isSyscalls() {
214 return fIsSyscalls;
215 }
216
217 @Override
218 public boolean isAllSyscalls() {
219 return fIsAllSyscalls;
220 }
221
222 @Override
223 public List<String> getEventNames() {
224 return new ArrayList<>(fSelectedEvents);
225 }
226
227 @Override
228 public boolean isDynamicProbe() {
229 return fIsDynamicProbe;
230 }
231
232 @Override
233 public String getProbeName() {
234 return fProbeString;
235 }
236
237 @Override
238 public String getProbeEventName() {
239 return fProbeEventName;
240 }
241
242 @Override
243 public boolean isDynamicFunctionProbe() {
244 return fIsDynamicFunctionProbe;
245 }
246
247 @Override
248 public String getFunctionEventName() {
249 return fFunctionEventName;
250 }
251
252 @Override
253 public String getFunction() {
254 return fFunctionString;
255 }
256
257 @Override
258 public String getFilterExpression() {
259 return fFilterExpression;
260 }
261
262 // ------------------------------------------------------------------------
263 // Operations
264 // ------------------------------------------------------------------------
265
266 /**
267 * Creates the composite content
268 */
269 public void createContent() {
270
271 // All Tracepoints/syscalls Group
272 createAllTracepointsSyscallGroup();
273
274 // Tracepoints Group
275 createTracepointsGroup();
276
277 // Syscalls Group
278 createSyscallsGroup();
279
280 // Dynamic Probe Group
281 createDynamicProbeGroup();
282
283 // Dynamic Function Probe Group
284 createDynamicFunctionPropeGroup();
285
286 // Filter Group
287 createFilterGroup();
288
289 // Set default enablements
290 setKernelEnablements(KernelGroupEnum.ALL);
291 }
292
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() {
298 fIsAllTracepointsAndSyscalls = fAllActivateButton.getSelection();
299 fIsTracepoints = fTracepointsActivateButton.getSelection();
300 fIsSyscalls = fSyscallsActivateButton.getSelection();
301 fIsDynamicProbe = fProbeActivateButton.getSelection();
302 fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection();
303
304 // initialize tracepoint fields
305 fIsAllTracepoints = false;
306 fSelectedEvents = new ArrayList<>();
307
308 if (fIsTracepoints) {
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 }
315 }
316 // verify if all events are selected
317 int nbEvents = 0;
318 List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class);
319 for (ITraceControlComponent comp : comps) {
320 for (ITraceControlComponent event : comp.getChildren()) {
321 if (event instanceof BaseEventComponent && ((BaseEventComponent) event).getEventType() == TraceEventType.TRACEPOINT) {
322 nbEvents++;
323 }
324 }
325 }
326 fIsAllTracepoints = (nbEvents == fSelectedEvents.size());
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 }
337 }
338
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
370 if (fIsDynamicProbe) {
371 String temp = fProbeEventNameText.getText();
372 if (temp.trim().isEmpty() ||
373 (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
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
381 fProbeEventName = temp;
382 // fProbeString will be validated by lttng-tools
383 fProbeString = fProbeText.getText();
384 }
385
386 // initialize function string
387 fFunctionEventName = null;
388 fFunctionString = null;
389 if (fIsDynamicFunctionProbe) {
390 String functionTemp = fFunctionEventNameText.getText();
391 if (functionTemp.trim().isEmpty() ||
392 (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$
393 MessageDialog.openError(getShell(),
394 Messages.TraceControl_EnableEventsDialogTitle,
395 Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
396
397 return false;
398 }
399
400 fFunctionEventName = functionTemp;
401 // fFunctionString will be validated by lttng-tools
402 fFunctionString = fFunctionText.getText();
403 }
404
405 // initialize filter with null
406 fFilterExpression = null;
407 if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) {
408 String tempFilter = fFilterText.getText();
409
410 if(!tempFilter.trim().isEmpty()) {
411 fFilterExpression = tempFilter;
412 }
413 }
414
415 return true;
416 }
417
418 /**
419 * Creates all tracepoints/syscalls group.
420 */
421 private void createAllTracepointsSyscallGroup() {
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
450 /**
451 * Creates tracepoints group.
452 */
453 private void createTracepointsGroup() {
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
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);
491
492 fTracepointsViewer.setContentProvider(new KernelContentProvider(TraceEventType.TRACEPOINT));
493 fTracepointsViewer.setLabelProvider(new KernelLabelProvider());
494 fTracepointsViewer.addCheckStateListener(new KernelCheckListener(fTracepointsViewer));
495 fTracepointsViewer.setInput(fProviderGroup);
496
497 fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
498 return fTracepointsViewer;
499 }
500
501 @Override
502 protected void updateToolbar(boolean visible) {
503 super.updateToolbar(visible);
504 treeViewer.expandAll();
505 }
506 };
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);
515 specificEventLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel);
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);
525 }
526
527 /**
528 * Creates syscalls group.
529 */
530 private void createSyscallsGroup() {
531 GridLayout layout;
532 GridData data;
533 Group syscallMainGroup = new Group(this, SWT.SHADOW_NONE);
534 syscallMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName);
535 layout = new GridLayout(2, false);
536 syscallMainGroup.setLayout(layout);
537 data = new GridData(GridData.FILL_BOTH);
538 syscallMainGroup.setLayoutData(data);
539
540 Composite buttonComposite = new Composite(syscallMainGroup, SWT.NONE);
541 layout = new GridLayout(1, true);
542 buttonComposite.setLayout(layout);
543 data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true);
544 buttonComposite.setLayoutData(data);
545
546 fSyscallsActivateButton = new Button(buttonComposite, SWT.RADIO);
547 fSyscallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName);
548 fSyscallsActivateButton.setSelection(false);
549 data = new GridData(GridData.FILL_HORIZONTAL);
550 fSyscallsActivateButton.setLayoutData(data);
551 fSyscallsActivateButton.addSelectionListener(new SelectionAdapter() {
552 @Override
553 public void widgetSelected(SelectionEvent e) {
554 setKernelEnablements(KernelGroupEnum.SYSCALLS);
555 }
556 });
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 }
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) {
718 fAllActivateButton.setSelection(group == KernelGroupEnum.ALL);
719 fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS);
720 fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS);
721 fSpecificEventText.setEnabled(group == KernelGroupEnum.TRACEPOINTS);
722
723 fSyscallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS);
724 if (fProviderGroup.isPerSyscallEventsSupported()) {
725 fSyscallsViewer.getTree().setEnabled(group == KernelGroupEnum.SYSCALLS);
726 }
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
737 private void createFilterGroup() {
738 if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) {
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
753 // ------------------------------------------------------------------------
754 // Local classes
755 // ------------------------------------------------------------------------
756 /**
757 * Content provider for the tracepoints and syscalls tree.
758 */
759 public static final class KernelContentProvider extends TraceControlContentProvider {
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
775 @Override
776 public Object[] getChildren(Object parentElement) {
777 if (parentElement instanceof TraceProviderGroup) {
778 List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class);
779 return children.toArray(new ITraceControlComponent[children.size()]);
780 }
781 if (parentElement instanceof ITraceControlComponent) {
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()]);
789 }
790 return new Object[0];
791 }
792 }
793
794 /**
795 * Content label for the tracepoints and syscalls tree.
796 */
797 public static final class KernelLabelProvider extends TraceControlLabelProvider {
798 @Override
799 public Image getImage(Object element) {
800 return null;
801 }
802
803 @Override
804 public String getText(Object element) {
805 if ((element != null) && (element instanceof KernelProviderComponent)) {
806 return Messages.TraceControl_EnableEventsTreeAllLabel;
807 }
808 return super.getText(element);
809 }
810 }
811
812 /**
813 * Check state listener for the tracepoints and syscalls tree.
814 */
815 public final class KernelCheckListener implements ICheckStateListener {
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
831 @Override
832 public void checkStateChanged(CheckStateChangedEvent event) {
833 if (event.getChecked()) {
834 if (event.getElement() instanceof KernelProviderComponent) {
835 fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), true);
836 }
837 } else {
838 if (event.getElement() instanceof KernelProviderComponent) {
839 fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), false);
840 } else {
841 ITraceControlComponent component = (ITraceControlComponent) event.getElement();
842 fCheckBoxTreeViewer.setChecked(component.getParent(), false);
843 }
844 }
845 }
846 }
847 }
This page took 0.049857 seconds and 5 git commands to generate.