All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Gladkov <gladkov.alexey@gmail.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: linux-sparse@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
	Alexey Gladkov <gladkov.alexey@gmail.com>
Subject: [PATCH 2/3] dissect: Show macro definitions
Date: Tue,  2 Nov 2021 15:06:44 +0100	[thread overview]
Message-ID: <20211102140645.83081-3-gladkov.alexey@gmail.com> (raw)
In-Reply-To: <20211102140645.83081-1-gladkov.alexey@gmail.com>

Add the ability to dissect to see macro definitions. The patch does not
add full support for the usage of macros, but only their definitions.

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
---
 dissect.c      | 13 ++++++++++++-
 test-dissect.c |  3 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dissect.c b/dissect.c
index 0d6c3288..7d5d92c9 100644
--- a/dissect.c
+++ b/dissect.c
@@ -610,6 +610,11 @@ static struct symbol *do_initializer(struct symbol *type, struct expression *exp
 	return type;
 }
 
+static inline bool is_macro(struct symbol *sym)
+{
+	return (sym->namespace == NS_MACRO || sym->namespace == NS_UNDEF);
+}
+
 static inline struct symbol *do_symbol(struct symbol *sym)
 {
 	struct symbol *type = base_type(sym);
@@ -654,7 +659,7 @@ static void do_sym_list(struct symbol_list *list)
 
 static inline bool valid_namespace(enum namespace ns)
 {
-	return (ns == NS_STRUCT || ns == NS_SYMBOL);
+	return (ns == NS_MACRO || ns == NS_UNDEF || ns == NS_STRUCT || ns == NS_SYMBOL);
 }
 
 static void do_file(char *file)
@@ -668,6 +673,12 @@ static void do_file(char *file)
 
 	DO_LIST(file_scope->symbols, sym,
 		if (input_streams[sym->pos.stream].fd != -1 && valid_namespace(sym->namespace)) {
+			if (is_macro(sym)) {
+				sym->kind = 'd';
+				reporter->r_symdef(sym);
+				continue;
+			}
+
 			if (sym->type == SYM_STRUCT || sym->type == SYM_UNION) {
 				sym->ctype.base_type = sym;
 				examine_sym_node(sym, NULL);
diff --git a/test-dissect.c b/test-dissect.c
index 58b3e633..3d870a97 100644
--- a/test-dissect.c
+++ b/test-dissect.c
@@ -57,11 +57,12 @@ static void r_symbol(unsigned mode, struct position *pos, struct symbol *sym)
 		show_typename(sym->ctype.base_type));
 
 	switch (sym->kind) {
+	case 'd':
+		break;
 	case 's':
 		if (sym->type == SYM_STRUCT || sym->type == SYM_UNION)
 			break;
 		goto err;
-
 	case 'f':
 		if (sym->type != SYM_BAD && sym->ctype.base_type->type != SYM_FN)
 			goto err;
-- 
2.33.0


  parent reply	other threads:[~2021-11-02 14:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 14:06 [PATCH 0/3] semind: Index more symbols Alexey Gladkov
2021-11-02 14:06 ` [PATCH 1/3] dissect: Allow to show all symbols Alexey Gladkov
2021-11-02 14:06 ` Alexey Gladkov [this message]
2021-11-02 14:06 ` [PATCH 3/3] dissect: Show typedefs Alexey Gladkov
2021-12-14 15:16 ` [PATCH 0/3] semind: Index more symbols Alexey Gladkov
2022-05-21  9:46 ` Luc Van Oostenryck
2022-05-23 12:45   ` Alexey Gladkov

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=20211102140645.83081-3-gladkov.alexey@gmail.com \
    --to=gladkov.alexey@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=oleg@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.