@@ -106,6 +106,7 @@ class ReflectionContext
106
106
typename super::StoredPointer target_future_adapter = 0 ;
107
107
typename super::StoredPointer target_task_wait_throwing_resume_adapter = 0 ;
108
108
typename super::StoredPointer target_task_future_wait_resume_adapter = 0 ;
109
+ bool supportsPriorityEscalation = false ;
109
110
110
111
public:
111
112
using super::getBuilder;
@@ -164,7 +165,7 @@ class ReflectionContext
164
165
165
166
ReflectionContext (const ReflectionContext &other) = delete ;
166
167
ReflectionContext &operator =(const ReflectionContext &other) = delete ;
167
-
168
+
168
169
MemoryReader &getReader () {
169
170
return *this ->Reader ;
170
171
}
@@ -367,7 +368,7 @@ class ReflectionContext
367
368
368
369
auto Begin = RemoteRef<void >(Addr, BufStart);
369
370
auto Size = COFFSec->VirtualSize ;
370
-
371
+
371
372
// FIXME: This code needs to be cleaned up and updated
372
373
// to make it work for 32 bit platforms.
373
374
Begin = Begin.atByteOffset (8 );
@@ -605,7 +606,7 @@ class ReflectionContext
605
606
}
606
607
607
608
// / Parses metadata information from an ELF image. Because the Section
608
- // / Header Table maybe be missing (for example, when reading from a
609
+ // / Header Table maybe be missing (for example, when reading from a
609
610
// / process) this method optionally receives a buffer with the contents
610
611
// / of the image's file, from where it will the necessary information.
611
612
// /
@@ -652,19 +653,19 @@ class ReflectionContext
652
653
auto Magic = this ->getReader ().readBytes (ImageStart, sizeof (uint32_t ));
653
654
if (!Magic)
654
655
return false ;
655
-
656
+
656
657
uint32_t MagicWord;
657
658
memcpy (&MagicWord, Magic.get (), sizeof (MagicWord));
658
-
659
+
659
660
// 32- and 64-bit Mach-O.
660
661
if (MagicWord == llvm::MachO::MH_MAGIC) {
661
662
return readMachOSections<MachOTraits<4 >>(ImageStart);
662
663
}
663
-
664
+
664
665
if (MagicWord == llvm::MachO::MH_MAGIC_64) {
665
666
return readMachOSections<MachOTraits<8 >>(ImageStart);
666
667
}
667
-
668
+
668
669
// PE. (This just checks for the DOS header; `readPECOFF` will further
669
670
// validate the existence of the PE header.)
670
671
auto MagicBytes = (const char *)Magic.get ();
@@ -739,7 +740,7 @@ class ReflectionContext
739
740
return true ;
740
741
return ownsAddress (RemoteAddress (*MetadataAddress));
741
742
}
742
-
743
+
743
744
// / Returns true if the address falls within a registered image.
744
745
bool ownsAddressRaw (RemoteAddress Address) {
745
746
for (auto Range : imageRanges) {
@@ -1214,7 +1215,7 @@ class ReflectionContext
1214
1215
}
1215
1216
return llvm::None;
1216
1217
}
1217
-
1218
+
1218
1219
// / Fetch the metadata pointer from a metadata allocation, or 0 if this
1219
1220
// / allocation's tag is not handled or an error occurred.
1220
1221
StoredPointer allocationMetadataPointer (
@@ -1312,7 +1313,7 @@ class ReflectionContext
1312
1313
getReader ().readPointer (AllocationPoolAddrAddr, sizeof (StoredPointer));
1313
1314
if (!AllocationPoolAddr)
1314
1315
return " failed to read value of " + AllocationPoolPointerName;
1315
-
1316
+
1316
1317
struct PoolRange {
1317
1318
StoredPointer Begin;
1318
1319
StoredSize Remaining;
@@ -1358,10 +1359,10 @@ class ReflectionContext
1358
1359
Allocation.Ptr = RemoteAddr;
1359
1360
Allocation.Size = Header->Size ;
1360
1361
Call (Allocation);
1361
-
1362
+
1362
1363
Offset += sizeof (AllocationHeader) + Header->Size ;
1363
1364
}
1364
-
1365
+
1365
1366
TrailerPtr = Trailer->PrevTrailer ;
1366
1367
}
1367
1368
return llvm::None;
@@ -1442,13 +1443,20 @@ class ReflectionContext
1442
1443
1443
1444
std::pair<llvm::Optional<std::string>, AsyncTaskInfo>
1444
1445
asyncTaskInfo (StoredPointer AsyncTaskPtr) {
1445
- auto AsyncTaskObj = readObj<AsyncTask<Runtime>>(AsyncTaskPtr);
1446
+ loadTargetPointers ();
1447
+
1448
+ if (supportsPriorityEscalation) {
1449
+ return {std::string (" Failure reading async task with escalation support" ), {}};
1450
+ }
1451
+
1452
+ using AsyncTask = AsyncTask<Runtime, ActiveTaskStatusWithoutEscalation<Runtime>>;
1453
+ auto AsyncTaskObj = readObj<AsyncTask>(AsyncTaskPtr);
1446
1454
if (!AsyncTaskObj)
1447
1455
return {std::string (" failure reading async task" ), {}};
1448
1456
1449
1457
AsyncTaskInfo Info{};
1450
1458
Info.JobFlags = AsyncTaskObj->Flags ;
1451
- Info.TaskStatusFlags = AsyncTaskObj->PrivateStorage .Status .Flags ;
1459
+ Info.TaskStatusFlags = AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] ;
1452
1460
Info.Id =
1453
1461
AsyncTaskObj->Id | ((uint64_t )AsyncTaskObj->PrivateStorage .Id << 32 );
1454
1462
Info.AllocatorSlabPtr = AsyncTaskObj->PrivateStorage .Allocator .FirstSlab ;
@@ -1482,7 +1490,7 @@ class ReflectionContext
1482
1490
Info.ChildTasks .push_back (ChildTask);
1483
1491
1484
1492
StoredPointer ChildFragmentAddr =
1485
- ChildTask + sizeof (AsyncTask<Runtime> );
1493
+ ChildTask + sizeof (AsyncTask);
1486
1494
auto ChildFragmentObj =
1487
1495
readObj<ChildFragment<Runtime>>(ChildFragmentAddr);
1488
1496
if (ChildFragmentObj)
@@ -1499,8 +1507,8 @@ class ReflectionContext
1499
1507
// that's available.
1500
1508
int IsCancelledFlag = 0x100 ;
1501
1509
int IsRunningFlag = 0x800 ;
1502
- if (!(AsyncTaskObj->PrivateStorage .Status .Flags & IsCancelledFlag) &&
1503
- !(AsyncTaskObj->PrivateStorage .Status .Flags & IsRunningFlag)) {
1510
+ if (!(AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] & IsCancelledFlag) &&
1511
+ !(AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] & IsRunningFlag)) {
1504
1512
auto ResumeContext = AsyncTaskObj->ResumeContextAndReserved [0 ];
1505
1513
while (ResumeContext) {
1506
1514
auto ResumeContextObj = readObj<AsyncContext<Runtime>>(ResumeContext);
@@ -1551,7 +1559,7 @@ class ReflectionContext
1551
1559
private:
1552
1560
// Get the most human meaningful "run job" function pointer from the task,
1553
1561
// like AsyncTask::getResumeFunctionForLogging does.
1554
- StoredPointer getRunJob (const AsyncTask<Runtime> *AsyncTaskObj) {
1562
+ StoredPointer getRunJob (const AsyncTask<Runtime, ActiveTaskStatusWithoutEscalation<Runtime> > *AsyncTaskObj) {
1555
1563
auto Fptr = stripSignedPointer (AsyncTaskObj->RunJob );
1556
1564
1557
1565
loadTargetPointers ();
@@ -1610,6 +1618,11 @@ class ReflectionContext
1610
1618
getFunc (" _swift_concurrency_debug_task_wait_throwing_resume_adapter" );
1611
1619
target_task_future_wait_resume_adapter =
1612
1620
getFunc (" _swift_concurrency_debug_task_future_wait_resume_adapter" );
1621
+ auto supportsPriorityEscalationAddr = getReader ().getSymbolAddress (" _swift_concurrency_debug_supportsPriorityEscalation" );
1622
+ if (supportsPriorityEscalationAddr) {
1623
+ getReader ().readInteger (supportsPriorityEscalationAddr, &supportsPriorityEscalation);
1624
+ }
1625
+
1613
1626
setupTargetPointers = true ;
1614
1627
}
1615
1628
0 commit comments