Do not pass type flag to symbol callback
authorTeng Qin <qinteng@fb.com>
Wed, 10 May 2017 19:51:17 +0000 (12:51 -0700)
committerTeng Qin <qinteng@fb.com>
Sat, 20 May 2017 04:55:57 +0000 (21:55 -0700)
As the symbol type check now controled by the specified
`bcc_symbol_option` and handled in lower level, there is not need to
pass the type flag to the callback anymore.

src/cc/bcc_elf.c
src/cc/bcc_elf.h
src/cc/bcc_perf_map.c
src/cc/bcc_perf_map.h
src/cc/bcc_syms.cc
src/cc/syms.h

index 4b742eba006ee23176a941c87a127e0aea78825f..f04ad2467862cfbf68a1016b3b9e5d906e1ca4c3 100644 (file)
@@ -182,7 +182,7 @@ static int list_in_scn(Elf *e, Elf_Scn *section, size_t stridx, size_t symsize,
       if (!(option->use_symbol_type & flag))
         continue;
 
-      if (callback(name, sym.st_value, sym.st_size, sym.st_info, payload) < 0)
+      if (callback(name, sym.st_value, sym.st_size, payload) < 0)
         return 1;      // signal termination to caller
     }
   }
index bece58673f527766caf6b9f671539c6cc378f3b1..5399936092a8e2116a3b5c67f32915c074b1ebc8 100644 (file)
@@ -34,7 +34,9 @@ struct bcc_elf_usdt {
 
 typedef void (*bcc_elf_probecb)(const char *, const struct bcc_elf_usdt *,
                                 void *);
-typedef int (*bcc_elf_symcb)(const char *, uint64_t, uint64_t, int, void *);
+
+// Symbol name, start address, length, payload
+typedef int (*bcc_elf_symcb)(const char *, uint64_t, uint64_t, void *);
 
 int bcc_elf_foreach_usdt(const char *path, bcc_elf_probecb callback,
                          void *payload);
index e7de08c8e2d4191c9d259f2a01d61cccb13c9032..290e10229dc7288820c16e7966fa076ea51c7d11 100644 (file)
@@ -109,7 +109,7 @@ int bcc_perf_map_foreach_sym(const char *path, bcc_perf_map_symcb callback,
     if (newline)
         newline[0] = '\0';
 
-    callback(cursor, begin, len, 0, payload);
+    callback(cursor, begin, len, payload);
   }
 
   free(line);
index ddfd1c939504fcff3eb92cd87c0b2848f381d5a6..508f262edd1ef06e660c753a633c643768ba15a5 100644 (file)
@@ -24,8 +24,8 @@ extern "C" {
 #include <stdbool.h>
 #include <unistd.h>
 
-typedef int (*bcc_perf_map_symcb)(const char *, uint64_t, uint64_t, int,
-                                  void *);
+// Symbol name, start address, length, payload
+typedef int (*bcc_perf_map_symcb)(const char *, uint64_t, uint64_t, void *);
 
 bool bcc_is_perf_map(const char *path);
 
index b8021beb0a444fe858acf9c360304143f1dfc3f3..0d3b4a4a6bb445fdc56c38f20d8646aa1add734b 100644 (file)
@@ -290,10 +290,10 @@ bool ProcSyms::Module::init() {
 }
 
 int ProcSyms::Module::_add_symbol(const char *symname, uint64_t start,
-                                  uint64_t end, int flags, void *p) {
+                                  uint64_t size, void *p) {
   Module *m = static_cast<Module *>(p);
   auto res = m->symnames_.emplace(symname);
-  m->syms_.emplace_back(&*(res.first), start, end, flags);
+  m->syms_.emplace_back(&*(res.first), start, size);
   return 0;
 }
 
@@ -450,8 +450,8 @@ int bcc_resolve_global_addr(int pid, const char *module, const uint64_t address,
   return 0;
 }
 
-static int _sym_cb_wrapper(const char *symname, uint64_t addr, uint64_t end,
-                           int flags, void *payload) {
+static int _sym_cb_wrapper(const char *symname, uint64_t addr, uint64_t,
+                           void *payload) {
   SYM_CB cb = (SYM_CB) payload;
   return cb(symname, addr);
 }
@@ -470,8 +470,8 @@ int bcc_foreach_function_symbol(const char *module, SYM_CB cb) {
       module, _sym_cb_wrapper, &default_option, (void *)cb);
 }
 
-static int _find_sym(const char *symname, uint64_t addr, uint64_t end,
-                     int flags, void *payload) {
+static int _find_sym(const char *symname, uint64_t addr, uint64_t,
+                     void *payload) {
   struct bcc_symbol *sym = (struct bcc_symbol *)payload;
   if (!strcmp(sym->name, symname)) {
     sym->offset = addr;
index ea0584d36b96da50aeb48eb84512a434f2533f0e..35463ef5a7b0a8dffa8e359c71fe4b6f52adf4fd 100644 (file)
@@ -98,12 +98,11 @@ private:
 
 class ProcSyms : SymbolCache {
   struct Symbol {
-    Symbol(const std::string *name, uint64_t start, uint64_t size, int flags = 0)
-        : name(name), start(start), size(size), flags(flags) {}
+    Symbol(const std::string *name, uint64_t start, uint64_t size)
+        : name(name), start(start), size(size) {}
     const std::string *name;
     uint64_t start;
     uint64_t size;
-    int flags;
 
     bool operator<(const struct Symbol& rhs) const {
       return start < rhs.start;
@@ -144,8 +143,8 @@ class ProcSyms : SymbolCache {
     bool find_addr(uint64_t offset, struct bcc_symbol *sym);
     bool find_name(const char *symname, uint64_t *addr);
 
-    static int _add_symbol(const char *symname, uint64_t start, uint64_t end,
-                           int flags, void *p);
+    static int _add_symbol(const char *symname, uint64_t start, uint64_t size,
+                           void *p);
   };
 
   int pid_;