Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Rylek <trylek@microsoft.com>2016-09-20 03:02:22 +0300
committerTomas Rylek <trylek@microsoft.com>2016-09-20 03:02:22 +0300
commitf33b7cc2c9d090cece779a0a237bbb97b7a6d9d7 (patch)
treee03857835cf9c2312b5ada3b0b7ba11ff2341ef5
parentbb4bada4d04d0bb69326177b34398d34fa36345a (diff)
Rollback of CS# 1628088, stack trace generator changes originally due to Cody Ohlsen with help from Andrew Au. Multiple team members expressed concerns towards current form of this change. I'll send out a new code review for this change in a day or two, after I manage to sufficiently familiarize with the change.
Thanks Tomas [tfs-changeset: 1628158]
-rw-r--r--Documentation/design-docs/diagnostics/stack-trace-data.md77
-rw-r--r--src/Common/src/Internal/Runtime/MetadataBlob.cs4
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs127
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceBlobIndex.cs134
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceDecoder.cs47
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceMethodDescriptor.cs130
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceStringDescriptor.cs54
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTrieNode.cs74
-rw-r--r--src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTypeDescriptor.cs229
-rw-r--r--src/System.Private.CoreLib/src/System.Private.CoreLib.csproj9
10 files changed, 28 insertions, 857 deletions
diff --git a/Documentation/design-docs/diagnostics/stack-trace-data.md b/Documentation/design-docs/diagnostics/stack-trace-data.md
deleted file mode 100644
index accafde02..000000000
--- a/Documentation/design-docs/diagnostics/stack-trace-data.md
+++ /dev/null
@@ -1,77 +0,0 @@
-# StackTrace Data
-
-In order to support showing textual stack trace when `exception.ToString()` is called, a blob named StackTraceData is introduced. This is produced at compile time and embedded into the binary, and consumed at runtime to produce the textual string. In this document, we will talk about the design goal of the data format, and we will describe the format in detail.
-
-# Design Goal
-Beyond providing the necessary information for building up the stack trace string, one would like the format to have these characteristics, in priority order:
-
-1. It is space efficient - the data is embedded in the binary, which mean it is memory mapped to the process image, and that take time to read from the hard disk, which impact start up time.
-2. It is fast to produce - you don't want to wait for long for a debug build.
-3. Consuming it requires low memory footprint, especially so if there are any memory usage that is used even when an exception is not thrown.
-4. Consuming it does not take long. It is obvious why we will want this, but this is least prioritized because you have already incurred the cost of throwing an exception in the first place, as long as the speed is not too slow, we should be fine.
-
-# Basic concepts
-The overall scheme for this data is a serialized object graph. The objects are the type system objects, such as methods, types and so on. A method contains a declaring type, a collection of generic types, and a collection of argument types. A type may have a enclosing type (in the nested type scenario), a runtime type, a wrapped type (in the array/pointer/byref scenario), an a name. To further compress the names, the names are tokenized by the namespace separator dot, as well as by the camel casing. Then these tokens are arranged in a trie to make sure common prefix are shared.
-
-## References
-In the serialized representation, an object reference another object by index. For example, the declared type of the 7th method reference the 2nd type, then we just output 2 in the serialized representation of the 7th method. At runtime, we can deserialize the data easily by just reading off the 2nd row of the table when we need the declared type.
-
-## Numbers
-In the serialized representation, numbers of variable length encoded. The scheme is basically a "null" terminated integer. If a number is less than 128 (i.e. representable in 7 bits), we represent it with a byte. If not, we represent the most significant 7 bits in a byte, and set the 1st bit to 1. Then we recursively encode the remaining bits. The scheme make the representation of an object variable length, so we cannot use a simple rule to find out the offset of an object, and this is okay because at runtime we can do a single scan and build an index to these objects, and any subsequent access will be fast.
-
-## Strings
-Strings are represented as UTF-8 because code is mostly in English and therefore take only one byte per character. This incurs some runtime cost for reading the string because strings are represented as UTF-16. To avoid scanning the string when building the index, we prefix the string with its length. For most strings, this is just 1 byte and is the same cost for a null terminating character.
-
-## Optimization
-In order to reduce the number of bits used in references, we sort the object by their incoming references count. That way a lot of references will take much less space.
-
-## Special bytes
-There are some bytes that we specially designed to pack more information in one byte. An example would be the type encoding byte. We used 1 bit of it to represent whether or not it is being nested (i.e. has an enclosing type), 1 bit to represent if it has a runtime type, 3 bits to represent if it is array/byref/..., and finally the remaining 3 bits to represent the number of generic arguments. There are only two such special representation and will be documented in depth when we encounter one.
-
-# Detailed Specification
-The data begins with a magic 32 bit integer (in little endian) 0x000000C0, the number serve both as a sanity check (so that we are not reading a wrong blob) and also for versioning (for whatever reason we need to revise the format, we can change the magic number and does not break the dependency)
-
-The data continues with the table sizes in terms of number of records, starting with the method table size, the type table size, the string table size and the node table size, all in 32 bit integers (again little endian order)
-
-The data continues with the method table. Each method is emitted as follow:
-
-1. Reference to the trie node that has the method name
-2. Reference to the declaring type
-3. A special byte that encode the number of arguments and number of generics (see below)
-4. For each argument, the reference to the argument type
-5. For each generic argument, the reference to the generic argument type
-
-The special byte represents the number of arguments using the most significant 4 bits, and the number of generic arguments using the least signficant 4 bits. Suppose we have 15 or more arguments, we will encode the number of arguments - 15 after it, and then if we have more than 15 generic arguments, we will encode the number of generic arguments - 15 after it.
-
-After all the methods are encoded, the data continues with the type table. There are actually two types of types (in terms of encoding), and we can determine that using the 1st byte.
-
-The 1st byte is a special byte. The most significant bit represents if it is a runtime type. The next bit represents if it is a nested type so that it has an enclosing type. The next 3 bits represents the type of the type, the next 3 bits represents the number of generic arguments.
-
-Suppose we have 7 or more generic type arguments, we will encode the number of generic type argument - 7.
-
-The middle 3 bits is interesting, there are 5 types of type as follow:
-
-None = 0x000
-ByRef = 0x001
-Ptr = 0x010
-SzArray = 0x011
-Array = 0x100
-
-The none type is actually the predominant type. The rest are special. We about the none case first.
-
-In the none case, we will encode as follow
-
-1. Reference to the trie node that has the type name
-2. Reference to the runtime type if any (i.e. if the first bit on)
-3. Reference to the enclosing type if any (i.e. if the second bit on)
-1. For each generic type, the reference to the generic argument type
-
-For the other case, we will simply encode the wrapped type.
-
-After the type table, we have the strings. The strings are simply encoded with their length as prefix.
-
-After the string table, we have the trie nodes. The trie node is a little different because we need to be able to encode a NULL reference. any node that does not have a parent points to 0, and the trie node references start from 1
-
-We first encode the parent reference, and then the string reference.
-
-That's all how the encoding works! \ No newline at end of file
diff --git a/src/Common/src/Internal/Runtime/MetadataBlob.cs b/src/Common/src/Internal/Runtime/MetadataBlob.cs
index 64751e561..b2ba2e36e 100644
--- a/src/Common/src/Internal/Runtime/MetadataBlob.cs
+++ b/src/Common/src/Internal/Runtime/MetadataBlob.cs
@@ -30,10 +30,6 @@ namespace Internal.Runtime
TypeTemplateMap = 21,
GenericMethodsTemplateMap = 22,
DynamicInvokeTemplateData = 23,
-
- // Stack Trace information
- StackTraceData = 24,
-
//Native layout blobs:
NativeLayoutInfo = 30, // Created by MDIL binder
NativeReferences = 31, // Created by MDIL binder
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs
index 091465499..9b3092b9c 100644
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs
+++ b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/DeveloperExperience.cs
@@ -2,51 +2,18 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-// #define DUMP_STACKTRACE_BLOB // uncomment this to print the entire stack trace blob's raw encoded bytes to the debug console.
-
using System;
-using System.Collections.Generic;
+using System.Text;
using System.Runtime;
using System.Diagnostics;
using System.Diagnostics.Contracts;
-using System.Text;
-using Internal.Runtime;
using Internal.Runtime.Augments;
-using Internal.DeveloperExperience.StackTrace;
namespace Internal.DeveloperExperience
{
public class DeveloperExperience
{
- // For every module, keep a map of StackTraceBlobIndexes for each module.
- private static LowLevelDictionary<IntPtr, StackTraceBlobIndex> s_stackTraceBlobIndexes;
-
- // Given an rva for a method, Walks through the binary, reading descriptors, to build up and return the method name.
- private unsafe static string CreateStackTraceString(StackTraceBlobIndex stackTraceBlobIndex, uint rva, byte* pBlob)
- {
- uint methodStartRva = rva;
- uint methodCount = *((uint*)(pBlob) + 1); // Skipping the magic byte
- uint* pRvaTable = ((uint*)(pBlob) + 5); // Skipping the magic byte and the table sizes
-
- // Iterate through each rva.
- for (uint i = 0; i < methodCount; i++)
- {
- if (*pRvaTable != methodStartRva)
- {
- pRvaTable++;
- }
- else
- {
- // Create the method descriptor from the offset found.
- StackTraceMethodDescriptor md = StackTraceMethodDescriptor.CreateFromBuffer(stackTraceBlobIndex, pBlob, stackTraceBlobIndex.methodOffsets[(int)i]);
- return md.ToString();
- }
- }
-
- return null;
- }
-
public virtual void WriteLine(String s)
{
Debug.WriteLine(s);
@@ -55,82 +22,43 @@ namespace Internal.DeveloperExperience
public virtual String CreateStackTraceString(IntPtr ip, bool includeFileInfo)
{
- string methodName = String.Empty;
- IntPtr moduleBase = RuntimeImports.RhGetModuleFromPointer(ip);
- IntPtr methodStart = RuntimeImports.RhFindMethodStartAddress(ip);
- try
+ ReflectionExecutionDomainCallbacks reflectionCallbacks = RuntimeAugments.CallbacksIfAvailable;
+ String moduleFullFileName = null;
+
+ if (reflectionCallbacks != null)
{
+ IntPtr methodStart = RuntimeImports.RhFindMethodStartAddress(ip);
if (methodStart != IntPtr.Zero)
{
- int rva = RuntimeAugments.ConvertIpToRva(methodStart);
- unsafe
+ string methodName = string.Empty;
+ try
{
- byte* pBlob = null;
- uint cbBlob = 0;
- if (RuntimeImports.RhFindBlob(moduleBase, (uint)ReflectionMapBlob.StackTraceData, &pBlob, &cbBlob) && cbBlob > 0)
- {
- StackTraceBlobIndex stackTraceBlobIndex = null;
- if (s_stackTraceBlobIndexes == null)
- {
- s_stackTraceBlobIndexes = new LowLevelDictionary<IntPtr, StackTraceBlobIndex>();
- }
- if (!s_stackTraceBlobIndexes.TryGetValue(moduleBase, out stackTraceBlobIndex))
- {
-#if DUMP_STACKTRACE_BLOB
- Debug.WriteLine("Entire blob:");
- for (int i = 0; i < cbBlob; i++)
- {
- Debug.WriteLine(pBlob[i]);
- }
-#endif
- stackTraceBlobIndex = StackTraceBlobIndex.BuildStackTraceBlobIndex(pBlob, cbBlob);
- s_stackTraceBlobIndexes.Add(moduleBase, stackTraceBlobIndex);
- }
-
- methodName = CreateStackTraceString(stackTraceBlobIndex, (uint)rva, pBlob);
- Debug.Assert(methodName != null, "If we have the blob, we better have all the method names for every methods in the module.");
- }
+ methodName = reflectionCallbacks.GetMethodNameFromStartAddressIfAvailable(methodStart);
}
+ catch { }
- if (methodName == null)
- {
- // If we can't find anything, default to reflection.
- // This can happen if the app is not compiled with the /EnableTextualStackTrace flag
- ReflectionExecutionDomainCallbacks reflectionCallbacks = RuntimeAugments.CallbacksIfAvailable;
-
- if (reflectionCallbacks != null)
- {
- methodName = reflectionCallbacks.GetMethodNameFromStartAddressIfAvailable(methodStart);
- }
- }
+ if (!string.IsNullOrEmpty(methodName))
+ return methodName;
}
- }
- catch
- {
- // Ignoring any error occurred while trying to figure out the methodName
+
+ // If we don't have precise information, try to map it at least back to the right module.
+ IntPtr moduleBase = RuntimeImports.RhGetModuleFromPointer(ip);
+ moduleFullFileName = RuntimeAugments.TryGetFullPathToApplicationModule(moduleBase);
}
- if (methodName != null)
+ // Without any callbacks or the ability to map ip correctly we better admit that we don't know
+ if (string.IsNullOrEmpty(moduleFullFileName))
{
- return methodName;
+ return "<unknown>";
}
- else
- {
- string moduleFullFileName = RuntimeAugments.TryGetFullPathToApplicationModule(moduleBase);
- // Without any callbacks or the ability to map ip correctly we better admit that we don't know
- if (string.IsNullOrEmpty(moduleFullFileName))
- {
- return "<unknown>";
- }
-
- StringBuilder sb = new StringBuilder();
- string fileNameWithoutExtension = GetFileNameWithoutExtension(moduleFullFileName);
- sb.Append(fileNameWithoutExtension);
- sb.Append("!<BaseAddress>+0x");
- sb.Append(RuntimeAugments.ConvertIpToRva(ip).ToString("x"));
- return sb.ToString();
- }
+ StringBuilder sb = new StringBuilder();
+ String fileNameWithoutExtension = GetFileNameWithoutExtension(moduleFullFileName);
+ int rva = RuntimeAugments.ConvertIpToRva(ip);
+ sb.Append(fileNameWithoutExtension);
+ sb.Append("!<BaseAddress>+0x");
+ sb.Append(rva.ToString("x"));
+ return sb.ToString();
}
public virtual void TryGetSourceLineInfo(IntPtr ip, out string fileName, out int lineNumber, out int columnNumber)
@@ -177,7 +105,7 @@ namespace Internal.DeveloperExperience
private static String GetFileName(String path)
{
int length = path.Length;
- for (int i = length; --i >= 0; )
+ for (int i = length; --i >= 0;)
{
char ch = path[i];
if (ch == '/' || ch == '\\' || ch == ':')
@@ -189,3 +117,4 @@ namespace Internal.DeveloperExperience
private static DeveloperExperience s_developerExperience;
}
}
+
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceBlobIndex.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceBlobIndex.cs
deleted file mode 100644
index a5f7d806b..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceBlobIndex.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-// 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.
-
-// #define DUMP_STACKTRACE_DECODE // uncomment this to print the stack trace blob's decoded bytes to the debug console.
-
-using System.Diagnostics;
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceBlobIndex
- {
- private const int STACK_TRACE_MAGIC_WORD_INDEX = 0;
- private const int STACK_TRACE_METHOD_DESCRIPTOR_COUNT_INDEX = 1;
- private const int STACK_TRACE_TYPE_DESCRIPTOR_COUNT_INDEX = 2;
- private const int STACK_TRACE_STRING_COUNT_INDEX = 3;
- private const int STACK_TRACE_TRIE_NODE_COUNT_INDEX = 4;
-
- // This constant marks the beginning of the stack trace data embedded in the binary
- // Just in case we need to update this format, we can update the magic byte so that we
- // know at runtime which version of the toolchain built this binary and decode the blob
- // accordingly.
- private const uint STACK_TRACE_MAGIC_WORD = 0xC0;
- private const int INT_SIZE = sizeof(uint);
- private const int RVA_SIZE = INT_SIZE;
-
- // These lists are built up after initializing offsets.
- // They are a mapping, from id (or list index) of the descriptor to the offset in the binary where that descriptor is located.
- public uint[] methodOffsets;
- public uint[] typeOffsets;
- public uint[] trieNodeOffsets;
- public uint[] stringOffsets;
-
- // Initializes all offset lists to be able to quickly find descriptors based on their ids.
- // The four lists, offsets.methodOffsets, offsets.typeOffsets, offsets.stringOffsets, and offsets.trieNodeOffsets are stored in memory,
- // and every method name lookup after these lists are stored is done in constant time after finding the method descriptor.
- public unsafe static StackTraceBlobIndex BuildStackTraceBlobIndex(byte* pBlob, uint cbBlob)
- {
- StackTraceBlobIndex stackTraceBlobIndex = new StackTraceBlobIndex();
-
- uint* pHeader = (uint*)pBlob;
-
- // The blob start with the magic word
- uint magicByte = pHeader[STACK_TRACE_MAGIC_WORD_INDEX];
- if (magicByte != STACK_TRACE_MAGIC_WORD)
- {
- return null;
- }
-
- // Then it stores the number of method descriptors
- uint methodCount = pHeader[STACK_TRACE_METHOD_DESCRIPTOR_COUNT_INDEX];
-
- // Then it stores the number of type descriptors
- uint typeDescCount = pHeader[STACK_TRACE_TYPE_DESCRIPTOR_COUNT_INDEX];
-
- // Then it stores the number of strings, and
- uint stringCount = pHeader[STACK_TRACE_STRING_COUNT_INDEX];
-
- // Finally, it stores the number of trie nodes
- uint trieNodeCount = pHeader[STACK_TRACE_TRIE_NODE_COUNT_INDEX];
-
- stackTraceBlobIndex.methodOffsets = new uint[(int)methodCount];
- stackTraceBlobIndex.typeOffsets = new uint[(int)typeDescCount];
- stackTraceBlobIndex.stringOffsets = new uint[(int)stringCount];
- stackTraceBlobIndex.trieNodeOffsets = new uint[(int)trieNodeCount];
-
- // Then it stores all the RVAs of the methods (i.e. methodCount * RVA_SIZE)
-
- // The method table starts right after the RVAs and counts
- uint tableOffset = methodCount * RVA_SIZE + 5 * INT_SIZE; // for the data we read above.
- byte* tablePtr = pBlob + tableOffset;
-
- // Keeps a running total of bytes read.
- uint bytesRead = 0;
- int i = 0;
-
- // Read all the method descriptors.
- for (i = 0; i < methodCount; i++)
- {
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("BeginMethod(" + i + ")");
-#endif
- stackTraceBlobIndex.methodOffsets[i] = tableOffset + bytesRead;
- bytesRead += StackTraceMethodDescriptor.CalculateSize(tablePtr, bytesRead);
-
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("EndMethod");
-#endif
- }
-
- // Read all the type descriptors.
- for (i = 0; i < typeDescCount; i++)
- {
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("BeginType(" + i + ")");
-#endif
- stackTraceBlobIndex.typeOffsets[i] = tableOffset + bytesRead;
- bytesRead += StackTraceTypeDescriptor.CalculateSize(tablePtr, bytesRead);
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("EndType");
-#endif
- }
-
- // Read all the strings.
- for (i = 0; i < stringCount; i++)
- {
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("BeginString(" + i + ")");
-#endif
- stackTraceBlobIndex.stringOffsets[i] = tableOffset + bytesRead;
- bytesRead += StackTraceStringDescriptor.CalculateSize(tablePtr, bytesRead);
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("EndString");
-#endif
- }
-
- // Read all the trie nodes.
- for (i = 0; i < trieNodeCount; i++)
- {
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("BeginNode(" + i + ")");
-#endif
- stackTraceBlobIndex.trieNodeOffsets[i] = tableOffset + bytesRead;
- bytesRead += StackTraceTrieNode.CalculateSize(tablePtr, bytesRead);
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine("EndNode");
-#endif
- }
-
- Debug.Assert(bytesRead + tableOffset == cbBlob, "StackTraceBlob deserialization error");
- return stackTraceBlobIndex;
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceDecoder.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceDecoder.cs
deleted file mode 100644
index 57da86303..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceDecoder.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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.
-
-// #define DUMP_STACKTRACE_DECODE // uncomment this to print the stack trace blob's decoded bytes to the debug console.
-
-using System.Diagnostics;
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceDecoder
- {
- public static uint MAX_DECODE_BYTES = 5;
-
- // Decodes a uint (with variable length) from the byte buffer using MSB decoding.
- // returns an uint32_t representing the decoded uint, and the number of bytes read.
- public static unsafe uint DecodeUInt(byte* buffer, uint size, ref uint bytesRead)
- {
- uint decodedId = 0;
- uint originalBytesRead = bytesRead;
- uint i = 0;
- for (; i < size; i++)
- {
- // extracts the 7 bits into the decoded id.
- decodedId |= (uint)(buffer[i] & ((byte)((1 << 7) - 1))) << ((byte)(7 * i));
-
- // If the MSB flag is not set, break.
- if ((buffer[i] & ((byte)(1 << 7))) == 0)
- break;
- }
- bytesRead += i + 1;
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine(decodedId.ToString() + " in " + (bytesRead - originalBytesRead) + " bytes");
-#endif
- return decodedId;
- }
-
- public static unsafe byte DecodeByte(byte* buffer, ref uint bytesRead)
- {
- bytesRead++;
-#if DUMP_STACKTRACE_DECODE
- Debug.WriteLine(buffer[0].ToString() + " in 1 bytes");
-#endif
- return buffer[0];
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceMethodDescriptor.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceMethodDescriptor.cs
deleted file mode 100644
index 3e4a7429c..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceMethodDescriptor.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-// 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.
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceMethodDescriptor
- {
- private uint leafId;
- private uint declTypeDescId;
- private uint[] argTypeDescIds;
- private uint[] genericArgTypeDescIds;
-
- public StackTraceTrieNode name;
- public StackTraceTypeDescriptor declType;
- public StackTraceTypeDescriptor[] argTypes;
- public StackTraceTypeDescriptor[] genericTypes;
-
- private unsafe StackTraceMethodDescriptor(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint leafId, uint declTypeDescId, uint[] argTypeDescIds, uint[] genericArgTypeDescIds)
- {
- this.leafId = leafId;
- this.declTypeDescId = declTypeDescId;
- this.argTypeDescIds = argTypeDescIds;
- this.genericArgTypeDescIds = genericArgTypeDescIds;
-
- // Creates the object references.
- this.name = StackTraceTrieNode.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.trieNodeOffsets[(int)this.leafId - 1]);
- this.declType = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)this.declTypeDescId]);
-
- this.argTypes = new StackTraceTypeDescriptor[argTypeDescIds.Length];
- for (int i = 0; i < argTypeDescIds.Length; i++)
- {
- this.argTypes[i] = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)argTypeDescIds[i]]);
- }
-
- this.genericTypes = new StackTraceTypeDescriptor[genericArgTypeDescIds.Length];
- for (int i = 0; i < genericArgTypeDescIds.Length; i++)
- {
- this.genericTypes[i] = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)genericArgTypeDescIds[i]]);
- }
- }
-
- public unsafe static StackTraceMethodDescriptor CreateFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset)
- {
- uint bytesRead;
- return ReadFromBuffer(stackTraceBlobIndex, buffer, offset, out bytesRead);
- }
-
- public static unsafe uint CalculateSize(byte* buffer, uint offset)
- {
- uint bytesRead = 0;
- ReadFromBuffer(null, buffer, offset, out bytesRead);
- return bytesRead;
- }
-
- public override string ToString()
- {
- string genericParams = (genericTypes.Length == 0) ? "" : "<" + string.Join(",", (object[])this.genericTypes) + ">";
- return declType.ToString() + "." + name.ToString() + genericParams + "(" + string.Join(",", (object[])this.argTypes) + ")";
- }
-
- private unsafe static StackTraceMethodDescriptor ReadFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset, out uint bytesRead)
- {
- bool constructDescriptor = stackTraceBlobIndex != null;
- byte* pMyBuffer = buffer + offset;
- bytesRead = 0;
-
- uint leafId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- uint declTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
-
- // un-concatenates the two sizes placed in this byte.
- uint numArgsAndGenericArgs = StackTraceDecoder.DecodeByte(pMyBuffer + bytesRead, ref bytesRead);
- uint numArgs = numArgsAndGenericArgs >> 4;
- uint numGenerics = numArgsAndGenericArgs & 0x0F;
-
- if (numArgs == 15)
- {
- numArgs += StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- }
-
- if (numGenerics == 15)
- {
- numGenerics += StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- }
-
- uint[] argsTypeIdsList = null;
- uint[] genericTypeIdsList = null;
-
- if (constructDescriptor)
- {
- argsTypeIdsList = new uint[numArgs];
- genericTypeIdsList = new uint[numGenerics];
- }
-
- for (uint i = 0; i < numArgs; i++)
- {
- uint argsTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- if (constructDescriptor)
- {
- argsTypeIdsList[i] = argsTypeId;
- }
- }
-
- for (uint i = 0; i < numGenerics; i++)
- {
- uint genericTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- if (constructDescriptor)
- {
- genericTypeIdsList[i] = genericTypeId;
- }
- }
-
- if (constructDescriptor)
- {
- return new StackTraceMethodDescriptor(
- stackTraceBlobIndex,
- buffer,
- leafId,
- declTypeId,
- argsTypeIdsList,
- genericTypeIdsList
- );
- }
- else
- {
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceStringDescriptor.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceStringDescriptor.cs
deleted file mode 100644
index 5c3b8b2ed..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceStringDescriptor.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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;
-using System.Text;
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceStringDescriptor
- {
- private static UTF8Encoding encoding;
-
- public static unsafe string CreateString(byte* buffer, uint offset)
- {
- uint bytesRead = 0;
- return ReadString(true, buffer, offset, out bytesRead);
- }
-
- public static unsafe uint CalculateSize(byte* buffer, uint offset)
- {
- uint bytesRead = 0;
- ReadString(false, buffer, offset, out bytesRead);
- return bytesRead;
- }
-
- private static unsafe string ReadString(bool constructInstance, byte* buffer, uint offset, out uint bytesRead)
- {
- byte* pMyBuffer = buffer + offset;
- bytesRead = 0;
- uint size = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- if (constructInstance)
- {
- if (encoding == null)
- {
- encoding = new UTF8Encoding();
- }
-
- int charCount = encoding.GetCharCount(pMyBuffer + bytesRead, (int)size);
- var d = new char[charCount];
- fixed (char* c = d)
- {
- encoding.GetChars(pMyBuffer + bytesRead, (int)size, c, charCount);
- return new String(c);
- }
- }
- else
- {
- bytesRead += size;
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTrieNode.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTrieNode.cs
deleted file mode 100644
index 700516b03..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTrieNode.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceTrieNode
- {
- private uint parentId;
- private uint stringId;
-
- public StackTraceTrieNode parent;
- public string name;
-
- private unsafe StackTraceTrieNode(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint parentId, uint stringId)
- {
- this.parentId = parentId;
- this.stringId = stringId;
-
- // Creates the objects from the ids.
- this.parent = (this.parentId == 0) ? null : StackTraceTrieNode.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.trieNodeOffsets[(int)this.parentId - 1]);
- this.name = StackTraceStringDescriptor.CreateString(buffer, stackTraceBlobIndex.stringOffsets[(int)this.stringId]);
- }
-
- public unsafe static StackTraceTrieNode CreateFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset)
- {
- uint bytesRead;
- return ReadFromBuffer(stackTraceBlobIndex, buffer, offset, out bytesRead);
- }
-
- public static unsafe uint CalculateSize(byte* buffer, uint offset)
- {
- uint bytesRead = 0;
- ReadFromBuffer(null, buffer, offset, out bytesRead);
- return bytesRead;
- }
-
- public override string ToString()
- {
- if (parent == null)
- {
- return name;
- }
- else
- {
- return this.parent.ToString() + name;
- }
- }
-
- private static unsafe StackTraceTrieNode ReadFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset, out uint bytesRead)
- {
- bool constructDescriptor = stackTraceBlobIndex != null;
- bytesRead = 0;
- byte* pMyBuffer = buffer + offset;
-
- uint parentId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- uint stringId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
-
- if (constructDescriptor)
- {
- return new StackTraceTrieNode(
- stackTraceBlobIndex,
- buffer,
- parentId,
- stringId
- );
- }
- else
- {
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTypeDescriptor.cs b/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTypeDescriptor.cs
deleted file mode 100644
index 31c244c48..000000000
--- a/src/System.Private.CoreLib/src/Internal/DeveloperExperience/StackTrace/StackTraceTypeDescriptor.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-// 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;
-
-namespace Internal.DeveloperExperience.StackTrace
-{
- internal class StackTraceTypeDescriptor
- {
- public TypeRepresentation typeRep;
- private uint? wrappedTypeId;
- private uint? rank;
- private uint? leafId;
- private uint? enclosingTypeId;
- private uint? runtimeTypeId;
- private uint[] genericArgTypeDescIds;
-
- public StackTraceTypeDescriptor wrappedType;
- public StackTraceTrieNode name;
- public StackTraceTypeDescriptor enclosingType;
- public StackTraceTypeDescriptor runtimeType;
- public StackTraceTypeDescriptor[] genericArgTypes;
-
- public enum TypeRepresentation
- {
- None = 0,
- ByRef = 1,
- Ptr = 2,
- SzArray = 3,
- Array = 4
- }
-
- const byte HasEnclosingTypeMask = 0x80;
- const byte IsRuntimeTypeMask = 0x40;
- const byte TypeRepresentationMask = 0x38;
- const byte NumGenericTypesMask = 0x07;
-
- private unsafe StackTraceTypeDescriptor(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer,
- TypeRepresentation typeRepresentation,
- uint? wrappedTypeId,
- uint? rank,
- uint? leafId,
- uint? enclosingTypeId,
- uint? runtimeTypeId,
- uint[] genericArgTypeDescIds)
- {
- this.typeRep = typeRepresentation;
- this.wrappedTypeId = wrappedTypeId;
- this.rank = rank;
- this.leafId = leafId;
- this.enclosingTypeId = enclosingTypeId;
- this.runtimeTypeId = runtimeTypeId;
- this.genericArgTypeDescIds = genericArgTypeDescIds;
-
- // Creates the objects from the ids.
- if (this.wrappedTypeId == null)
- {
- this.name = StackTraceTrieNode.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.trieNodeOffsets[(int)this.leafId - 1]);
- }
-
- if (runtimeTypeId != null)
- {
- this.runtimeType = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)this.runtimeTypeId.Value]);
- }
-
- if (enclosingTypeId != null)
- {
- this.enclosingType = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)this.enclosingTypeId.Value]);
- }
-
- if (wrappedTypeId != null)
- {
- this.wrappedType = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)this.wrappedTypeId.Value]);
- }
-
- if (this.genericArgTypeDescIds != null)
- {
- this.genericArgTypes = new StackTraceTypeDescriptor[genericArgTypeDescIds.Length];
-
- for (int i = 0; i < genericArgTypeDescIds.Length; i++)
- {
- this.genericArgTypes[i] = StackTraceTypeDescriptor.CreateFromBuffer(stackTraceBlobIndex, buffer, stackTraceBlobIndex.typeOffsets[(int)genericArgTypeDescIds[i]]);
- }
- }
- }
-
- public unsafe static StackTraceTypeDescriptor CreateFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset)
- {
- uint bytesRead;
- return ReadFromBuffer(stackTraceBlobIndex, buffer, offset, out bytesRead);
- }
-
- public static unsafe uint CalculateSize(byte* buffer, uint offset)
- {
- uint bytesRead = 0;
- ReadFromBuffer(null, buffer, offset, out bytesRead);
- return bytesRead;
- }
-
- public override string ToString()
- {
- if (this.typeRep == TypeRepresentation.None)
- {
- string stringName = "";
- string genericParams = (genericArgTypes.Length == 0) ? "" : "<" + string.Join(",", (object[])this.genericArgTypes) + ">";
- if (runtimeType != null)
- {
- stringName += runtimeType.ToString() + "_";
- }
-
- if (enclosingType != null)
- {
- stringName += enclosingType.ToString() + "+";
- }
-
- stringName += name.ToString() + genericParams;
- return stringName;
- }
- else
- {
- string suffix = "";
- switch (typeRep)
- {
- case TypeRepresentation.ByRef:
- suffix = "&";
- break;
-
- case TypeRepresentation.Ptr:
- suffix = "*";
- break;
-
- case TypeRepresentation.SzArray:
- suffix = "[]";
- break;
-
- case TypeRepresentation.Array:
- suffix = "[" + new string(',', ((int)this.rank) - 1) + "]";
- break;
- }
-
- return this.wrappedType.ToString() + suffix;
- }
- }
-
- public static unsafe StackTraceTypeDescriptor ReadFromBuffer(StackTraceBlobIndex stackTraceBlobIndex, byte* buffer, uint offset, out uint bytesRead)
- {
- bool constructDescriptor = stackTraceBlobIndex != null;
-
- bytesRead = 0;
-
- byte* pMyBuffer = buffer + offset;
-
- // Gets the byte containing the number of generic args, the type representation and the enclosing class or runtime type bits.
- uint encodedByte = StackTraceDecoder.DecodeByte(pMyBuffer + bytesRead, ref bytesRead); // [hasEnclosingType(7) | isRuntimeType(6) | typeRepresentation(543) | numberOfGenerics(210)]
- bool hasEnclosingType = (encodedByte & HasEnclosingTypeMask) != 0;
- bool isRuntimeType = (encodedByte & IsRuntimeTypeMask) != 0;
- TypeRepresentation typeRepresentation = (TypeRepresentation)((encodedByte & TypeRepresentationMask) >> 3);
- uint numGenericArgs = encodedByte & NumGenericTypesMask;
-
- if (numGenericArgs == 7)
- {
- numGenericArgs += StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- }
-
- uint? leafId = null;
- uint? runtimeTypeId = null;
- uint? enclosingTypeId = null;
- uint? wrappedTypeId = null;
- uint? rank = null;
- uint[] genericTypeIdsList = null;
-
- if (typeRepresentation != TypeRepresentation.None)
- {
- wrappedTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead); // wrapped type id
- if (typeRepresentation == TypeRepresentation.Array)
- {
- rank = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead); // rank
- }
- }
- else
- {
- leafId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
-
- if (hasEnclosingType)
- {
- enclosingTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead); // enclosing type id
- }
-
- if (isRuntimeType)
- {
- runtimeTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead); // runtime type id
- }
-
- if (constructDescriptor)
- {
- genericTypeIdsList = new uint[numGenericArgs];
- }
-
- for (uint i = 0; i < numGenericArgs; i++)
- {
- uint genericTypeId = StackTraceDecoder.DecodeUInt(pMyBuffer + bytesRead, StackTraceDecoder.MAX_DECODE_BYTES, ref bytesRead);
- if (constructDescriptor)
- {
- genericTypeIdsList[i] = genericTypeId;
- }
- }
- }
-
- if (constructDescriptor)
- {
- return new StackTraceTypeDescriptor(
- stackTraceBlobIndex,
- buffer,
- typeRepresentation,
- wrappedTypeId,
- rank,
- leafId,
- enclosingTypeId,
- runtimeTypeId,
- genericTypeIdsList);
- }
- else
- {
- return null;
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
index 97180bf66..b5a9d276d 100644
--- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
@@ -55,9 +55,6 @@
<Compile Include="Internal\Diagnostics\ExceptionExtensions.cs" />
<Compile Include="Internal\Diagnostics\StackTraceHelper.cs" />
<Compile Include="Internal\Helpers.cs" />
- <Compile Include="..\..\Common\src\Internal\Runtime\MetadataBlob.cs">
- <Link>Common\src\Internal\Runtime\MetadataBlob.cs</Link>
- </Compile>
</ItemGroup>
<ItemGroup Condition="'$(IsProjectNLibrary)' != 'true'">
<Compile Include="..\..\Common\src\Internal\NativeFormat\NativeFormatReader.cs">
@@ -89,12 +86,6 @@
<Compile Include="Internal\Threading\Tracing\SpinLockTrace.cs" />
<Compile Include="Internal\Toolchain\NonExecutableAttribute.cs" />
<Compile Include="Internal\DeveloperExperience\DeveloperExperience.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceBlobIndex.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceDecoder.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceMethodDescriptor.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceStringDescriptor.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceTrieNode.cs" />
- <Compile Include="Internal\DeveloperExperience\StackTrace\StackTraceTypeDescriptor.cs" />
<Compile Include="Internal\Runtime\Augments\RuntimeAugments.cs" />
<Compile Include="Internal\Runtime\Augments\ReflectionExecutionDomainCallbacks.cs" />
<Compile Include="Internal\Runtime\Augments\TypeLoaderCallbacks.cs" />