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
.IKernelAnalysisEventLayout
;
15 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelTrace
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
21 * This analysis module creates a stateprovider that keeps track of the memory
22 * allocated and deallocated by the kernel
24 * @author Samuel Gagnon
27 public class KernelMemoryAnalysisModule
extends TmfStateSystemAnalysisModule
{
30 * Analysis ID, it should match that in the plugin.xml file
32 public static final @NonNull String ID
= "org.eclipse.tracecompass.analysis.os.linux.core.kernelmemory"; //$NON-NLS-1$
35 * Each thread attribute in the tree has an attribute for keeping the lowest memory
36 * value for that thread during the trace. (Those values can be negative because we
37 * don't have access to a memory dump before the trace)
39 public static final @NonNull String THREAD_LOWEST_MEMORY_VALUE
= "lowestMemory"; //$NON-NLS-1$
42 protected @NonNull ITmfStateProvider
createStateProvider() {
43 ITmfTrace trace
= checkNotNull(getTrace());
44 IKernelAnalysisEventLayout layout
;
46 if (trace
instanceof IKernelTrace
) {
47 layout
= ((IKernelTrace
) trace
).getKernelEventLayout();
49 /* Fall-back to the base LttngEventLayout */
50 layout
= IKernelAnalysisEventLayout
.DEFAULT_LAYOUT
;
52 return new KernelMemoryStateProvider(trace
, layout
);