Skip to content

Commit 8009551

Browse files
author
Max Charlamb
committed
remove unwinders so cross platforms can build correctly
1 parent da73082 commit 8009551

3 files changed

Lines changed: 23 additions & 125 deletions

File tree

src/coreclr/unwinder/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ function(create_platform_unwinder)
104104
# target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE SELF_NO_HOST)
105105
endfunction()
106106

107-
create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
108-
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
107+
# create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
108+
# create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)

src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs

Lines changed: 19 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -187,137 +187,35 @@ internal static unsafe partial class Unwinder
187187
// If the moduleBase or funcEntry can not be found, both will be 0.
188188
public delegate void GetStackWalkInfo(ulong controlPC, void* pModuleBase, void* pFuncEntry);
189189

190-
[LibraryImport("unwinder_cdac_arm64", EntryPoint = "arm64Unwind")]
191-
private static partial int ARM64Unwind(
192-
ref ARM64Context context,
193-
[MarshalAs(UnmanagedType.FunctionPtr)] ReadCallback readCallback,
194-
[MarshalAs(UnmanagedType.FunctionPtr)] GetAllocatedBuffer getAllocatedBuffer,
195-
[MarshalAs(UnmanagedType.FunctionPtr)] GetStackWalkInfo getStackWalkInfo);
196-
197-
[LibraryImport("unwinder_cdac_amd64", EntryPoint = "amd64Unwind")]
198-
private static partial int AMD64Unwind(
199-
ref AMD64Context context,
200-
[MarshalAs(UnmanagedType.FunctionPtr)] ReadCallback readCallback,
201-
[MarshalAs(UnmanagedType.FunctionPtr)] GetAllocatedBuffer getAllocatedBuffer,
202-
[MarshalAs(UnmanagedType.FunctionPtr)] GetStackWalkInfo getStackWalkInfo);
190+
// [LibraryImport("unwinder_cdac_arm64", EntryPoint = "arm64Unwind")]
191+
// private static partial int ARM64Unwind(
192+
// ref ARM64Context context,
193+
// [MarshalAs(UnmanagedType.FunctionPtr)] ReadCallback readCallback,
194+
// [MarshalAs(UnmanagedType.FunctionPtr)] GetAllocatedBuffer getAllocatedBuffer,
195+
// [MarshalAs(UnmanagedType.FunctionPtr)] GetStackWalkInfo getStackWalkInfo);
196+
197+
// [LibraryImport("unwinder_cdac_amd64", EntryPoint = "amd64Unwind")]
198+
// private static partial int AMD64Unwind(
199+
// ref AMD64Context context,
200+
// [MarshalAs(UnmanagedType.FunctionPtr)] ReadCallback readCallback,
201+
// [MarshalAs(UnmanagedType.FunctionPtr)] GetAllocatedBuffer getAllocatedBuffer,
202+
// [MarshalAs(UnmanagedType.FunctionPtr)] GetStackWalkInfo getStackWalkInfo);
203203

204204
public static int AMD64Unwind(
205205
ref AMD64Context context,
206206
Target target)
207207
{
208-
ReadCallback readCallback;
209-
GetAllocatedBuffer getAllocatedBuffer;
210-
GetStackWalkInfo getStackWalkInfo;
211-
212-
// Move to IDisposable for freeing
213-
List<IntPtr> allocatedRegions = [];
214-
215-
readCallback = (address, pBuffer, bufferSize) =>
216-
{
217-
Span<byte> span = new Span<byte>(pBuffer, bufferSize);
218-
target.ReadBuffer(address, span);
219-
return 0;
220-
};
221-
getAllocatedBuffer = (bufferSize, ppBuffer) =>
222-
{
223-
*ppBuffer = NativeMemory.Alloc((nuint)bufferSize);
224-
IntPtr pBuffer = new(*ppBuffer);
225-
//Console.WriteLine($"Allocating buffer at {pBuffer:x16}");
226-
allocatedRegions.Add(pBuffer);
227-
return 0;
228-
};
229-
getStackWalkInfo = (controlPC, pModuleBase, pFuncEntry) =>
230-
{
231-
IExecutionManager eman = target.Contracts.ExecutionManager;
232-
233-
if ((nuint)pModuleBase != 0) *(nuint*)pModuleBase = 0;
234-
if ((nuint)pFuncEntry != 0) *(nuint*)pFuncEntry = 0;
235-
236-
try
237-
{
238-
if (eman.GetCodeBlockHandle(controlPC) is CodeBlockHandle cbh)
239-
{
240-
TargetPointer methodDesc = eman.GetMethodDesc(cbh);
241-
TargetPointer moduleBase = eman.GetModuleBaseAddress(cbh);
242-
TargetPointer unwindInfo = eman.GetUnwindInfo(cbh, controlPC);
243-
if ((nuint)pModuleBase != 0) *(nuint*)pModuleBase = (nuint)moduleBase.Value;
244-
if ((nuint)pFuncEntry != 0) *(nuint*)pFuncEntry = (nuint)unwindInfo.Value;
245-
}
246-
}
247-
catch (System.Exception ex)
248-
{
249-
Console.WriteLine($"GetStackWalkInfo failed: {ex}");
250-
}
251-
};
252-
253-
int ret = AMD64Unwind(ref context, readCallback, getAllocatedBuffer, getStackWalkInfo);
254-
255-
foreach (IntPtr ptr in allocatedRegions)
256-
{
257-
//Console.WriteLine($"Freeing buffer at {ptr:x16}");
258-
NativeMemory.Free(ptr.ToPointer());
259-
}
260-
261-
return ret;
208+
Console.WriteLine(context);
209+
Console.WriteLine(target.PointerSize);
210+
return 1;
262211
}
263212

264213
public static int ARM64Unwind(
265214
ref ARM64Context context,
266215
Target target)
267216
{
268-
ReadCallback readCallback;
269-
GetAllocatedBuffer getAllocatedBuffer;
270-
GetStackWalkInfo getStackWalkInfo;
271-
272-
// Move to IDisposable for freeing
273-
List<IntPtr> allocatedRegions = [];
274-
275-
readCallback = (address, pBuffer, bufferSize) =>
276-
{
277-
Span<byte> span = new Span<byte>(pBuffer, bufferSize);
278-
target.ReadBuffer(address, span);
279-
return 0;
280-
};
281-
getAllocatedBuffer = (bufferSize, ppBuffer) =>
282-
{
283-
*ppBuffer = NativeMemory.Alloc((nuint)bufferSize);
284-
IntPtr pBuffer = new(*ppBuffer);
285-
//Console.WriteLine($"Allocating buffer at {pBuffer:x16}");
286-
allocatedRegions.Add(pBuffer);
287-
return 0;
288-
};
289-
getStackWalkInfo = (controlPC, pModuleBase, pFuncEntry) =>
290-
{
291-
IExecutionManager eman = target.Contracts.ExecutionManager;
292-
293-
if ((nuint)pModuleBase != 0) *(nuint*)pModuleBase = 0;
294-
if ((nuint)pFuncEntry != 0) *(nuint*)pFuncEntry = 0;
295-
296-
try
297-
{
298-
if (eman.GetCodeBlockHandle(controlPC) is CodeBlockHandle cbh)
299-
{
300-
TargetPointer methodDesc = eman.GetMethodDesc(cbh);
301-
TargetPointer moduleBase = eman.GetModuleBaseAddress(cbh);
302-
TargetPointer unwindInfo = eman.GetUnwindInfo(cbh, controlPC);
303-
if ((nuint)pModuleBase != 0) *(nuint*)pModuleBase = (nuint)moduleBase.Value;
304-
if ((nuint)pFuncEntry != 0) *(nuint*)pFuncEntry = (nuint)unwindInfo.Value;
305-
}
306-
}
307-
catch (System.Exception ex)
308-
{
309-
Console.WriteLine($"GetStackWalkInfo failed: {ex}");
310-
}
311-
};
312-
313-
int ret = ARM64Unwind(ref context, readCallback, getAllocatedBuffer, getStackWalkInfo);
314-
315-
foreach (IntPtr ptr in allocatedRegions)
316-
{
317-
//Console.WriteLine($"Freeing buffer at {ptr:x16}");
318-
NativeMemory.Free(ptr.ToPointer());
319-
}
320-
321-
return ret;
217+
Console.WriteLine(context);
218+
Console.WriteLine(target.PointerSize);
219+
return 2;
322220
}
323221
}

src/native/managed/cdacreader/src/cdacreader.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<DirectPInvoke Include="unwinder_cdac_amd64" />
34+
<!-- <DirectPInvoke Include="unwinder_cdac_amd64" />
3535
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_amd64.lib" Condition="'$(TargetsWindows)' == 'true'" />
3636
<DirectPInvoke Include="unwinder_cdac_arm64" />
37-
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_arm64.lib" Condition="'$(TargetsWindows)' == 'true'" />
37+
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_arm64.lib" Condition="'$(TargetsWindows)' == 'true'" /> -->
3838
<!-- <NativeLibrary Include="unwinder_cdac_static.a" Condition="'$(TargetsWindows)' != 'true'" /> -->
3939
</ItemGroup>
4040

0 commit comments

Comments
 (0)