summaryrefslogtreecommitdiff
path: root/src/ToolBox
diff options
context:
space:
mode:
authorEvgeny Pavlov <lucenticus@gmail.com>2016-10-01 20:33:25 +0300
committerMike McLaughlin <mikem@microsoft.com>2016-10-01 10:33:25 -0700
commit569d72ead112ff9702c0c0babc2c01e945b6a51c (patch)
treea28bc6c2e362080c4219ca2de8979d0ac86f9086 /src/ToolBox
parent60d4c9781d487a34f4864023255c745768f50e98 (diff)
downloadcoreclr-569d72ead112ff9702c0c0babc2c01e945b6a51c.tar.gz
coreclr-569d72ead112ff9702c0c0babc2c01e945b6a51c.tar.bz2
coreclr-569d72ead112ff9702c0c0babc2c01e945b6a51c.zip
Initial support of local variables and method arguments in GDB JIT interface (#7400)
Diffstat (limited to 'src/ToolBox')
-rw-r--r--src/ToolBox/SOS/NETCore/SymbolReader.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/ToolBox/SOS/NETCore/SymbolReader.cs b/src/ToolBox/SOS/NETCore/SymbolReader.cs
index f4a3ce30d8..1feaf033c2 100644
--- a/src/ToolBox/SOS/NETCore/SymbolReader.cs
+++ b/src/ToolBox/SOS/NETCore/SymbolReader.cs
@@ -28,6 +28,9 @@ namespace SOS
{
public IntPtr points;
public int size;
+ public IntPtr locals;
+ public int localsSize;
+
}
/// <summary>
@@ -378,7 +381,48 @@ namespace SOS
}
return false;
}
+ internal static bool GetLocalsInfoForMethod(string assemblyPath, int methodToken, out List<string> locals)
+ {
+ locals = null;
+
+ OpenedReader openedReader = GetReader(assemblyPath, isFileLayout: true, peStream: null, pdbStream: null);
+ if (openedReader == null)
+ return false;
+
+ using (openedReader)
+ {
+ try
+ {
+ Handle handle = MetadataTokens.Handle(methodToken);
+ if (handle.Kind != HandleKind.MethodDefinition)
+ return false;
+ locals = new List<string>();
+
+ MethodDebugInformationHandle methodDebugHandle =
+ ((MethodDefinitionHandle)handle).ToDebugInformationHandle();
+ LocalScopeHandleCollection localScopes = openedReader.Reader.GetLocalScopes(methodDebugHandle);
+ foreach (LocalScopeHandle scopeHandle in localScopes)
+ {
+ LocalScope scope = openedReader.Reader.GetLocalScope(scopeHandle);
+ LocalVariableHandleCollection localVars = scope.GetLocalVariables();
+ foreach (LocalVariableHandle varHandle in localVars)
+ {
+ LocalVariable localVar = openedReader.Reader.GetLocalVariable(varHandle);
+ if (localVar.Attributes == LocalVariableAttributes.DebuggerHidden)
+ continue;
+ locals.Add(openedReader.Reader.GetString(localVar.Name));
+ }
+ }
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ return true;
+
+ }
/// <summary>
/// Returns source name, line numbers and IL offsets for given method token.
/// </summary>
@@ -392,11 +436,17 @@ namespace SOS
try
{
List<DebugInfo> points = null;
+ List<string> locals = null;
if (!GetDebugInfoForMethod(assemblyPath, methodToken, out points))
{
return false;
}
+
+ if (!GetLocalsInfoForMethod(assemblyPath, methodToken, out locals))
+ {
+ return false;
+ }
var structSize = Marshal.SizeOf<DebugInfo>();
debugInfo.size = points.Count;
@@ -407,6 +457,14 @@ namespace SOS
Marshal.StructureToPtr(info, ptr, false);
ptr = (IntPtr)(ptr.ToInt64() + structSize);
}
+ debugInfo.localsSize = locals.Count;
+ debugInfo.locals = Marshal.AllocHGlobal(debugInfo.localsSize * Marshal.SizeOf<IntPtr>());
+ IntPtr ptrLocals = debugInfo.locals;
+ foreach (string s in locals)
+ {
+ Marshal.WriteIntPtr(ptrLocals, Marshal.StringToHGlobalUni(s));
+ ptrLocals += Marshal.SizeOf<IntPtr>();
+ }
return true;
}
catch