当前位置:网站首页>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: 0From the output, the two values are: StackBase=000000b4d9fa0000 and StackLimit=000000b4d9f98000, then its size is 32768byte = 32k.
0:000> ? 000000b4d9fa0000 - 000000b4d9f98000Evaluate expression: 32768 = 00000000`00008000It 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_TIBAs you can see, the above two values are exactly the same as those displayed by !teb.
边栏推荐
猜你喜欢

Redis cluster configuration

"Weekly Translate Go" This time we have something different!-- "How to Code in Go" series launched

美国爱荷华州立大学| Improving Distantly Supervised Relation Extraction by Natural Language Inference(通过自然语言推理改进远程监督关系提取)

56.【全局变量和局部变量专题】

go——垃圾回收机制(GC)

Five data structures of Redis and their corresponding usage scenarios

iframe------------frame-

一次线上事故,我顿悟了异步的精髓

信息学奥赛一本通(1259:【例9.3】求最长不下降序列)

交 叉 数 组
随机推荐
V - memo new instructions
Common tools and test methods for interface testing (Introduction)
Informatics Olympiad All-in-One (1260: [Example 9.4] Intercepting Missiles (Noip1999))
什么是乙二醇二乙酸酯(EGDA)?
The five classification of software testing
Leetcode刷题——单调栈问题(739每日温度问题、496下一个更大元素I、503下一个更大元素 II)
Bena的生命周期
信息学奥赛一本通(1258:【例9.2】数字金字塔)
【21天学习挑战赛】冒泡排序与插入排序
【实战 已完结】WPF开发自动化生产管理平台
Thread线程类基本使用(上)
软件测试的流程规范有哪些?具体要怎么做?
遇上Mysql亿级优化,怎么办
什么是 IDE
六石管理学:入门机会只有一次,先把产品做好
The so-called fighting skill again gao also afraid of the chopper - partition, depots, table, and the merits of the distributed
Flutter 常见异常分析
特拉维夫大学 | Efficient Long-Text Understanding with Short-Text Models(使用短文本模型进行高效的长文本理解)
golang源码分析:time/rate
STP生成树协议