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

[Profiler] Fix Windows 64 bit stack walking #6583

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ bool Windows64BitStackFramesCollector::TryGetThreadStackBoundaries(HANDLE thread
return false;
}

BOOL GetThreadInfo(ManagedThreadInfo* pThreadInfo, CONTEXT& context, HANDLE& handle)
{
if (pThreadInfo == nullptr)
{
::RtlCaptureContext(&context);
handle = ::GetCurrentThread();
return TRUE;
}

handle = pThreadInfo->GetOsThreadHandle();
return ::GetThreadContext(handle, &context);
}

StackSnapshotResultBuffer* Windows64BitStackFramesCollector::CollectStackSampleImplementation(ManagedThreadInfo* pThreadInfo,
uint32_t* pHR,
bool selfCollect)
Expand All @@ -188,7 +175,18 @@ StackSnapshotResultBuffer* Windows64BitStackFramesCollector::CollectStackSampleI
CONTEXT context;
context.ContextFlags = CONTEXT_FULL;
HANDLE handle;
BOOL hasInfo = GetThreadInfo(selfCollect ? nullptr : pThreadInfo, context, handle);
BOOL hasInfo = false;
if (selfCollect || (pThreadInfo == nullptr)) // TODO: handle pThreadInfo == nullptr and selfCollect == false
{
::RtlCaptureContext(&context);
handle = ::GetCurrentThread();
hasInfo = TRUE;
}
else
{
handle = pThreadInfo->GetOsThreadHandle();
hasInfo = ::GetThreadContext(handle, &context);
}

if (!hasInfo)
{
Expand Down
Loading