perf annotate: Fix BUG_ON in basic block processing
PATCH 1/1 perf annotate: Fix BUG_ON in basic block processing
Hit with perf annotate --code-with-type --stdio
perf: util/annotate-data.c:1299: find_data_type_insn: Assertion `!(bb->begin->al.offset == -1 || bb->end->al.offset == -1)' failed.
This makes sure to skip non instruction disasm lines in all cases that add basic blocks. Also added some extra BUG_ONs for this case.
Signed-off-by Andi Kleen <[email protected]>
--- tools/perf/util/annotate-data.c | 10 +++++++++- tools/perf/util/annotate.c | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-)
tools/perf/util/annotate-data.c +9 -1
@@ -986,7 +986,15 @@ static void prepend_basic_blocks(struct list_head *this_blocks, }/* Point to the insn before the last when adding this block to full_blocks */ - last_bb->end =list_prev_entry (last_bb->end, al.node); +do { +/* Nothing useful found */ +if (last_bb->end == last_bb->begin) { +list_del (&last_bb->list); +free (last_bb); + goto out; + } + last_bb->end =list_prev_entry (last_bb->end, al.node); + }while (last_bb->end->al.offset ==-1 ); out:list_splice (this_blocks, full_blocks);
tools/perf/util/annotate.c +3 -1
@@ -2966,6 +2966,7 @@ static int add_basic_block(struct basic_block_data *bb_data,if (dl ==NULL )return -1 ; +BUG_ON (dl->al.offset ==-1 );if (!is_new_basic_block (bb_data, dl))return 0 ;
@@ -3006,7 +3007,7 @@ static bool process_basic_block(struct basic_block_data *bb_data, last_dl =list_last_entry (¬es->src->source, struct disasm_line, al.node); -if (last_dl->al.offset ==-1 ) +while (last_dl && last_dl->al.offset ==-1 ) last_dl =annotation__prev_asm_line (notes, last_dl);if (last_dl ==NULL )
@@ -3052,6 +3053,7 @@ static bool process_basic_block(struct basic_block_data *bb_data,break ; } +BUG_ON (dl->al.offset ==-1 ); link->bb->end = dl;return found; }
Signature · 1 line
2.49.0
Quoted 9 lines · Andi Kleen
Hit with perf annotate --code-with-type --stdio
perf:
util/annotate-data.c:1299:find_data_type_insn: Assertion `!(bb->begin->al.offset == -1 ||bb->end->al.offset== -1)' failed.This makes sure to skip non instruction disasm lines in all cases that add basic blocks. Also added some extra
BUG_ONsfor this case.Signed-off-by Andi Kleen <[email protected]>
Acked-by Namhyung Kim <[email protected]>
Thanks,
Namhyung
Quoted 58 lines
--- tools/perf/util/annotate-data.c | 10 +++++++++- tools/perf/util/annotate.c | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-)tools/perf/util/annotate-data.c +9
-1@@ -986,7 +986,15 @@ static void prepend_basic_blocks(struct list_head *this_blocks, }/* Point to the insn before the last when adding this block to full_blocks */ - last_bb->end =list_prev_entry (last_bb->end, al.node); +do { +/* Nothing useful found */ +if (last_bb->end == last_bb->begin) { +list_del (&last_bb->list); +free (last_bb); + goto out; + } + last_bb->end =list_prev_entry (last_bb->end, al.node); + }while (last_bb->end->al.offset ==-1 ); out:list_splice (this_blocks, full_blocks);tools/perf/util/annotate.c +3
-1@@ -2966,6 +2966,7 @@ static int add_basic_block(struct basic_block_data *bb_data,if (dl ==NULL )return -1 ; +BUG_ON (dl->al.offset ==-1 );if (!is_new_basic_block (bb_data, dl))return 0 ;@@ -3006,7 +3007,7 @@ static bool process_basic_block(struct basic_block_data *bb_data, last_dl =list_last_entry (¬es->src->source, struct disasm_line, al.node); -if (last_dl->al.offset ==-1 ) +while (last_dl && last_dl->al.offset ==-1 ) last_dl =annotation__prev_asm_line (notes, last_dl);if (last_dl ==NULL )@@ -3052,6 +3053,7 @@ static bool process_basic_block(struct basic_block_data *bb_data,break ; } +BUG_ON (dl->al.offset ==-1 ); link->bb->end = dl;return found; }Signature · 1 line
2.49.0