From: Amy Date: Mon, 23 Jul 2018 20:35:57 +0000 (-0700) Subject: R2RDump - UnwindInfo for x86 (dotnet/coreclr#18994) X-Git-Tag: submit/tizen/20210909.063632~11030^2~4297 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f97c123a13276b84d46b9208ad3c622db565978;p=platform%2Fupstream%2Fdotnet%2Fruntime.git R2RDump - UnwindInfo for x86 (dotnet/coreclr#18994) * UnwindInfo for x86 * Update tests Commit migrated from https://github.com/dotnet/coreclr/commit/53e07bfd459df597f833bb3ac8673aadb247a253 --- diff --git a/src/coreclr/src/tools/r2rdump/Amd64/UnwindInfo.cs b/src/coreclr/src/tools/r2rdump/Amd64/UnwindInfo.cs index 4f7bb45..1bc8308 100644 --- a/src/coreclr/src/tools/r2rdump/Amd64/UnwindInfo.cs +++ b/src/coreclr/src/tools/r2rdump/Amd64/UnwindInfo.cs @@ -62,7 +62,7 @@ namespace R2RDump.Amd64 } } - public struct UnwindInfo : BaseUnwindInfo + public class UnwindInfo : BaseUnwindInfo { private const int _sizeofUnwindCode = 2; private const int _offsetofUnwindCode = 4; @@ -75,7 +75,8 @@ namespace R2RDump.Amd64 public byte FrameOffset { get; set; } //4 bits public UnwindCode[] UnwindCode { get; set; } public uint PersonalityRoutineRVA { get; set; } - public int Size { get; set; } + + public UnwindInfo() { } public UnwindInfo(byte[] image, int offset) { diff --git a/src/coreclr/src/tools/r2rdump/NativeReader.cs b/src/coreclr/src/tools/r2rdump/NativeReader.cs index 5839580..c55d48b 100644 --- a/src/coreclr/src/tools/r2rdump/NativeReader.cs +++ b/src/coreclr/src/tools/r2rdump/NativeReader.cs @@ -304,5 +304,23 @@ namespace R2RDump } return data; } + + /// + /// Based on decodeUnsigned in gcdecoder.cpp, used by the x86 gcdump and unwindinfo + /// + public static uint DecodeUnsignedGc(byte[] image, ref int start) + { + int size = 1; + byte data = image[start++]; + uint value = (uint)data & 0x7f; + while ((data & 0x80) != 0) + { + size++; + data = image[start++]; + value <<= 7; + value += (uint)data & 0x7f; + } + return value; + } } } diff --git a/src/coreclr/src/tools/r2rdump/R2RMethod.cs b/src/coreclr/src/tools/r2rdump/R2RMethod.cs index 5cd8c3a..788ebbb 100644 --- a/src/coreclr/src/tools/r2rdump/R2RMethod.cs +++ b/src/coreclr/src/tools/r2rdump/R2RMethod.cs @@ -13,9 +13,9 @@ using System.Xml.Serialization; namespace R2RDump { - public interface BaseUnwindInfo + public abstract class BaseUnwindInfo { - + public int Size { get; set; } } public class RuntimeFunction @@ -67,6 +67,10 @@ namespace R2RDump { Size = endRva - startRva; } + else if (unwindInfo is x86.UnwindInfo) + { + Size = (int)((x86.UnwindInfo)unwindInfo).FunctionLength; + } else if (gcInfo != null) { Size = gcInfo.CodeLength; diff --git a/src/coreclr/src/tools/r2rdump/R2RReader.cs b/src/coreclr/src/tools/r2rdump/R2RReader.cs index 9b2940d..25568b0 100644 --- a/src/coreclr/src/tools/r2rdump/R2RReader.cs +++ b/src/coreclr/src/tools/r2rdump/R2RReader.cs @@ -306,7 +306,15 @@ namespace R2RDump unwindInfo = new Amd64.UnwindInfo(Image, unwindOffset); if (isEntryPoint[runtimeFunctionId]) { - gcInfo = new GcInfo(Image, unwindOffset + ((Amd64.UnwindInfo)unwindInfo).Size, Machine, R2RHeader.MajorVersion); + gcInfo = new GcInfo(Image, unwindOffset + unwindInfo.Size, Machine, R2RHeader.MajorVersion); + } + } + else if (Machine == Machine.I386) + { + unwindInfo = new x86.UnwindInfo(Image, unwindOffset); + if (isEntryPoint[runtimeFunctionId]) + { + //gcInfo = new GcInfo(Image, unwindOffset + unwindInfo.Size, Machine, R2RHeader.MajorVersion); } } diff --git a/src/coreclr/src/tools/r2rdump/x86/UnwindInfo.cs b/src/coreclr/src/tools/r2rdump/x86/UnwindInfo.cs new file mode 100644 index 0000000..7f617f0 --- /dev/null +++ b/src/coreclr/src/tools/r2rdump/x86/UnwindInfo.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text; +using System.Xml.Serialization; + +namespace R2RDump.x86 +{ + public class UnwindInfo : BaseUnwindInfo + { + public uint FunctionLength { get; set; } + + public UnwindInfo() { } + + public UnwindInfo(byte[] image, int offset) + { + FunctionLength = NativeReader.DecodeUnsignedGc(image, ref offset); + Size = sizeof(int); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"\tFunctionLength: {FunctionLength}"); + return sb.ToString(); + } + } +} diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml index a9ede31..eb2dc12 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml @@ -180,10 +180,16 @@ 1 10200 - 0 + 6 10420 0 + + + 4 + 6 + + @@ -201,10 +207,16 @@ 2 10208 - 0 + 127 10424 0 + + + 4 + 127 + + @@ -222,10 +234,16 @@ 3 10336 - 0 + 6 10420 0 + + + 4 + 6 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml index 4e37c5b..119e0c4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml @@ -160,10 +160,16 @@ 1 10380 - 0 + 8 10528 0 + + + 4 + 8 + + @@ -181,10 +187,16 @@ 2 10388 - 0 + 9 10532 0 + + + 4 + 9 + + @@ -208,10 +220,16 @@ 4 10412 - 0 + 19 10542 0 + + + 4 + 19 + + @@ -229,10 +247,16 @@ 5 10432 - 0 + 6 10546 0 + + + 4 + 6 + + @@ -250,10 +274,16 @@ 3 10400 - 0 + 10 10536 0 + + + 4 + 10 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml index 2f9bbef..88feff4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml @@ -193,10 +193,16 @@ 1 10096 - 0 + 20 10180 0 + + + 4 + 20 + + @@ -214,10 +220,16 @@ 2 10116 - 0 + 6 10184 0 + + + 4 + 6 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml index 64ae247..44d42f4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml @@ -123,10 +123,16 @@ 1 10016 - 0 + 6 10076 0 + + + 4 + 6 + + @@ -144,10 +150,16 @@ 2 10024 - 0 + 6 10076 0 + + + 4 + 6 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml index a9ede31..eb2dc12 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml @@ -180,10 +180,16 @@ 1 10200 - 0 + 6 10420 0 + + + 4 + 6 + + @@ -201,10 +207,16 @@ 2 10208 - 0 + 127 10424 0 + + + 4 + 127 + + @@ -222,10 +234,16 @@ 3 10336 - 0 + 6 10420 0 + + + 4 + 6 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml index 4e37c5b..119e0c4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml @@ -160,10 +160,16 @@ 1 10380 - 0 + 8 10528 0 + + + 4 + 8 + + @@ -181,10 +187,16 @@ 2 10388 - 0 + 9 10532 0 + + + 4 + 9 + + @@ -208,10 +220,16 @@ 4 10412 - 0 + 19 10542 0 + + + 4 + 19 + + @@ -229,10 +247,16 @@ 5 10432 - 0 + 6 10546 0 + + + 4 + 6 + + @@ -250,10 +274,16 @@ 3 10400 - 0 + 10 10536 0 + + + 4 + 10 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml index 2f9bbef..88feff4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml @@ -193,10 +193,16 @@ 1 10096 - 0 + 20 10180 0 + + + 4 + 20 + + @@ -214,10 +220,16 @@ 2 10116 - 0 + 6 10184 0 + + + 4 + 6 + + diff --git a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml index 64ae247..44d42f4 100644 --- a/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml +++ b/src/coreclr/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml @@ -123,10 +123,16 @@ 1 10016 - 0 + 6 10076 0 + + + 4 + 6 + + @@ -144,10 +150,16 @@ 2 10024 - 0 + 6 10076 0 + + + 4 + 6 + +