diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/CMakeLists.txt b/src/OpenTelemetry.AutoInstrumentation.Native/CMakeLists.txt
index 535dcc10b3..28593fc970 100644
--- a/src/OpenTelemetry.AutoInstrumentation.Native/CMakeLists.txt
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/CMakeLists.txt
@@ -168,6 +168,8 @@ endif()
add_library("OpenTelemetry.AutoInstrumentation.Native.static" STATIC
class_factory.cpp
clr_helpers.cpp
+ continuous_profiler_clr_helpers.cpp
+ continuous_profiler.cpp
cor_profiler_base.cpp
cor_profiler.cpp
il_rewriter_wrapper.cpp
diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.def b/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.def
index 09ba4f7371..8b60f1af11 100644
--- a/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.def
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.def
@@ -7,3 +7,7 @@ EXPORTS
IsProfilerAttached
AddInstrumentations
AddDerivedInstrumentations
+ ConfigureContinuousProfiler
+ ContinuousProfilerReadThreadSamples
+ ContinuousProfilerReadAllocationSamples
+ ContinuousProfilerSetNativeContext
diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.vcxproj b/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.vcxproj
index d5d1c3f994..6953fc9394 100644
--- a/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.vcxproj
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/OpenTelemetry.AutoInstrumentation.Native.vcxproj
@@ -186,6 +186,8 @@
+
+
@@ -220,6 +222,8 @@
+
+
diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.cpp
index 77379e8c54..3d9d10ab28 100644
--- a/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.cpp
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.cpp
@@ -487,6 +487,13 @@ WSTRING GetSigTypeTokName(PCCOR_SIGNATURE& pbCur, const ComPtr
ref_flag = true;
}
+ bool pointer_flag = false;
+ if (*pbCur == ELEMENT_TYPE_PTR)
+ {
+ pbCur++;
+ pointer_flag = true;
+ }
+
switch (*pbCur)
{
case ELEMENT_TYPE_BOOLEAN:
@@ -610,6 +617,12 @@ WSTRING GetSigTypeTokName(PCCOR_SIGNATURE& pbCur, const ComPtr
{
tokenName += WStr("&");
}
+
+ if (pointer_flag)
+ {
+ tokenName += WStr("*");
+ }
+
return tokenName;
}
@@ -856,6 +869,9 @@ bool ParseParamOrLocal(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd)
if (*pbCur == ELEMENT_TYPE_BYREF)
pbCur++;
+ if (*pbCur == ELEMENT_TYPE_PTR)
+ pbCur++;
+
return ParseType(pbCur, pbEnd);
}
diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.h b/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.h
index af9ec64aa9..82fb47043a 100644
--- a/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.h
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/clr_helpers.h
@@ -629,6 +629,28 @@ HRESULT GetCorLibAssemblyRef(const ComPtr& assembly_emit,
bool FindTypeDefByName(const trace::WSTRING instrumentationTargetMethodTypeName, const trace::WSTRING assemblyName,
const ComPtr& metadata_import, mdTypeDef& typeDef);
+
+// FunctionMethodSignature
+bool ParseByte(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd, unsigned char* pbOut);
+bool ParseNumber(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd, unsigned* pOut);
+bool ParseTypeDefOrRefEncoded(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd, unsigned char* pIndexTypeOut,
+ unsigned* pIndexOut);
+
+/* we don't support
+ PTR CustomMod* VOID
+ PTR CustomMod* Type
+ FNPTR MethodDefSig
+ FNPTR MethodRefSig
+ ARRAY Type ArrayShape
+ SZARRAY CustomMod+ Type (but we do support SZARRAY Type)
+ */
+bool ParseType(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd);
+// Param ::= CustomMod* ( TYPEDBYREF | [BYREF] Type )
+// CustomMod* TYPEDBYREF we don't support
+bool ParseParamOrLocal(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd);
+// RetType ::= CustomMod* ( VOID | TYPEDBYREF | [BYREF] Type )
+// CustomMod* TYPEDBYREF we don't support
+bool ParseRetType(PCCOR_SIGNATURE& pbCur, PCCOR_SIGNATURE pbEnd);
} // namespace trace
#endif // OTEL_CLR_PROFILER_CLR_HELPERS_H_
diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/continuous_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/continuous_profiler.cpp
new file mode 100644
index 0000000000..ad4e30b071
--- /dev/null
+++ b/src/OpenTelemetry.AutoInstrumentation.Native/continuous_profiler.cpp
@@ -0,0 +1,1076 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+// We want to use std::min, not the windows.h macro
+#define NOMINMAX
+#include "continuous_profiler.h"
+#include "logger.h"
+#include
+#include