|
25 | 25 | // ByteSwapContext. |
26 | 26 | // |
27 | 27 |
|
28 | | -// |
29 | | -// **** NOTE: Keep these in sync with pal/inc/pal.h **** |
30 | | -// |
| 28 | +// **** |
| 29 | +// **** NOTE: T_CONTEXT (in pal/inc/pal.h) can now be larger than DT_CONTEXT (currently T_CONTEXT on Linux/MacOS |
| 30 | +// **** x64 includes the XSTATE registers). This means the following: |
| 31 | +// **** |
| 32 | +// **** 1) The DBI/DAC APIs cannot assume that incoming context buffers are T_CONTEXT sized. |
| 33 | +// **** 2) When the DAC calls the supplied data target's context APIs, the size of the context buffer must |
| 34 | +// **** be the size of the DT_CONTEXT for compatiblity. |
| 35 | +// **** 3) DBI/DAC code can not cast and copy from a T_CONTEXT into a DT_CONTEXT buffer. |
| 36 | +// **** |
31 | 37 |
|
32 | 38 | // This odd define pattern is needed because in DBI we set _TARGET_ to match the host and |
33 | 39 | // DBG_TARGET to control our targeting. In x-plat DBI DBG_TARGET won't match _TARGET_ and |
|
54 | 60 | #define DTCONTEXT_IS_RISCV64 |
55 | 61 | #endif |
56 | 62 |
|
| 63 | +#define CONTEXT_AREA_MASK 0xffff |
| 64 | + |
57 | 65 | #if defined(DTCONTEXT_IS_X86) |
58 | 66 |
|
59 | 67 | #define DT_SIZE_OF_80387_REGISTERS 80 |
@@ -118,6 +126,8 @@ typedef struct { |
118 | 126 |
|
119 | 127 | } DT_CONTEXT; |
120 | 128 |
|
| 129 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size on X86"); |
| 130 | + |
121 | 131 | // Since the target is little endian in this case we only have to provide a real implementation of |
122 | 132 | // ByteSwapContext if the platform we're building on is big-endian. |
123 | 133 | #ifdef BIGENDIAN |
@@ -280,6 +290,12 @@ typedef struct DECLSPEC_ALIGN(16) { |
280 | 290 | DWORD64 LastExceptionFromRip; |
281 | 291 | } DT_CONTEXT; |
282 | 292 |
|
| 293 | +#if !defined(CROSS_COMPILE) && !defined(TARGET_WINDOWS) |
| 294 | +static_assert(sizeof(DT_CONTEXT) == offsetof(T_CONTEXT, XStateFeaturesMask), "DT_CONTEXT must not include the XSTATE registers on AMD64"); |
| 295 | +#else |
| 296 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size on AMD64"); |
| 297 | +#endif |
| 298 | + |
283 | 299 | #elif defined(DTCONTEXT_IS_ARM) |
284 | 300 |
|
285 | 301 | #define DT_CONTEXT_ARM 0x00200000L |
@@ -361,6 +377,8 @@ typedef DECLSPEC_ALIGN(8) struct { |
361 | 377 |
|
362 | 378 | } DT_CONTEXT; |
363 | 379 |
|
| 380 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size on ARM32"); |
| 381 | + |
364 | 382 | #elif defined(DTCONTEXT_IS_ARM64) |
365 | 383 |
|
366 | 384 | #define DT_CONTEXT_ARM64 0x00400000L |
@@ -452,7 +470,10 @@ typedef DECLSPEC_ALIGN(16) struct { |
452 | 470 |
|
453 | 471 | } DT_CONTEXT; |
454 | 472 |
|
| 473 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size on ARM64"); |
| 474 | + |
455 | 475 | #elif defined(DTCONTEXT_IS_LOONGARCH64) |
| 476 | + |
456 | 477 | #define DT_CONTEXT_LOONGARCH64 0x00800000L |
457 | 478 |
|
458 | 479 | #define DT_CONTEXT_CONTROL (DT_CONTEXT_LOONGARCH64 | 0x1L) |
@@ -516,7 +537,10 @@ typedef DECLSPEC_ALIGN(16) struct { |
516 | 537 | ULONGLONG F[32]; |
517 | 538 | } DT_CONTEXT; |
518 | 539 |
|
| 540 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size"); |
| 541 | + |
519 | 542 | #elif defined(DTCONTEXT_IS_RISCV64) |
| 543 | + |
520 | 544 | #define DT_CONTEXT_RISCV64 0x01000000L |
521 | 545 |
|
522 | 546 | #define DT_CONTEXT_CONTROL (DT_CONTEXT_RISCV64 | 0x1L) |
@@ -580,10 +604,10 @@ typedef DECLSPEC_ALIGN(16) struct { |
580 | 604 | ULONGLONG F[32]; |
581 | 605 | } DT_CONTEXT; |
582 | 606 |
|
| 607 | +static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size"); |
583 | 608 |
|
584 | 609 | #else |
585 | 610 | #error Unsupported platform |
586 | 611 | #endif |
587 | 612 |
|
588 | | - |
589 | 613 | #endif // __DBG_TARGET_CONTEXT_INCLUDED |
0 commit comments