Skip to content

Commit a912343

Browse files
authored
Fix usage of uintptr_t accross GC and HeapCluster classes (#3076)
***NO_CI***
1 parent fc8a2ad commit a912343

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

src/CLR/Core/CLR_RT_HeapCluster.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ void CLR_RT_HeapCluster::ValidateBlock(CLR_RT_HeapBlock *ptr)
346346
(uintptr_t)this,
347347
(uintptr_t)m_payloadStart,
348348
(uintptr_t)m_payloadEnd);
349-
350349
#else
351350

352351
CLR_Debug::Printf(
353-
"Block beyond cluster limits: %08x [%08x : %08x-%08x]\r\n",
354-
(size_t)ptr,
355-
(size_t)this,
356-
(size_t)m_payloadStart,
357-
(size_t)m_payloadEnd);
352+
"Block beyond cluster limits: 0x%08" PRIxPTR " [0x%08" PRIxPTR " : 0x%08" PRIxPTR "-0x%08" PRIxPTR
353+
"]\r\n",
354+
(uintptr_t)ptr,
355+
(uintptr_t)this,
356+
(uintptr_t)m_payloadStart,
357+
(uintptr_t)m_payloadEnd);
358358
#endif
359359

360360
break;
@@ -372,12 +372,12 @@ void CLR_RT_HeapCluster::ValidateBlock(CLR_RT_HeapBlock *ptr)
372372
(uintptr_t)m_payloadEnd);
373373
#else
374374
CLR_Debug::Printf(
375-
"Bad Block Type: %08x %02x [%08x : %08x-%08x]\r\n",
376-
(size_t)ptr,
375+
"Bad Block Type: 0x%08" PRIxPTR " %02x [0x%08" PRIxPTR " : 0x%08" PRIxPTR "-0x%08" PRIxPTR "]\r\n",
376+
(uintptr_t)ptr,
377377
ptr->DataType(),
378-
(size_t)this,
379-
(size_t)m_payloadStart,
380-
(size_t)m_payloadEnd);
378+
(uintptr_t)this,
379+
(uintptr_t)m_payloadStart,
380+
(uintptr_t)m_payloadEnd);
381381
#endif
382382

383383
break;
@@ -394,11 +394,11 @@ void CLR_RT_HeapCluster::ValidateBlock(CLR_RT_HeapBlock *ptr)
394394
(uintptr_t)m_payloadEnd);
395395
#else
396396
CLR_Debug::Printf(
397-
"Bad Block null-size: %08x [%08x : %08x-%08x]\r\n",
398-
(size_t)ptr,
399-
(size_t)this,
400-
(size_t)m_payloadStart,
401-
(size_t)m_payloadEnd);
397+
"Bad Block null-size: 0x%08" PRIxPTR " [0x%08" PRIxPTR " : 0x%08" PRIxPTR "-0x%08" PRIxPTR "]\r\n",
398+
(uintptr_t)ptr,
399+
(uintptr_t)this,
400+
(uintptr_t)m_payloadStart,
401+
(uintptr_t)m_payloadEnd);
402402
#endif
403403

404404
break;
@@ -415,12 +415,12 @@ void CLR_RT_HeapCluster::ValidateBlock(CLR_RT_HeapBlock *ptr)
415415
(uintptr_t)m_payloadEnd);
416416
#else
417417
CLR_Debug::Printf(
418-
"Bad Block size: %d %08x [%08x : %08x-%08x]\r\n",
418+
"Bad Block size: %d 0x%08" PRIxPTR " [0x%08" PRIxPTR " : 0x%08" PRIxPTR "-0x%08" PRIxPTR "]\r\n",
419419
ptr->DataSize(),
420-
(size_t)ptr,
421-
(size_t)this,
422-
(size_t)m_payloadStart,
423-
(size_t)m_payloadEnd);
420+
(uintptr_t)ptr,
421+
(uintptr_t)this,
422+
(uintptr_t)m_payloadStart,
423+
(uintptr_t)m_payloadEnd);
424424
#endif
425425

426426
break;

src/CLR/Core/GarbageCollector_Info.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void CLR_RT_GarbageCollector::ValidateCluster(CLR_RT_HeapCluster *hc)
113113
#ifdef _WIN64
114114
CLR_Debug::Printf("Block exceeds cluster boundary: 0x%016" PRIxPTR "\r\n", (uintptr_t)ptr);
115115
#else
116-
CLR_Debug::Printf("Block exceeds cluster boundary: %08x\r\n", ptr);
116+
CLR_Debug::Printf("Block exceeds cluster boundary: 0x%08" PRIxPTR "\r\n", (uintptr_t)ptr)
117117
#endif
118118

119119
NANOCLR_DEBUG_STOP();
@@ -135,7 +135,9 @@ void CLR_RT_GarbageCollector::ValidateCluster(CLR_RT_HeapCluster *hc)
135135
"Overlapping blocks detected. Next block of 0x%016" PRIxPTR " is overlapping it.\r\n",
136136
(uintptr_t)ptr);
137137
#else
138-
CLR_Debug::Printf("Overlapping blocks detected: Next block of %08x is overlapping it.\r\n", ptr);
138+
CLR_Debug::Printf(
139+
"Overlapping blocks detected: Next block of 0x%08" PRIxPTR " is overlapping it.\r\n",
140+
(uintptr_t)ptr);
139141
#endif
140142
}
141143
}
@@ -157,8 +159,8 @@ void CLR_RT_GarbageCollector::ValidateCluster(CLR_RT_HeapCluster *hc)
157159
(uintptr_t)ptr);
158160
#else
159161
CLR_Debug::Printf(
160-
"Overlapping blocks detected: Previous block of %08x is overlapping it.\r\n",
161-
ptr);
162+
"Overlapping blocks detected: Previous block of 0x%08" PRIxPTR " is overlapping it.\r\n",
163+
(uintptr_t)ptr);
162164
#endif
163165
}
164166
}
@@ -207,7 +209,11 @@ void CLR_RT_GarbageCollector::ValidateBlockNotInFreeList(CLR_RT_DblLinkedList &l
207209
(uintptr_t)ptr,
208210
(uintptr_t)ptrEnd);
209211
#else
210-
CLR_Debug::Printf("Pointer into free list!! %08x %08x %08x\r\n", dst, ptr, ptrEnd);
212+
CLR_Debug::Printf(
213+
"Pointer into free list!! 0x%08" PRIxPTR " 0x%08" PRIxPTR " 0x%08" PRIxPTR "\r\n",
214+
(uintptr_t)dst,
215+
(uintptr_t)ptr,
216+
(uintptr_t)ptrEnd);
211217
#endif
212218

213219
NANOCLR_DEBUG_STOP();
@@ -299,7 +305,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
299305
#ifdef _WIN64
300306
CLR_Debug::Printf("Duplicate base OLD: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
301307
#else
302-
CLR_Debug::Printf("Duplicate base OLD: %08x\r\n", ref);
308+
CLR_Debug::Printf("Duplicate base OLD: 0x%08" PRIxPTR "\r\n", (uintptr_t)ref);
303309
#endif
304310
// need to free the memory allocated for the record
305311
platform_free(ptr);
@@ -314,7 +320,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
314320
#ifdef _WIN64
315321
CLR_Debug::Printf("Some data points into a free list: 0x%016" PRIxPTR "\r\n", (uintptr_t)dst);
316322
#else
317-
CLR_Debug::Printf("Some data points into a free list: %08x\r\n", dst);
323+
CLR_Debug::Printf("Some data points into a free list: 0x%08" PRIxPTR "\r\n", (uintptr_t)dst);
318324
#endif
319325

320326
// need to free the memory allocated for the record
@@ -382,7 +388,7 @@ void CLR_RT_GarbageCollector::TestPointers_Remap()
382388
#ifdef _WIN64
383389
CLR_Debug::Printf("Duplicate base NEW: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
384390
#else
385-
CLR_Debug::Printf("Duplicate base NEW: %08x\r\n", ref);
391+
CLR_Debug::Printf("Duplicate base NEW: 0x%08" PRIxPTR "\r\n", (uintptr_t)ref);
386392
#endif
387393
NANOCLR_DEBUG_STOP();
388394
}
@@ -417,7 +423,10 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
417423
(uintptr_t)ptr->newPtr,
418424
(uintptr_t)dst);
419425
#else
420-
CLR_Debug::Printf("Bad pointer: %08x %08x\r\n", ptr->newPtr, dst);
426+
CLR_Debug::Printf(
427+
"Bad pointer: 0x%08" PRIxPTR " 0x%08" PRIxPTR "\r\n",
428+
(uintptr_t)ptr->newPtr,
429+
(uintptr_t)dst);
421430
#endif
422431
NANOCLR_DEBUG_STOP();
423432
}
@@ -429,7 +438,10 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
429438
(uintptr_t)ptr->data,
430439
(uintptr_t)*dst);
431440
#else
432-
CLR_Debug::Printf("Bad data: %08x %08x\r\n", ptr->data, *dst);
441+
CLR_Debug::Printf(
442+
"Bad data: 0x%08" PRIxPTR " 0x%08" PRIxPTR "\r\n",
443+
(uintptr_t)ptr->data,
444+
(uintptr_t)*dst);
433445
#endif
434446

435447
NANOCLR_DEBUG_STOP();
@@ -440,7 +452,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
440452
#ifdef _WIN64
441453
CLR_Debug::Printf("Some data points into a free list: 0x%016" PRIxPTR "\r\n", (uintptr_t)dst);
442454
#else
443-
CLR_Debug::Printf("Some data points into a free list: %08x\r\n", dst);
455+
CLR_Debug::Printf("Some data points into a free list: 0x%08" PRIxPTR "\r\n", (uintptr_t)dst);
444456
#endif
445457

446458
NANOCLR_DEBUG_STOP();
@@ -453,7 +465,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
453465
#ifdef _WIN64
454466
CLR_Debug::Printf("Bad base: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
455467
#else
456-
CLR_Debug::Printf("Bad base: 0x%08x\r\n", ref);
468+
CLR_Debug::Printf("Bad base: 0x0x%08" PRIxPTR "\r\n", (uintptr_t)ref);
457469
#endif
458470

459471
NANOCLR_DEBUG_STOP();

0 commit comments

Comments
 (0)