Skip to content

Commit

Permalink
see more stuff...
Browse files Browse the repository at this point in the history
  • Loading branch information
cnkz committed Jan 10, 2024
1 parent d53ba9d commit 5ced3d3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/ManagedObjectSize.Tests/ObjectSizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,7 @@ public static unsafe IEnumerable<object[]> GetTestObjects()
return result;
}

[DllImport("libc")]
private static extern int prctl(int option, UIntPtr arg2, UIntPtr arg3, UIntPtr arg4, UIntPtr arg5);
private const int PR_SET_PTRACER = 0x59616d61;

public TestContext TestContext { get; set; } = null!;

[TestMethod]
[DynamicData(nameof(GetTestObjects), DynamicDataSourceType.Method)]
Expand All @@ -376,16 +373,22 @@ public unsafe void ObjectSize_ReportsCorrectSize(bool useRtHelpers, bool useObje

GetSize(options, name, obj, data);

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
prctl(PR_SET_PTRACER, (UIntPtr)Environment.ProcessId, UIntPtr.Zero, UIntPtr.Zero, UIntPtr.Zero);
}

using (var dt = DataTarget.CreateSnapshotAndAttach(Environment.ProcessId))
{
// Got the snapshot. Release GC.
GC.EndNoGCRegion();

TestContext.WriteLine("ObjectSize: starting");
TestContext.WriteLine("ObjectSize: PointerSize " + dt.DataReader.PointerSize);
TestContext.WriteLine("ObjectSize: Architecture " + dt.DataReader.Architecture);
TestContext.WriteLine("ObjectSize: DisplayName " + dt.DataReader.DisplayName);

foreach (var x in dt.ClrVersions)
{
TestContext.WriteLine("ObjectSize: " + x.Version);
}
TestContext.WriteLine("ObjectSize: complete");

using (var runtime = dt.ClrVersions.Single().CreateRuntime())
{
#if false
Expand Down

0 comments on commit 5ced3d3

Please sign in to comment.