[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240617175818.58219-26-samitolvanen@google.com>
Date: Mon, 17 Jun 2024 17:58:28 +0000
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Masahiro Yamada <masahiroy@...nel.org>, Luis Chamberlain <mcgrof@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Matthew Maurer <mmaurer@...gle.com>, Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>, Gary Guo <gary@...yguo.net>, linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-modules@...r.kernel.org,
rust-for-linux@...r.kernel.org, Sami Tolvanen <samitolvanen@...gle.com>
Subject: [PATCH 09/15] gendwarfksyms: Expand array_type
Add support for expanding DW_TAG_array_type, and the subrange type
indicating array size.
Example output with --debug:
variable array_type [34] {
pointer_type <unnamed> {
const_type <unnamed> {
base_type char byte_size(1)
}
}
};
Signed-off-by: Sami Tolvanen <samitolvanen@...gle.com>
---
tools/gendwarfksyms/types.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tools/gendwarfksyms/types.c b/tools/gendwarfksyms/types.c
index a56aeaa4f3a1..b1b82d166eb8 100644
--- a/tools/gendwarfksyms/types.c
+++ b/tools/gendwarfksyms/types.c
@@ -177,6 +177,7 @@ DEFINE_PROCESS_UDATA_ATTRIBUTE(byte_size)
}
DEFINE_MATCH(formal_parameter)
+DEFINE_MATCH(subrange)
bool match_all(Dwarf_Die *die)
{
@@ -268,6 +269,31 @@ DEFINE_PROCESS_TYPE(shared)
DEFINE_PROCESS_TYPE(volatile)
DEFINE_PROCESS_TYPE(typedef)
+static int process_subrange_type(struct state *state, struct cached_die *cache,
+ Dwarf_Die *die)
+{
+ Dwarf_Word count = 0;
+
+ if (get_udata_attr(die, DW_AT_count, &count))
+ return check(process_fmt(state, cache, "[%" PRIu64 "]", count));
+
+ return check(process(state, cache, "[]"));
+}
+
+static int process_array_type(struct state *state, struct cached_die *cache,
+ Dwarf_Die *die)
+{
+ check(process(state, cache, "array_type "));
+ /* Array size */
+ check(process_die_container(state, cache, die, process_type,
+ match_subrange_type));
+ check(process(state, cache, " {"));
+ check(process_linebreak(cache, 1));
+ check(process_type_attr(state, cache, die));
+ check(process_linebreak(cache, -1));
+ return check(process(state, cache, "}"));
+}
+
static int __process_subroutine_type(struct state *state,
struct cached_die *cache, Dwarf_Die *die,
const char *type)
@@ -378,7 +404,9 @@ static int process_type(struct state *state, struct cached_die *parent,
PROCESS_TYPE(volatile)
/* Subtypes */
PROCESS_TYPE(formal_parameter)
+ PROCESS_TYPE(subrange)
/* Other types */
+ PROCESS_TYPE(array)
PROCESS_TYPE(base)
PROCESS_TYPE(subroutine)
PROCESS_TYPE(typedef)
--
2.45.2.627.g7a2c4fd464-goog
Powered by blists - more mailing lists