Skip to content

Commit

Permalink
Merge pull request iovisor#1652 from palmtenor/stack_fixes
Browse files Browse the repository at this point in the history
Two minor fixes on Stack-trace table
  • Loading branch information
yonghong-song committed Mar 27, 2018
2 parents 955b55e + 7bfa4a1 commit 76bec4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cc/api/BPFTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ void BPFStackTable::clear_table_non_atomic() {
std::vector<uintptr_t> BPFStackTable::get_stack_addr(int stack_id) {
std::vector<uintptr_t> res;
stacktrace_t stack;
if (stack_id < 0)
return res;
if (!lookup(&stack_id, &stack))
return res;
for (int i = 0; (i < BPF_MAX_STACK_DEPTH) && (stack.ip[i] != 0); i++)
Expand All @@ -189,6 +191,8 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
int pid) {
auto addresses = get_stack_addr(stack_id);
std::vector<std::string> res;
if (addresses.empty())
return res;
res.reserve(addresses.size());

if (pid < 0)
Expand Down
3 changes: 2 additions & 1 deletion src/cc/export/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ R"********(
#include <uapi/linux/bpf.h>
#include <uapi/linux/if_packet.h>
#include <linux/version.h>
#include <linux/log2.h>

#ifndef CONFIG_BPF_SYSCALL
#error "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"
Expand Down Expand Up @@ -184,7 +185,7 @@ struct bpf_stacktrace {
};

#define BPF_STACK_TRACE(_name, _max_entries) \
BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, _max_entries)
BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, roundup_pow_of_two(_max_entries))

#define BPF_PROG_ARRAY(_name, _max_entries) \
BPF_TABLE("prog", u32, u32, _name, _max_entries)
Expand Down

0 comments on commit 76bec4d

Please sign in to comment.