From: Josh Triplett <josh@freedesktop.org>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1] Adding debug option for showing the linearized instruction.
Date: Thu, 22 Feb 2007 20:28:25 -0800 [thread overview]
Message-ID: <45DE6D69.1050705@freedesktop.org> (raw)
In-Reply-To: <20070210001332.GA20604@chrisli.org>
[-- Attachment #1: Type: text/plain, Size: 4914 bytes --]
Looks reasonable; debug information does seem like a logical extension of verbosity.
Could I get a signoff, please?
- Josh Triplett
Christopher Li wrote:
> Index: sparse/lib.c
> ===================================================================
> --- sparse.orig/lib.c 2007-02-02 16:57:04.000000000 -0800
> +++ sparse/lib.c 2007-02-02 17:06:51.000000000 -0800
> @@ -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(in
> add_ptr_list_notag(filelist, arg);
> }
> handle_switch_W_finalize();
> + handle_switch_v_finalize();
>
> list = NULL;
> if (!ptr_list_empty(filelist)) {
> Index: sparse/lib.h
> ===================================================================
> --- sparse.orig/lib.h 2007-02-02 16:57:04.000000000 -0800
> +++ sparse/lib.h 2007-02-02 17:06:51.000000000 -0800
> @@ -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.orig/sparse.c 2007-02-02 16:57:04.000000000 -0800
> +++ sparse/sparse.c 2007-02-02 17:06:51.000000000 -0800
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
next prev parent reply other threads:[~2007-02-23 4:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-10 0:13 [PATCH 1] Adding debug option for showing the linearized instruction Christopher Li
2007-02-23 4:28 ` Josh Triplett [this message]
2007-02-23 22:42 ` Christopher Li
2007-02-25 22:53 ` Josh Triplett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45DE6D69.1050705@freedesktop.org \
--to=josh@freedesktop.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).