Compare commits

...

2 Commits

Author SHA1 Message Date
Cornelius Riemenschneider
996990f58a C#: DO NOT MERGE YET! Disable the CLR tracer. 2021-09-09 17:21:25 +00:00
Cornelius Riemenschneider
bdfd651e71 C#: Add experimental lua-based tracing config. 2021-09-09 17:21:08 +00:00
2 changed files with 80 additions and 6 deletions

View File

@@ -4,12 +4,6 @@ version: 1.22.1
column_kind: "utf16"
extra_env_vars:
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
COR_ENABLE_PROFILING: "1"
COR_PROFILER: "{A3C70A64-7D41-4A94-A3F6-FD47D9259997}"
COR_PROFILER_PATH_64: "${env.CODEQL_EXTRACTOR_CSHARP_ROOT}/tools/${env.CODEQL_PLATFORM}/clrtracer64${env.CODEQL_PLATFORM_DLL_EXTENSION}"
CORECLR_ENABLE_PROFILING: "1"
CORECLR_PROFILER: "{A3C70A64-7D41-4A94-A3F6-FD47D9259997}"
CORECLR_PROFILER_PATH_64: "${env.CODEQL_EXTRACTOR_CSHARP_ROOT}/tools/${env.CODEQL_PLATFORM}/clrtracer64${env.CODEQL_PLATFORM_DLL_EXTENSION}"
file_types:
- name: cs
display_name: C# sources

View File

@@ -0,0 +1,80 @@
function RegisterExtractorPack()
local extractorDirectory = "tools" .. PathSep .. PlatformDirectory ..
PathSep
local csharpExtractor = extractorDirectory ..
'Semmle.Extraction.CSharp.Driver'
if OperatingSystem == 'windows' then
csharpExtractor = extractorDirectory ..
'Semmle.Extraction.CSharp.Driver.exe'
end
-- TODO Windows support for the entire file
-- everything here is very experimental and only a proof of concept
function DotnetMatcherBuild(compilerName, compilerPath, argv)
if compilerName ~= 'dotnet' then return nil end
-- this is probably too simplistic, but works for now
local match = false
for _, arg in ipairs(argv) do
if arg == 'build' then
match = true
break
end
end
if match then
table.insert(argv, '/p:UseSharedCompilation=false')
return {
trace = true,
replace = true,
invocations = {{path = compilerPath, argv = argv}}
}
else
return nil
end
end
function DotnetMatcherExec(compilerName, compilerPath, argv)
if compilerName ~= 'dotnet' then return nil end
-- TODO on windows this doesn't split argv correctly
local match = false
local newArgv = {'--compiler'}
for i, arg in ipairs(argv) do
-- TODO check if this is the correct regex, or if it should be more specific (and escape the dots!)
if arg:match('csc.exe') or arg:match('mcs.exe') or
arg:match('csc.dll') then
match = true
-- newArgv contains all elements of argv from i+1 to the end
table.insert(newArgv, arg)
table.insert(newArgv, '--cil')
for j = i + 1, #argv do
table.insert(newArgv, argv[j])
end
break
end
end
if match then
return {
trace = true,
replace = false,
invocations = {
{
path = GetExtractorPath('csharp', csharpExtractor),
argv = newArgv
}
}
}
else
return nil
end
end
-- TODO windows matchers patterns
local matchers = {
CreatePatternMatcher('csharp', {'^mcs.exe$', '^csc.exe$'},
MatchCompilerName, csharpExtractor,
{prepend = {'--compiler', '${compiler}', '--cil'}}),
DotnetMatcherBuild, DotnetMatcherExec
}
RegisterLanguage('csharp', matchers)
end