Skip to contentSkip to conversation

perf annotate browser: Handle NULL jump targets

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Apr 27, 2012 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  9481ede909e08418c9379665ee9f25335d20dd06
Gitweb:     http://git.kernel.org/tip/9481ede909e08418c9379665ee9f25335d20dd06
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 25 Apr 2012 07:48:42 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 25 Apr 2012 07:48:42 -0300

perf annotate browser: Handle NULL jump targets

In annotate_browser__mark_jump_targets

702                     dlt = browser->offsets[dl->ops.target];
703                     bdlt = disasm_line__browser(dlt);
704                     bdlt->jump_target = true;

705 }
706
707 }

(gdb) p size
$5 = 2415
(gdb) p offset
$6 = 140
(gdb) p dl->ops.target
$7 = 143
(gdb) p browser->offsets[143]
$8 = (struct disasm_line *) 0x0
(gdb) p dl->name
$9 = 0x2363bd0 "je"
(gdb)

Really strange, the code assumed that at the jump target we would have an assembly line, but only in the previous instruction offset we have a 'lock':

(gdb) p browser->offsets[144]
$10 = (struct disasm_line *) 0x0
(gdb) p browser->offsets[142]
$11 = (struct disasm_line *) 0x27bd620
(gdb) p browser->offsets[142]->name
$12 = 0x237a8a0 "lock"
(gdb)

I'll study this more, but for now I'll just check if there is a disasm_line at dl->ops.target, i.e. a valid jump target.

---
 tools/perf/ui/browsers/annotate.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
tools/perf/ui/browsers/annotate.c +7 -0
index 9e3310c..4c83fe3 100644
@@ -700,6 +700,13 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser
 		}
 
 		dlt = browser->offsets[dl->ops.target];
+		/*
+ 		 * FIXME: Oops, no jump target? Buggy disassembler? Or do we
+ 		 * have to adjust to the previous offset?
+ 		 */
+		if (dlt == NULL)
+			continue;
+
 		bdlt = disasm_line__browser(dlt);
 		bdlt->jump_target = true;
 	}