Skip to content

Commit 2c241bd

Browse files
committed
perf symbols: Make sym->end be the first address after the symbol range
To follow vm_area_struct->vm_end convention. By adhering to the convention that ->end is the first address outside the symbol's range we can do things like: sym->end = start + len; len = sym->end - sym->start; This is also now the convention used for struct map->end, fixing some off-by-one bugs. Cc: Adrian Hunter <[email protected]> Cc: Chuck Ebbert <[email protected]> Cc: David Ahern <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent eba8523 commit 2c241bd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

tools/perf/util/annotate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
478478

479479
pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
480480

481-
if (addr < sym->start || addr > sym->end)
481+
if (addr < sym->start || addr >= sym->end)
482482
return -ERANGE;
483483

484484
offset = addr - sym->start;
@@ -836,7 +836,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
836836
end = map__rip_2objdump(map, sym->end);
837837

838838
offset = line_ip - start;
839-
if ((u64)line_ip < start || (u64)line_ip > end)
839+
if ((u64)line_ip < start || (u64)line_ip >= end)
840840
offset = -1;
841841
else
842842
parsed_line = tmp2 + 1;
@@ -966,7 +966,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
966966
kce.kcore_filename = symfs_filename;
967967
kce.addr = map__rip_2objdump(map, sym->start);
968968
kce.offs = sym->start;
969-
kce.len = sym->end + 1 - sym->start;
969+
kce.len = sym->end - sym->start;
970970
if (!kcore_extract__create(&kce)) {
971971
delete_extract = true;
972972
strlcpy(symfs_filename, kce.extract_filename,
@@ -987,7 +987,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
987987
disassembler_style ? "-M " : "",
988988
disassembler_style ? disassembler_style : "",
989989
map__rip_2objdump(map, sym->start),
990-
map__rip_2objdump(map, sym->end+1),
990+
map__rip_2objdump(map, sym->end),
991991
symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
992992
symbol_conf.annotate_src ? "-S" : "",
993993
symfs_filename, filename);

tools/perf/util/symbol.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void symbols__fixup_end(struct rb_root *symbols)
186186
curr = rb_entry(nd, struct symbol, rb_node);
187187

188188
if (prev->end == prev->start && prev->end != curr->start)
189-
prev->end = curr->start - 1;
189+
prev->end = curr->start;
190190
}
191191

192192
/* Last entry */
@@ -229,7 +229,7 @@ struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name)
229229
sym = ((void *)sym) + symbol_conf.priv_size;
230230

231231
sym->start = start;
232-
sym->end = len ? start + len - 1 : start;
232+
sym->end = len ? start + len : start;
233233
sym->binding = binding;
234234
sym->namelen = namelen - 1;
235235

@@ -325,7 +325,7 @@ static struct symbol *symbols__find(struct rb_root *symbols, u64 ip)
325325

326326
if (ip < s->start)
327327
n = n->rb_left;
328-
else if (ip > s->end)
328+
else if (ip >= s->end)
329329
n = n->rb_right;
330330
else
331331
return s;

tools/perf/util/symbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void symbols__delete(struct rb_root *symbols);
9595

9696
static inline size_t symbol__size(const struct symbol *sym)
9797
{
98-
return sym->end - sym->start + 1;
98+
return sym->end - sym->start;
9999
}
100100

101101
struct strlist;

0 commit comments

Comments
 (0)