簡體   English   中英

如何使用 windbg 檢查堆轉儲中 static thread_local 變量的內容?

[英]How can I inspect the contents of a static thread_local variable on a heap dump with windbg?

給定以下源代碼:

namespace EventThreadLocal {

  static thread_local std::unique_ptr<std::vector<EventInfo>> Stack;

  static const EventInfo* Top()
  {
    auto stack = Stack.get();
    if (!stack)
      return nullptr;
    if (stack->empty())
      return nullptr;

    return &(stack->back());
  }
}

如何檢查堆轉儲中 static thread_local 變量 Stack 的內容?

我的理解是命令,tls 顯示線程本地存儲槽? 但是我怎么知道這個變量使用的合適的槽索引呢?

您不需要知道與static thread_local變量關聯的 TLS 插槽,調試器已經使用x命令解決了該問題。 請參見下面的示例 output, xStack解析為 WinDbg 中不同線程的不同地址。

0:000> x test_exe!Stack
00000296`a5437410 test_exe!Stack = empty
0:000>~1s
0:001> x test_exe!stack
00000296`a543e230 test_exe!Stack = empty

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM