1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 * Marc-Andre Laperle - Add filtering textbox
12 **********************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Arrays
;
17 import java
.util
.List
;
18 import java
.util
.stream
.Collectors
;
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
;
50 * A composite for collecting information about kernel events to be enabled.
53 * @author Bernd Hufmann
55 public class EnableKernelEventComposite
extends Composite
implements IEnableKernelEvents
{
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
60 private enum KernelGroupEnum
{ ALL
, TRACEPOINTS
, SYSCALLS
, PROBE
, FUNCTION
}
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * A button to enable/disable the all tracepoints&sycalls group
69 private Button fAllActivateButton
;
71 * A button to enable/disable the tracepoints group
73 private Button fTracepointsActivateButton
;
75 * A tree viewer for displaying and selection of available tracepoints.
77 private CheckboxTreeViewer fTracepointsViewer
;
79 * A tree viewer for displaying and selection of available syscalls.
81 private CheckboxTreeViewer fSyscallsViewer
;
83 * A button to enable/disable the syscalls group
85 private Button fSyscallsActivateButton
;
87 * A Text field for the specific event name.
89 private Text fSpecificEventText
;
91 * A button to enable or disable the dynamic probe group.
93 private Button fProbeActivateButton
;
95 * The text field for the event name for the dynamic probe.
97 private Text fProbeEventNameText
;
99 * The text field for the dynamic probe.
101 private Text fProbeText
;
103 * A button to enable or disable the dynamic function probe group.
105 private Button fFunctionActivateButton
;
107 * The text field for the event name for the dynamic probe.
109 private Text fFunctionEventNameText
;
111 * The text field for the dynamic function entry/return probe.
113 private Text fFunctionText
;
117 private Text fFilterText
;
119 * The referenced trace provider group containing the kernel provider
120 * component which contains a list of available tracepoints.
122 private final TraceProviderGroup fProviderGroup
;
124 * The flag indicating that all tracepoints/syscalls are selected.
126 private boolean fIsAllTracepointsAndSyscalls
;
128 * The flag indicating that tracepoints are selected.
130 private boolean fIsTracepoints
;
132 * The flag indicating that all tracepoints are selected.
134 private boolean fIsAllTracepoints
;
136 * The flag indicating that syscalls are selected.
138 private boolean fIsSyscalls
;
140 * The flag indicating that all syscalls are selected.
142 private boolean fIsAllSyscalls
;
144 * The list of tracepoints to be enabled.
146 private List
<String
> fSelectedEvents
;
148 * The flag indicating that dynamic probe is selected.
150 private boolean fIsDynamicProbe
;
152 * The event name of the dynamic probe.
154 private String fProbeEventName
;
158 private String fProbeString
;
160 * The flag indicating that the dynamic function probe is selected.
162 private boolean fIsDynamicFunctionProbe
;
164 * The event name of the dynamic function entry/return probe.
166 private String fFunctionEventName
;
168 * The dynamic function entry/return probe.
170 private String fFunctionString
;
172 * The filter expression
174 private String fFilterExpression
;
176 // ------------------------------------------------------------------------
178 // ------------------------------------------------------------------------
184 * The parent composite
186 * The index of the style for this event composite
187 * @param providerGroup
188 * The trace provider group
190 public EnableKernelEventComposite(Composite parent
, int style
, TraceProviderGroup providerGroup
) {
191 super(parent
, style
);
192 fProviderGroup
= providerGroup
;
195 // ------------------------------------------------------------------------
197 // ------------------------------------------------------------------------
199 public boolean isAllEvents() {
200 return fIsAllTracepointsAndSyscalls
;
203 public boolean isTracepoints() {
204 return fIsTracepoints
;
208 public boolean isAllTracePoints() {
209 return fIsAllTracepoints
;
213 public boolean isSyscalls() {
218 public boolean isAllSyscalls() {
219 return fIsAllSyscalls
;
223 public List
<String
> getEventNames() {
224 return new ArrayList
<>(fSelectedEvents
);
228 public boolean isDynamicProbe() {
229 return fIsDynamicProbe
;
233 public String
getProbeName() {
238 public String
getProbeEventName() {
239 return fProbeEventName
;
243 public boolean isDynamicFunctionProbe() {
244 return fIsDynamicFunctionProbe
;
248 public String
getFunctionEventName() {
249 return fFunctionEventName
;
253 public String
getFunction() {
254 return fFunctionString
;
258 public String
getFilterExpression() {
259 return fFilterExpression
;
262 // ------------------------------------------------------------------------
264 // ------------------------------------------------------------------------
267 * Creates the composite content
269 public void createContent() {
271 // All Tracepoints/syscalls Group
272 createAllTracepointsSyscallGroup();
275 createTracepointsGroup();
278 createSyscallsGroup();
280 // Dynamic Probe Group
281 createDynamicProbeGroup();
283 // Dynamic Function Probe Group
284 createDynamicFunctionPropeGroup();
289 // Set default enablements
290 setKernelEnablements(KernelGroupEnum
.ALL
);
294 * Validates the kernel composite input data.
295 * @return true if configured data is valid and can be retrieved.
297 public boolean isValid() {
298 fIsAllTracepointsAndSyscalls
= fAllActivateButton
.getSelection();
299 fIsTracepoints
= fTracepointsActivateButton
.getSelection();
300 fIsSyscalls
= fSyscallsActivateButton
.getSelection();
301 fIsDynamicProbe
= fProbeActivateButton
.getSelection();
302 fIsDynamicFunctionProbe
= fFunctionActivateButton
.getSelection();
304 // initialize tracepoint fields
305 fIsAllTracepoints
= false;
306 fSelectedEvents
= new ArrayList
<>();
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());
316 // verify if all events are selected
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
) {
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());
339 fIsAllSyscalls
= false;
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());
350 // verify if all events are selected
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
) {
360 fIsAllSyscalls
= (nbSyscalls
== fSelectedEvents
.size());
361 if (!fIsAllSyscalls
) {
362 fSelectedEvents
= fSelectedEvents
.stream().distinct().collect(Collectors
.toList());
365 // for version < LTTng 2.6.0 only all syscalls could be enabled
366 fIsAllSyscalls
= true;
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$
381 fProbeEventName
= temp
;
382 // fProbeString will be validated by lttng-tools
383 fProbeString
= fProbeText
.getText();
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$
400 fFunctionEventName
= functionTemp
;
401 // fFunctionString will be validated by lttng-tools
402 fFunctionString
= fFunctionText
.getText();
405 // initialize filter with null
406 fFilterExpression
= null;
407 if (fProviderGroup
.isEventFilteringSupported(TraceDomainType
.KERNEL
)) {
408 String tempFilter
= fFilterText
.getText();
410 if(!tempFilter
.trim().isEmpty()) {
411 fFilterExpression
= tempFilter
;
419 * Creates all tracepoints/syscalls group.
421 private void createAllTracepointsSyscallGroup() {
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
);
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
);
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() {
444 public void widgetSelected(SelectionEvent e
) {
445 setKernelEnablements(KernelGroupEnum
.ALL
);
451 * Creates tracepoints group.
453 private void createTracepointsGroup() {
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
);
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
);
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() {
475 public void widgetSelected(SelectionEvent e
) {
476 setKernelEnablements(KernelGroupEnum
.TRACEPOINTS
);
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
);
486 new FilteredTree(tracepointsGroup
, SWT
.MULTI
| SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.BORDER
, new PatternFilter(), true) {
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
);
492 fTracepointsViewer
.setContentProvider(new KernelContentProvider(TraceEventType
.TRACEPOINT
));
493 fTracepointsViewer
.setLabelProvider(new KernelLabelProvider());
494 fTracepointsViewer
.addCheckStateListener(new KernelCheckListener(fTracepointsViewer
));
495 fTracepointsViewer
.setInput(fProviderGroup
);
497 fTracepointsViewer
.getTree().setLayoutData(new GridData(GridData
.FILL_BOTH
));
498 return fTracepointsViewer
;
502 protected void updateToolbar(boolean visible
) {
503 super.updateToolbar(visible
);
504 treeViewer
.expandAll();
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
));
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
);
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
);
528 * Creates syscalls group.
530 private void createSyscallsGroup() {
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
);
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
);
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() {
553 public void widgetSelected(SelectionEvent e
) {
554 setKernelEnablements(KernelGroupEnum
.SYSCALLS
);
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
);
565 new FilteredTree(syscallGroup
, SWT
.MULTI
| SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.BORDER
, new PatternFilter(), true) {
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
);
571 fSyscallsViewer
.setContentProvider(new KernelContentProvider(TraceEventType
.SYSCALL
));
572 fSyscallsViewer
.setLabelProvider(new KernelLabelProvider());
573 fSyscallsViewer
.addCheckStateListener(new KernelCheckListener(fSyscallsViewer
));
574 fSyscallsViewer
.setInput(fProviderGroup
);
576 fSyscallsViewer
.getTree().setLayoutData(new GridData(GridData
.FILL_BOTH
));
578 return fSyscallsViewer
;
582 protected void updateToolbar(boolean visible
) {
583 super.updateToolbar(visible
);
584 treeViewer
.expandAll();
591 * Creates dynamic probe group.
593 private void createDynamicProbeGroup() {
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
);
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
);
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() {
616 public void widgetSelected(SelectionEvent e
) {
617 setKernelEnablements(KernelGroupEnum
.PROBE
);
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
));
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
);
632 fProbeEventNameText
= new Text(probeGroup
, SWT
.LEFT
);
633 fProbeEventNameText
.setToolTipText(Messages
.TraceControl_EnableEventsProbeEventNameTooltip
);
635 data
= new GridData(GridData
.FILL_BOTH
);
636 data
.horizontalSpan
= 3;
637 fProbeEventNameText
.setLayoutData(data
);
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
);
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
);
653 * Creates dynamic function entry/return probe group.
655 private void createDynamicFunctionPropeGroup() {
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
);
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
);
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() {
678 public void widgetSelected(SelectionEvent e
) {
679 setKernelEnablements(KernelGroupEnum
.FUNCTION
);
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
));
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
);
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
);
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
);
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
);
714 * Enable/selects widgets depending on the group specified.
715 * @param group - group to enable.
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
);
723 fSyscallsActivateButton
.setSelection(group
== KernelGroupEnum
.SYSCALLS
);
724 if (fProviderGroup
.isPerSyscallEventsSupported()) {
725 fSyscallsViewer
.getTree().setEnabled(group
== KernelGroupEnum
.SYSCALLS
);
728 fProbeActivateButton
.setSelection(group
== KernelGroupEnum
.PROBE
);
729 fProbeEventNameText
.setEnabled(group
== KernelGroupEnum
.PROBE
);
730 fProbeText
.setEnabled(group
== KernelGroupEnum
.PROBE
);
732 fFunctionActivateButton
.setSelection(group
== KernelGroupEnum
.FUNCTION
);
733 fFunctionEventNameText
.setEnabled(group
== KernelGroupEnum
.FUNCTION
);
734 fFunctionText
.setEnabled(group
== KernelGroupEnum
.FUNCTION
);
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
);
746 fFilterText
= new Text(filterMainGroup
, SWT
.LEFT
);
747 fFilterText
.setToolTipText(Messages
.TraceControl_EnableEventsFilterTooltip
);
748 data
= new GridData(GridData
.FILL_HORIZONTAL
);
749 fFilterText
.setLayoutData(data
);
753 // ------------------------------------------------------------------------
755 // ------------------------------------------------------------------------
757 * Content provider for the tracepoints and syscalls tree.
759 public static final class KernelContentProvider
extends TraceControlContentProvider
{
761 * The type of event ({@link TraceEventType})
763 private final TraceEventType fEventType
;
769 * the type of event ({@link TraceEventType})
771 public KernelContentProvider(TraceEventType eventType
) {
772 fEventType
= eventType
;
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()]);
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
) {
788 return events
.toArray(new ITraceControlComponent
[events
.size()]);
790 return new Object
[0];
795 * Content label for the tracepoints and syscalls tree.
797 public static final class KernelLabelProvider
extends TraceControlLabelProvider
{
799 public Image
getImage(Object element
) {
804 public String
getText(Object element
) {
805 if ((element
!= null) && (element
instanceof KernelProviderComponent
)) {
806 return Messages
.TraceControl_EnableEventsTreeAllLabel
;
808 return super.getText(element
);
813 * Check state listener for the tracepoints and syscalls tree.
815 public final class KernelCheckListener
implements ICheckStateListener
{
817 * The check box tree viewer.
819 private final CheckboxTreeViewer fCheckBoxTreeViewer
;
824 * @param checkBoxTreeViewer
825 * the check box tree viewer.
827 public KernelCheckListener(CheckboxTreeViewer checkBoxTreeViewer
) {
828 fCheckBoxTreeViewer
= checkBoxTreeViewer
;
832 public void checkStateChanged(CheckStateChangedEvent event
) {
833 if (event
.getChecked()) {
834 if (event
.getElement() instanceof KernelProviderComponent
) {
835 fCheckBoxTreeViewer
.setSubtreeChecked(event
.getElement(), true);
838 if (event
.getElement() instanceof KernelProviderComponent
) {
839 fCheckBoxTreeViewer
.setSubtreeChecked(event
.getElement(), false);
841 ITraceControlComponent component
= (ITraceControlComponent
) event
.getElement();
842 fCheckBoxTreeViewer
.setChecked(component
.getParent(), false);