This patch just adds the type and updates all the switch cases.
It does nothing else for now, but it reduces the noise of the
other patch which actually adds the behavior of the custom value.
Change-Id: Ie16b2ff851968edc581f14abce175f0c0f2c6cc3
Signed-off-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/70173
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
case STRING:
writer.println("TmfStateValue.newValueString(\"" + val.unboxStr() + "\"),");
break;
+ case CUSTOM:
default:
writer.println(val.toString());
break;
import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
for (ITmfStateInterval cpuInterval : StateSystemUtils.queryHistoryRange(ss, statusQuark, start, end - 1, resolution, monitor)) {
ITmfStateValue stateValue = cpuInterval.getStateValue();
- switch (stateValue.getType()) {
- case INTEGER:
+ if (stateValue.getType() == Type.INTEGER) {
int value = stateValue.unboxInt();
/*
* If the current CPU is either preempted or in
* processes
*/
if ((value & (VcpuStateValues.VCPU_PREEMPT | VcpuStateValues.VCPU_VMM)) == 0) {
- break;
+ continue;
}
Integer threadOnCpu = KernelThreadInformationProvider.getThreadOnCpu(kernelModule, virtualCPU, cpuInterval.getStartTime());
if (threadOnCpu != null) {
map.put(threadOnCpu, new TmfStateInterval(cpuInterval.getStartTime(), cpuInterval.getEndTime(), threadOnCpu, VCPU_PREEMPT_VALUE));
}
- break;
- case DOUBLE:
- case LONG:
- case NULL:
- case STRING:
- default:
- break;
}
-
}
}
} catch (AttributeNotFoundException | StateSystemDisposedException e) {
private static final byte TYPE_STRING = 1;
private static final byte TYPE_LONG = 2;
private static final byte TYPE_DOUBLE = 3;
+ private static final byte TYPE_CUSTOM = 20;
private final long start;
private final long end;
* String's length + 2 (1 byte for size, 1 byte for \0 at the end
*/
return (minSize + sv.unboxStr().getBytes().length + 2);
+ case CUSTOM:
default:
/*
* It's very important that we know how to write the state value in
value = TmfStateValue.newValueDouble(buffer.getDouble());
break;
+ case TYPE_CUSTOM:
default:
/* Unknown data, better to not make anything up... */
throw new IOException(errMsg);
return TYPE_LONG;
case DOUBLE:
return TYPE_DOUBLE;
+ case CUSTOM:
+ return TYPE_CUSTOM;
default:
/* Should not happen if the switch is fully covered */
throw new IllegalStateException();
return Double.compare(this.value, other.unboxDouble());
case STRING:
throw new StateValueTypeException("A Double state value cannot be compared to a String state value."); //$NON-NLS-1$
+ case CUSTOM:
default:
throw new StateValueTypeException("A Double state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
}
DOUBLE,
/** Variable-length string value */
STRING,
+ /** Custom state value type
+ * @since 2.0 */
+ CUSTOM;
}
/**
return Integer.compare(this.value, other.unboxInt());
case STRING:
throw new StateValueTypeException("An Integer state value cannot be compared to a String state value."); //$NON-NLS-1$
+ case CUSTOM:
default:
throw new StateValueTypeException("An Integer state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
}
return Long.compare(this.value, other.unboxLong());
case STRING:
throw new StateValueTypeException("A Long state value cannot be compared to a String state value."); //$NON-NLS-1$
+ case CUSTOM:
default:
throw new StateValueTypeException("A Long state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
}
case STRING:
StringStateValue otherStringValue = (StringStateValue) other;
return value.compareTo(otherStringValue.value);
+ case CUSTOM:
default:
throw new StateValueTypeException("A String state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
}
case STRING:
builder.append(value.unboxStr());
break;
+ case CUSTOM:
default:
throw new StateValueTypeException("Invalid type of state value"); //$NON-NLS-1$
}
}
case DOUBLE:
case NULL:
+ case CUSTOM:
default:
quark = IXmlStateSystemContainer.ERROR_QUARK; // error
break;
case DOUBLE:
value = TmfStateValue.newValueDouble(Double.parseDouble(fieldString));
break;
+ case CUSTOM:
+ throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
case NULL:
case STRING:
default:
case DOUBLE:
value = TmfStateValue.newValueDouble(fieldLong.doubleValue());
break;
+ case CUSTOM:
+ throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
case LONG:
case NULL:
default:
case DOUBLE:
value = TmfStateValue.newValueDouble(fieldInteger.doubleValue());
break;
+ case CUSTOM:
+ throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
case INTEGER:
case NULL:
default:
case INTEGER:
value = TmfStateValue.newValueInt(fieldDouble.intValue());
break;
+ case CUSTOM:
+ throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
case DOUBLE:
case NULL:
default:
case DOUBLE:
case NULL:
case STRING:
+ case CUSTOM:
default:
}
return value;
case LONG:
return TYPE_LONG;
case DOUBLE:
+ case CUSTOM:
default:
/* Should not happen if the switch is fully covered */
throw new IllegalStateException("Data type " + type + " not supported"); //$NON-NLS-1$ //$NON-NLS-2$
break;
case NULL:
case STRING:
+ case CUSTOM:
default:
break;
}
case NULL:
case STRING:
+ case CUSTOM:
default:
throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
}
case NULL:
case STRING:
+ case CUSTOM:
default:
throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
}
/** Label for the type String */
public static String TypeString;
+
+ /** Label for the type Custom
+ * @since 2.0 */
+ public static String TypeCustom;
}
case LONG:
case DOUBLE:
case STRING:
+ case CUSTOM:
return fValue.toString();
case NULL:
default:
return Messages.TypeDouble;
case STRING:
return Messages.TypeString;
+ case CUSTOM:
+ return Messages.TypeCustom;
case NULL:
default:
return EMPTY_STRING;
TypeLong=Long
TypeDouble=Double
TypeString=String
+TypeCustom=Custom