Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gendwarfksyms: Add die_map debugging

Debugging the DWARF processing can be somewhat challenging, so add
more detailed debugging output for die_map operations. Add the
--dump-die-map flag, which adds color coded tags to the output for
die_map changes.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Sami Tolvanen and committed by
Masahiro Yamada
d2ffdc1c f936c129

+35
+15
scripts/gendwarfksyms/dwarf.c
··· 146 146 if (dump_dies) 147 147 fputs(s, stderr); 148 148 149 + if (cache) 150 + die_debug_r("cache %p string '%s'", cache, s); 149 151 die_map_add_string(cache, s); 150 152 } 151 153 ··· 596 594 list_for_each_entry(df, &cache->fragments, list) { 597 595 switch (df->type) { 598 596 case FRAGMENT_STRING: 597 + die_debug_b("cache %p STRING '%s'", cache, 598 + df->data.str); 599 599 process(NULL, df->data.str); 600 600 break; 601 601 case FRAGMENT_LINEBREAK: ··· 607 603 if (!dwarf_die_addr_die(dwarf_cu_getdwarf(die->cu), 608 604 (void *)df->data.addr, &child)) 609 605 error("dwarf_die_addr_die failed"); 606 + die_debug_b("cache %p DIE addr %" PRIxPTR " tag %x", 607 + cache, df->data.addr, dwarf_tag(&child)); 610 608 check(process_type(state, NULL, &child)); 611 609 break; 612 610 default: ··· 677 671 cache = die_map_get(die, want_state); 678 672 679 673 if (cache->state == want_state) { 674 + die_debug_g("cached addr %p tag %x -- %s", die->addr, tag, 675 + die_state_name(cache->state)); 676 + 680 677 process_cached(state, cache, die); 681 678 die_map_add_die(parent, cache); 682 679 683 680 expansion_state_restore(&state->expand, &saved); 684 681 return 0; 685 682 } 683 + 684 + die_debug_g("addr %p tag %x -- %s -> %s", die->addr, tag, 685 + die_state_name(cache->state), die_state_name(want_state)); 686 686 687 687 switch (tag) { 688 688 /* Type modifiers */ ··· 724 712 default: 725 713 error("unexpected type: %x", tag); 726 714 } 715 + 716 + die_debug_r("parent %p cache %p die addr %p tag %x", parent, cache, 717 + die->addr, tag); 727 718 728 719 /* Update cache state and append to the parent (if any) */ 729 720 cache->tag = tag;
+7
scripts/gendwarfksyms/gendwarfksyms.c
··· 19 19 int debug; 20 20 /* Dump DIE contents */ 21 21 int dump_dies; 22 + /* Print debugging information about die_map changes */ 23 + int dump_die_map; 22 24 23 25 static void usage(void) 24 26 { ··· 28 26 "Options:\n" 29 27 " -d, --debug Print debugging information\n" 30 28 " --dump-dies Dump DWARF DIE contents\n" 29 + " --dump-die-map Print debugging information about die_map changes\n" 31 30 " -h, --help Print this message\n" 32 31 "\n", 33 32 stderr); ··· 78 75 static const struct option opts[] = { 79 76 { "debug", 0, NULL, 'd' }, 80 77 { "dump-dies", 0, &dump_dies, 1 }, 78 + { "dump-die-map", 0, &dump_die_map, 1 }, 81 79 { "help", 0, NULL, 'h' }, 82 80 { 0, 0, NULL, 0 } 83 81 }; ··· 98 94 return 1; 99 95 } 100 96 } 97 + 98 + if (dump_die_map) 99 + dump_dies = 1; 101 100 102 101 if (optind >= argc) { 103 102 usage();
+13
scripts/gendwarfksyms/gendwarfksyms.h
··· 21 21 */ 22 22 extern int debug; 23 23 extern int dump_dies; 24 + extern int dump_die_map; 24 25 25 26 /* 26 27 * Output helpers ··· 43 42 __println("error: ", format, ##__VA_ARGS__); \ 44 43 exit(1); \ 45 44 } while (0) 45 + 46 + #define __die_debug(color, format, ...) \ 47 + do { \ 48 + if (dump_dies && dump_die_map) \ 49 + fprintf(stderr, \ 50 + "\033[" #color "m<" format ">\033[39m", \ 51 + __VA_ARGS__); \ 52 + } while (0) 53 + 54 + #define die_debug_r(format, ...) __die_debug(91, format, __VA_ARGS__) 55 + #define die_debug_g(format, ...) __die_debug(92, format, __VA_ARGS__) 56 + #define die_debug_b(format, ...) __die_debug(94, format, __VA_ARGS__) 46 57 47 58 /* 48 59 * Error handling helpers