Skip to content

Fix format string for 64bits vars #3021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/CLR/Core/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <nanoHAL_Power.h>
#include <nanoHAL_Time.h>

#ifdef _WIN64
#include <inttypes.h>
#include <stdint.h>
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////

static const CLR_INT64 c_MaximumTimeToActive = (TIME_CONVERSION__ONEMINUTE * TIME_CONVERSION__TO_SECONDS);
Expand Down Expand Up @@ -176,8 +181,8 @@ HRESULT CLR_RT_ExecutionEngine::AllocateHeaps()
CLR_Debug::Printf("Heap Cluster information\r\n");

#ifdef _WIN64
CLR_Debug::Printf("Start: 0x%I64X\r\n", (size_t)heapFirstFree);
CLR_Debug::Printf("Free: 0x%I64X\r\n", (size_t)heapFree);
CLR_Debug::Printf("Start: 0x%" PRIx64 "\r\n", (uint64_t)heapFirstFree);
CLR_Debug::Printf("Free: 0x%" PRIx64 "\r\n", (uint64_t)heapFree);
CLR_Debug::Printf("Block size: %d\r\n", sizeof(struct CLR_RT_HeapBlock));
#else
CLR_Debug::Printf("Start: %08x\r\n", (size_t)heapFirstFree);
Expand Down
33 changes: 19 additions & 14 deletions src/CLR/Diagnostics/Profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
//
#include "Diagnostics.h"

#ifdef _WIN64
#include <inttypes.h>
#include <stdint.h>
#endif

#if defined(NANOCLR_PROFILE_NEW)

CLR_PRF_Profiler g_CLR_PRF_Profiler;
Expand Down Expand Up @@ -700,9 +705,9 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr)

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler info: ! (0x0x%I64X | %d) DT: %d %d bytes idx: %08x\r\n",
"\r\n Profiler info: ! (0x0x%" PRIx64 " | %d) DT: %d %d bytes idx: %08x\r\n",
(size_t)((CLR_UINT8 *)ptr),
(CLR_UINT32)((size_t *)ptr - s_CLR_RT_Heap.m_location),
(CLR_UINT32)((size_t *)ptr - (size_t *)s_CLR_RT_Heap.m_location),
(CLR_UINT32)dt,
(dataSize * sizeof(struct CLR_RT_HeapBlock)),
idx.m_data);
Expand Down Expand Up @@ -730,9 +735,9 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr)

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler info: ! (0x0x%I64X | %d) DT: %d [%08x] %d bytes\r\n",
"\r\n Profiler info: ! (0x0x%" PRIx64 " | %d) DT: %d [%08x] %d bytes\r\n",
(size_t)((CLR_UINT8 *)ptr),
(CLR_UINT32)((size_t *)ptr - s_CLR_RT_Heap.m_location),
(CLR_UINT32)((size_t *)ptr - (size_t *)s_CLR_RT_Heap.m_location),
(CLR_UINT32)dt,
elementIdx.m_data,
(dataSize * sizeof(struct CLR_RT_HeapBlock)));
Expand All @@ -753,9 +758,9 @@ void CLR_PRF_Profiler::TrackObjectCreation(CLR_RT_HeapBlock *ptr)
{
#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler info: ! (0x0x%I64X | %d) DT: %d %d bytes\r\n",
"\r\n Profiler info: ! (0x0x%" PRIx64 " | %d) DT: %d %d bytes\r\n",
(size_t)((CLR_UINT8 *)ptr),
(CLR_UINT32)((size_t *)ptr - s_CLR_RT_Heap.m_location),
(CLR_UINT32)((size_t *)ptr - (size_t *)s_CLR_RT_Heap.m_location),
(CLR_UINT32)dt,
(dataSize * sizeof(struct CLR_RT_HeapBlock)));

Expand Down Expand Up @@ -802,9 +807,9 @@ void CLR_PRF_Profiler::TrackObjectDeletion(CLR_RT_HeapBlock *ptr)

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler info: * (0x0x%I64X | %d) %d bytes\r\n",
"\r\n Profiler info: * (0x0x%" PRIx64 " | %d) %d bytes\r\n",
(size_t)((CLR_UINT8 *)ptr),
(CLR_UINT32)((size_t *)ptr - s_CLR_RT_Heap.m_location),
(CLR_UINT32)((size_t *)ptr - (size_t *)s_CLR_RT_Heap.m_location),
(dataSize * sizeof(struct CLR_RT_HeapBlock)));

#else
Expand Down Expand Up @@ -848,7 +853,7 @@ void CLR_PRF_Profiler::TrackObjectRelocation()

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler msg: u 0x%I64X 0x%I64X %d\r\n",
"\r\n Profiler msg: u 0x%" PRIx64 " 0x%" PRIx64 " %d\r\n",
relocBlocks[i].m_start,
relocBlocks[i].m_start + relocBlocks[i].m_offset,
relocBlocks[i].m_end - relocBlocks[i].m_offset);
Expand Down Expand Up @@ -887,7 +892,7 @@ void CLR_PRF_Profiler::RecordGarbageCollectionBegin()

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler msg: b 1 0 0 0x%I64X 0x%I64X %d 0\r\n",
"\r\n Profiler msg: b 1 0 0 0x%" PRIx64 " 0x%" PRIx64 " %d 0\r\n",
(CLR_UINT32)s_CLR_RT_Heap.m_location,
s_CLR_RT_Heap.m_size,
g_CLR_RT_GarbageCollector.m_totalBytes);
Expand Down Expand Up @@ -926,12 +931,12 @@ void CLR_PRF_Profiler::RecordGarbageCollectionEnd()
#ifdef _WIN64
NANOCLR_FOREACH_NODE(CLR_RT_HeapCluster, hc, g_CLR_RT_ExecutionEngine.m_heap)
{
CLR_Debug::Printf("\r\n Profiler msg: v 0x%I64X 0\r\n", (CLR_UINT32)hc->m_payloadStart);
CLR_Debug::Printf("\r\n Profiler msg: v 0x%" PRIx64 " 0\r\n", (CLR_UINT32)hc->m_payloadStart);
}
NANOCLR_FOREACH_NODE_END();

CLR_Debug::Printf(
"\r\n Profiler msg: b 0 0 0 0x%I64X 0x%I64X %d 0\r\n",
"\r\n Profiler msg: b 0 0 0 0x%" PRIx64 " 0x%" PRIx64 " %d 0\r\n",
(CLR_UINT32)s_CLR_RT_Heap.m_location,
s_CLR_RT_Heap.m_size,
g_CLR_RT_GarbageCollector.m_totalBytes);
Expand Down Expand Up @@ -975,7 +980,7 @@ void CLR_PRF_Profiler::RecordHeapCompactionBegin()

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler msg: b 1 0 0 0x%I64X 0x%I64X %d 0\r\n",
"\r\n Profiler msg: b 1 0 0 0x%" PRIx64 " 0x%" PRIx64 " %d 0\r\n",
(CLR_UINT32)s_CLR_RT_Heap.m_location,
s_CLR_RT_Heap.m_size,
g_CLR_RT_GarbageCollector.m_totalBytes);
Expand Down Expand Up @@ -1013,7 +1018,7 @@ void CLR_PRF_Profiler::RecordHeapCompactionEnd()

#ifdef _WIN64
CLR_Debug::Printf(
"\r\n Profiler msg: b 0 0 0 0x%I64X 0x%I64X %d 0\r\n",
"\r\n Profiler msg: b 0 0 0 0x%" PRIx64 " 0x%" PRIx64 " %d 0\r\n",
(CLR_UINT32)s_CLR_RT_Heap.m_location,
s_CLR_RT_Heap.m_size,
g_CLR_RT_GarbageCollector.m_totalBytes);
Expand Down