Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tracer/src/Datadog.Tracer.Native/cor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un
return E_FAIL;
}

// CallSite stuff
// Legacy callSite stuff
if (!IsCallSiteManagedActivationEnabled())
{
Logger::Info("Callsite managed activation is disabled.");
Expand Down Expand Up @@ -1301,8 +1301,6 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Shutdown()
rejit_handler = nullptr;
}

DEL(_dataflow);

auto definitions = definitions_ids.Get();

Logger::Info("Exiting...");
Expand Down Expand Up @@ -2072,10 +2070,12 @@ long CorProfiler::DisableCallTargetDefinitions(UINT32 disabledCategories)
int CorProfiler::RegisterIastAspects(WCHAR** aspects, int aspectsLength, UINT32 enabledCategories, UINT32 platform)
{
auto _ = trace::Stats::Instance()->InitializeProfilerMeasure();
auto definitions = definitions_ids.Get(); // Synchronize Aspects loading

auto dataflow = _dataflow;
if (dataflow == nullptr && IsCallSiteManagedActivationEnabled())
{
Logger::Debug("Creating Dataflow.");
dataflow = new iast::Dataflow(info_, rejit_handler, runtime_information_);
}

Expand All @@ -2090,6 +2090,7 @@ int CorProfiler::RegisterIastAspects(WCHAR** aspects, int aspectsLength, UINT32
{
Logger::Info("Callsite instrumentation is disabled.");
}

return 0;
}

Expand Down
47 changes: 5 additions & 42 deletions tracer/src/Datadog.Tracer.Native/iast/dataflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,15 @@ Dataflow::Dataflow(ICorProfilerInfo* profiler, std::shared_ptr<RejitHandler> rej

Dataflow::~Dataflow()
{
_initialized = false;
REL(_profiler);
DEL_MAP_VALUES(_modules);
DEL_MAP_VALUES(_appDomains);
DEL_MAP_VALUES(_moduleAspects);
}

void Dataflow::LoadAspects(WCHAR** aspects, int aspectsLength, UINT32 enabledCategories, UINT32 platform)
{
if (!_initialized)
{
_initialized = true;
CSGUARD(_cs);

if (_aspects.size() == 0)
{
// Init aspects
DBG("Dataflow::LoadAspects -> Processing aspects... ", aspectsLength, " Enabled categories: ", enabledCategories, " Platform: ", platform);

Expand Down Expand Up @@ -369,11 +365,6 @@ void Dataflow::LoadSecurityControls()

HRESULT Dataflow::AppDomainShutdown(AppDomainID appDomainId)
{
if (!_initialized)
{
return S_OK;
}

CSGUARD(_cs);
auto it = _appDomains.find(appDomainId);
if (it != _appDomains.end())
Expand All @@ -388,22 +379,12 @@ HRESULT Dataflow::AppDomainShutdown(AppDomainID appDomainId)

HRESULT Dataflow::ModuleLoaded(ModuleID moduleId, ModuleInfo** pModuleInfo)
{
if (!_initialized)
{
return S_OK;
}

GetModuleInfo(moduleId);
return S_OK;
}

HRESULT Dataflow::ModuleUnloaded(ModuleID moduleId)
{
if (!_initialized)
{
return S_OK;
}

CSGUARD(_cs);
{
auto it = _moduleAspects.find(moduleId);
Expand Down Expand Up @@ -608,6 +589,7 @@ ModuleInfo* Dataflow::GetAspectsModule(AppDomainID id)

MethodInfo* Dataflow::GetMethodInfo(ModuleID moduleId, mdMethodDef methodId)
{
CSGUARD(_cs);
auto module = GetModuleInfo(moduleId);
if (module)
{
Expand All @@ -618,11 +600,6 @@ MethodInfo* Dataflow::GetMethodInfo(ModuleID moduleId, mdMethodDef methodId)

bool Dataflow::IsInlineEnabled(ModuleID calleeModuleId, mdToken calleeMethodId)
{
if (!_initialized)
{
return true;
}

auto method = JITProcessMethod(calleeModuleId, calleeMethodId);
if (method)
{
Expand All @@ -632,21 +609,12 @@ bool Dataflow::IsInlineEnabled(ModuleID calleeModuleId, mdToken calleeMethodId)
}
bool Dataflow::JITCompilationStarted(ModuleID moduleId, mdToken methodId)
{
if (!_initialized)
{
return false;
}

auto method = JITProcessMethod(moduleId, methodId);
return method != nullptr;
}
MethodInfo* Dataflow::JITProcessMethod(ModuleID moduleId, mdToken methodId, trace::FunctionControlWrapper* pFunctionControl)
{
if (!_initialized)
{
return nullptr;
}

CSGUARD(_cs);
MethodInfo* method = nullptr;
auto module = GetModuleInfo(moduleId);
if (module && !module->IsExcluded())
Expand Down Expand Up @@ -783,11 +751,6 @@ void Dataflow::AddNGenInlinerModule(ModuleID moduleId)

HRESULT Dataflow::RejitMethod(trace::FunctionControlWrapper& functionControl)
{
if (!_initialized)
{
return S_FALSE;
}

auto method = JITProcessMethod(functionControl.GetModuleId(), functionControl.GetMethodId(), &functionControl);
if (method && method->IsWritten())
{
Expand Down
1 change: 0 additions & 1 deletion tracer/src/Datadog.Tracer.Native/iast/dataflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ namespace iast

void LoadSecurityControls();
protected:
bool _initialized = false;
bool _setILOnJit = false;

std::vector<DataflowAspectClass*> _aspectClasses;
Expand Down
Loading