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
19 changes: 0 additions & 19 deletions managed/CounterStrikeSharp.API/Core/FunctionReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,6 @@ private FunctionReference(Delegate method, FunctionLifetime lifetime)

private unsafe CallbackDelegate CreateWrappedCallback()
{
var methodName = _targetMethod.Method.DeclaringType?.FullName + "." + _targetMethod.Method.Name;
var profileName = "ScriptCallback::Execute::" + _targetMethod.Method.Name;

var stackTrace = new StackTrace(2, true);
var firstUserFrame = stackTrace.GetFrames()?.FirstOrDefault(frame =>
{
var declaring = frame.GetMethod()?.DeclaringType?.FullName;
return declaring != null &&
!declaring.StartsWith("CounterStrikeSharp") &&
!declaring.Contains("SafeExecutor") &&
!declaring.Contains("FunctionReference");
});

string caller = firstUserFrame != null
? $"{firstUserFrame.GetMethod()?.DeclaringType?.FullName}.{firstUserFrame.GetMethod()?.Name} @ {firstUserFrame.GetFileName()}:{firstUserFrame.GetFileLineNumber()}"
: "Unknown (no user frame)";

Helpers.RegisterCallbackTrace(methodName, 1, profileName, caller);

return context =>
{
try
Expand Down
3 changes: 0 additions & 3 deletions managed/CounterStrikeSharp.API/Core/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@ public static class Helpers
[SecurityCritical]
[DllImport(dllPath, EntryPoint = "InvokeNative")]
public static extern void InvokeNative(IntPtr ptr);

[DllImport(dllPath, EntryPoint = "RegisterCallbackTrace")]
public static extern void RegisterCallbackTrace(string name, int count, string profile, string callerStack);
}
}
27 changes: 0 additions & 27 deletions src/scripting/callback_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,6 @@
#include "core/log.h"
#include "vprof.h"

DLL_EXPORT void RegisterCallbackTrace(const char* name, size_t count, const char* profile, const char* callerStack)
{
// Dummy logic to prevent compiler from optimizing this function away
volatile size_t hash = 5381;

if (name)
{
for (const char* c = name; *c; ++c)
hash = ((hash << 5) + hash) + *c;
}

if (profile)
{
for (const char* c = profile; *c; ++c)
hash = ((hash << 5) + hash) + *c;
}

if (callerStack)
{
for (int i = 0; callerStack[i] && i < 128; ++i)
hash ^= callerStack[i];
}

hash ^= count;
(void)hash;
}

namespace counterstrikesharp {

ScriptCallback::ScriptCallback(const char* szName) : m_root_context(fxNativeContext{})
Expand Down
Loading