Skip to content

Commit ea4e0d8

Browse files
authored
Fix format string to output x64 addresses (#3067)
***NO_CI***
1 parent 43763a5 commit ea4e0d8

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/CLR/Core/Core.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -21,4 +21,8 @@
2121
// #include <SPOT_hardware_native.h>
2222
#include <nanoCLR_Runtime__HeapBlock.h>
2323

24+
#ifdef _WIN64
25+
#include <inttypes.h>
26+
#endif
27+
2428
#endif // NANOCLR_CORE_H

src/CLR/Core/GarbageCollector_Info.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -138,7 +138,11 @@ void CLR_RT_GarbageCollector::ValidateBlockNotInFreeList(CLR_RT_DblLinkedList &l
138138
if (ptr <= dst && dst < ptrEnd)
139139
{
140140
#ifdef _WIN64
141-
CLR_Debug::Printf("Pointer into free list!! %I64X %I64X %I64X\r\n", dst, ptr, ptrEnd);
141+
CLR_Debug::Printf(
142+
"Pointer into free list!! 0x%016" PRIxPTR " 0x%016" PRIxPTR " 0x%016" PRIxPTR "\r\n",
143+
(uintptr_t)dst,
144+
(uintptr_t)ptr,
145+
(uintptr_t)ptrEnd);
142146
#else
143147
CLR_Debug::Printf("Pointer into free list!! %08x %08x %08x\r\n", dst, ptr, ptrEnd);
144148
#endif
@@ -225,7 +229,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
225229
if (s_mapOldToRecord.find(ref) != s_mapOldToRecord.end())
226230
{
227231
#ifdef _WIN64
228-
CLR_Debug::Printf("Duplicate base OLD: %I64X\r\n", ref);
232+
CLR_Debug::Printf("Duplicate base OLD: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
229233
#else
230234
CLR_Debug::Printf("Duplicate base OLD: %08x\r\n", ref);
231235
#endif
@@ -238,7 +242,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
238242
if (IsBlockInFreeList(g_CLR_RT_ExecutionEngine.m_heap, (CLR_RT_HeapBlock_Node *)dst, false))
239243
{
240244
#ifdef _WIN64
241-
CLR_Debug::Printf("Some data points into a free list: %I64X\r\n", dst);
245+
CLR_Debug::Printf("Some data points into a free list: 0x%016" PRIxPTR "\r\n", (uintptr_t)dst);
242246
#else
243247
CLR_Debug::Printf("Some data points into a free list: %08x\r\n", dst);
244248
#endif
@@ -302,7 +306,7 @@ void CLR_RT_GarbageCollector::TestPointers_Remap()
302306
if (s_mapNewToRecord.find(ref) != s_mapNewToRecord.end())
303307
{
304308
#ifdef _WIN64
305-
CLR_Debug::Printf("Duplicate base NEW: %I64X\r\n", ref);
309+
CLR_Debug::Printf("Duplicate base NEW: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
306310
#else
307311
CLR_Debug::Printf("Duplicate base NEW: %08x\r\n", ref);
308312
#endif
@@ -334,7 +338,10 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
334338
if (ptr->newPtr != dst)
335339
{
336340
#ifdef _WIN64
337-
CLR_Debug::Printf("Bad pointer: %I64X %I64X\r\n", ptr->newPtr, dst);
341+
CLR_Debug::Printf(
342+
"Bad pointer: 0x%016" PRIxPTR " 0x%016" PRIxPTR "\r\n",
343+
(uintptr_t)ptr->newPtr,
344+
(uintptr_t)dst);
338345
#else
339346
CLR_Debug::Printf("Bad pointer: %08x %08x\r\n", ptr->newPtr, dst);
340347
#endif
@@ -343,7 +350,10 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
343350
else if (ptr->data != *dst)
344351
{
345352
#ifdef _WIN64
346-
CLR_Debug::Printf("Bad data: %I64X %I64X\r\n", ptr->data, *dst);
353+
CLR_Debug::Printf(
354+
"Bad data: 0x%016" PRIxPTR " 0x%016" PRIxPTR "\r\n",
355+
(uintptr_t)ptr->data,
356+
(uintptr_t)*dst);
347357
#else
348358
CLR_Debug::Printf("Bad data: %08x %08x\r\n", ptr->data, *dst);
349359
#endif
@@ -354,7 +364,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
354364
if (IsBlockInFreeList(g_CLR_RT_ExecutionEngine.m_heap, (CLR_RT_HeapBlock_Node *)dst, false))
355365
{
356366
#ifdef _WIN64
357-
CLR_Debug::Printf("Some data points into a free list: %I64X\r\n", dst);
367+
CLR_Debug::Printf("Some data points into a free list: 0x%016" PRIxPTR "\r\n", (uintptr_t)dst);
358368
#else
359369
CLR_Debug::Printf("Some data points into a free list: %08x\r\n", dst);
360370
#endif
@@ -367,7 +377,7 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateNew_Worker(void **ref)
367377
else
368378
{
369379
#ifdef _WIN64
370-
CLR_Debug::Printf("Bad base: 0x%0I64X\r\n", ref);
380+
CLR_Debug::Printf("Bad base: 0x%016" PRIxPTR "\r\n", (uintptr_t)ref);
371381
#else
372382
CLR_Debug::Printf("Bad base: 0x%08x\r\n", ref);
373383
#endif

0 commit comments

Comments
 (0)