Commit 97001f83 authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #96 from iovisor/bug

fix print() top logic
parents 7404d0e8 80b54e9a
......@@ -645,6 +645,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div)
if (div == 0)
div = 1;
uint32_t i = 0;
int total = values_by_key.size();
for (auto &pair : values_by_key)
{
auto key = pair.first;
......@@ -652,10 +653,9 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div)
if (top)
{
if (i < (values_by_key.size() - top))
if (total > top && i++ < (total - top))
continue;
}
i++;
std::cout << map.name_ << map.key_.argument_value_list(*this, key) << ": ";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment