protected void FormatBase(int index, object number, string formattedString, Formatter formatter) { string actualFormattedString1; string actualFormattedString2; var numberOptions = NumberFormattingOptions.CreateImmediate(formatter.Options); switch (number) { case sbyte value: actualFormattedString1 = formatter.FormatInt8(value); actualFormattedString2 = formatter.FormatInt8(value, numberOptions); break; case short value: actualFormattedString1 = formatter.FormatInt16(value); actualFormattedString2 = formatter.FormatInt16(value, numberOptions); break; case int value: actualFormattedString1 = formatter.FormatInt32(value); actualFormattedString2 = formatter.FormatInt32(value, numberOptions); break; case long value: actualFormattedString1 = formatter.FormatInt64(value); actualFormattedString2 = formatter.FormatInt64(value, numberOptions); break; case byte value: actualFormattedString1 = formatter.FormatUInt8(value); actualFormattedString2 = formatter.FormatUInt8(value, numberOptions); break; case ushort value: actualFormattedString1 = formatter.FormatUInt16(value); actualFormattedString2 = formatter.FormatUInt16(value, numberOptions); break; case uint value: actualFormattedString1 = formatter.FormatUInt32(value); actualFormattedString2 = formatter.FormatUInt32(value, numberOptions); break; case ulong value: actualFormattedString1 = formatter.FormatUInt64(value); actualFormattedString2 = formatter.FormatUInt64(value, numberOptions); break; default: throw new InvalidOperationException(); } #pragma warning disable xUnit2006 // Do not use invalid string equality check // Show the full string without ellipses by using Equal<string>() instead of Equal() Assert.Equal <string>(formattedString, actualFormattedString1); Assert.Equal <string>(formattedString, actualFormattedString2); #pragma warning restore xUnit2006 // Do not use invalid string equality check }
public override bool TryGetDisplSymbol(int operand, Code code, ulong displacement, ref bool ripRelativeAddresses, out SymbolResult symbol, ref NumberFormattingOptions options) { if (tryGetDisplSymbol != null) { return(tryGetDisplSymbol(displacement, ref ripRelativeAddresses, out symbol, ref options)); } return(base.TryGetDisplSymbol(operand, code, displacement, ref ripRelativeAddresses, out symbol, ref options)); }
public override bool TryGetImmediateSymbol(int operand, Code code, ulong immediate, out SymbolResult symbol, ref NumberFormattingOptions options) { if (tryGetImmediateSymbol != null) { return(tryGetImmediateSymbol(immediate, out symbol, ref options)); } return(base.TryGetImmediateSymbol(operand, code, immediate, out symbol, ref options)); }
public override bool TryGetFarBranchSymbol(int operand, Code code, ushort selector, uint address, out SymbolResult symbolSelector, out SymbolResult symbol, ref bool showBranchSize, ref NumberFormattingOptions options) { if (tryGetFarBranchSymbol != null) { return(tryGetFarBranchSymbol(selector, address, out symbolSelector, out symbol, ref showBranchSize, ref options)); } return(base.TryGetFarBranchSymbol(operand, code, selector, address, out symbolSelector, out symbol, ref showBranchSize, ref options)); }
public override bool TryGetBranchSymbol(int operand, Code code, ulong address, out SymbolResult symbol, ref bool showBranchSize, ref NumberFormattingOptions options) { if (tryGetBranchSymbol != null) { return(tryGetBranchSymbol(address, out symbol, ref showBranchSize, ref options)); } return(base.TryGetBranchSymbol(operand, code, address, out symbol, ref showBranchSize, ref options)); }
/// <summary> /// Formats a <see cref="ulong"/> /// </summary> /// <param name="value">Value</param> /// <returns></returns> public string FormatUInt64(ulong value) => FormatUInt64(value, NumberFormattingOptions.CreateImmediate(Options));
/// <summary> /// Formats a <see cref="uint"/> /// </summary> /// <param name="value">Value</param> /// <returns></returns> public string FormatUInt32(uint value) => FormatUInt32(value, NumberFormattingOptions.CreateImmediate(Options));
/// <summary> /// Formats a <see cref="ushort"/> /// </summary> /// <param name="value">Value</param> /// <returns></returns> public string FormatUInt16(ushort value) => FormatUInt16(value, NumberFormattingOptions.CreateImmediate(Options));
/// <summary> /// Formats a <see cref="byte"/> /// </summary> /// <param name="value">Value</param> /// <returns></returns> public string FormatUInt8(byte value) => FormatUInt8(value, NumberFormattingOptions.CreateImmediate(Options));
protected override bool TryGetSymbol(int operand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol, ref NumberFormattingOptions options) { if (owner.cachedSymbolResolver.TryResolve(address, out var symResult, out bool fakeSymbol)) { if (!fakeSymbol || owner.AddLabels) { Debug.Assert(symResult.Address == address, "Symbol address != orig address: NYI"); if (symResult.Address == address) { symbol = new SymbolResult(symResult.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symResult.Kind), SymbolFlags.Address); return(true); } } } return(base.TryGetSymbol(operand, ref instruction, address, addressSize, out symbol, ref options)); }
protected override bool TryGetSymbol(int operand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol, ref NumberFormattingOptions options) { if (owner.cachedSymbolResolver.TryResolve(address, out var symResult, out bool fakeSymbol)) { if (!fakeSymbol || owner.AddLabels) { bool isBranch = symResult.Kind == SymbolKind.Function && instruction.FlowControl is var flowControl && (flowControl == FlowControl.UnconditionalBranch || flowControl == FlowControl.ConditionalBranch || flowControl == FlowControl.Call || flowControl == FlowControl.XbeginXabortXend); if (!isBranch || !IsCurrentMethod(symResult.Address)) { //TODO: need to support 'symResult.Address != address' (add a displacement to the symbol, eg. func+123) symbol = new SymbolResult(symResult.Symbol, SymbolKindUtils.ToFormatterOutputTextKind(symResult.Kind), SymbolFlags.Address); return(true); } } } return(base.TryGetSymbol(operand, ref instruction, address, addressSize, out symbol, ref options)); }