/*******************************************************************************
- * Copyright (c) 2014, 2015 École Polytechnique de Montréal
+ * Copyright (c) 2014, 2016 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
if (!(trace instanceof LttngUstTrace)) {
return false;
}
- /*
- * setTrace() calls getAnalysisRequirements, so we need the field set
- * for the check to work.
- */
- fAnalysisRequirements = requirementsForTrace((LttngUstTrace) trace);
- boolean traceIsSet = super.setTrace(trace);
- if (!traceIsSet) {
- /* Unset the requirements, the trace was not good after all. */
- fAnalysisRequirements = null;
- }
- return traceIsSet;
+ return super.setTrace(trace);
}
@Override
return (LttngUstTrace) super.getTrace();
}
- private static Set<TmfAnalysisRequirement> requirementsForTrace(LttngUstTrace trace) {
- /*
- * Compute the list of required events, whose exact names can change
- * depending on the tracer's version.
- */
- ILttngUstEventLayout layout = trace.getEventLayout();
- Set<String> requiredEvents = ImmutableSet.of(
- layout.eventLibcMalloc(),
- layout.eventLibcFree(),
- layout.eventLibcCalloc(),
- layout.eventLibcRealloc(),
- layout.eventLibcMemalign(),
- layout.eventLibcPosixMemalign()
- );
-
- /* Initialize the requirements for the analysis: domain and events */
- TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, requiredEvents, ValuePriorityLevel.MANDATORY);
- /*
- * In order to have these events, the libc wrapper with probes should be
- * loaded
- */
- eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingInformation));
- eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation));
-
- /* The domain type of the analysis */
- TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
- domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY);
-
- return ImmutableSet.of(domainReq, eventsReq);
- }
-
@Override
public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
- Set<TmfAnalysisRequirement> reqs = fAnalysisRequirements;
- if (reqs == null) {
- throw new IllegalStateException("Cannot get the analysis requirements without an assigned trace."); //$NON-NLS-1$
+ Set<TmfAnalysisRequirement> requirements = fAnalysisRequirements;
+ if (requirements == null) {
+ LttngUstTrace trace = getTrace();
+ ILttngUstEventLayout layout;
+ if (trace == null) {
+ layout = ILttngUstEventLayout.DEFAULT_LAYOUT;
+ } else {
+ layout = trace.getEventLayout();
+ }
+
+ @NonNull Set<@NonNull String> requiredEvents = ImmutableSet.of(
+ layout.eventLibcMalloc(),
+ layout.eventLibcFree(),
+ layout.eventLibcCalloc(),
+ layout.eventLibcRealloc(),
+ layout.eventLibcMemalign(),
+ layout.eventLibcPosixMemalign()
+ );
+
+ /* Initialize the requirements for the analysis: domain and events */
+ TmfAnalysisRequirement eventsReq = new TmfAnalysisRequirement(
+ nullToEmptyString(SessionConfigStrings.CONFIG_ELEMENT_EVENT), requiredEvents, ValuePriorityLevel.MANDATORY);
+ /*
+ * In order to have these events, the libc wrapper with probes should be
+ * loaded
+ */
+ eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingInformation));
+ eventsReq.addInformation(nullToEmptyString(Messages.UstMemoryAnalysisModule_EventsLoadingExampleInformation));
+
+ /* The domain type of the analysis */
+ TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(nullToEmptyString(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN));
+ domainReq.addValue(nullToEmptyString(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST), ValuePriorityLevel.MANDATORY);
+
+ requirements = ImmutableSet.of(domainReq, eventsReq);
+ fAnalysisRequirements = requirements;
}
- return reqs;
+ return requirements;
}
}