| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 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 | * Alexandre Montplaisir - Initial API and implementation |
| 11 | * Patrick Tasse - Add methods to get attribute paths |
| 12 | *******************************************************************************/ |
| 13 | |
| 14 | package org.eclipse.tracecompass.tmf.ui.views.callstack; |
| 15 | |
| 16 | import org.eclipse.jdt.annotation.NonNullByDefault; |
| 17 | import org.eclipse.tracecompass.tmf.core.callstack.CallStackStateProvider; |
| 18 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; |
| 19 | import org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput; |
| 20 | |
| 21 | /** |
| 22 | * The base classes for analyses who want to populate the CallStack View. |
| 23 | * |
| 24 | * @author Alexandre Montplaisir |
| 25 | */ |
| 26 | @NonNullByDefault |
| 27 | public abstract class AbstractCallStackAnalysis extends TmfStateSystemAnalysisModule { |
| 28 | |
| 29 | private static final String[] DEFAULT_PROCESSES_PATTERN = |
| 30 | new String[] { CallStackStateProvider.PROCESSES, "*" }; //$NON-NLS-1$ |
| 31 | |
| 32 | private static final String DEFAULT_THREADS_PATTERN = ".*"; //$NON-NLS-1$ |
| 33 | |
| 34 | private static final String[] DEFAULT_CALL_STACK_PATH = |
| 35 | new String[] { CallStackStateProvider.CALL_STACK }; |
| 36 | |
| 37 | /** |
| 38 | * Abstract constructor (should only be called via the sub-classes' |
| 39 | * constructors. |
| 40 | */ |
| 41 | protected AbstractCallStackAnalysis() { |
| 42 | super(); |
| 43 | registerOutput(new TmfAnalysisViewOutput(CallStackView.ID)); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * The quark pattern to get the list of attributes representing the |
| 48 | * different processes. |
| 49 | * |
| 50 | * It is passed as-is to |
| 51 | * {@link org.eclipse.tracecompass.statesystem.core.ITmfStateSystem#getQuarks} |
| 52 | * . |
| 53 | * @return The quark pattern to find the processes attribute |
| 54 | * @since 2.0 |
| 55 | */ |
| 56 | public String[] getProcessesPattern() { |
| 57 | return DEFAULT_PROCESSES_PATTERN; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * The regex to match sub-attributes of each Process attributes representing |
| 62 | * the threads of this process. |
| 63 | * |
| 64 | * This will be passed as-is to |
| 65 | * {@link org.eclipse.tracecompass.statesystem.core.ITmfStateSystem#getSubAttributes(int, boolean, String)} |
| 66 | * |
| 67 | * @return The regex to pass |
| 68 | * @since 2.0 |
| 69 | */ |
| 70 | public String getThreadsForProcessPattern() { |
| 71 | return DEFAULT_THREADS_PATTERN; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Get the call stack attribute path relative to a thread attribute found by |
| 76 | * {@link #getThreadsForProcessPattern()}. Override this method if the state |
| 77 | * system attributes do not match the default pattern defined by |
| 78 | * {@link CallStackStateProvider}. |
| 79 | * |
| 80 | * @return the relative path of the call stack attribute |
| 81 | * @since 2.0 |
| 82 | */ |
| 83 | public String[] getCallStackPathForThread() { |
| 84 | return DEFAULT_CALL_STACK_PATH; |
| 85 | } |
| 86 | } |