Skip to content

Commit 71ab28c

Browse files
committed
pcm-raw: add verbose mode
1 parent 781d335 commit 71ab28c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/pcm-raw.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void print_usage(const string progname)
7575
cerr << " -tr | /tr => transpose output (print single event data in a row)\n";
7676
cerr << " -ext => add headers to transposed output and extend printout to match it\n";
7777
cerr << " -s | /s => print a sample separator line between samples in transposed output\n";
78+
cerr << " -v | /v => verbose mode (print additional diagnostic messages)\n";
7879
cerr << " -l => use locale for printing values, calls -tab for readability\n";
7980
cerr << " -tab => replace default comma separator with tab\n";
8081
cerr << " -el event_list.txt | /el event_list.txt => read event list from event_list.txt file, \n";
@@ -88,6 +89,8 @@ void print_usage(const string progname)
8889
cerr << "\n";
8990
}
9091

92+
bool verbose = false;
93+
9194
PCM::RawEventConfig initCoreConfig()
9295
{
9396
return PCM::RawEventConfig{ {0,0,0,
@@ -1887,6 +1890,13 @@ int main(int argc, char* argv[])
18871890
sampleSeparator = true;
18881891
continue;
18891892
}
1893+
else if (
1894+
strncmp(*argv, "-v", 2) == 0 ||
1895+
strncmp(*argv, "/v", 2) == 0)
1896+
{
1897+
verbose = true;
1898+
continue;
1899+
}
18901900
else if (strncmp(*argv, "--", 2) == 0)
18911901
{
18921902
argv++;
@@ -1950,7 +1960,21 @@ int main(int argc, char* argv[])
19501960

19511961
auto programPMUs = [&m](const PCM::RawPMUConfigs & config)
19521962
{
1953-
PCM::ErrorCode status = m->program(config, true);
1963+
if (verbose)
1964+
{
1965+
for (const auto & pmuConfig: config)
1966+
{
1967+
for (const auto & e : pmuConfig.second.fixed)
1968+
{
1969+
cerr << "Programming " << pmuConfig.first << " fixed event: " << e.second << "\n";
1970+
}
1971+
for (const auto & e : pmuConfig.second.programmable)
1972+
{
1973+
cerr << "Programming " << pmuConfig.first << " programmable event: " << e.second << "\n";
1974+
}
1975+
}
1976+
}
1977+
PCM::ErrorCode status = m->program(config, !verbose);
19541978
m->checkError(status);
19551979
};
19561980

0 commit comments

Comments
 (0)