J
John Riggs
Hi,
I've been attempting to use StackWalk64 on IA64. Unfortunately, the
Microsoft docs seem to be rather vague as to what is required. My test
program works on the I386, but won't not on the IA64.
On the IA64 the StackWalk64 returns true, so the call thinks it
succeeded. But the resulting StackFrame64 does not have correct data,
and further calls to StackWalk64 return false.
Has anybody gotten this to work that might be able to provide me
with some pointers as to what I am doing wrong? My code is posted
below. I've tried lots of different code hacks to get this to work,
but nothing is helping. I suspect that the thread context is what is
throwing me off, but I've exhausted my leads to track this down.
Thanks,
John
void StackTrace()
{
int success = 0;
HANDLE hThread = GetCurrentThread();
HANDLE hProcess = GetCurrentProcess();
CONTEXT context;
memset (&context, 0, sizeof(context));
context.ContextFlags = CONTEXT_CONTROL;
success = GetThreadContext(hThread, &context);
STACKFRAME64 stackFrame;
memset (&stackFrame, 0, sizeof(stackFrame));
stackFrame.AddrPC.Offset = context.StIIP;
stackFrame.AddrPC.Mode = AddrModeFlat;
stackFrame.AddrStack.Offset = context.IntSp;
stackFrame.AddrStack.Mode = AddrModeFlat;
stackFrame.AddrBStore.Offset = context.RsBSP;
stackFrame.AddrBStore.Mode = AddrModeFlat;
DWORD machineType = IMAGE_FILE_MACHINE_IA64;
while (success)
{
success = StackWalk64(machineType, hProcess, hThread,
&stackFrame, &context, NULL, NULL, NULL, NULL);
printf ("%#08x, %#08x\n", (unsigned int)stackFrame.AddrReturn.Offset,
(unsigned int)stackFrame.AddrPC.Offset);
}
}
I've been attempting to use StackWalk64 on IA64. Unfortunately, the
Microsoft docs seem to be rather vague as to what is required. My test
program works on the I386, but won't not on the IA64.
On the IA64 the StackWalk64 returns true, so the call thinks it
succeeded. But the resulting StackFrame64 does not have correct data,
and further calls to StackWalk64 return false.
Has anybody gotten this to work that might be able to provide me
with some pointers as to what I am doing wrong? My code is posted
below. I've tried lots of different code hacks to get this to work,
but nothing is helping. I suspect that the thread context is what is
throwing me off, but I've exhausted my leads to track this down.
Thanks,
John
void StackTrace()
{
int success = 0;
HANDLE hThread = GetCurrentThread();
HANDLE hProcess = GetCurrentProcess();
CONTEXT context;
memset (&context, 0, sizeof(context));
context.ContextFlags = CONTEXT_CONTROL;
success = GetThreadContext(hThread, &context);
STACKFRAME64 stackFrame;
memset (&stackFrame, 0, sizeof(stackFrame));
stackFrame.AddrPC.Offset = context.StIIP;
stackFrame.AddrPC.Mode = AddrModeFlat;
stackFrame.AddrStack.Offset = context.IntSp;
stackFrame.AddrStack.Mode = AddrModeFlat;
stackFrame.AddrBStore.Offset = context.RsBSP;
stackFrame.AddrBStore.Mode = AddrModeFlat;
DWORD machineType = IMAGE_FILE_MACHINE_IA64;
while (success)
{
success = StackWalk64(machineType, hProcess, hThread,
&stackFrame, &context, NULL, NULL, NULL, NULL);
printf ("%#08x, %#08x\n", (unsigned int)stackFrame.AddrReturn.Offset,
(unsigned int)stackFrame.AddrPC.Offset);
}
}