aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 809b4c50beae..7dabde14ea54 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -232,9 +232,16 @@ static int mov__parse(struct ins_operands *ops)
232 return -1; 232 return -1;
233 233
234 target = ++s; 234 target = ++s;
235 comment = strchr(s, '#');
235 236
236 while (s[0] != '\0' && !isspace(s[0])) 237 if (comment != NULL)
237 ++s; 238 s = comment - 1;
239 else
240 s = strchr(s, '\0') - 1;
241
242 while (s > target && isspace(s[0]))
243 --s;
244 s++;
238 prev = *s; 245 prev = *s;
239 *s = '\0'; 246 *s = '\0';
240 247
@@ -244,7 +251,6 @@ static int mov__parse(struct ins_operands *ops)
244 if (ops->target.raw == NULL) 251 if (ops->target.raw == NULL)
245 goto out_free_source; 252 goto out_free_source;
246 253
247 comment = strchr(s, '#');
248 if (comment == NULL) 254 if (comment == NULL)
249 return 0; 255 return 0;
250 256
@@ -472,7 +478,7 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
472 478
473 pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr)); 479 pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
474 480
475 if (addr < sym->start || addr > sym->end) 481 if (addr < sym->start || addr >= sym->end)
476 return -ERANGE; 482 return -ERANGE;
477 483
478 offset = addr - sym->start; 484 offset = addr - sym->start;
@@ -830,7 +836,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
830 end = map__rip_2objdump(map, sym->end); 836 end = map__rip_2objdump(map, sym->end);
831 837
832 offset = line_ip - start; 838 offset = line_ip - start;
833 if ((u64)line_ip < start || (u64)line_ip > end) 839 if ((u64)line_ip < start || (u64)line_ip >= end)
834 offset = -1; 840 offset = -1;
835 else 841 else
836 parsed_line = tmp2 + 1; 842 parsed_line = tmp2 + 1;
@@ -899,10 +905,8 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
899 struct kcore_extract kce; 905 struct kcore_extract kce;
900 bool delete_extract = false; 906 bool delete_extract = false;
901 907
902 if (filename) { 908 if (filename)
903 snprintf(symfs_filename, sizeof(symfs_filename), "%s%s", 909 symbol__join_symfs(symfs_filename, filename);
904 symbol_conf.symfs, filename);
905 }
906 910
907 if (filename == NULL) { 911 if (filename == NULL) {
908 if (dso->has_build_id) { 912 if (dso->has_build_id) {
@@ -922,8 +926,7 @@ fallback:
922 * DSO is the same as when 'perf record' ran. 926 * DSO is the same as when 'perf record' ran.
923 */ 927 */
924 filename = (char *)dso->long_name; 928 filename = (char *)dso->long_name;
925 snprintf(symfs_filename, sizeof(symfs_filename), "%s%s", 929 symbol__join_symfs(symfs_filename, filename);
926 symbol_conf.symfs, filename);
927 free_filename = false; 930 free_filename = false;
928 } 931 }
929 932
@@ -963,7 +966,7 @@ fallback:
963 kce.kcore_filename = symfs_filename; 966 kce.kcore_filename = symfs_filename;
964 kce.addr = map__rip_2objdump(map, sym->start); 967 kce.addr = map__rip_2objdump(map, sym->start);
965 kce.offs = sym->start; 968 kce.offs = sym->start;
966 kce.len = sym->end + 1 - sym->start; 969 kce.len = sym->end - sym->start;
967 if (!kcore_extract__create(&kce)) { 970 if (!kcore_extract__create(&kce)) {
968 delete_extract = true; 971 delete_extract = true;
969 strlcpy(symfs_filename, kce.extract_filename, 972 strlcpy(symfs_filename, kce.extract_filename,
@@ -984,7 +987,7 @@ fallback:
984 disassembler_style ? "-M " : "", 987 disassembler_style ? "-M " : "",
985 disassembler_style ? disassembler_style : "", 988 disassembler_style ? disassembler_style : "",
986 map__rip_2objdump(map, sym->start), 989 map__rip_2objdump(map, sym->start),
987 map__rip_2objdump(map, sym->end+1), 990 map__rip_2objdump(map, sym->end),
988 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw", 991 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
989 symbol_conf.annotate_src ? "-S" : "", 992 symbol_conf.annotate_src ? "-S" : "",
990 symfs_filename, filename); 993 symfs_filename, filename);