当前位置:网站首页>How to use windbg check c # a thread stack size?
How to use windbg check c # a thread stack size?
2022-08-02 23:35:00 【biyusr】
Each thread has a thread environment block data structure called TEB (Thread Environment Block)
, which has a structure called NT_TIB
, which containsThe two fields are StackBase
and StackLimit
, the former is called stack base, which is the top of the stack, and the latter is called stack boundary , because the stack space grows to a small address, the so-called stack memory size can be calculated with StackBase - StackLimit
, and then we will use windbg to demonstrate it.
One: windbg demo
1. Use the !teb command
You can use windbg to debug your program directly. I just have a dump file in my hand. Let's start from the main thread here.
0:000> ~0sntdll!NtWaitForSingleObject+0x14:00007ffe`28b9fa74 c3 ret0:000> !tebTEB at 000000b4da0ae000ExceptionList: 00000000000000000StackBase: 000000b4d9fa0000StackLimit: 000000b4d9f98000SubSystemTib: 0000000000000000FiberData: 0000000000001e00ArbitraryUserPointer: 0000000000000000Self: 000000b4da0ae000EnvironmentPointer: 0000000000000000ClientId: 0000000000000c74 . 00000000000041a4RpcHandle: 0000000000000000Tls Storage: 000001f90edad1d0PEB Address: 000000b4da0ad000LastErrorValue: 0LastStatusValue: 103Count Owned Locks: 0HardErrorMode: 0
From the output, the two values are: StackBase=000000b4d9fa0000
and StackLimit=000000b4d9f98000
, then its size is 32768byte = 32k
.
0:000> ? 000000b4d9fa0000 - 000000b4d9f98000Evaluate expression: 32768 = 00000000`00008000
It should be reminded here that the memory page of the operating system is a granularity of 4k
, which means that all output results must be multiples of 4k
, such as the current stack spaceThat is 8
memory pages.
2. View the NT_TIB
structure
The shortcut command was used just now. Next, we directly view the NT_TIB
struct structure variable under the _TEB structure.
0:000> .threadImplicit thread is now 000000b4`da0ae0000:000> dt _NT_TIB 000000b4`da0ae000combase!_NT_TIB+0x000 ExceptionList : (null)+0x008 StackBase : 0x000000b4`d9fa0000 Void+0x010 StackLimit : 0x000000b4`d9f98000 Void+0x018 SubSystemTib : (null)+0x020 FiberData : 0x00000000`00001e00 Void+0x020 Version : 0x1e00+0x028 ArbitraryUserPointer: (null)+0x030 Self : 0x000000b4`da0ae000 _NT_TIB
As you can see, the above two values are exactly the same as those displayed by !teb
.
边栏推荐
- OP-5,输入/输出信号范围-一信号处理能力
- Xcode13.1运行工程报错fatal error: ‘IFlyMSC/IFly.h‘ file not found的问题
- go——垃圾回收机制(GC)
- Flutter with internationalized adapter automatically generated
- 李沐动手学深度学习V2-BERT预训练和代码实现
- Day35 LeetCode
- 基本语法(三)
- 新增指令 v-memo
- The so-called fighting skill again gao also afraid of the chopper - partition, depots, table, and the merits of the distributed
- Parse common methods in the Collection interface that are overridden by subclasses
猜你喜欢
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)
Thread线程类基本使用(下)
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
信息学奥赛一本通(1259:【例9.3】求最长不下降序列)
实现fashion_minst服装图像分类
Parse the commonly used methods in the List interface that are overridden by subclasses
Leetcode刷题——单调栈问题(739每日温度问题、496下一个更大元素I、503下一个更大元素 II)
数字孪生助力智慧城市可视化建设
OpenCV开发中的内存管理问题
unittest自动化测试框架总结
随机推荐
C# Barrier class
【 LeetCode 】 1374. Generate each character string is an odd number
Soft Exam ----- UML Design and Analysis (Part 2)
SQL 嵌套 N 层太长太难写怎么办?
56.【全局变量和局部变量专题】
第一次进入前20名
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)
Leetcode刷题——单调栈问题(739每日温度问题、496下一个更大元素I、503下一个更大元素 II)
J9 Digital Currency Theory: Identifying Web3's New Scarcity: Open Source Developers
ECCV 2022 | 通往数据高效的Transformer目标检测器
Redis cluster configuration
Helm基础知识
J9 digital theory: the Internet across chain bridge has what effect?
LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路
什么是 IDE
实现fashion_minst服装图像分类
【StoneDB性能相关工具】内存监控
Geoip2 - golang golang source code analysis
10 种最佳 IDE 软件 ,你更忠爱哪一个?
EasyExcel dynamic parsing and save table columns