From dd14c49a6486c35e029699f6eb5595325b2e3e3c Mon Sep 17 00:00:00 2001 From: Gregory LEOCADIE Date: Fri, 10 Oct 2025 14:43:38 +0200 Subject: [PATCH 1/2] Add module path to frames --- .../Datadog.Profiler.Native.Linux/CrashReportingLinux.cpp | 1 + .../CrashReportingWindows.cpp | 1 + .../Datadog.Profiler.Native/CrashReporting.cpp | 8 ++++++-- .../Datadog.Profiler.Native/CrashReporting.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CrashReportingLinux.cpp b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CrashReportingLinux.cpp index 8a86ff237461..599b26fe67c4 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CrashReportingLinux.cpp +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CrashReportingLinux.cpp @@ -249,6 +249,7 @@ std::vector CrashReportingLinux::GetThreadFrames(int32_t tid, Resolv stackFrame.isSuspicious = false; stackFrame.buildId = module->build_id; + stackFrame.modulePath = module->path; fs::path modulePath(module->path); diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Windows/CrashReportingWindows.cpp b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Windows/CrashReportingWindows.cpp index 5024c057beec..6cd29bb765ef 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Windows/CrashReportingWindows.cpp +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Windows/CrashReportingWindows.cpp @@ -172,6 +172,7 @@ std::vector CrashReportingWindows::GetThreadFrames(int32_t tid, Reso { stackFrame.moduleAddress = module->startAddress; stackFrame.buildId = module->buildId; + stackFrame.modulePath = module->path; std::ostringstream methodName; methodName << module->path << "!+" << std::hex << (nativeStackFrame.AddrPC.Offset - module->startAddress); diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.cpp b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.cpp index 5d4a7f569ec1..b4b3c7104970 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.cpp +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.cpp @@ -260,11 +260,15 @@ int32_t CrashReporting::ResolveStacks(int32_t crashingThreadId, ResolveManagedCa CHECK_RESULT(ddog_crasht_StackFrame_with_sp(&frame, currentFrame.sp)); CHECK_RESULT(ddog_crasht_StackFrame_with_module_base_address(&frame, currentFrame.moduleAddress)); CHECK_RESULT(ddog_crasht_StackFrame_with_relative_address(&frame, relativeAddress)); - CHECK_RESULT(ddog_crasht_StackFrame_with_symbol_address(&frame, currentFrame.symbolAddress)); + if (!currentFrame.modulePath.empty()) + { + CHECK_RESULT(ddog_crasht_StackFrame_with_path(&frame, {currentFrame.modulePath.data(), currentFrame.modulePath.size()})); + } + auto buildId = currentFrame.buildId; - if (buildId.size() != 0) + if (!buildId.empty()) { CHECK_RESULT(ddog_crasht_StackFrame_with_build_id(&frame, {buildId.data(), buildId.size()})); #ifdef _WINDOWS diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.h b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.h index 3a29d3ca83fb..fe89cd598980 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.h +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/CrashReporting.h @@ -78,6 +78,7 @@ struct StackFrame uint64_t moduleAddress; bool isSuspicious; std::string_view buildId; + std::string_view modulePath; }; struct Tag From 5e300de47dc6ece48c0eedf87a7ed1a9e5acffef Mon Sep 17 00:00:00 2001 From: Gregory LEOCADIE Date: Fri, 10 Oct 2025 15:33:31 +0200 Subject: [PATCH 2/2] Update test --- .../CreatedumpTests.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/CreatedumpTests.cs b/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/CreatedumpTests.cs index aa6460ee266a..0b1e680c9454 100644 --- a/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/CreatedumpTests.cs +++ b/tracer/test/Datadog.Trace.Tools.dd_dotnet.ArtifactTests/CreatedumpTests.cs @@ -630,9 +630,15 @@ void ValidateStacktrace(JToken callstack) foreach (var frame in frames) { - var moduleName = frame["function"].Value().Split('!').First(); + string moduleName = null; - if (moduleName.Length > 0 && !moduleName.StartsWith("<") && Path.IsPathRooted(moduleName)) + // we do not set the path for managed assemblies. + if (frame.ContainsKey("path")) + { + moduleName = frame["path"].Value(); + } + + if (!string.IsNullOrEmpty(moduleName) && !moduleName.StartsWith("<") && Path.IsPathRooted(moduleName)) { if (!validatedModules.Add(moduleName)) {