Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows arm64 support #1050

Open
adamsitnik opened this issue Dec 1, 2022 · 5 comments
Open

Windows arm64 support #1050

adamsitnik opened this issue Dec 1, 2022 · 5 comments

Comments

@adamsitnik
Copy link
Member

adamsitnik commented Dec 1, 2022

Are there any plans for adding Windows arm64 support?

Currently I can't attach to an arm64 process on Windows due to missing DAC.

Context: we have recently implemented an arm64 disassembler for BenchmarkDotNet and it works great on Linux, but does not on Windows. It would be nice to have it working too.

@leculver
Copy link
Contributor

leculver commented Dec 7, 2022

What's the error you are getting? AFAIK this should work, but I don't have an arm64 machine handy. All of the requisite pieces should be there, but I've never tested it.

@adamsitnik
Copy link
Member Author

System.IO.FileNotFoundException: 'Could not find matching DAC for this runtime.'
   at Microsoft.Diagnostics.Runtime.ClrInfo.CreateRuntime()

@leculver
Copy link
Contributor

Sorry, I've been heads down for the last few weeks. I'm now a bit more free to look at issues.

System.IO.FileNotFoundException: 'Could not find matching DAC for this runtime.'
   at Microsoft.Diagnostics.Runtime.ClrInfo.CreateRuntime()

If this is a crash dump, can you please share it with me offline?

I assume this is a live process though, right? Is there an Arm64 machine you can share credentials with me (offline) so I can go investigate this with a debugger?

@k15tfu
Copy link
Contributor

k15tfu commented Sep 7, 2023

@leculver Hi! I faced with the same issue, this happens because of:

public Architecture Architecture => IntPtr.Size == 4 ? Architecture.X86 : Architecture.X64;

, so the corresponding DebugLibraryInfo for shared\Microsoft.NETCore.App\7.0.10\mscordaccore.dll has TargetArchitecture which is equal to Amd64:

artifacts.Insert(0, dacLibraryInfo);

Besides, looks like WindowsProcessDataReader.GetThreadContext() should also support ARM64Context:

public bool GetThreadContext(uint threadID, uint contextFlags, Span<byte> context)
{
// We need to set the ContextFlags field to be the value of contextFlags. For AMD64, that field is
// at offset 0x30. For all other platforms that field is at offset 0. We test here whether the context
// is large enough to write the flags and then assign the value based on the architecture's offset.
bool amd64 = Architecture == Architecture.X64;
if (context.Length < 4 || (amd64 && context.Length < 0x34))
return false;
if (amd64)
{
fixed (byte* ptr = context)
{
AMD64Context* ctx = (AMD64Context*)ptr;
ctx->ContextFlags = contextFlags;
}
}
else
{
fixed (byte* ptr = context)
{
uint* intPtr = (uint*)ptr;
*intPtr = contextFlags;
}
}

Please tell me if you need anything else.

@leculver
Copy link
Contributor

leculver commented Sep 7, 2023

Thank you! This is extremely helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants