Skip to content

Commit

Permalink
cc: Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg committed May 6, 2016
1 parent 1043645 commit 040df7d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
5 changes: 2 additions & 3 deletions src/cc/bcc_syms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ ino_t ProcStat::getinode_() {
return (!stat(procfs_.c_str(), &s)) ? s.st_ino : -1;
}

ProcStat::ProcStat(int pid) :
procfs_(tfm::format("/proc/%d/exe", pid)),
inode_(getinode_()) {}
ProcStat::ProcStat(int pid)
: procfs_(tfm::format("/proc/%d/exe", pid)), inode_(getinode_()) {}

void KSyms::_add_symbol(const char *symname, uint64_t addr, void *p) {
KSyms *ks = static_cast<KSyms *>(p);
Expand Down
26 changes: 13 additions & 13 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,20 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
text = to_string(numcpu);
rewriter_.ReplaceText(SourceRange(Call->getLocStart(), Call->getLocEnd()), text);
} else if (Decl->getName() == "bpf_usdt_readarg_p") {
text = "({ u64 __addr = 0x0; ";
text += "_bpf_readarg_" + current_fn_ + "_" + args[0] + "(" +
args[1] + ", &__addr, sizeof(__addr));";
text += "bpf_probe_read(" + args[2] + ", " + args[3] +
", (void *)__addr);";
text += "})";
rewriter_.ReplaceText(
SourceRange(Call->getLocStart(), Call->getLocEnd()), text);
text = "({ u64 __addr = 0x0; ";
text += "_bpf_readarg_" + current_fn_ + "_" + args[0] + "(" +
args[1] + ", &__addr, sizeof(__addr));";
text += "bpf_probe_read(" + args[2] + ", " + args[3] +
", (void *)__addr);";
text += "})";
rewriter_.ReplaceText(
SourceRange(Call->getLocStart(), Call->getLocEnd()), text);
} else if (Decl->getName() == "bpf_usdt_readarg") {
text = "_bpf_readarg_" + current_fn_ + "_" + args[0] + "(" +
args[1] + ", " + args[2] + ", sizeof(*(" + args[2] + ")))";
rewriter_.ReplaceText(
SourceRange(Call->getLocStart(), Call->getLocEnd()), text);
}
text = "_bpf_readarg_" + current_fn_ + "_" + args[0] + "(" + args[1] +
", " + args[2] + ", sizeof(*(" + args[2] + ")))";
rewriter_.ReplaceText(
SourceRange(Call->getLocStart(), Call->getLocEnd()), text);
}
}
}
}
Expand Down
27 changes: 13 additions & 14 deletions src/cc/usdt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ bool Probe::in_shared_object() {

bool Probe::resolve_global_address(uint64_t *global, const uint64_t addr) {
if (in_shared_object()) {
return (pid_ && !bcc_resolve_global_addr(
*pid_, bin_path_.c_str(), addr, global));
return (pid_ &&
!bcc_resolve_global_addr(*pid_, bin_path_.c_str(), addr, global));
}

*global = addr;
Expand Down Expand Up @@ -154,16 +154,16 @@ bool Probe::usdt_getarg(std::ostream &stream) {
std::string cptr = tfm::format("*((%s *)dest)", ctype);

tfm::format(stream,
"static inline int _bpf_readarg_%s_%d("
"struct pt_regs *ctx, void *dest, size_t len) {\n"
" if (len != sizeof(%s)) return -1;\n",
attached_to_.value(), arg_n + 1, ctype);
"static inline int _bpf_readarg_%s_%d("
"struct pt_regs *ctx, void *dest, size_t len) {\n"
" if (len != sizeof(%s)) return -1;\n",
attached_to_.value(), arg_n + 1, ctype);

if (locations_.size() == 1) {
Location &location = locations_.front();
stream << " ";
if (!location.arguments_[arg_n].assign_to_local(stream, cptr,
bin_path_, pid_))
if (!location.arguments_[arg_n].assign_to_local(stream, cptr, bin_path_,
pid_))
return false;
stream << "\n return 0;\n}\n";
} else {
Expand All @@ -175,8 +175,8 @@ bool Probe::usdt_getarg(std::ostream &stream) {
return false;

tfm::format(stream, " case 0x%xULL: ", global_address);
if (!location.arguments_[arg_n].assign_to_local(stream, cptr,
bin_path_, pid_))
if (!location.arguments_[arg_n].assign_to_local(stream, cptr, bin_path_,
pid_))
return false;

stream << " return 0;\n";
Expand Down Expand Up @@ -211,8 +211,8 @@ void Context::add_probe(const char *binpath, const struct bcc_elf_usdt *probe) {
}
}

probes_.emplace_back(new Probe(binpath, probe->provider,
probe->name, probe->semaphore, pid_));
probes_.emplace_back(
new Probe(binpath, probe->provider, probe->name, probe->semaphore, pid_));
probes_.back()->add_location(probe->pc, probe->arg_fmt);
}

Expand Down Expand Up @@ -282,8 +282,7 @@ Context::Context(int pid) : pid_(pid), pid_stat_(pid), loaded_(false) {

Context::~Context() {
if (pid_stat_ && !pid_stat_->is_stale()) {
for (auto &p : probes_)
p->disable();
for (auto &p : probes_) p->disable();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cc/test_usdt_probes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_CASE("test finding a probe in our own process", "[usdt]") {
REQUIRE(ctx.num_probes() >= 1);

SECTION("our test probe") {
auto probe = ctx.get("sample_probe_1");
auto probe = ctx.get("sample_probe_1");
REQUIRE(probe);

REQUIRE(probe->in_shared_object() == false);
Expand Down

0 comments on commit 040df7d

Please sign in to comment.