@@ -106,6 +106,7 @@ class ReflectionContext
106106 typename super::StoredPointer target_future_adapter = 0 ;
107107 typename super::StoredPointer target_task_wait_throwing_resume_adapter = 0 ;
108108 typename super::StoredPointer target_task_future_wait_resume_adapter = 0 ;
109+ bool supportsPriorityEscalation = false ;
109110
110111public:
111112 using super::getBuilder;
@@ -164,7 +165,7 @@ class ReflectionContext
164165
165166 ReflectionContext (const ReflectionContext &other) = delete ;
166167 ReflectionContext &operator =(const ReflectionContext &other) = delete ;
167-
168+
168169 MemoryReader &getReader () {
169170 return *this ->Reader ;
170171 }
@@ -367,7 +368,7 @@ class ReflectionContext
367368
368369 auto Begin = RemoteRef<void >(Addr, BufStart);
369370 auto Size = COFFSec->VirtualSize ;
370-
371+
371372 // FIXME: This code needs to be cleaned up and updated
372373 // to make it work for 32 bit platforms.
373374 Begin = Begin.atByteOffset (8 );
@@ -605,7 +606,7 @@ class ReflectionContext
605606 }
606607
607608 // / 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
609610 // / process) this method optionally receives a buffer with the contents
610611 // / of the image's file, from where it will the necessary information.
611612 // /
@@ -652,19 +653,19 @@ class ReflectionContext
652653 auto Magic = this ->getReader ().readBytes (ImageStart, sizeof (uint32_t ));
653654 if (!Magic)
654655 return false ;
655-
656+
656657 uint32_t MagicWord;
657658 memcpy (&MagicWord, Magic.get (), sizeof (MagicWord));
658-
659+
659660 // 32- and 64-bit Mach-O.
660661 if (MagicWord == llvm::MachO::MH_MAGIC) {
661662 return readMachOSections<MachOTraits<4 >>(ImageStart);
662663 }
663-
664+
664665 if (MagicWord == llvm::MachO::MH_MAGIC_64) {
665666 return readMachOSections<MachOTraits<8 >>(ImageStart);
666667 }
667-
668+
668669 // PE. (This just checks for the DOS header; `readPECOFF` will further
669670 // validate the existence of the PE header.)
670671 auto MagicBytes = (const char *)Magic.get ();
@@ -739,7 +740,7 @@ class ReflectionContext
739740 return true ;
740741 return ownsAddress (RemoteAddress (*MetadataAddress));
741742 }
742-
743+
743744 // / Returns true if the address falls within a registered image.
744745 bool ownsAddressRaw (RemoteAddress Address) {
745746 for (auto Range : imageRanges) {
@@ -1193,7 +1194,7 @@ class ReflectionContext
11931194 IterateConformanceTable (ConformancesAddr->getResolvedAddress (), Call);
11941195 return llvm::None;
11951196 }
1196-
1197+
11971198 // / Fetch the metadata pointer from a metadata allocation, or 0 if this
11981199 // / allocation's tag is not handled or an error occurred.
11991200 StoredPointer allocationMetadataPointer (
@@ -1291,7 +1292,7 @@ class ReflectionContext
12911292 getReader ().readPointer (AllocationPoolAddrAddr, sizeof (StoredPointer));
12921293 if (!AllocationPoolAddr)
12931294 return " failed to read value of " + AllocationPoolPointerName;
1294-
1295+
12951296 struct PoolRange {
12961297 StoredPointer Begin;
12971298 StoredSize Remaining;
@@ -1337,10 +1338,10 @@ class ReflectionContext
13371338 Allocation.Ptr = RemoteAddr;
13381339 Allocation.Size = Header->Size ;
13391340 Call (Allocation);
1340-
1341+
13411342 Offset += sizeof (AllocationHeader) + Header->Size ;
13421343 }
1343-
1344+
13441345 TrailerPtr = Trailer->PrevTrailer ;
13451346 }
13461347 return llvm::None;
@@ -1421,13 +1422,20 @@ class ReflectionContext
14211422
14221423 std::pair<llvm::Optional<std::string>, AsyncTaskInfo>
14231424 asyncTaskInfo (StoredPointer AsyncTaskPtr) {
1424- auto AsyncTaskObj = readObj<AsyncTask<Runtime>>(AsyncTaskPtr);
1425+ loadTargetPointers ();
1426+
1427+ if (supportsPriorityEscalation) {
1428+ return {std::string (" Failure reading async task with escalation support" ), {}};
1429+ }
1430+
1431+ using AsyncTask = AsyncTask<Runtime, ActiveTaskStatusWithoutEscalation<Runtime>>;
1432+ auto AsyncTaskObj = readObj<AsyncTask>(AsyncTaskPtr);
14251433 if (!AsyncTaskObj)
14261434 return {std::string (" failure reading async task" ), {}};
14271435
14281436 AsyncTaskInfo Info{};
14291437 Info.JobFlags = AsyncTaskObj->Flags ;
1430- Info.TaskStatusFlags = AsyncTaskObj->PrivateStorage .Status .Flags ;
1438+ Info.TaskStatusFlags = AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] ;
14311439 Info.Id =
14321440 AsyncTaskObj->Id | ((uint64_t )AsyncTaskObj->PrivateStorage .Id << 32 );
14331441 Info.AllocatorSlabPtr = AsyncTaskObj->PrivateStorage .Allocator .FirstSlab ;
@@ -1461,7 +1469,7 @@ class ReflectionContext
14611469 Info.ChildTasks .push_back (ChildTask);
14621470
14631471 StoredPointer ChildFragmentAddr =
1464- ChildTask + sizeof (AsyncTask<Runtime> );
1472+ ChildTask + sizeof (AsyncTask);
14651473 auto ChildFragmentObj =
14661474 readObj<ChildFragment<Runtime>>(ChildFragmentAddr);
14671475 if (ChildFragmentObj)
@@ -1478,8 +1486,8 @@ class ReflectionContext
14781486 // that's available.
14791487 int IsCancelledFlag = 0x100 ;
14801488 int IsRunningFlag = 0x800 ;
1481- if (!(AsyncTaskObj->PrivateStorage .Status .Flags & IsCancelledFlag) &&
1482- !(AsyncTaskObj->PrivateStorage .Status .Flags & IsRunningFlag)) {
1489+ if (!(AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] & IsCancelledFlag) &&
1490+ !(AsyncTaskObj->PrivateStorage .Status .Flags [ 0 ] & IsRunningFlag)) {
14831491 auto ResumeContext = AsyncTaskObj->ResumeContextAndReserved [0 ];
14841492 while (ResumeContext) {
14851493 auto ResumeContextObj = readObj<AsyncContext<Runtime>>(ResumeContext);
@@ -1530,7 +1538,7 @@ class ReflectionContext
15301538private:
15311539 // Get the most human meaningful "run job" function pointer from the task,
15321540 // like AsyncTask::getResumeFunctionForLogging does.
1533- StoredPointer getRunJob (const AsyncTask<Runtime> *AsyncTaskObj) {
1541+ StoredPointer getRunJob (const AsyncTask<Runtime, ActiveTaskStatusWithoutEscalation<Runtime> > *AsyncTaskObj) {
15341542 auto Fptr = stripSignedPointer (AsyncTaskObj->RunJob );
15351543
15361544 loadTargetPointers ();
@@ -1589,6 +1597,11 @@ class ReflectionContext
15891597 getFunc (" _swift_concurrency_debug_task_wait_throwing_resume_adapter" );
15901598 target_task_future_wait_resume_adapter =
15911599 getFunc (" _swift_concurrency_debug_task_future_wait_resume_adapter" );
1600+ auto supportsPriorityEscalationAddr = getReader ().getSymbolAddress (" _swift_concurrency_debug_supportsPriorityEscalation" );
1601+ if (supportsPriorityEscalationAddr) {
1602+ getReader ().readInteger (supportsPriorityEscalationAddr, &supportsPriorityEscalation);
1603+ }
1604+
15921605 setupTargetPointers = true ;
15931606 }
15941607
0 commit comments