Skip to content

Commit 8c28d62

Browse files
committed
Debugging event emission
1 parent 10b7e42 commit 8c28d62

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
let Microsoft_Windows_DotNETRuntime_flags = new_dotnet_provider_flags();
2-
record_dotnet_provider("Microsoft-Windows-DotNETRuntime", 0x80000000000, 4, Microsoft_Windows_DotNETRuntime_flags);
2+
record_dotnet_provider("Microsoft-Windows-DotNETRuntime", 0x80000000001, 4, Microsoft_Windows_DotNETRuntime_flags);

src/tests/tracing/eventpipe/userevents/userevents.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ public static int TestEntryPoint()
5252
return -1;
5353
}
5454

55-
string traceFilePath = Path.GetTempFileName();
56-
File.Delete(traceFilePath); // record-trace requires the output file to not exist
57-
traceFilePath = Path.ChangeExtension(traceFilePath, ".nettrace");
55+
string traceFilePath = Path.Combine(appBaseDir, "trace.nettrace"); // Path.GetTempFileName();
56+
string helixWorkItemDirectory = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
57+
if (helixWorkItemDirectory != null && Directory.Exists(helixWorkItemDirectory))
58+
{
59+
traceFilePath = Path.Combine(helixWorkItemDirectory, "trace.nettrace");
60+
}
61+
// File.Delete(traceFilePath); // record-trace requires the output file to not exist
62+
// traceFilePath = Path.ChangeExtension(traceFilePath, ".nettrace");
5863

5964
ProcessStartInfo recordTraceStartInfo = new();
6065
recordTraceStartInfo.FileName = "sudo";
@@ -112,7 +117,7 @@ public static int TestEntryPoint()
112117
traceeProcess.BeginErrorReadLine();
113118

114119
Console.WriteLine($"Waiting for tracee process to exit...");
115-
if (!traceeProcess.HasExited && !traceeProcess.WaitForExit(5000))
120+
if (!traceeProcess.HasExited && !traceeProcess.WaitForExit(15000))
116121
{
117122
Console.WriteLine($"Tracee process did not exit within the 5s timeout, killing it.");
118123
traceeProcess.Kill();
@@ -125,7 +130,7 @@ public static int TestEntryPoint()
125130
Console.WriteLine($"Stopping record-trace with SIGINT.");
126131
Kill(recordTraceProcess.Id, SIGINT);
127132
Console.WriteLine($"Waiting for record-trace to exit...");
128-
if (!recordTraceProcess.WaitForExit(20000))
133+
if (!recordTraceProcess.WaitForExit(30000))
129134
{
130135
// record-trace needs to stop gracefully to generate the trace file
131136
Console.WriteLine($"record-trace did not exit within the 20s timeout, killing it.");
@@ -147,7 +152,7 @@ public static int TestEntryPoint()
147152
if (!ValidateTraceeEvents(traceFilePath))
148153
{
149154
Console.Error.WriteLine($"Trace file `{traceFilePath}` does not contain expected events.");
150-
UploadTraceFile(traceFilePath);
155+
// UploadTraceFile(traceFilePath);
151156
return -1;
152157
}
153158

@@ -157,21 +162,32 @@ public static int TestEntryPoint()
157162
private static bool ValidateTraceeEvents(string traceFilePath)
158163
{
159164
using EventPipeEventSource source = new EventPipeEventSource(traceFilePath);
165+
bool startEventFound = false;
166+
bool stopEventFound = false;
160167
bool allocationSampledEventFound = false;
161168

162169
source.Dynamic.All += (TraceEvent e) =>
163170
{
164171
if (e.ProviderName == "Microsoft-Windows-DotNETRuntime")
165172
{
166-
if (e.EventName == "AllocationSampled" || (e.ID == (TraceEventID)303 && e.EventName.StartsWith("Unknown")))
173+
Console.WriteLine($"Event: {e.ProviderName} - {e.EventName} (ID: {e.ID})");
174+
if (e.EventName == "GC/Start" || (e.ID == (TraceEventID)1 && e.EventName.StartsWith("Unknown")))
175+
{
176+
startEventFound = true;
177+
}
178+
else if (e.EventName == "GC/Stop" || (e.ID == (TraceEventID)2 && e.EventName.StartsWith("Unknown")))
179+
{
180+
stopEventFound = true;
181+
}
182+
else if (e.EventName == "AllocationSampled" || (e.ID == (TraceEventID)303 && e.EventName.StartsWith("Unknown")))
167183
{
168184
allocationSampledEventFound = true;
169185
}
170186
}
171187
};
172188

173189
source.Process();
174-
return allocationSampledEventFound;
190+
return startEventFound && stopEventFound && allocationSampledEventFound;
175191
}
176192

177193
private static void UploadTraceFile(string traceFilePath)

src/tests/tracing/eventpipe/userevents/usereventstracee.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ public class UserEventsTracee
1414
public static void Run()
1515
{
1616
long startTimestamp = Stopwatch.GetTimestamp();
17-
long targetTicks = Stopwatch.Frequency; // 1s
17+
long targetTicks = Stopwatch.Frequency * 10; // 10s
1818

1919
while (Stopwatch.GetTimestamp() - startTimestamp < targetTicks)
2020
{
2121
s_array = new byte[1024 * 100];
22+
GC.Collect(2);
2223
Thread.Sleep(100);
2324
}
2425
}

0 commit comments

Comments
 (0)