kconfig: zconfdump() clean-up
RFC 1/1 kconfig: zconfdump() clean-up
Hi Michal,
The following patch is a summarize of changes I made in zconfdump() last week when debugging Yann's multiple choice issue. This might help debugging a bit, espectially by exposing the tree depth.
Considering the following Kconfig:
config A
bool "A"
if A
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # A
config B
bool "B"
depends on ! A
if B
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # A
It generates the following output, after menu_finalize():
config A
boolean
symbol
prompt "A"
choice C
boolean
symbol
#choice
prompt "C" if A
config C1
boolean
symbol
prompt "C1" if C
#choice
config C2
boolean
symbol
prompt "C2" if C
#choice
endchoice
config B
boolean
symbol
prompt "B" if !A
choice C
boolean
symbol
#choice
prompt "C" if B
config C1
boolean
symbol
prompt "C1" if C
config C2
boolean
symbol
prompt "C2" if C
endchoice
instead of:
config A
boolean
unknown prop 9!
prompt "A"
choice
boolean
unknown prop 9!
#choice value
prompt "C" if A
config C1
boolean
unknown prop 9!
prompt "C1" if C
#choice value
config C2
boolean
unknown prop 9!
prompt "C2" if C
#choice value
config B
boolean
unknown prop 9!
prompt "B" if !A
choice
boolean
unknown prop 9!
#choice value
prompt "C" if B
config C1
boolean
unknown prop 9!
prompt "C1" if C
config C2
boolean
unknown prop 9!
prompt "C2" if C
endmenu
Broken down patches are available at:
https://github.com/lacombar/linux-2.6/tree/kconfig-zconfdump
Not for merge for now, even if it merges fine with your kbuild/kconfig's tip.
Regards,
- Arnaud
--- scripts/kconfig/zconf.y | 161 +++++++++++++++++++---------------------------- 1 files changed, 66 insertions(+), 95 deletions(-)
scripts/kconfig/zconf.y +66 -95
@@ -612,129 +612,100 @@ static void print_quoted_string(FILE *out, const char *str) putc('"', out); } -static void print_symbol(FILE *out, struct menu *menu) +static int indent; + +static void print_property(FILE *out, struct property *prop) { - struct symbol *sym = menu->sym; - struct property *prop; + const char *prop_string; - if (sym_is_choice(sym)) - fprintf(out, "\nchoice\n"); - else - fprintf(out, "\nconfig %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); + prop_string = prop_get_type_name(prop->type); + if (prop_string == NULL) + return; + + fprintf(out, "%*s %s%s ", indent * 8, "", + (prop->type == P_CHOICE) ? "#" : "", + prop_string); + + switch (prop->type) { + case P_PROMPT: + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_STRING: - fputs(" string\n", out); + case P_DEFAULT: + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_INT: - fputs(" integer\n", out); + case P_SELECT: + case P_RANGE: + expr_fprint(prop->expr, out); break; - case S_HEX: - fputs(" hex\n", out); + case P_MENU: + case P_COMMENT: + print_quoted_string(out, prop->text); break; default: - fputs(" ???\n", out); break; } + fprintf(out, "\n"); +} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + fprintf(out, "%*s%s %s\n", indent * 8, "", + (sym_is_choice(sym)) ? "choice" : "config", + (sym->name) ? sym->name: ""); + fprintf(out, "%*s %s\n", indent * 8, "", + sym_type_name(sym->type)); + for (prop = sym->prop; prop; prop = prop->next) { if (prop->menu != menu) continue; - switch (prop->type) { - case P_PROMPT: - fputs(" prompt ", out); - print_quoted_string(out, prop->text); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_DEFAULT: - fputs( " default ", out); - expr_fprint(prop->expr, out); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_CHOICE: - fputs(" #choice value\n", out); - break; - case P_SELECT: - fputs( " select ", out); - expr_fprint(prop->expr, out); - fputc('\n', out); - break; - case P_RANGE: - fputs( " range ", out); - expr_fprint(prop->expr, out); - fputc('\n', out); - break; - case P_MENU: - fputs( " menu ", out); - print_quoted_string(out, prop->text); - fputc('\n', out); - break; - case P_SYMBOL: - break; - default: - fprintf(out, " unknown prop %d!\n", prop->type); - break; - } - } - if (menu->help) { - int len = strlen(menu->help); - while (menu->help[--len] == '\n') - menu->help[len] = 0; - fprintf(out, " help\n%s\n", menu->help); + print_property(out, prop); } + fprintf(out, "\n"); } void zconfdump(FILE *out) { - struct property *prop; - struct symbol *sym; struct menu *menu; menu = rootmenu.list; while (menu) { - if ((sym = menu->sym)) + if (menu->sym) print_symbol(out, menu); - else if ((prop = menu->prompt)) { - switch (prop->type) { - case P_COMMENT: - fputs("\ncomment ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - case P_MENU: - fputs("\nmenu ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - default: - ; - } - if (!expr_is_yes(prop->visible.expr)) { - fputs(" depends ", out); - expr_fprint(prop->visible.expr, out); - fputc('\n', out); - } + + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, "%*s help\n%s\n", indent * 8, "", + menu->help); } - if (menu->list) + if (menu->list) { + indent++; menu = menu->list; + } else if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { - if (menu->prompt && menu->prompt->type == P_MENU) - fputs("\nendmenu\n", out); + if (menu != &rootmenu) + indent--; + fprintf(out, "%*s", indent * 8, ""); + if (menu->sym && sym_is_choice(menu->sym)) + fprintf(out, "endchoice\n\n"); + if (menu->prompt && menu->prompt->type == P_MENU && + menu != &rootmenu) + fprintf(out, "endmenu\n\n"); if (menu->next) { menu = menu->next; break;
Signature · 1 line
1.7.3.4.574.g608b.dirty
Hi,
Quoted 3 lines · Arnaud Lacombe
config A
boolean
symbol
actually, this "symbol" property should not appear in the dump.
- Arnaud
Hi,
Quoted 129 lines · Arnaud Lacombe
Hi Michal,
The following patch is a summarize of changes I made in
zconfdump()last week when debugging Yann's multiple choice issue. This might help debugging a bit, espectially by exposing the tree depth.Considering the following
Kconfig:config A
bool "A"
if A
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # Aconfig B
bool "B"
depends on ! A
if B
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # AIt generates the following output, after
menu_finalize():config A
boolean
symbol
prompt "A"choice C
boolean
symbol
#choice
prompt "C" if Aconfig C1
boolean
symbol
prompt "C1" if C
#choiceconfig C2
boolean
symbol
prompt "C2" if C
#choiceendchoice
config B
boolean
symbol
prompt "B" if !Achoice C
boolean
symbol
#choice
prompt "C" if Bconfig C1
boolean
symbol
prompt "C1" if Cconfig C2
boolean
symbol
prompt "C2" if Cendchoice
instead of:
config A
boolean
unknown prop 9!
prompt "A"choice
boolean
unknown prop 9!
#choice value
prompt "C" if Aconfig C1
boolean
unknown prop 9!
prompt "C1" if C
#choice valueconfig C2
boolean
unknown prop 9!
prompt "C2" if C
#choice valueconfig B
boolean
unknown prop 9!
prompt "B" if !Achoice
boolean
unknown prop 9!
#choice value
prompt "C" if Bconfig C1
boolean
unknown prop 9!
prompt "C1" if Cconfig C2
boolean
unknown prop 9!
prompt "C2" if C
Quoted 8 lines
endmenu
Broken down patches are available at:
https://github.com/lacombar/linux-2.6/tree/kconfig-zconfdump
Not for merge for now, even if it merges fine with your kbuild/kconfig's tip.
ping ?
- Arnaud
Quoted 211 lines
Regards,
- Arnaud---
scripts/kconfig/zconf.y | 161 +++++++++++++++++++----------------------------1 files changed, 66 insertions(+), 95 deletions(-)scripts/kconfig/zconf.y +31
-19@@ -612,129 +612,100 @@ static void print_quoted_string(FILE *out, const char *str) putc('"', out); } -static void print_symbol(FILE *out, struct menu *menu) +static int indent; + +static void print_property(FILE *out, struct property *prop) { - struct symbol *sym = menu->sym; - struct property *prop; + const char *prop_string; - if (sym_is_choice(sym)) - fprintf(out, "\nchoice\n"); - else - fprintf(out, "\nconfig %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); + prop_string = prop_get_type_name(prop->type); + if (prop_string == NULL) + return; + + fprintf(out, "%*s %s%s ", indent * 8, "", + (prop->type == P_CHOICE) ? "#" : "", + prop_string); + + switch (prop->type) { + case P_PROMPT: + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_STRING: - fputs(" string\n", out); + case P_DEFAULT: + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_INT: - fputs(" integer\n", out); + case P_SELECT: + case P_RANGE: + expr_fprint(prop->expr, out); break; - case S_HEX: - fputs(" hex\n", out); + case P_MENU: + case P_COMMENT: + print_quoted_string(out, prop->text); break;default:
-fputs(" ???\n", out);
break;
}
+fprintf(out, "\n");scripts/kconfig/zconf.y +13
-0+} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + fprintf(out, "%*s%s %s\n", indent * 8, "", + (sym_is_choice(sym)) ? "choice" : "config", + (sym->name) ? sym->name: ""); + fprintf(out, "%*s %s\n", indent * 8, "", + sym_type_name(sym->type)); +for (prop =
sym->prop; prop; prop =prop->next) {
if (prop->menu!= menu)
continue;
- switch (prop->type) {
- caseP_PROMPT:
-fputs(" prompt ", out);
-print_quoted_string(out, prop->text);
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" if ", out);
-expr_fprint(prop->visible.expr, out);
- }
-fputc('\n', out);
- break;
- caseP_DEFAULT:
-fputs( " default ", out);
-expr_fprint(prop->expr, out);
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" if ", out);
-expr_fprint(prop->visible.expr, out);
- }
-fputc('\n', out);
- break;
- caseP_CHOICE:
-fputs(" #choice value\n", out);
- break;
- caseP_SELECT:
-fputs( " select ", out);
-expr_fprint(prop->expr, out);
-fputc('\n', out);
- break;
- caseP_RANGE:
-fputs( " range ", out);
-expr_fprint(prop->expr, out);
-fputc('\n', out);
- break;
- caseP_MENU:
-fputs( " menu ", out);
-print_quoted_string(out, prop->text);
-fputc('\n', out);
- break;
- caseP_SYMBOL:
- break;
- default:
-fprintf(out, " unknown prop %d!\n", prop->type);
- break;
- }
- }
- if (menu->help) {
- int len =strlen(menu->help);
- while (menu->help[--len] == '\n')
- menu->help[len] = 0;
-fprintf(out, " help\n%s\n", menu->help);
+print_property(out, prop);
}
+fprintf(out, "\n");
}void
zconfdump(FILE *out)
{
- struct property *prop;
- struct symbol *sym;
struct menu *menu;menu = rootmenu.list;
while (menu) {
- if ((sym =menu->sym))
+ if (menu->sym)
print_symbol(out, menu);
- else if ((prop =menu->prompt)) {
- switch (prop->type) {
- caseP_COMMENT:
-fputs("\ncomment ", out);
-print_quoted_string(out, prop->text);
-fputs("\n", out);
- break;
- caseP_MENU:
-fputs("\nmenu ", out);
-print_quoted_string(out, prop->text);
-fputs("\n", out);
- break;
- default:
- ;
- }
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" depends ", out);
-expr_fprint(prop->visible.expr, out);
-fputc('\n', out);
- }
+
+ if (menu->help) {
+ int len =strlen(menu->help);
+ while (menu->help[--len] == '\n')
+ menu->help[len] = 0;
+ fprintf(out, "%*s help\n%s\n", indent * 8, "",
+menu->help);
}- if (
menu->list)
+ if (menu->list) {
+ indent++;
menu =menu->list;
+ }
else if (menu->next)
menu =menu->next;
else while ((menu =menu->parent)) {
- if (menu->prompt&&menu->prompt->type==P_MENU)
-fputs("\nendmenu\n", out);
+ if (menu != &rootmenu)
+ indent--;
+fprintf(out, "%*s", indent * 8, "");
+ if (menu->sym&&sym_is_choice(menu->sym))
+fprintf(out, "endchoice\n\n");
+ if (menu->prompt&&menu->prompt->type==P_MENU&&
+ menu != &rootmenu)
+fprintf(out, "endmenu\n\n");
if (menu->next) {
menu =menu->next;
break;
--
1.7.3.4.574.g608b.dirty
Hi,
Quoted 134 lines · Arnaud Lacombe
Hi,
Quoted 131 lines · Arnaud Lacombe
Hi Michal,
The following patch is a summarize of changes I made in
zconfdump()last week when debugging Yann's multiple choice issue. This might help debugging a bit, espectially by exposing the tree depth.Considering the following
Kconfig:config A
bool "A"
if A
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # Aconfig B
bool "B"
depends on ! A
if B
choice C
bool "C"
config C1
bool "C1"
config C2
bool "C2"
endchoice
endif # AIt generates the following output, after
menu_finalize():config A
boolean
symbol
prompt "A"choice C
boolean
symbol
#choice
prompt "C" if Aconfig C1
boolean
symbol
prompt "C1" if C
#choiceconfig C2
boolean
symbol
prompt "C2" if C
#choiceendchoice
config B
boolean
symbol
prompt "B" if !Achoice C
boolean
symbol
#choice
prompt "C" if Bconfig C1
boolean
symbol
prompt "C1" if Cconfig C2
boolean
symbol
prompt "C2" if Cendchoice
instead of:
config A
boolean
unknown prop 9!
prompt "A"choice
boolean
unknown prop 9!
#choice value
prompt "C" if Aconfig C1
boolean
unknown prop 9!
prompt "C1" if C
#choice valueconfig C2
boolean
unknown prop 9!
prompt "C2" if C
#choice valueconfig B
boolean
unknown prop 9!
prompt "B" if !Achoice
boolean
unknown prop 9!
#choice value
prompt "C" if Bconfig C1
boolean
unknown prop 9!
prompt "C1" if Cconfig C2
boolean
unknown prop 9!
prompt "C2" if Cendmenu
Quoted 8 lines
Quoted 6 lines
Broken down patches are available at:
https://github.com/lacombar/linux-2.6/tree/kconfig-zconfdump
Not for merge for now, even if it merges fine with your kbuild/kconfig's tip.
ping ?
ping^2 ?
- Arnaud
Quoted 213 lines
Quoted 212 lines
Regards,
- Arnaud---
scripts/kconfig/zconf.y | 161 +++++++++++++++++++----------------------------1 files changed, 66 insertions(+), 95 deletions(-)scripts/kconfig/zconf.y +31
-19@@ -612,129 +612,100 @@ static void print_quoted_string(FILE *out, const char *str) putc('"', out); } -static void print_symbol(FILE *out, struct menu *menu) +static int indent; + +static void print_property(FILE *out, struct property *prop) { - struct symbol *sym = menu->sym; - struct property *prop; + const char *prop_string; - if (sym_is_choice(sym)) - fprintf(out, "\nchoice\n"); - else - fprintf(out, "\nconfig %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); + prop_string = prop_get_type_name(prop->type); + if (prop_string == NULL) + return; + + fprintf(out, "%*s %s%s ", indent * 8, "", + (prop->type == P_CHOICE) ? "#" : "", + prop_string); + + switch (prop->type) { + case P_PROMPT: + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_STRING: - fputs(" string\n", out); + case P_DEFAULT: + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } break; - case S_INT: - fputs(" integer\n", out); + case P_SELECT: + case P_RANGE: + expr_fprint(prop->expr, out); break; - case S_HEX: - fputs(" hex\n", out); + case P_MENU: + case P_COMMENT: + print_quoted_string(out, prop->text); break;default:
-fputs(" ???\n", out);
break;
}
+fprintf(out, "\n");scripts/kconfig/zconf.y +13
-0+} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + fprintf(out, "%*s%s %s\n", indent * 8, "", + (sym_is_choice(sym)) ? "choice" : "config", + (sym->name) ? sym->name: ""); + fprintf(out, "%*s %s\n", indent * 8, "", + sym_type_name(sym->type)); +for (prop =
sym->prop; prop; prop =prop->next) {
if (prop->menu!= menu)
continue;
- switch (prop->type) {
- caseP_PROMPT:
-fputs(" prompt ", out);
-print_quoted_string(out, prop->text);
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" if ", out);
-expr_fprint(prop->visible.expr, out);
- }
-fputc('\n', out);
- break;
- caseP_DEFAULT:
-fputs( " default ", out);
-expr_fprint(prop->expr, out);
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" if ", out);
-expr_fprint(prop->visible.expr, out);
- }
-fputc('\n', out);
- break;
- caseP_CHOICE:
-fputs(" #choice value\n", out);
- break;
- caseP_SELECT:
-fputs( " select ", out);
-expr_fprint(prop->expr, out);
-fputc('\n', out);
- break;
- caseP_RANGE:
-fputs( " range ", out);
-expr_fprint(prop->expr, out);
-fputc('\n', out);
- break;
- caseP_MENU:
-fputs( " menu ", out);
-print_quoted_string(out, prop->text);
-fputc('\n', out);
- break;
- caseP_SYMBOL:
- break;
- default:
-fprintf(out, " unknown prop %d!\n", prop->type);
- break;
- }
- }
- if (menu->help) {
- int len =strlen(menu->help);
- while (menu->help[--len] == '\n')
- menu->help[len] = 0;
-fprintf(out, " help\n%s\n", menu->help);
+print_property(out, prop);
}
+fprintf(out, "\n");
}void
zconfdump(FILE *out)
{
- struct property *prop;
- struct symbol *sym;
struct menu *menu;menu = rootmenu.list;
while (menu) {
- if ((sym =menu->sym))
+ if (menu->sym)
print_symbol(out, menu);
- else if ((prop =menu->prompt)) {
- switch (prop->type) {
- caseP_COMMENT:
-fputs("\ncomment ", out);
-print_quoted_string(out, prop->text);
-fputs("\n", out);
- break;
- caseP_MENU:
-fputs("\nmenu ", out);
-print_quoted_string(out, prop->text);
-fputs("\n", out);
- break;
- default:
- ;
- }
- if (!expr_is_yes(prop->visible.expr)) {
-fputs(" depends ", out);
-expr_fprint(prop->visible.expr, out);
-fputc('\n', out);
- }
+
+ if (menu->help) {
+ int len =strlen(menu->help);
+ while (menu->help[--len] == '\n')
+ menu->help[len] = 0;
+ fprintf(out, "%*s help\n%s\n", indent * 8, "",
+menu->help);
}- if (
menu->list)
+ if (menu->list) {
+ indent++;
menu =menu->list;
+ }
else if (menu->next)
menu =menu->next;
else while ((menu =menu->parent)) {
- if (menu->prompt&&menu->prompt->type==P_MENU)
-fputs("\nendmenu\n", out);
+ if (menu != &rootmenu)
+ indent--;
+fprintf(out, "%*s", indent * 8, "");
+ if (menu->sym&&sym_is_choice(menu->sym))
+fprintf(out, "endchoice\n\n");
+ if (menu->prompt&&menu->prompt->type==P_MENU&&
+ menu != &rootmenu)
+fprintf(out, "endmenu\n\n");
if (menu->next) {
menu =menu->next;
break;
--
1.7.3.4.574.g608b.dirty
Quoted 40 lines · Arnaud Lacombe
Hi Michal,
The following patch is a summarize of changes I made in
zconfdump()last week when debugging Yann's multiple choice issue. This might help debugging a bit, espectially by exposing the tree depth.Considering the following
Kconfig:config A
bool "A"
if A
choice C
bool "C"
config C1bool "C1" config C2 bool "C2"endchoice
endif # Aconfig B
bool "B"
depends on ! A
if B
choice C
bool "C"
config C1bool "C1" config C2 bool "C2"endchoice
endif # AIt generates the following output, after
menu_finalize():config A
boolean
symbol
prompt "A"
Quoted 5 lines
choice C
boolean
symbol
#choice
prompt "C" if A
Why not. zconfdump() is only used for debugging and you've been doing most of the kconfig work lately, so if this suits you, then I'll merge it. I only spotted one minor issue:
commit 21685d396a123a576bbe487651cb5cc04fa5f9a3
Author: Arnaud Lacombe <[email protected]> Date: Tue May 10 22:55:20 2011 -0400
kconfig/zconfdump(): output newline at the *end* of statement
puts the newline between the symbol statement and it's help text (if any). So if there is help text defined, it will appear attached to the next symbol. But it's not really an issue.
Michal