Skip to content

Commit 2c62eb7

Browse files
Copilotxusheng6
authored andcommitted
Fix fmt-style LogError/LogInfo calls to use proper printf-style format strings (#847)
1 parent 103f9ae commit 2c62eb7

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

core/adapters/dbgengttdadapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ bool DbgEngTTDAdapter::SetTTDPosition(const TTDPosition& position)
466466
bool success = output.find("error") == std::string::npos && output.find("failed") == std::string::npos;
467467
if (success)
468468
{
469-
LogInfo("Successfully navigated to TTD position {:X}:{:X}", position.sequence, position.step);
469+
LogInfo("%s", fmt::format("Successfully navigated to TTD position {:X}:{:X}", position.sequence, position.step).c_str());
470470
}
471471
else
472472
{
473-
LogError("Failed to navigate to TTD position {:X}:{:X}", position.sequence, position.step);
473+
LogError("%s", fmt::format("Failed to navigate to TTD position {:X}:{:X}", position.sequence, position.step).c_str());
474474
}
475475
return success;
476476
}

core/debuggercontroller.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,7 +2971,7 @@ bool DebuggerController::RunCodeCoverageAnalysis(uint64_t startAddress, uint64_t
29712971
m_executedInstructions.clear();
29722972
m_codeCoverageAnalysisRun = false;
29732973

2974-
LogInfo("Starting TTD code coverage analysis for range 0x" PRIX64 " - 0x" PRIX64 "...", startAddress, endAddress);
2974+
LogInfo("Starting TTD code coverage analysis for range 0x%" PRIX64 " - 0x%" PRIX64 "...", startAddress, endAddress);
29752975

29762976
// Query TTD for execute access covering the specified range
29772977
auto events = GetTTDMemoryAccessForAddress(startAddress, endAddress, TTDMemoryExecute);
@@ -2989,8 +2989,8 @@ bool DebuggerController::RunCodeCoverageAnalysis(uint64_t startAddress, uint64_t
29892989
}
29902990

29912991
m_codeCoverageAnalysisRun = true;
2992-
LogInfo("TTD code coverage analysis completed for range. Found %d executed instructions.",
2993-
m_executedInstructions.size());
2992+
LogInfo("TTD code coverage analysis completed for range. Found 0x%" PRIu64 "executed instructions.",
2993+
(uint64_t)m_executedInstructions.size());
29942994

29952995
return true;
29962996
}
@@ -3015,7 +3015,7 @@ bool DebuggerController::SaveCodeCoverageToFile(const std::string& filePath) con
30153015
std::ofstream file(filePath, std::ios::binary);
30163016
if (!file.is_open())
30173017
{
3018-
LogError("Failed to open file for writing: {}", filePath.c_str());
3018+
LogError("%s", fmt::format("Failed to open file for writing: {}", filePath.c_str()).c_str());
30193019
return false;
30203020
}
30213021

@@ -3035,12 +3035,13 @@ bool DebuggerController::SaveCodeCoverageToFile(const std::string& filePath) con
30353035
}
30363036

30373037
file.close();
3038-
LogInfo("Saved %d executed instruction addresses to %s", count, filePath.c_str());
3038+
LogError("%s", fmt::format("Saved {} executed instruction addresses to {}", count, filePath.c_str()).c_str());
3039+
30393040
return true;
30403041
}
30413042
catch (const std::exception& e)
30423043
{
3043-
LogError("Error saving code coverage: {}", e.what());
3044+
LogError("%s", fmt::format("Error saving code coverage: {}", e.what()).c_str());
30443045
return false;
30453046
}
30463047
}
@@ -3053,7 +3054,7 @@ bool DebuggerController::LoadCodeCoverageFromFile(const std::string& filePath)
30533054
std::ifstream file(filePath, std::ios::binary);
30543055
if (!file.is_open())
30553056
{
3056-
LogError("Failed to open file for reading: {}", filePath.c_str());
3057+
LogError("%s", fmt::format("Failed to open file for reading: {}", filePath.c_str()).c_str());
30573058
return false;
30583059
}
30593060

@@ -3071,7 +3072,7 @@ bool DebuggerController::LoadCodeCoverageFromFile(const std::string& filePath)
30713072
file.read(reinterpret_cast<char*>(&version), sizeof(version));
30723073
if (version != 1)
30733074
{
3074-
LogError("Unsupported file version: {}", version);
3075+
LogError("%s", fmt::format("Unsupported file version: {}", version).c_str());
30753076
return false;
30763077
}
30773078

@@ -3090,12 +3091,12 @@ bool DebuggerController::LoadCodeCoverageFromFile(const std::string& filePath)
30903091
file.close();
30913092
m_codeCoverageAnalysisRun = true;
30923093

3093-
LogInfo("Loaded {} executed instruction addresses from {}", count, filePath.c_str());
3094+
LogInfo("%s", fmt::format("Loaded {} executed instruction addresses from {}", count, filePath.c_str()).c_str());
30943095
return true;
30953096
}
30963097
catch (const std::exception& e)
30973098
{
3098-
LogError("Error loading code coverage: {}", e.what());
3099+
LogError("%s", fmt::format("Error loading code coverage: {}", e.what()).c_str());
30993100
return false;
31003101
}
31013102
}

0 commit comments

Comments
 (0)