1 /**********************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
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 package org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernelmemoryusage
;
11 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
13 import org
.eclipse
.jdt
.annotation
.NonNull
;
14 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.DefaultEventLayout
;
15 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelAnalysisEventLayout
;
16 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelTrace
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
22 * This analysis module creates a stateprovider that keeps track of the memory
23 * allocated and deallocated by the kernel
25 * @author Samuel Gagnon
28 public class KernelMemoryAnalysisModule
extends TmfStateSystemAnalysisModule
{
31 * Analysis ID, it should match that in the plugin.xml file
33 public static final @NonNull String ID
= "org.eclipse.tracecompass.analysis.os.linux.core.kernelmemory"; //$NON-NLS-1$
36 * Each thread attribute in the tree has an attribute for keeping the lowest memory
37 * value for that thread during the trace. (Those values can be negative because we
38 * don't have access to a memory dump before the trace)
40 public static final @NonNull String THREAD_LOWEST_MEMORY_VALUE
= "lowestMemory"; //$NON-NLS-1$
43 protected @NonNull ITmfStateProvider
createStateProvider() {
44 ITmfTrace trace
= checkNotNull(getTrace());
45 IKernelAnalysisEventLayout layout
;
47 if (trace
instanceof IKernelTrace
) {
48 layout
= ((IKernelTrace
) trace
).getKernelEventLayout();
50 /* Fall-back to the base LttngEventLayout */
51 layout
= DefaultEventLayout
.getInstance();
53 return new KernelMemoryStateProvider(trace
, layout
);