Skip to content

Commit a0345f4

Browse files
authored
Merge pull request #908 from intel/push-2025-02-12
Push 2025 02 12
2 parents 76cb400 + c6ef450 commit a0345f4

File tree

10 files changed

+115
-93
lines changed

10 files changed

+115
-93
lines changed

doc/ENVVAR_README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
`PCM_NO_MAIN_EXCEPTION_HANDLER=1` : don't catch exceptions in the main function of pcm tools (a debugging option)
1414

1515
`PCM_ENFORCE_MBM=1` : force-enable Memory Bandwidth Monitoring (MBM) metrics (LocalMemoryBW = LMB) and (RemoteMemoryBW = RMB) on processors with RDT/MBM errata
16+
17+
`PCM_DEBUG_LEVEL=x` : x is an integer defining debug output level. level = 0 (default): minimal or no debug info, > 0 increases verbosity

perfmon

src/cpucounters.cpp

Lines changed: 83 additions & 86 deletions
Large diffs are not rendered by default.

src/pcm-tpmi.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int mainThrows(int argc, char * argv[])
6262
{
6363
case 'w':
6464
write = true;
65-
value = (pcm::uint32)read_number(optarg);
65+
value = read_number(optarg);
6666
break;
6767
case 'd':
6868
dec = true;
@@ -126,7 +126,7 @@ int mainThrows(int argc, char * argv[])
126126
continue;
127127
}
128128
TPMIHandle h(i, requestedID, requestedRelativeOffset, !write);
129-
auto one = [&](const size_t p)
129+
auto one = [&](const size_t p, uint64 value)
130130
{
131131
if (!dec)
132132
std::cout << std::hex << std::showbase;
@@ -152,7 +152,7 @@ int mainThrows(int argc, char * argv[])
152152
{
153153
if (p < h.getNumEntries())
154154
{
155-
one(p);
155+
one(p, value);
156156
}
157157
}
158158
}

src/utils.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ extern char ** environ;
2929
#include <glob.h>
3030
#endif
3131

32+
#include "debug.h"
33+
3234
namespace pcm {
3335

3436

@@ -46,6 +48,17 @@ bool isInKeepList(const StringType& varName, const std::vector<StringType>& keep
4648
return false;
4749
}
4850

51+
void setDefaultDebugLevel()
52+
{
53+
auto strDebugLevel = pcm::safe_getenv("PCM_DEBUG_LEVEL");
54+
if (strDebugLevel.empty() == false)
55+
{
56+
auto intDebugLevel = std::stoi(strDebugLevel);
57+
debug::dyn_debug_level(intDebugLevel);
58+
DBG(0, "Debug level set to ", intDebugLevel);
59+
}
60+
}
61+
4962
#if defined(_MSC_VER)
5063

5164
void eraseEnvironmentVariables(const std::vector<std::wstring>& keepList) {

src/utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#ifdef __linux__
4141
#include <unistd.h>
4242
#endif
43+
4344
namespace pcm {
4445

4546
template <class T>
@@ -81,6 +82,7 @@ namespace pcm {
8182
#define PCM_STRING(x) (x)
8283
#endif
8384
void eraseEnvironmentVariables(const std::vector<StringType>& keepList);
85+
void setDefaultDebugLevel();
8486
}
8587

8688
#ifdef _MSC_VER
@@ -103,6 +105,7 @@ int main(int argc, char * argv[]) \
103105
PCM_SET_DLL_DIR \
104106
if (pcm::safe_getenv("PCM_NO_MAIN_EXCEPTION_HANDLER") == std::string("1")) return mainThrows(argc, argv); \
105107
try { \
108+
setDefaultDebugLevel(); \
106109
return mainThrows(argc, argv); \
107110
} catch(const std::runtime_error & e) \
108111
{ \

tests/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ if [ "$?" -ne "0" ]; then
2222
exit 1
2323
fi
2424

25+
echo Testing pcm with PCM_DEBUG_LEVEL=100
26+
PCM_DEBUG_LEVEL=100 ./pcm -r -- sleep 1
27+
if [ "$?" -ne "0" ]; then
28+
echo "Error in pcm"
29+
exit 1
30+
fi
31+
2532
echo Testing pcm w/o env vars
2633
./pcm -r -- sleep 1
2734
if [ "$?" -ne "0" ]; then

0 commit comments

Comments
 (0)