public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Willy Tarreau <w@1wt.eu>
Cc: dwarves@vger.kernel.org, Alan Maguire <alan.maguire@oracle.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Clark Williams <williams@redhat.com>,
	Kate Carcia <kcarcia@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: [PATCH 1/5] core: Move class__has_flexible_array() from pahole to the core
Date: Mon,  7 Oct 2024 17:25:27 -0300	[thread overview]
Message-ID: <20241007202531.942648-2-acme@kernel.org> (raw)
In-Reply-To: <20241007202531.942648-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We want to cache that info, look if there are embedded fields of structs
with flexible arrays, etc.

Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 dwarves.c | 23 +++++++++++++++++++++++
 dwarves.h |  1 +
 pahole.c  | 23 -----------------------
 3 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/dwarves.c b/dwarves.c
index 6e6a9e69a61d1e37..3d91e629277a329f 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -1575,6 +1575,29 @@ void lexblock__add_label(struct lexblock *block, struct label *label)
 	lexblock__add_tag(block, &label->ip.tag);
 }
 
+bool class__has_flexible_array(struct class *class, const struct cu *cu)
+{
+	struct class_member *member = type__last_member(&class->type);
+
+	if (member == NULL)
+		return false;
+
+	struct tag *type = cu__type(cu, member->tag.type);
+
+	if (type->tag != DW_TAG_array_type)
+		return false;
+
+	struct array_type *array = tag__array_type(type);
+
+	if (array->dimensions > 1)
+		return false;
+
+	if (array->nr_entries == NULL || array->nr_entries[0] == 0)
+		return true;
+
+	return false;
+}
+
 const struct class_member *class__find_bit_hole(const struct class *class,
 					    const struct class_member *trailer,
 						const uint16_t bit_hole_size)
diff --git a/dwarves.h b/dwarves.h
index 2bb0eed461d08d51..757fc05dd3363bf1 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -1454,6 +1454,7 @@ static inline int class__is_struct(const struct class *cls)
 	return tag__is_struct(&cls->type.namespace.tag);
 }
 
+bool class__has_flexible_array(struct class *class, const struct cu *cu);
 void class__find_holes(struct class *cls);
 int class__has_hole_ge(const struct class *cls, const uint16_t size);
 
diff --git a/pahole.c b/pahole.c
index 766835d93a1f3d1e..8bdfaf3e84c407d7 100644
--- a/pahole.c
+++ b/pahole.c
@@ -725,29 +725,6 @@ static int class__packable(struct class *class, struct cu *cu)
 	return 0;
 }
 
-static bool class__has_flexible_array(struct class *class, struct cu *cu)
-{
-	struct class_member *member = type__last_member(&class->type);
-
-	if (member == NULL)
-		return false;
-
-	struct tag *type = cu__type(cu, member->tag.type);
-
-	if (type->tag != DW_TAG_array_type)
-		return false;
-
-	struct array_type *array = tag__array_type(type);
-
-	if (array->dimensions > 1)
-		return false;
-
-	if (array->nr_entries == NULL || array->nr_entries[0] == 0)
-		return true;
-
-	return false;
-}
-
 static struct class *class__filter(struct class *class, struct cu *cu,
 				   uint32_t tag_id)
 {
-- 
2.46.2


  reply	other threads:[~2024-10-07 20:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-07 20:25 [PATCH RFC 0/5] pahole --with_embedded_flexible_array Arnaldo Carvalho de Melo
2024-10-07 20:25 ` Arnaldo Carvalho de Melo [this message]
2024-10-07 20:25 ` [PATCH 2/5] core: Cache info about flexible arrays in class__has_flexible_array() Arnaldo Carvalho de Melo
2024-10-07 20:25 ` [PATCH 3/5] core: Introduce class__has_embedded_flexible_array() Arnaldo Carvalho de Melo
2024-10-07 20:25 ` [PATCH 4/5] fprintf: Add a comment if a member type has an embedded flexible array Arnaldo Carvalho de Melo
2024-10-07 20:25 ` [PATCH 5/5] pahole: Introduce --with_embedded_flexible_array Arnaldo Carvalho de Melo

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=20241007202531.942648-2-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alan.maguire@oracle.com \
    --cc=dwarves@vger.kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=kcarcia@redhat.com \
    --cc=w@1wt.eu \
    --cc=williams@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox