aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c63
1 files changed, 53 insertions, 10 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e89afc097d8a..95e249779931 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -410,7 +410,7 @@ struct symbol *dso__find_symbol(struct dso *dso,
410 return symbols__find(&dso->symbols[type], addr); 410 return symbols__find(&dso->symbols[type], addr);
411} 411}
412 412
413struct symbol *dso__first_symbol(struct dso *dso, enum map_type type) 413static struct symbol *dso__first_symbol(struct dso *dso, enum map_type type)
414{ 414{
415 return symbols__first(&dso->symbols[type]); 415 return symbols__first(&dso->symbols[type]);
416} 416}
@@ -1251,6 +1251,46 @@ out_failure:
1251 return -1; 1251 return -1;
1252} 1252}
1253 1253
1254static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
1255 enum dso_binary_type type)
1256{
1257 switch (type) {
1258 case DSO_BINARY_TYPE__JAVA_JIT:
1259 case DSO_BINARY_TYPE__DEBUGLINK:
1260 case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
1261 case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
1262 case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
1263 case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
1264 case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
1265 return !kmod && dso->kernel == DSO_TYPE_USER;
1266
1267 case DSO_BINARY_TYPE__KALLSYMS:
1268 case DSO_BINARY_TYPE__VMLINUX:
1269 case DSO_BINARY_TYPE__KCORE:
1270 return dso->kernel == DSO_TYPE_KERNEL;
1271
1272 case DSO_BINARY_TYPE__GUEST_KALLSYMS:
1273 case DSO_BINARY_TYPE__GUEST_VMLINUX:
1274 case DSO_BINARY_TYPE__GUEST_KCORE:
1275 return dso->kernel == DSO_TYPE_GUEST_KERNEL;
1276
1277 case DSO_BINARY_TYPE__GUEST_KMODULE:
1278 case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
1279 /*
1280 * kernel modules know their symtab type - it's set when
1281 * creating a module dso in machine__new_module().
1282 */
1283 return kmod && dso->symtab_type == type;
1284
1285 case DSO_BINARY_TYPE__BUILD_ID_CACHE:
1286 return true;
1287
1288 case DSO_BINARY_TYPE__NOT_FOUND:
1289 default:
1290 return false;
1291 }
1292}
1293
1254int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) 1294int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1255{ 1295{
1256 char *name; 1296 char *name;
@@ -1261,6 +1301,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1261 int ss_pos = 0; 1301 int ss_pos = 0;
1262 struct symsrc ss_[2]; 1302 struct symsrc ss_[2];
1263 struct symsrc *syms_ss = NULL, *runtime_ss = NULL; 1303 struct symsrc *syms_ss = NULL, *runtime_ss = NULL;
1304 bool kmod;
1264 1305
1265 dso__set_loaded(dso, map->type); 1306 dso__set_loaded(dso, map->type);
1266 1307
@@ -1301,7 +1342,11 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1301 if (!name) 1342 if (!name)
1302 return -1; 1343 return -1;
1303 1344
1304 /* Iterate over candidate debug images. 1345 kmod = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
1346 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
1347
1348 /*
1349 * Iterate over candidate debug images.
1305 * Keep track of "interesting" ones (those which have a symtab, dynsym, 1350 * Keep track of "interesting" ones (those which have a symtab, dynsym,
1306 * and/or opd section) for processing. 1351 * and/or opd section) for processing.
1307 */ 1352 */
@@ -1311,6 +1356,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1311 1356
1312 enum dso_binary_type symtab_type = binary_type_symtab[i]; 1357 enum dso_binary_type symtab_type = binary_type_symtab[i];
1313 1358
1359 if (!dso__is_compatible_symtab_type(dso, kmod, symtab_type))
1360 continue;
1361
1314 if (dso__read_binary_type_filename(dso, symtab_type, 1362 if (dso__read_binary_type_filename(dso, symtab_type,
1315 root_dir, name, PATH_MAX)) 1363 root_dir, name, PATH_MAX))
1316 continue; 1364 continue;
@@ -1353,15 +1401,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1353 if (!runtime_ss && syms_ss) 1401 if (!runtime_ss && syms_ss)
1354 runtime_ss = syms_ss; 1402 runtime_ss = syms_ss;
1355 1403
1356 if (syms_ss) { 1404 if (syms_ss)
1357 int km; 1405 ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod);
1358 1406 else
1359 km = dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
1360 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
1361 ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, km);
1362 } else {
1363 ret = -1; 1407 ret = -1;
1364 }
1365 1408
1366 if (ret > 0) { 1409 if (ret > 0) {
1367 int nr_plt; 1410 int nr_plt;