Commit 6d6dec86 authored by Alastair Robertson's avatar Alastair Robertson

Print out values and keys as signed integers

parent 17117141
...@@ -90,7 +90,7 @@ int BPFtrace::print_map(Map &map) const ...@@ -90,7 +90,7 @@ int BPFtrace::print_map(Map &map) const
{ {
std::cout << map.name_ << map.key_.argument_value_list(*this, key) << ": "; std::cout << map.name_ << map.key_.argument_value_list(*this, key) << ": ";
uint64_t value; int64_t value;
int err = bpf_lookup_elem(map.mapfd_, key.data(), &value); int err = bpf_lookup_elem(map.mapfd_, key.data(), &value);
if (err) if (err)
{ {
...@@ -264,7 +264,7 @@ std::vector<uint8_t> BPFtrace::find_empty_key(Map &map, size_t size) const ...@@ -264,7 +264,7 @@ std::vector<uint8_t> BPFtrace::find_empty_key(Map &map, size_t size) const
throw std::runtime_error("Could not find empty key"); throw std::runtime_error("Could not find empty key");
} }
std::string BPFtrace::get_stack(uint64_t stackid, int indent) const std::string BPFtrace::get_stack(uint32_t stackid, int indent) const
{ {
auto stack_trace = std::vector<uint64_t>(MAX_STACK_SIZE); auto stack_trace = std::vector<uint64_t>(MAX_STACK_SIZE);
int err = bpf_lookup_elem(stackid_map_->mapfd_, &stackid, stack_trace.data()); int err = bpf_lookup_elem(stackid_map_->mapfd_, &stackid, stack_trace.data());
......
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
int start(); int start();
void stop(); void stop();
int print_maps() const; int print_maps() const;
std::string get_stack(uint64_t stackid, int indent=0) const; std::string get_stack(uint32_t stackid, int indent=0) const;
std::map<std::string, std::unique_ptr<Map>> maps_; std::map<std::string, std::unique_ptr<Map>> maps_;
std::map<std::string, std::tuple<uint8_t *, uintptr_t>> sections_; std::map<std::string, std::tuple<uint8_t *, uintptr_t>> sections_;
......
...@@ -29,7 +29,7 @@ Map::Map(std::string name) : name_(name) ...@@ -29,7 +29,7 @@ Map::Map(std::string name) : name_(name)
{ {
// Only used for creating maps for storing stack IDs // Only used for creating maps for storing stack IDs
int key_size = 4; int key_size = 4;
int value_size = 8 * MAX_STACK_SIZE; int value_size = sizeof(uintptr_t) * MAX_STACK_SIZE;
int max_entries = 128; int max_entries = 128;
int flags = 0; int flags = 0;
mapfd_ = bpf_create_map(BPF_MAP_TYPE_STACK_TRACE, key_size, value_size, max_entries, flags); mapfd_ = bpf_create_map(BPF_MAP_TYPE_STACK_TRACE, key_size, value_size, max_entries, flags);
......
...@@ -61,9 +61,9 @@ std::string MapKey::argument_value(const BPFtrace &bpftrace, ...@@ -61,9 +61,9 @@ std::string MapKey::argument_value(const BPFtrace &bpftrace,
switch (arg.size) switch (arg.size)
{ {
case 8: case 8:
return std::to_string(*(uint64_t*)data); return std::to_string(*(int64_t*)data);
case 4: case 4:
return std::to_string(*(uint32_t*)data); return std::to_string(*(int32_t*)data);
} }
case Type::stack: case Type::stack:
return bpftrace.get_stack(*(uint32_t*)data); return bpftrace.get_stack(*(uint32_t*)data);
......
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