Adding debug option for showing the linearized instruction.
Christopher Li
maintainerPATCH 1/1 Adding debug option for showing the linearized instruction.
lib.c +49 -14
@@ -190,6 +190,9 @@ int Waddress_space = 1;int Wenum_mismatch =1 ;int Wdo_while =1 ;int Wuninitialized =1 ; + +int dbg_entry; +int preprocess_only;char *include;
@@ -237,14 +240,6 @@ static char **handle_switch_E(char *arg,return next; } -static char **handle_switch_v (char *arg,char **next) -{ -do { - verbose++; - }while (*++arg =='v' ); -return next; -} -static char **handle_switch_I (char *arg,char **next) {char *path = arg+1 ;
@@ -352,14 +347,14 @@ enum { }; -static char **handle_switch_W (char *arg,char **next) +static char **handle_onoff_switch (char *arg,char **next,const struct warning warnings[],int n) {int flag =WARNING_ON ;char *p = arg +1 ;unsigned i;if (!strcmp (p,"all" )) { -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag !=WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_ON ; }
@@ -373,7 +368,7 @@ static char **handle_switch_W(char *arg, flag =WARNING_FORCE_OFF ; } -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (!strcmp (p,warnings[i].name)) { *warnings[i].flag = flag;return next;
@@ -381,26 +376,65 @@ static char **handle_switch_W(char *arg, }// Unknown. +return NULL ; +} + +static char **handle_switch_W (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, warnings,sizeof warnings/sizeof warnings[0 ]); +if (ret) +return ret; + +// Unknown. return next; } -static void handle_switch_W_finalize (void ) +static struct warning debugs[] = { + {"entry" , &dbg_entry}, +}; + + +static char **handle_switch_v (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, debugs,sizeof debugs/sizeof debugs[0 ]); +if (ret) +return ret; + +// Unknown. +do { + verbose++; + }while (*++arg =='v' ); +return next; +} + + +static void handle_onoff_switch_finalize (const struct warning warnings[],int n) {unsigned i; -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag ==WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_OFF ; } } +static void handle_switch_W_finalize (void ) +{ +handle_onoff_switch_finalize (warnings,sizeof (warnings) /sizeof (warnings[0 ])); +} + +static void handle_switch_v_finalize (void ) +{ +handle_onoff_switch_finalize (debugs,sizeof (debugs) /sizeof (debugs[0 ])); +} +static char **handle_switch_U (char *arg,char **next) {const char *name = arg +1 ;add_pre_buffer ("#undef %s\n" , name);return next; } - +static char **handle_switch_O (char *arg,char **next) {int level =1 ;
@@ -661,6 +695,7 @@ struct symbol_list *sparse_initialize(inadd_ptr_list_notag (filelist, arg); }handle_switch_W_finalize (); +handle_switch_v_finalize (); list =NULL ;if (!ptr_list_empty (filelist)) {
lib.h +2 -0
@@ -97,6 +97,8 @@ extern int Wcast_truncate;extern int Wdo_while;extern int Wuninitialized; +extern int dbg_entry; +extern void declare_builtin_functions (void );extern void create_builtin_stream (void );extern struct symbol_list *sparse_initialize (int argc,char **argv,struct string_list **files);
sparse.c +5 -1
@@ -264,8 +264,12 @@ static void check_symbols(struct symbol_expand_symbol (sym); ep =linearize_symbol (sym); -if (ep) +if (ep) { +if (dbg_entry) +show_entry (ep); +check_context (ep); + } }END_FOR_EACH_PTR (sym); }
Looks reasonable; debug information does seem like a logical extension of verbosity.
Could I get a signoff, please?
- Josh Triplett
Quoted 169 lines · Christopher Li
Index:
sparse/lib.c
===================================================================lib.c +49
-14@@ -190,6 +190,9 @@ int Waddress_space = 1;int Wenum_mismatch =1 ;int Wdo_while =1 ;int Wuninitialized =1 ; + +int dbg_entry; +int preprocess_only;char *include;@@ -237,14 +240,6 @@ static char **handle_switch_E(char *arg,return next; } -static char **handle_switch_v (char *arg,char **next) -{ -do { - verbose++; - }while (*++arg =='v' ); -return next; -} -static char **handle_switch_I (char *arg,char **next) {char *path = arg+1 ;@@ -352,14 +347,14 @@ enum { }; -static char **handle_switch_W (char *arg,char **next) +static char **handle_onoff_switch (char *arg,char **next,const struct warning warnings[],int n) {int flag =WARNING_ON ;char *p = arg +1 ;unsigned i;if (!strcmp (p,"all" )) { -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag !=WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_ON ; }@@ -373,7 +368,7 @@ static char **handle_switch_W(char *arg, flag =WARNING_FORCE_OFF ; } -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (!strcmp (p,warnings[i].name)) { *warnings[i].flag = flag;return next;@@ -381,26 +376,65 @@ static char **handle_switch_W(char *arg, }// Unknown. +return NULL ; +} + +static char **handle_switch_W (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, warnings,sizeof warnings/sizeof warnings[0 ]); +if (ret) +return ret; + +// Unknown. return next; } -static void handle_switch_W_finalize (void ) +static struct warning debugs[] = { + {"entry" , &dbg_entry}, +}; + + +static char **handle_switch_v (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, debugs,sizeof debugs/sizeof debugs[0 ]); +if (ret) +return ret; + +// Unknown. +do { + verbose++; + }while (*++arg =='v' ); +return next; +} + + +static void handle_onoff_switch_finalize (const struct warning warnings[],int n) {unsigned i; -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag ==WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_OFF ; } } +static void handle_switch_W_finalize (void ) +{ +handle_onoff_switch_finalize (warnings,sizeof (warnings) /sizeof (warnings[0 ])); +} + +static void handle_switch_v_finalize (void ) +{ +handle_onoff_switch_finalize (debugs,sizeof (debugs) /sizeof (debugs[0 ])); +} +static char **handle_switch_U (char *arg,char **next) {const char *name = arg +1 ;add_pre_buffer ("#undef %s\n" , name);return next; } - +static char **handle_switch_O (char *arg,char **next) {int level =1 ;@@ -661,6 +695,7 @@ struct symbol_list *sparse_initialize(inadd_ptr_list_notag (filelist, arg); }handle_switch_W_finalize (); +handle_switch_v_finalize (); list =NULL ;if (!ptr_list_empty (filelist)) {Index:
sparse/lib.h
===================================================================lib.h +2
-0@@ -97,6 +97,8 @@ extern int Wcast_truncate;extern int Wdo_while;extern int Wuninitialized; +extern int dbg_entry; +extern void declare_builtin_functions (void );extern void create_builtin_stream (void );extern struct symbol_list *sparse_initialize (int argc,char **argv,struct string_list **files);Index:
sparse/sparse.c
===================================================================sparse.c +5
-2@@ -264,8 +264,12 @@ static void check_symbols(struct symbol_expand_symbol (sym); ep =linearize_symbol (sym); -if (ep) +if (ep) { +if (dbg_entry) +show_entry (ep); +check_context (ep); + } }END_FOR_EACH_PTR (sym); } -To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Christopher Li
maintainerQuoted 6 lines · Josh Triplett
Looks reasonable; debug information does seem like a logical extension of verbosity.
Could I get a signoff, please?
- Josh Triplett
Adding debug option for showing the linearized instruction.
lib.c +49 -14
@@ -190,6 +190,9 @@ int Waddress_space = 1;int Wenum_mismatch =1 ;int Wdo_while =1 ;int Wuninitialized =1 ; + +int dbg_entry; +int preprocess_only;char *include;
@@ -237,14 +240,6 @@ static char **handle_switch_E(char *arg,return next; } -static char **handle_switch_v (char *arg,char **next) -{ -do { - verbose++; - }while (*++arg =='v' ); -return next; -} -static char **handle_switch_I (char *arg,char **next) {char *path = arg+1 ;
@@ -352,14 +347,14 @@ enum { }; -static char **handle_switch_W (char *arg,char **next) +static char **handle_onoff_switch (char *arg,char **next,const struct warning warnings[],int n) {int flag =WARNING_ON ;char *p = arg +1 ;unsigned i;if (!strcmp (p,"all" )) { -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag !=WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_ON ; }
@@ -373,7 +368,7 @@ static char **handle_switch_W(char *arg, flag =WARNING_FORCE_OFF ; } -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (!strcmp (p,warnings[i].name)) { *warnings[i].flag = flag;return next;
@@ -381,26 +376,65 @@ static char **handle_switch_W(char *arg, }// Unknown. +return NULL ; +} + +static char **handle_switch_W (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, warnings,sizeof warnings/sizeof warnings[0 ]); +if (ret) +return ret; + +// Unknown. return next; } -static void handle_switch_W_finalize (void ) +static struct warning debugs[] = { + {"entry" , &dbg_entry}, +}; + + +static char **handle_switch_v (char *arg,char **next) +{ +char ** ret =handle_onoff_switch (arg, next, debugs,sizeof debugs/sizeof debugs[0 ]); +if (ret) +return ret; + +// Unknown. +do { + verbose++; + }while (*++arg =='v' ); +return next; +} + + +static void handle_onoff_switch_finalize (const struct warning warnings[],int n) {unsigned i; -for (i =0 ; i <sizeof (warnings) /sizeof (warnings[0 ]); i++) { +for (i =0 ; i < n; i++) {if (*warnings[i].flag ==WARNING_FORCE_OFF ) *warnings[i].flag =WARNING_OFF ; } } +static void handle_switch_W_finalize (void ) +{ +handle_onoff_switch_finalize (warnings,sizeof (warnings) /sizeof (warnings[0 ])); +} + +static void handle_switch_v_finalize (void ) +{ +handle_onoff_switch_finalize (debugs,sizeof (debugs) /sizeof (debugs[0 ])); +} +static char **handle_switch_U (char *arg,char **next) {const char *name = arg +1 ;add_pre_buffer ("#undef %s\n" , name);return next; } - +static char **handle_switch_O (char *arg,char **next) {int level =1 ;
@@ -661,6 +695,7 @@ struct symbol_list *sparse_initialize(inadd_ptr_list_notag (filelist, arg); }handle_switch_W_finalize (); +handle_switch_v_finalize (); list =NULL ;if (!ptr_list_empty (filelist)) {
lib.h +2 -0
@@ -97,6 +97,8 @@ extern int Wcast_truncate;extern int Wdo_while;extern int Wuninitialized; +extern int dbg_entry; +extern void declare_builtin_functions (void );extern void create_builtin_stream (void );extern struct symbol_list *sparse_initialize (int argc,char **argv,struct string_list **files);
sparse.c +5 -1
@@ -264,8 +264,12 @@ static void check_symbols(struct symbol_expand_symbol (sym); ep =linearize_symbol (sym); -if (ep) +if (ep) { +if (dbg_entry) +show_entry (ep); +check_context (ep); + } }END_FOR_EACH_PTR (sym); }
Josh Triplett
AppliedQuoted 11 lines · Christopher Li
Quoted 6 lines · Josh Triplett
Looks reasonable; debug information does seem like a logical extension of verbosity.
Could I get a signoff, please?
- Josh Triplett
Adding debug option for showing the linearized instruction.
Signed-off-by Christopher Li <[email protected]>
Applied.
- Josh Triplett