Commit f37ab00
Remove TEB field from Thread, DAC, and cDAC (#126902)
> [!NOTE]
> This PR was generated with the assistance of GitHub Copilot.
## Summary
Remove the TEB (Thread Environment Block) pointer from the DAC/cDAC
Thread data contract. Consumers should look up the TEB from the OS
thread ID via the debugger's native API instead.
## Background
The `Thread::m_pTEB` field was exposed through `DacpThreadData.teb` and
through the cDAC `ThreadData.TEB` contract field. Analysis of all
consumers shows:
- **SOS** reads `DacpThreadData.teb` in one place (`strike.cpp:4460`) to
display COM apartment state in `!Threads`. A companion PR in
dotnet/diagnostics switches this to use
`IDebuggerServices::GetThreadTeb(osThreadId)` instead.
- **ClrMD** reads `DacpThreadData.Teb` to derive
`StackBase`/`StackLimit`. A companion PR in microsoft/clrmd switches
this to use `IThreadReader.GetThreadTeb(osThreadId)` instead.
- **NativeAOT** already returns `TargetPointer.Null` for TEB.
- **Non-Windows** platforms already return NULL for TEB.
## Changes
- `request.cpp`: Always set `threadData->teb = NULL` (field retained for
binary layout compatibility)
- `datadescriptor.inc`: Remove TEB field from Thread type descriptor
- `threads.h`: Remove TEB from `cdac_data<Thread>`
- `Data/Thread.cs`: Remove TEB property and reading logic
- `Thread_1.cs`: Remove TEB from ThreadData construction
- `IThread.cs`: Remove TEB from ThreadData record
- `SOSDacImpl.cs`: Set `data->teb = 0`, remove debug assertion
- `Thread.md`: Remove TEB from data contract documentation
- Test mocks: Remove TEB from mock thread descriptors
## Companion PRs
- dotnet/diagnostics#5804 — SOS switches to `GetThreadTeb(osThreadId)`
for apartment state display + new ThreadApartment regression test
- microsoft/clrmd#1419 — `DacRuntime` switches to
`IThreadReader.GetThreadTeb(osThreadId)` for stack bounds
## Validation
- cDAC build: 0 warnings, 0 errors
- cDAC tests: 1586/1586 passed
- cdb verification: `!Threads` output identical between legacy DAC and
cDAC (Release)
- Manual cdb verification: STA/MTA apartment state displays correctly
with both old and new SOS
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3024b5a commit f37ab00
13 files changed
Lines changed: 4 additions & 45 deletions
File tree
- docs/design/datacontracts
- src
- coreclr
- debug/daccess
- vm
- datadescriptor
- native/managed/cdac
- Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts
- Microsoft.Diagnostics.DataContractReader.Contracts
- Contracts
- Data
- Microsoft.Diagnostics.DataContractReader.Legacy
- tests
- MockDescriptors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
| |||
184 | 182 | | |
185 | 183 | | |
186 | 184 | | |
187 | | - | |
188 | 185 | | |
189 | 186 | | |
190 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1227 | 1227 | | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | 1230 | | |
1235 | 1231 | | |
1236 | 1232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
894 | | - | |
895 | | - | |
| 893 | + | |
| 894 | + | |
896 | 895 | | |
897 | | - | |
898 | 896 | | |
899 | 897 | | |
900 | 898 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1513 | 1513 | | |
1514 | 1514 | | |
1515 | 1515 | | |
1516 | | - | |
1517 | | - | |
1518 | 1516 | | |
1519 | 1517 | | |
1520 | 1518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
912 | 912 | | |
913 | 913 | | |
914 | 914 | | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | 915 | | |
930 | 916 | | |
931 | 917 | | |
| |||
3786 | 3772 | | |
3787 | 3773 | | |
3788 | 3774 | | |
3789 | | - | |
3790 | 3775 | | |
3791 | 3776 | | |
3792 | 3777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2893 | 2893 | | |
2894 | 2894 | | |
2895 | 2895 | | |
2896 | | - | |
2897 | | - | |
2898 | | - | |
2899 | | - | |
2900 | 2896 | | |
2901 | | - | |
| 2897 | + | |
2902 | 2898 | | |
2903 | 2899 | | |
2904 | 2900 | | |
| |||
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
49 | | - | |
50 | 47 | | |
51 | 48 | | |
52 | 49 | | |
| |||
0 commit comments