Fixes concerning zconfdump()
cover Fixes concerning zconfdump()
Hi Masahiro,
this series contains two actual fixes, the third patch is rather aimed to be an RFC. I find it quite useful to have a target at hand to easily generate debugging output from the parser when needed. I could imagine this target could also be used to add some parser tests to the recently introduced automated tests, but perhap you already have other plans or better suggestions.
Dirk
Dirk Gouders (3):
kconfig: avoid assert()-triggered segfaults in xfwrite()
kconfig: handle P_SYMBOL in print_symbol()
kconfig: add debugconfig target for debugging purposes
scripts/kconfig/Makefile | 10 ++++++++- scripts/kconfig/dconf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/expr.c | 5 ++++- scripts/kconfig/expr.h | 3 +++ scripts/kconfig/zconf.y | 4 ++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 scripts/kconfig/dconf.c
Signature · 1 line
2.13.6
PATCH 1/3 kconfig: avoid assert()-triggered segfaults in xfwrite()
xfwrite uses assert() to ensure it does not operate on empty strings. Two users respect this, expr_print_file_helper() doesn't and causes segfaults e.g. when the dependency for an empty default string is printed.
Fix this by calling xfwrite with an empty string pattern ("") for empty strings.
INITRAMFS_SOURCE was one symbol that caused this problem, with this fix applied the zconfdump() output for this symbol looks as follows:
------------------------------------------------------------------------
config INITRAMFS_SOURCE
string
symbol INITRAMFS_SOURCE
prompt "Initramfs source file(s)" if BLK_DEV_INITRD default "" if BLK_DEV_INITRD
help
This can be either a single cpio archive with a .cpio suffix or a space-separated list of directories and files for building the initramfs image. A cpio archive should contain a filesystem archive to be used as an initramfs image. Directories should contain a filesystem layout to be included in the initramfs image. Files should contain entries according to the format described by the "usr/gen_init_cpio" program in the kernel tree.
When multiple directories and files are specified then the initramfs image will be the aggregate of all of them.
See <file:Documentation/early-userspace/README> for more details.
If you are not sure, leave it blank.
------------------------------------------------------------------------
--- scripts/kconfig/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/kconfig/expr.c +4 -1
@@ -1231,7 +1231,10 @@ void expr_print(struct expr *e,static void expr_print_file_helper (void *data,struct symbol *sym,const char *str) { -xfwrite (str,strlen (str),1 , data); +if (*str !='\0' ) +xfwrite (str,strlen (str),1 , data); +else +xfwrite ("\"\"" ,2 ,1 , data); }void expr_fprint (struct expr *e,FILE *out)
Signature · 1 line
2.13.6
Re: [PATCH 1/3] kconfig: avoid assert()-triggered segfaults in xfwrite()
2018-06-23 4:27 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 28 lines
xfwrite uses
assert()to ensure it does not operate on empty strings. Two users respect this,expr_print_file_helper()doesn't and causes segfaults e.g. when the dependency for an empty default string is printed.Fix this by calling xfwrite with an empty string pattern ("") for empty strings.
INITRAMFS_SOURCEwas one symbol that caused this problem, with this fix applied thezconfdump()output for this symbol looks as follows:------------------------------------------------------------------------
configINITRAMFS_SOURCE
string
symbolINITRAMFS_SOURCE
prompt "Initramfs source file(s)" ifBLK_DEV_INITRDdefault "" ifBLK_DEV_INITRD
help
This can be either a single cpio archive with a .cpio suffix or a space-separated list of directories and files for building the initramfs image. A cpio archive should contain a filesystem archive to be used as an initramfs image. Directories should contain a filesystem layout to be included in the initramfs image. Files should contain entries according to the format described by the "usr/gen_init_cpio" program in the kernel tree.When multiple directories and files are specified then the initramfs image will be the aggregate of all of them.
Quoted 7 lines
See <file:Documentation/early-userspace/README> for more details.
If you are not sure, leave it blank.
------------------------------------------------------------------------Signed-off-by Dirk Gouders <[email protected]>---
Hmm, please let me think about this.
I know this is an easy way to fix the seg-fault,
but I think it is not a correct way.
If the config entry were like this:
config INITRAMFS_SOURCE
string "Initramfs source file(s)"
default "foo"
It would be dumped like this:
config INITRAMFS_SOURCE
string
symbol INITRAMFS_SOURCE
prompt "Initramfs source file(s)"
default foo
I want it to be displayed like this:
default "foo"
If we can quote the string values,
the problem will be eventually fixed.
It may not be easy to fix it...
Quoted 26 lines
scripts/kconfig/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/kconfig/expr.c +4
-2@@ -1231,7 +1231,10 @@ void expr_print(struct expr *e,static void expr_print_file_helper (void *data,struct symbol *sym,const char *str) { -xfwrite (str,strlen (str),1 , data); +if (*str !='\0' ) +xfwrite (str,strlen (str),1 , data); +else +xfwrite ("\"\"" ,2 ,1 , data); }void expr_fprint (struct expr *e,FILE *out) --2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 1/3] kconfig: avoid assert()-triggered segfaults in xfwrite()
Quoted 66 lines · Masahiro Yamada
2018-06-23 4:27 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 28 lines
xfwrite uses
assert()to ensure it does not operate on empty strings. Two users respect this,expr_print_file_helper()doesn't and causes segfaults e.g. when the dependency for an empty default string is printed.Fix this by calling xfwrite with an empty string pattern ("") for empty strings.
INITRAMFS_SOURCEwas one symbol that caused this problem, with this fix applied thezconfdump()output for this symbol looks as follows:------------------------------------------------------------------------
configINITRAMFS_SOURCE
string
symbolINITRAMFS_SOURCE
prompt "Initramfs source file(s)" ifBLK_DEV_INITRDdefault "" ifBLK_DEV_INITRD
help
This can be either a single cpio archive with a .cpio suffix or a space-separated list of directories and files for building the initramfs image. A cpio archive should contain a filesystem archive to be used as an initramfs image. Directories should contain a filesystem layout to be included in the initramfs image. Files should contain entries according to the format described by the "usr/gen_init_cpio" program in the kernel tree.When multiple directories and files are specified then the initramfs image will be the aggregate of all of them.
Quoted 7 lines
See <file:Documentation/early-userspace/README> for more details.
If you are not sure, leave it blank.
------------------------------------------------------------------------Signed-off-by Dirk Gouders <[email protected]>---
Hmm, please let me think about this.
I know this is an easy way to fix the seg-fault,
but I think it is not a correct way.If the config entry were like this:
config
INITRAMFS_SOURCE
string "Initramfs source file(s)"
default "foo"It would be dumped like this:
config
INITRAMFS_SOURCE
string
symbolINITRAMFS_SOURCE
prompt "Initramfs source file(s)"
default fooI want it to be displayed like this:
Quoted 7 lines
default "foo"
If we can quote the string values,
the problem will be eventually fixed.It may not be easy to fix it...
That's a good idea, it provides more consistency.
I will send an update and also replace the term "segfault" with "abort" as this is the way assert() terminates the program.
Dirk
Quoted 27 lines
Quoted 27 lines
scripts/kconfig/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/kconfig/expr.c +4
-2@@ -1231,7 +1231,10 @@ void expr_print(struct expr *e,static void expr_print_file_helper (void *data,struct symbol *sym,const char *str) { -xfwrite (str,strlen (str),1 , data); +if (*str !='\0' ) +xfwrite (str,strlen (str),1 , data); +else +xfwrite ("\"\"" ,2 ,1 , data); }void expr_fprint (struct expr *e,FILE *out) --2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
cover kconfig: expr_print(): print constant symbols within quotes
Hi Masahiro,
I reworked the fix for the aborts in a way you suggested.
I decided to do it that way, because it reproduces the real content of Kconfig files. I hope that was what you meant with your comment to the previous attempt.
While working on that fix I found a comment in expr.h that seems to be wrong and send a fix for that, as well.
Dirk
Dirk Gouders (2):
kconfig: expr_print(): print constant symbols within quotes
kconfig: fix comment for symbol flag SYMBOL_AUTO
scripts/kconfig/expr.c | 12 +++++++++++- scripts/kconfig/expr.h | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-)
Signature · 1 line
2.16.1
PATCH v2 1/2 kconfig: expr_print(): print constant symbols within quotes
Motivation for this commit was the problem that xfwrite() uses assert() to ensure it does not operate on empty strings. This caused aborts when the dependency for an empty default string was printed.
A possibility to fix this issue would be to print all string constants in quotes which has the positive effect that empty strings have a length of 2 and do not trigger aborts.
But currently, constant symbols are typeless, so this patch implements a fix by identifying all constant symbols by the symbol flag SYMBOL_CONST and printing their names within quotes.
Note:
The symbols y, m and n are statically defined as constants in symbol.c and hence also printed within quotes. Kconfig files contain a mixture of those symbols specified within and without quotes and we cannot reproduce that after parsing.
Also, the kconfig language allows for (semantically meant) constant string, int and hex symbols to be specified within quotes or without, which is OK as long as there is no other symbol that is something other than the constant symbol that was meant to be; the following Kconfig file tries to illustrate this:
config a
int "Meant to have default 5..."
default 5
config 5
int "but this symbol plays games."
default "7"
This implementation reproduces exactly the described mixture from the Kconfig files, thus original data.
--- scripts/kconfig/expr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/kconfig/expr.c +11 -1
@@ -1141,6 +1141,8 @@ void expr_print(struct expr *e,void (*fn)(void *,struct symbol *,const char *), void *data, int prevtoken) { + const char *quoted; +if (!e) {fn (data,NULL ,"y" );return ;
@@ -1151,7 +1153,15 @@ void expr_print(struct expr *e,switch (e->type) {case E_SYMBOL :if (e->left.sym->name) -fn (data, e->left.sym, e->left.sym->name); +/* +* Print constant symbols within quotes +*/ +if (e->left.sym->flags &SYMBOL_CONST ) { + quoted =sym_escape_string_value (e->left.sym->name); +fn (data, e->left.sym, quoted); +free ((void *)quoted); + }else +fn (data, e->left.sym, e->left.sym->name);else fn (data,NULL ,"<choice>" );break ;
Signature · 1 line
2.16.1
PATCH 2/2 kconfig: fix comment for symbol flag SYMBOL_AUTO
In reply to Dirk GoudersI could not verify the comment for that symbol flag.
I could only find that flag set for choices and the defconfig_list symbol in a dump of all symbols, which corresponds to the only two locations in the code where that flag is being set explicitely.
--- scripts/kconfig/expr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/expr.h +3 -1
@@ -141,7 +141,9 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbols of type choice and the +* symbol with option defconfig_list +* have this flag set */ #define SYMBOL_CHECKED 0x2000/* used during dependency checking */ #define SYMBOL_WARNED 0x8000/* warning has been issued */
Signature · 1 line
2.16.1
Re: [PATCH 2/2] kconfig: fix comment for symbol flag SYMBOL_AUTO
2018-06-29 18:12 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 1 line
I could not verify the comment for that symbol flag.
Good catch.
I forgot to fix up the comment
in commit 104daea149c4.
Quoted 15 lines
I could only find that flag set for choices and the
defconfig_listsymbol in a dump of all symbols, which corresponds to the only two locations in the code where that flag is being set explicitely.Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/expr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/kconfig/expr.h +0
-0
scripts/kconfig/expr.h struct symbol { · line 146
Quoted 7 lines
scripts/kconfig/expr.h +3
-1@@ -141,7 +141,9 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbols of type choice and the +* symbol with option defconfig_list +* have this flag set */
Hmm. This explanation is not very helpful in my opinion. Could you reword that?
In my understanding, symbols with SYMBOL_AUTO
are never written out to file.
Quoted 10 lines
scripts/kconfig/expr.h +0
-1#define SYMBOL_CHECKED 0x2000/* used during dependency checking */ #define SYMBOL_WARNED 0x8000/* warning has been issued */ --2.16.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 2/2] kconfig: fix comment for symbol flag SYMBOL_AUTO
Quoted 34 lines · Masahiro Yamada
2018-06-29 18:12 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 1 line
I could not verify the comment for that symbol flag.
Good catch.
I forgot to fix up the comment
in commit104daea149c4.Quoted 15 lines
I could only find that flag set for choices and the
defconfig_listsymbol in a dump of all symbols, which corresponds to the only two locations in the code where that flag is being set explicitely.Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/expr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/kconfig/expr.h +0
-0scripts/kconfig/expr.h struct symbol { · line 146
Quoted 7 lines
scripts/kconfig/expr.h +3
-1@@ -141,7 +141,9 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbols of type choice and the +* symbol with option defconfig_list +* have this flag set */ Hmm. This explanation is not very helpful in my opinion. Could you reword that?
Quoted 2 lines
In my understanding, symbols with
SYMBOL_AUTO
are never written out to file.
Yes, that's right, sym_calc_value() clears SYMBOL_WRITE for those symbols and the comment should describe the effect of the flag, not it's users. I will read a bit more to see if the flag has more effects and reword the comment.
Sidenote: probably, AUTO is a misnomer for this flag. I would expect something like automatically generated symbols but the symbols that have this flag set are rather -- hmm, perhaps auxiliary symbols?
Dirk
Re: [PATCH 2/2] kconfig: fix comment for symbol flag SYMBOL_AUTO
2018-07-03 16:32 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 39 lines
Quoted 34 lines · Masahiro Yamada
2018-06-29 18:12 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 1 line
I could not verify the comment for that symbol flag.
Good catch.
I forgot to fix up the comment
in commit104daea149c4.Quoted 15 lines
I could only find that flag set for choices and the
defconfig_listsymbol in a dump of all symbols, which corresponds to the only two locations in the code where that flag is being set explicitely.Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/expr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/kconfig/expr.h +0
-0scripts/kconfig/expr.h struct symbol { · line 146
Quoted 7 lines
scripts/kconfig/expr.h +3
-1@@ -141,7 +141,9 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbols of type choice and the +* symbol with option defconfig_list +* have this flag set */ Hmm. This explanation is not very helpful in my opinion. Could you reword that?
Quoted 2 lines
In my understanding, symbols with
SYMBOL_AUTO
are never written out to file.
Quoted 6 lines
Yes, that's right,
sym_calc_value()clearsSYMBOL_WRITEfor those symbols and the comment should describe the effect of the flag, not it's users. I will read a bit more to see if the flag has more effects and reword the comment.Sidenote: probably, AUTO is a misnomer for this flag.
I agree.
Quoted 3 lines
I would expect
something like automatically generated symbols but the symbols that have this flag set are rather -- hmm, perhaps auxiliary symbols?
Good.
Another idea might be SYMBOL_NO_WRITE ??
(it seems almost self-commenting)
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 2/2] kconfig: fix comment for symbol flag SYMBOL_AUTO
Quoted 50 lines · Masahiro Yamada
2018-07-03 16:32 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 39 lines
Quoted 34 lines · Masahiro Yamada
2018-06-29 18:12 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 1 line
I could not verify the comment for that symbol flag.
Good catch.
I forgot to fix up the comment
in commit104daea149c4.Quoted 15 lines
I could only find that flag set for choices and the
defconfig_listsymbol in a dump of all symbols, which corresponds to the only two locations in the code where that flag is being set explicitely.Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/expr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)scripts/kconfig/expr.h +0
-0scripts/kconfig/expr.h struct symbol { · line 146
Quoted 7 lines
scripts/kconfig/expr.h +3
-1@@ -141,7 +141,9 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbols of type choice and the +* symbol with option defconfig_list +* have this flag set */ Hmm. This explanation is not very helpful in my opinion. Could you reword that?
Quoted 2 lines
In my understanding, symbols with
SYMBOL_AUTO
are never written out to file.Quoted 6 lines
Yes, that's right,
sym_calc_value()clearsSYMBOL_WRITEfor those symbols and the comment should describe the effect of the flag, not it's users. I will read a bit more to see if the flag has more effects and reword the comment.Sidenote: probably, AUTO is a misnomer for this flag.
I agree.
Quoted 7 lines
Quoted 3 lines
I would expect
something like automatically generated symbols but the symbols that have this flag set are rather -- hmm, perhaps auxiliary symbols?Good.
Another idea might beSYMBOL_NO_WRITE??
(it seems almost self-commenting)
Oh sorry, there was an overlap with me sending out v2 without recognizing and reading your reply.
I like SYMBOL_NO_WRITE, and would prepare v3 if nobody has objections.
Dirk
PATCH v3 1/1 kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE
Over time, the use of the flag SYMBOL_AUTO changed from initially marking three automatically generated symbols ARCH, KERNELRELEASE and UNAME_RELEASE to today's effect of protecting symbols from being written out.
Currently, only symbols of type CHOICE and those with option defconf_list set have that flag set.
Reflect that change in semantics in the flag's name.
--- scripts/kconfig/confdata.c | 4 ++-- scripts/kconfig/expr.h | 2 +- scripts/kconfig/gconf.c | 4 ++-- scripts/kconfig/menu.c | 2 +- scripts/kconfig/symbol.c | 2 +- scripts/kconfig/zconf.y | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
scripts/kconfig/confdata.c +2 -2
@@ -397,7 +397,7 @@ int conf_read(const char *name) for_all_symbols(i, sym) {sym_calc_value (sym); -if (sym_is_choice (sym) || (sym->flags &SYMBOL_AUTO )) +if (sym_is_choice (sym) || (sym->flags &SYMBOL_NO_WRITE ))continue ;if (sym_has_value (sym) && (sym->flags &SYMBOL_WRITE )) {/* check that calculated value agrees with saved value */
@@ -832,7 +832,7 @@ static int conf_split_config(void) res =0 ; for_all_symbols(i, sym) {sym_calc_value (sym); -if ((sym->flags &SYMBOL_AUTO ) || !sym->name) +if ((sym->flags &SYMBOL_NO_WRITE ) || !sym->name)continue ;if (sym->flags &SYMBOL_WRITE ) {if (sym->flags &SYMBOL_DEF_AUTO ) {
scripts/kconfig/expr.h +1 -1
@@ -141,7 +141,7 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_NO_WRITE 0x1000/* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000/* used during dependency checking */ #define SYMBOL_WARNED 0x8000/* warning has been issued */
scripts/kconfig/gconf.c +2 -2
@@ -101,8 +101,8 @@ const char *dbg_sym_flags(int val)strcat (buf,"write/" );if (val &SYMBOL_CHANGED )strcat (buf,"changed/" ); -if (val &SYMBOL_AUTO ) -strcat (buf,"auto/" ); +if (val &SYMBOL_NO_WRITE ) +strcat (buf,"no_write/" ); buf[strlen (buf) -1 ] ='\0' ;
scripts/kconfig/menu.c +1 -1
@@ -212,7 +212,7 @@ void menu_add_option(int token, char *arg) sym_defconfig_list = current_entry->sym; else if (sym_defconfig_list != current_entry->sym) zconf_error("trying to redefine defconfig symbol"); - sym_defconfig_list->flags |=SYMBOL_AUTO ; + sym_defconfig_list->flags |=SYMBOL_NO_WRITE ;break ;case T_OPT_ALLNOCONFIG_Y : current_entry->sym->flags |=SYMBOL_ALLNOCONFIG_Y ;
scripts/kconfig/symbol.c +1 -1
@@ -463,7 +463,7 @@ void sym_calc_value(struct symbol *sym) } } -if (sym->flags &SYMBOL_AUTO ) +if (sym->flags &SYMBOL_NO_WRITE ) sym->flags &= ~SYMBOL_WRITE ;if (sym->flags &SYMBOL_NEED_SET_CHOICE_VALUES )
scripts/kconfig/zconf.y +1 -1
@@ -265,7 +265,7 @@ symbol_option_arg: choice: T_CHOICE word_opt T_EOL { struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); - sym->flags |= SYMBOL_AUTO; + sym->flags |= SYMBOL_NO_WRITE; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); free($2);
Signature · 1 line
2.16.1
Re: [PATCH v3] kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE
2018-07-03 21:43 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 5 lines
Over time, the use of the flag
SYMBOL_AUTOchanged from initially marking three automatically generated symbols ARCH, KERNELRELEASE andUNAME_RELEASEto today's effect of protecting symbols from being written out.
Quoted 8 lines
Currently, only symbols of type CHOICE and those with option
defconf_listset have that flag set.Reflect that change in semantics in the flag's name.
Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>---
Applied to linux-kbuild/kconfig. Thanks!
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v2 1/1 kconfig: fix comment for symbol flag SYMBOL_AUTO
In reply to Masahiro YamadaOver time, the use of the flag changed from initially marking three automatically generated symbols ARCH, KERNELRELEASE and UNAME_RELEASE to protecting symbols from being written out, today.
Currently, only symbols of type CHOICE and those with option defconf_list set have that flag set so that they are not written out.
Document the current effect of that flag.
--- scripts/kconfig/expr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/expr.h +1 -1
@@ -141,7 +141,7 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ -#define SYMBOL_AUTO 0x1000/* value from environment variable */ +#define SYMBOL_AUTO 0x1000/* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000/* used during dependency checking */ #define SYMBOL_WARNED 0x8000/* warning has been issued */
Signature · 1 line
2.16.1
PATCH 2/3 kconfig: handle P_SYMBOL in print_symbol()
In reply to Dirk GoudersEach symbol has a property of type P_SYMBOL since commit 59e89e3ddf8523be (kconfig: save location of config symbols). Handle those properties in print_symbol().
Further, place a pointer to print_symbol() in the comment above the list of known property type.
--- scripts/kconfig/expr.h | 3 +++ scripts/kconfig/zconf.y | 4 ++++ 2 files changed, 7 insertions(+)
scripts/kconfig/expr.h +3 -0
@@ -171,6 +171,9 @@ struct symbol {* config BAZ * int "BAZ Value" * range 1..255 +* +* Please, also check zconf.y:print_symbol() when modifying the +* list of property types! */ enum prop_type {P_UNKNOWN ,
scripts/kconfig/zconf.y +4 -0
@@ -717,6 +717,10 @@ static void print_symbol(FILE *out, struct menu *menu) print_quoted_string(out, prop->text); fputc('\n', out); break; + case P_SYMBOL: + fputs( " symbol ", out); + fprintf(out, "%s\n", prop->sym->name); + break; default: fprintf(out, " unknown prop %d!\n", prop->type); break;
Signature · 1 line
2.13.6
Re: [PATCH 2/3] kconfig: handle P_SYMBOL in print_symbol()
2018-06-23 4:27 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 9 lines
Each symbol has a property of type
P_SYMBOLsince commit59e89e3ddf8523be(kconfig: save location of config symbols). Handle those properties inprint_symbol().Further, place a pointer to
print_symbol()in the comment above the list of known property type.Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>
Applied to linux-kbuild/fixes. Thanks!
Quoted 41 lines
--- scripts/kconfig/expr.h | 3 +++ scripts/kconfig/zconf.y | 4 ++++ 2 files changed, 7 insertions(+)scripts/kconfig/expr.h +3
-0@@ -171,6 +171,9 @@ struct symbol {* config BAZ * int "BAZ Value" * range 1..255 +* +* Please, also check zconf.y:print_symbol() when modifying the +* list of property types! */ enum prop_type {P_UNKNOWN ,scripts/kconfig/zconf.y +4
-1@@ -717,6 +717,10 @@ static void print_symbol(FILE *out, struct menu *menu) print_quoted_string(out, prop->text); fputc('\n', out); break; + case P_SYMBOL: + fputs( " symbol ", out); + fprintf(out, "%s\n", prop->sym->name); + break; default: fprintf(out, " unknown prop %d!\n", prop->type); break; --2.13.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 3/3 kconfig: add debugconfig target for debugging purposes
In reply to Dirk GoudersCurrently, we need to modify existing kconfig targets to generate debugging information from the parser. That information then has to be filtered somehow, automated tests are at least complicated to implement.
Add a debugconfig target for pure debugging purposes; the initial version of this target dumps the menu tree and with the --debug option activates the parsers debugging output via it's global variable cdebug. The environment variable ZCONF_DEBUG can be used to generate even more detailed debugging information.
Sample output for a simple Kconfig file:
$ scripts/kconfig/dconf --debug Kconfig.dconfig Kconfig.dconfig:1:config a Kconfig.dconfig:2:type(1) Kconfig.dconfig:4:endconfig Kconfig.dconfig:5:if Kconfig.dconfig:5:config b Kconfig.dconfig:6:type(1) Kconfig.dconfig:7:endconfig Kconfig.dconfig:7:endif
config a
bool
symbol a
prompt "a"
config b
bool
symbol b
prompt "b" if a
endmenu
--- scripts/kconfig/Makefile | 10 ++++++++- scripts/kconfig/dconf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 scripts/kconfig/dconf.c
scripts/kconfig/Makefile +9 -1
@@ -4,7 +4,7 @@ # These targets are used from top-level makefile PHONY += xconfig gconfig menuconfig config syncconfig \ - localmodconfig localyesconfig + localmodconfig localyesconfig debugconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG)
@@ -34,6 +34,9 @@ config: $(obj)/conf nconfig: $(obj)/nconf $< $(silent) $(Kconfig) +debugconfig: $(obj)/dconf + $< $(silent) $(Kconfig) + # This has become an internal implementation detail and is now deprecated # for external use. syncconfig: $(obj)/conf
@@ -149,6 +152,7 @@ help: @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' + @echo ' debugconfig - Debugging tool for developers' # =========================================================================== # Shared Makefile for the various kconfig executables:
@@ -165,6 +169,10 @@ targets += zconf.lex.c HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +# dconf: Used for kconfig debugging +hostprogs-y += dconf +dconf-objs := dconf.o zconf.tab.o + # nconf: Used for the nconfig target based on ncurses hostprogs-y += nconf nconf-objs := nconf.o zconf.tab.o nconf.gui.o
scripts/kconfig/dconf.c new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.13.6
Re: [PATCH 3/3] kconfig: add debugconfig target for debugging purposes
2018-06-23 4:27 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 148 lines
Currently, we need to modify existing kconfig targets to generate debugging information from the parser. That information then has to be filtered somehow, automated tests are at least complicated to implement.
Add a debugconfig target for pure debugging purposes; the initial version of this target dumps the menu tree and with the --debug option activates the parsers debugging output via it's global variable cdebug. The environment variable
ZCONF_DEBUGcan be used to generate even more detailed debugging information.Sample output for a simple
Kconfigfile:$ scripts/kconfig/dconf --debug Kconfig.dconfig Kconfig.dconfig:1:config a Kconfig.dconfig:2:type(1) Kconfig.dconfig:4:endconfig Kconfig.dconfig:5:if Kconfig.dconfig:5:config b Kconfig.dconfig:6:type(1) Kconfig.dconfig:7:endconfig Kconfig.dconfig:7:endifconfig a
bool
symbol a
prompt "a"config b
bool
symbol b
prompt "b" if aendmenu
Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/Makefile | 10 ++++++++- scripts/kconfig/dconf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 scripts/kconfig/dconf.cscripts/kconfig/Makefile +9
-1@@ -4,7 +4,7 @@ # These targets are used from top-level makefile PHONY += xconfig gconfig menuconfig config syncconfig \ - localmodconfig localyesconfig + localmodconfig localyesconfig debugconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG)@@ -34,6 +34,9 @@ config: $(obj)/conf nconfig: $(obj)/nconf $< $(silent) $(Kconfig) +debugconfig: $(obj)/dconf + $< $(silent) $(Kconfig) + # This has become an internal implementation detail and is now deprecated # for external use. syncconfig: $(obj)/conf@@ -149,6 +152,7 @@ help: @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' + @echo ' debugconfig - Debugging tool for developers' # =========================================================================== # Shared Makefile for the various kconfig executables:@@ -165,6 +169,10 @@ targets += zconf.lex.c HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +# dconf: Used for kconfig debugging +hostprogs-y += dconf +dconf-objs := dconf.o zconf.tab.o + # nconf: Used for the nconfig target based on ncurses hostprogs-y += nconf nconf-objs := nconf.o zconf.tab.o nconf.gui.oscripts/kconfig/dconf.c new file +55
-1@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 Dirk Gouders <[email protected]> + +#include <stdlib.h> +#include <stdio.h> +#include <getopt.h> + +#include "lkc.h" + +extern int cdebug; + +void usage (const char *progname); +void usage (const char *progname) +{ +printf ("Usage: %s --help | [--debug] <kconfig-file>\n" , progname); +} + +int main (int argc,char *argv[]) +{ +int c; +int opt_index =0 ; +char *filename; + +struct option long_opts[] = { + {"debug" , no_argument,NULL ,0 }, + {"help" , no_argument,NULL ,1 }, + {0 ,0 ,0 ,0 } + }; + +while (1 ) { + c =getopt_long (argc, argv,"" , long_opts, &opt_index); + +if (c ==-1 ) +break ; +if (c ==0 ) { + cdebug =0x02 ; + } +if (c ==1 ) { +usage (argv[0 ]); +exit (EXIT_SUCCESS ); + } + } + +if (optind == argc) { +usage (argv[0 ]); +exit (EXIT_FAILURE ); + }else + filename = argv[optind]; + +conf_parse (filename); +zconfdump (stdout); + +exit (EXIT_SUCCESS ); +} --2.13.6
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
You mentioned ZCONF_DEBUG in the log.
So, another possibility is to use
an environment variable to turn on debug features.
name = getenv("KCONFIG_DEBUG");
if (name && name[0] == '1')
zconfdump(stdout);Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 3/3] kconfig: add debugconfig target for debugging purposes
Quoted 157 lines · Masahiro Yamada
2018-06-23 4:27 GMT+09:00 Dirk Gouders <[email protected]>:
Quoted 148 lines
Currently, we need to modify existing kconfig targets to generate debugging information from the parser. That information then has to be filtered somehow, automated tests are at least complicated to implement.
Add a debugconfig target for pure debugging purposes; the initial version of this target dumps the menu tree and with the --debug option activates the parsers debugging output via it's global variable cdebug. The environment variable
ZCONF_DEBUGcan be used to generate even more detailed debugging information.Sample output for a simple
Kconfigfile:$ scripts/kconfig/dconf --debug Kconfig.dconfig Kconfig.dconfig:1:config a Kconfig.dconfig:2:type(1) Kconfig.dconfig:4:endconfig Kconfig.dconfig:5:if Kconfig.dconfig:5:config b Kconfig.dconfig:6:type(1) Kconfig.dconfig:7:endconfig Kconfig.dconfig:7:endifconfig a
bool
symbol a
prompt "a"config b
bool
symbol b
prompt "b" if aendmenu
Signed-off-by Dirk Gouders <[email protected]>Cc Sam Ravnborg <[email protected]>--- scripts/kconfig/Makefile | 10 ++++++++- scripts/kconfig/dconf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 scripts/kconfig/dconf.cscripts/kconfig/Makefile +9
-1@@ -4,7 +4,7 @@ # These targets are used from top-level makefile PHONY += xconfig gconfig menuconfig config syncconfig \ - localmodconfig localyesconfig + localmodconfig localyesconfig debugconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG)@@ -34,6 +34,9 @@ config: $(obj)/conf nconfig: $(obj)/nconf $< $(silent) $(Kconfig) +debugconfig: $(obj)/dconf + $< $(silent) $(Kconfig) + # This has become an internal implementation detail and is now deprecated # for external use. syncconfig: $(obj)/conf@@ -149,6 +152,7 @@ help: @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' + @echo ' debugconfig - Debugging tool for developers' # =========================================================================== # Shared Makefile for the various kconfig executables:@@ -165,6 +169,10 @@ targets += zconf.lex.c HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +# dconf: Used for kconfig debugging +hostprogs-y += dconf +dconf-objs := dconf.o zconf.tab.o + # nconf: Used for the nconfig target based on ncurses hostprogs-y += nconf nconf-objs := nconf.o zconf.tab.o nconf.gui.oscripts/kconfig/dconf.c new file +55
-1@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 Dirk Gouders <[email protected]> + +#include <stdlib.h> +#include <stdio.h> +#include <getopt.h> + +#include "lkc.h" + +extern int cdebug; + +void usage (const char *progname); +void usage (const char *progname) +{ +printf ("Usage: %s --help | [--debug] <kconfig-file>\n" , progname); +} + +int main (int argc,char *argv[]) +{ +int c; +int opt_index =0 ; +char *filename; + +struct option long_opts[] = { + {"debug" , no_argument,NULL ,0 }, + {"help" , no_argument,NULL ,1 }, + {0 ,0 ,0 ,0 } + }; + +while (1 ) { + c =getopt_long (argc, argv,"" , long_opts, &opt_index); + +if (c ==-1 ) +break ; +if (c ==0 ) { + cdebug =0x02 ; + } +if (c ==1 ) { +usage (argv[0 ]); +exit (EXIT_SUCCESS ); + } + } + +if (optind == argc) { +usage (argv[0 ]); +exit (EXIT_FAILURE ); + }else + filename = argv[optind]; + +conf_parse (filename); +zconfdump (stdout); + +exit (EXIT_SUCCESS ); +} --2.13.6
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlYou mentioned
ZCONF_DEBUGin the log.
Quoted 6 lines
So, another possibility is to use
an environment variable to turn on debug features.name = getenv("KCONFIG_DEBUG"); if (name && name[0] == '1') zconfdump(stdout);
Yes, that would also be a possibility. Perhaps even more flexibility would be gained if a path is allowed for the content of the environment variable to specify where the dump should go, e.g. KCONFIG_DEBUG="./zconfdump-%d.out". This way, we could dump without disturbing std{err,out}.
Since some days, I am thinking about the possibility of a "knob" for *config targets, once triggered, a dump will be produced to the specified location. But thinking of menuconfig, for example, I have not yet an idea what this "knob" could be -- we don't have many unused keys left. Perhaps a signal...
The following is only meant for exchange of ideas -- I currently do some debugging this way but chances are that all of it is not thought trough, very well and too complicated:
I am wondering if -- instead of providing a debugging tool -- it would be more practical to offer developers a hook to enable easy use of personal debugging tools through make(1) without disturbing git and the need to trimm the mainstream Makefile every time:
1) Add a hook to scripts/kconfig/Makefile to allow developers to add own tools if they want to:
#
# Include optional Makefile that developers can trimm without
# disturbing git to make use of tools that are still under development # or not adequate for mainstream. # -include scripts/kconfig/Makefile.devel
2) My Makefile.devel then looks like
PHONY += debugconfig
debugconfig: $(obj)/dconf
$< $(silent) $(dconfargs) $(Kconfig)
# dconf: Used for kconfig debugging
hostprogs-y += dconf
dconf-objs := dconf.o zconf.tab.o
3) This allows me to call debugconfig like this:
make dconfargs="--symdump=symdump" Kconfig=Kconfig_for_testing debugconfig
4) In case you are interested, my current debugging tool is attached. It grew a bit and it is bigger than it could be, because (for now) I want it to be standalone, without disturbing files that are controlled by git.
The tool now also produces a dump of all symbols, a bit different compared to walking symbols via the menu.
Dirk
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (C) 2018 Dirk Gouders <[email protected]>
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include "lkc.h"
#include "expr.h"
extern int cdebug;
#define SYMBOL_NO_WRITE 0x1000
void usage(const char *progname);
void usage(const char *progname)
{
printf("Usage: %s --help | [--debug] [--menudump[=file]] [--symdump[=file]] <kconfig-file>\n", progname);
}static void dconf_check_types()
{
}
static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
putc('"', out);
while ((p = strchr(str, '"'))) {
len = p - str;
if (len)
fprintf(out, "%.*s", len, str);
fputs("\\\"", out);
str = p + 1;
}
fputs(str, out);
putc('"', out);
}static void sym_print_flags(FILE *out, struct symbol *sym)
{
char *space = "";
fprintf(out, "Flags: ");
if (!sym->flags) {
fprintf(out, "\n");
return;
}
if (sym->flags & SYMBOL_CONST) {
fprintf(out, "CONST");
space = ", ";
}
if (sym->flags & SYMBOL_CHECK) {
fprintf(out, "%sCHECK", space);
space = ", ";
}
if (sym->flags & SYMBOL_CHOICE) {
fprintf(out, "%sCHOICE", space);
space = ", ";
}
if (sym->flags & SYMBOL_CHOICEVAL) {
fprintf(out, "%sCHOICEVAL", space);
space = ", ";
}
if (sym->flags & SYMBOL_VALID) {
fprintf(out, "%sVALID", space);
space = ", ";
}
if (sym->flags & SYMBOL_OPTIONAL) {
fprintf(out, "%sOPTIONAL", space);
space = ", ";
}
if (sym->flags & SYMBOL_WRITE) {
fprintf(out, "%sWRITE", space);
space = ", ";
}
if (sym->flags & SYMBOL_CHANGED) {
fprintf(out, "%sCHANGED", space);
space = ", ";
}
if (sym->flags & SYMBOL_NO_WRITE) {
fprintf(out, "%sNO_WRITE", space);
space = ", ";
}
if (sym->flags & SYMBOL_CHECKED) {
fprintf(out, "%sCHECKED", space);
space = ", ";
}
if (sym->flags & SYMBOL_WARNED) {
fprintf(out, "%sWARNED", space);
}
fprintf(out, "\n");
}
static void print_symbol(FILE *out, struct symbol *sym)
{
struct property *prop;
if (sym_is_choice(sym))
fprintf(out, "\nchoice\n");
else
fprintf(out, "\nconfig %s\n", sym->name);
sym_print_flags(out, sym);
switch (sym->type) {
case S_BOOLEAN:
fputs(" bool\n", out);
break;
case S_TRISTATE:
fputs(" tristate\n", out);
break;
case S_STRING:
fputs(" string\n", out);
break;
case S_INT:
fputs(" integer\n", out);
break;
case S_HEX:
fputs(" hex\n", out);
break;
default:
fputs(" unknown\n", out);
break;
}
fprintf(out, "Value: %s\n", sym_get_string_value(sym));
for (prop = sym->prop; prop; prop = prop->next) {
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);
if (!expr_is_yes(prop->visible.expr)) {
fputs(" if ", out);
expr_fprint(prop->visible.expr, out);
}
fputc('\n', out);
break;
case P_IMPLY:
fputs( " imply ", 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_RANGE:
fputs( " range ", 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_MENU:
fputs( " menu ", out);
print_quoted_string(out, prop->text);
fputc('\n', out);
break;
case P_SYMBOL:
fputs( " symbol ", out);
if (prop->sym)
fprintf(out, "%s (file %s:%d)\n", prop->sym->name,
prop->file->name, prop->lineno);
break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
}
}
fprintf(out, " Depends on: ");
if (!expr_is_yes(sym->dir_dep.expr))
expr_fprint(sym->dir_dep.expr, out);
fprintf(out, "\n Selected by: ");
if (!expr_is_yes(sym->rev_dep.expr))
expr_fprint(sym->rev_dep.expr, out);
fprintf(out, "\n Implied by: ");
if (!expr_is_yes(sym->implied.expr))
expr_fprint(sym->implied.expr, out);
fputc('\n', out);
}void sym_dump(FILE *);
void sym_dump(FILE *out)
{
struct symbol *sym;
int i;
print_symbol(out, &symbol_yes);
print_symbol(out, &symbol_mod);
print_symbol(out, &symbol_no);
for_all_symbols(i, sym) {
print_symbol(out, sym);
}
}int main(int argc, char *argv[])
{
int c;
int opt_index = 0;
char *filename;
int menudump = 0; /* Print menu structure */
FILE *menudump_out;
int symdump = 0; /* Print all symbols */
FILE *symdump_out;
struct option long_opts[] = {
{"debug", no_argument, NULL, 0},
{"help", no_argument, NULL, 1},
{"menudump", optional_argument, NULL, 2},
{"symdump", optional_argument, NULL, 3},
{0, 0, 0, 0}
};
while (1 ) {
c = getopt_long(argc, argv, "", long_opts, &opt_index);
if (c == -1)
break;
if (c == 0) {
cdebug = 0x02;
}
if (c == 1) {
usage(argv[0]);
exit(EXIT_SUCCESS);
}
if (c == 2) {
menudump = 1;
if (optarg) {
if (!strcmp(optarg, "stdout"))
menudump_out = stdout;
else if (!strcmp(optarg, "stderr"))
menudump_out = stderr;
else {
menudump_out = fopen(optarg, "w");
if (!menudump_out) {
perror(optarg);
}
}
} else
menudump_out = stdout;
}
if (c == 3) {
symdump = 1;
if (optarg) {
if (!strcmp(optarg, "stdout"))
symdump_out = stdout;
else if (!strcmp(optarg, "stderr"))
symdump_out = stderr;
else {
symdump_out = fopen(optarg, "w");
if (!symdump_out) {
perror(optarg);
}
}
} else
symdump_out = stdout;
}
}
if (optind == argc) {
usage(argv[0]);
exit(EXIT_FAILURE);
} else
filename = argv[optind];
//getc(stdin);
conf_parse(filename);
//conf_read(NULL);
if (menudump)
zconfdump(menudump_out);
if (symdump)
sym_dump(symdump_out);
exit(EXIT_SUCCESS);
}