Create SOS SymbolReader managed project and change SOS to use it. #6783

Merged
merged 2 commits into from Aug 19, 2016

Projects

None yet

4 participants

@mikem8361
Member

The portable PDB helper code for SOS source/line support has been moved from
System.Diagnostics.Debug.SymbolReader to a new managed SOS project in the coreclr
repo called SOS.NETCore.

The public APIs have now been made internal.

Plumb through the loaded PE address to the managed SymbolReader functions so it can be used as a key.

Fixed a stack trashing/overflow when a unresolved managed breakpoint is resolved because one of the
module name buffers was too small (MAX_PATH_FNAME). Changed it (and others) to MAXLONGPATH.

SOS now works with Portable PDBs on Windows.

New dac private get module data request. Used to get the necessary info for portable PDBs.

SOS now supports in-memory PE's on xplat and Windows. Needed to get and plumb though the in-memory
PE layout where it is file based or loaded.

Better Windows GetLineByILOffset support. Uses the SymbolReader and now works with in-memory PEs.

Misc code formatting and general cleanup.

@mikem8361 mikem8361 Change SOS to use wrapper class that is now in System.Diagnostics.Sta…
…ckTrace.

The portable PDB helper code for SOS source/line support has been moved from
System.Diagnostics.Debug.SymbolReader to a new managed SOS project in the coreclr
repo called SOS.NETCore.

The public APIs have now been made internal.

Plumb through the loaded PE address to the managed SymbolReader functions so it can be used as a key.

Fixed a stack trashing/overflow when a unresolved managed breakpoint is resolved because one of the
module name buffers was too small (MAX_PATH_FNAME). Changed it (and others) to MAXLONGPATH.

SOS now works with Portable PDBs on Windows.

New dac private get module data request. Used to get the necessary info for portable PDBs.

SOS now supports in-memory PE's on xplat and Windows. Needed to get and plumb though the in-memory
PE layout where it is file based or loaded.

Better Windows GetLineByILOffset support. Uses the SymbolReader and now works with in-memory PEs.

Misc code formatting and general cleanup.
b1e9c64
@mikem8361 mikem8361 added this to the 1.1.0 milestone Aug 18, 2016
@mikem8361 mikem8361 self-assigned this Aug 18, 2016
@mikem8361
Member

@adityamandaleeka @noahfalk this is the new PR for the SOS work. It address the previous code review feedback and moves the managed code from the corefx/runtime assembly to a new project in the coreclr repo.

Could you guys take a look again?

@mikem8361
Member

/cc @tmat

@mikem8361
Member

@dotnet-bot test FreeBSD x64 Checked Build

@tmat tmat and 2 others commented on an outdated diff Aug 18, 2016
src/ToolBox/SOS/NETCore/SymbolReader.cs
+ methodToken = 0;
+ ilOffset = 0;
+
+ GCHandle gch = GCHandle.FromIntPtr(symbolReaderHandle);
+ MetadataReader reader = ((OpenedReader)gch.Target).Reader;
+
+ try
+ {
+ foreach (MethodDebugInformationHandle methodDebugInformationHandle in reader.MethodDebugInformation)
+ {
+ MethodDebugInformation methodDebugInfo = reader.GetMethodDebugInformation(methodDebugInformationHandle);
+ SequencePointCollection sequencePoints = methodDebugInfo.GetSequencePoints();
+ foreach (SequencePoint point in sequencePoints)
+ {
+ string sourceName = reader.GetString(reader.GetDocument(point.Document).Name);
+ if (Path.GetFileName(sourceName) == Path.GetFileName(fileName) && point.StartLine == lineNumber)
@tmat
tmat Aug 18, 2016 edited Member

Perhaps hoist Path.GetFileName(fileName) outside of the loop? Is it not already a file name, btw?

@adityamandaleeka
adityamandaleeka Aug 18, 2016 Member

Would it make sense to do the line number check before the filename check since it should be cheaper and the chances of a collision would probably be lower?

BTW, I may be off base here, but if we see that one sequence point in a methodDebugInfo has a filename that doesn't match what we're looking for, do we need to go through the remaining sequence points in that methodDebugInfo?

@mikem8361
mikem8361 Aug 18, 2016 Member

I’ll check the line number first. I don’t know if we should assume that every sequence point in a method will be in the same source file even though that make sense on the surface.

/cc: @noahfalk, @tmat

@adityamandaleeka adityamandaleeka commented on an outdated diff Aug 18, 2016
src/ToolBox/SOS/NETCore/SymbolReader.cs
+ localVarName = reader.GetString(localVar.Name);
+ return true;
+ }
+ }
+ }
+ }
+ catch
+ {
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Returns source name, line numbers and IL offsets for given method token.
+ /// </summary>
+ /// <param name="assemblyPath">file name of the assembly</param>
@adityamandaleeka
adityamandaleeka Aug 18, 2016 Member

Should the comment say "path" instead of "file name" here?

@mikem8361 mikem8361 Code review feedback.
576b455
@mikem8361 mikem8361 merged commit 7589066 into dotnet:master Aug 19, 2016

0 of 10 checks passed

CentOS7.1 x64 Debug Build and Test Started.
Details
FreeBSD x64 Checked Build Triggered.
Details
Linux ARM Emulator Cross Debug Build Triggered.
Details
Linux ARM Emulator Cross Release Build Triggered.
Details
OSX x64 Checked Build and Test Started.
Details
Ubuntu x64 Checked Build and Test Started.
Details
Windows_NT x64 Debug Build and Test Triggered.
Details
Windows_NT x64 Release Priority 1 Build and Test Triggered.
Details
Windows_NT x86 legacy_backend Checked Build and Test Triggered.
Details
Windows_NT x86 ryujit Checked Build and Test Triggered.
Details
@mikem8361 mikem8361 deleted the mikem8361:symbolreader branch Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment