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.

kconfig: add a function to dump all menu entries in a tree-like format

This is useful for debugging purposes. menu_finalize() re-parents menu
entries, and this function can be used to dump the final structure of
the menu tree.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+75
+1
scripts/kconfig/lkc.h
··· 102 102 int get_jump_key_char(void); 103 103 struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); 104 104 void menu_get_ext_help(struct menu *menu, struct gstr *help); 105 + void menu_dump(void); 105 106 106 107 /* symbol.c */ 107 108 void sym_clear_all_valid(void);
+74
scripts/kconfig/menu.c
··· 788 788 if (sym) 789 789 get_symbol_str(help, sym, NULL); 790 790 } 791 + 792 + /** 793 + * menu_dump - dump all menu entries in a tree-like format 794 + */ 795 + void menu_dump(void) 796 + { 797 + struct menu *menu = &rootmenu; 798 + unsigned long long bits = 0; 799 + int indent = 0; 800 + 801 + while (menu) { 802 + 803 + for (int i = indent - 1; i >= 0; i--) { 804 + if (bits & (1ULL << i)) { 805 + if (i > 0) 806 + printf("| "); 807 + else 808 + printf("|-- "); 809 + } else { 810 + if (i > 0) 811 + printf(" "); 812 + else 813 + printf("`-- "); 814 + } 815 + } 816 + 817 + switch (menu->type) { 818 + case M_CHOICE: 819 + printf("choice \"%s\"\n", menu->prompt->text); 820 + break; 821 + case M_COMMENT: 822 + printf("comment \"%s\"\n", menu->prompt->text); 823 + break; 824 + case M_IF: 825 + printf("if\n"); 826 + break; 827 + case M_MENU: 828 + printf("menu \"%s\"", menu->prompt->text); 829 + if (!menu->sym) { 830 + printf("\n"); 831 + break; 832 + } 833 + printf(" + "); 834 + /* fallthrough */ 835 + case M_NORMAL: 836 + printf("symbol %s\n", menu->sym->name); 837 + break; 838 + } 839 + if (menu->list) { 840 + bits <<= 1; 841 + menu = menu->list; 842 + if (menu->next) 843 + bits |= 1; 844 + else 845 + bits &= ~1; 846 + indent++; 847 + continue; 848 + } 849 + 850 + while (menu && !menu->next) { 851 + menu = menu->parent; 852 + bits >>= 1; 853 + indent--; 854 + } 855 + 856 + if (menu) { 857 + menu = menu->next; 858 + if (menu->next) 859 + bits |= 1; 860 + else 861 + bits &= ~1; 862 + } 863 + } 864 + }