Skip to content

Commit

Permalink
1. Disable symdb compression
Browse files Browse the repository at this point in the history
2. Do not use LD in ER
3. Fix OutOfRange in SymDB
  • Loading branch information
dudikeleti committed Dec 19, 2024
1 parent aaaf963 commit 391c9a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Debugger/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public DebuggerSettings(IConfigurationSource? source, IConfigurationTelemetry te
.AsInt32(DefaultCodeOriginExitSpanFrames, frames => frames > 0)
.Value;

SymbolDatabaseCompressionEnabled = config.WithKeys(ConfigurationKeys.Debugger.SymbolDatabaseCompressionEnabled).AsBool(true);
SymbolDatabaseCompressionEnabled = config.WithKeys(ConfigurationKeys.Debugger.SymbolDatabaseCompressionEnabled).AsBool(false);
}

public bool Enabled { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection;
using System.Reflection.Emit;
using Datadog.Trace.Debugger.Symbols;
using Datadog.Trace.VendoredMicrosoftCode.System.Collections.Immutable;

#nullable enable
namespace Datadog.Trace.Debugger.ExceptionAutoInstrumentation
Expand Down Expand Up @@ -64,7 +65,7 @@ internal static bool IsBlockList(MethodBase method)
return true;
}

return AssemblyFilter.ShouldSkipAssembly(method.Module.Assembly, LiveDebugger.Instance.Settings.ThirdPartyDetectionExcludes, LiveDebugger.Instance.Settings.ThirdPartyDetectionIncludes);
return AssemblyFilter.ShouldSkipAssembly(method.Module.Assembly, ImmutableHashSet<string>.Empty, ImmutableHashSet<string>.Empty);
}

internal static bool ShouldSkipNamespaceIfOnTopOfStack(MethodBase method)
Expand Down
44 changes: 24 additions & 20 deletions tracer/src/Datadog.Trace/Debugger/Symbols/SymbolExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,46 +683,50 @@ void PopulateClosureMethod(MethodDefinition generatedMethod, TypeDefinition owne
return [new Symbol { Name = "this", SymbolType = SymbolType.Arg, Line = UnknownFieldAndArgLine, Type = method.GetDeclaringType().FullName(MetadataReader) }];
}

var argsSymbol = CreateArgSymbolArray(method, parameters);
var argsSymbol = method.IsStaticMethod() ? new Symbol[parameters.Count] : new Symbol[parameters.Count + 1]; // 'this'
int index = 0;
var methodSig = method.DecodeSignature(new TypeProvider(false), 0);
var paramTypesMatchArgSymbols = methodSig.ParameterTypes.Length == argsSymbol.Length || methodSig.ParameterTypes.Length == argsSymbol.Length - 1;
var typesIndex = 0;
if (!method.IsStaticMethod())
{
var thisSymbol = new Symbol { Name = "this", SymbolType = SymbolType.Arg, Line = UnknownFieldAndArgLine, Type = method.GetDeclaringType().FullName(MetadataReader) };
argsSymbol[0] = thisSymbol;
index++;
}

foreach (var parameterHandle in parameters)
{
if (parameterHandle.IsNil)
{
continue;
}

var parameterDef = MetadataReader.GetParameter(parameterHandle);
if (index == 0 && !method.IsStaticMethod())
var parameterName = MetadataReader.GetString(parameterDef.Name);
if (string.IsNullOrEmpty(parameterName))
{
argsSymbol[index] = new Symbol { Name = "this", SymbolType = SymbolType.Arg, Line = UnknownFieldAndArgLine, Type = method.GetDeclaringType().FullName(MetadataReader) };
index++;
continue;
}

if (parameterDef.IsHiddenThis())
{
continue;
}
if (parameterDef.IsHiddenThis())
{
continue;
}

argsSymbol[index] = new Symbol
{
Name = MetadataReader.GetString(parameterDef.Name),
Name = parameterName,
SymbolType = SymbolType.Arg,
Line = UnknownFieldAndArgLine,
Type = paramTypesMatchArgSymbols ? methodSig.ParameterTypes[parameterDef.IsHiddenThis() ? index : index - 1] : "Unknown"
Type = typesIndex < methodSig.ParameterTypes.Length ? methodSig.ParameterTypes[typesIndex] : "Unknown"
};
index++;
typesIndex++;
}

return argsSymbol;
}

private Symbol[] CreateArgSymbolArray(MethodDefinition method, ParameterHandleCollection parameters)
{
// ReSharper disable once NotDisposedResource
return method.IsStaticMethod() ?
new Symbol[parameters.Count] :
MetadataReader.GetParameter(parameters.GetEnumerator().Current).IsHiddenThis() ?
new Symbol[parameters.Count] : new Symbol[parameters.Count + 1];
}

private string[]? GetClassBaseClassNames(TypeDefinition type)
{
EntityHandle? baseType = type.BaseType;
Expand Down
4 changes: 2 additions & 2 deletions tracer/src/Datadog.Trace/Debugger/Upload/SymbolUploadApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private SymbolUploadApi(
{
_apiRequestFactory = apiRequestFactory;
_eventMetadata = eventMetadata;
_enableCompression = enableCompression;
_enableCompression = false; //enableCompression;
discoveryService.SubscribeToChanges(c => Endpoint = c.SymbolDbEndpoint);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public override async Task<bool> SendBatchAsync(ArraySegment<byte> symbols)
using var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress);
await gzipStream.WriteAsync(symbols.Array, 0, symbols.Array.Length).ConfigureAwait(false);
#endif
symbolsItem = new MultipartFormItem("file", "gzip", "file.gz", new ArraySegment<byte>(memoryStream.ToArray()));
symbolsItem = new MultipartFormItem("file", "application/gzip", "file.gz", new ArraySegment<byte>(memoryStream.ToArray()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private CustomDebugInfoAsyncAndClosure GetAsyncAndClosureCustomDebugInfoDnlib(in
{
cdiAsyncAndClosure.EncLambdaAndClosureMap = true;
}
else if (methodCustomDebugInfo.Kind is PdbCustomDebugInfoKind.StateMachineHoistedLocalScopes)
else if (methodCustomDebugInfo.Kind is PdbCustomDebugInfoKind.AsyncMethod)
{
cdiAsyncAndClosure.StateMachineHoistedLocal = true;
cdiAsyncAndClosure.StateMachineKickoffMethodRid = (int)((PdbAsyncMethodCustomDebugInfo)methodCustomDebugInfo).KickoffMethod.MDToken.Rid;
Expand Down

0 comments on commit 391c9a9

Please sign in to comment.