Skip to content

Commit

Permalink
Do not generate broken debug info for non-methods (#94757)
Browse files Browse the repository at this point in the history
The related methods (`EmitDebugInfo`, `EmitEHClauseInfo`) already do this - if the node is not a method node, don't emit anything. It is not clear what purpose the "if this is not a method, emit broken debug information" serves. I traced it all the way back to https://github.com/dotnet/corert/blob/d78cf62480331f63b26eb08b86b838ffa355ff0d/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs#L427-L447 - it was surrounded by TODOs so maybe it didn't fully stand out but it doesn't look right there already.

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and MichalStrehovsky committed Nov 22, 2023
1 parent ed56654 commit 72a375f
Showing 1 changed file with 3 additions and 7 deletions.
Expand Up @@ -439,15 +439,11 @@ public void EmitDebugEHClauseInfo(ObjectNode node)
private static extern void EmitDebugFunctionInfo(IntPtr objWriter, byte[] methodName, int methodSize, uint methodTypeIndex);
public void EmitDebugFunctionInfo(ObjectNode node, int methodSize)
{
uint methodTypeIndex = 0;

var methodNode = node as IMethodNode;
if (methodNode != null)
if (node is IMethodNode methodNode)
{
methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method);
uint methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method);
EmitDebugFunctionInfo(_nativeObjectWriter, _currentNodeZeroTerminatedName.UnderlyingArray, methodSize, methodTypeIndex);
}

EmitDebugFunctionInfo(_nativeObjectWriter, _currentNodeZeroTerminatedName.UnderlyingArray, methodSize, methodTypeIndex);
}

[DllImport(NativeObjectWriterFileName)]
Expand Down

0 comments on commit 72a375f

Please sign in to comment.