diff mbox series

[dwarves,v4,07/10] dwarf_loader: introduce cu->id

Message ID 20250107190855.2312210-8-ihor.solodrai@pm.me (mailing list archive)
State Not Applicable
Headers show
Series pahole: faster reproducible BTF encoding | expand

Commit Message

Ihor Solodrai Jan. 7, 2025, 7:09 p.m. UTC
Add an id member to the struct cu.

An id is an index of a CU, in order they are created in dwarf_loader.c
This allows for an easy identification of a CU, particularly when they
need to be processed in order.

Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
---
 dwarf_loader.c | 5 +++++
 dwarves.h      | 1 +
 2 files changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/dwarf_loader.c b/dwarf_loader.c
index 34376b2..39e4cba 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -3440,6 +3440,7 @@  struct dwarf_cus {
 	int		    build_id_len;
 	int		    error;
 	struct dwarf_cu	    *type_dcu;
+	uint32_t	nr_cus_created;
 };
 
 struct dwarf_thread {
@@ -3472,6 +3473,9 @@  static struct dwarf_cu *dwarf_cus__create_cu(struct dwarf_cus *dcus, Dwarf_Die *
 	cu->priv = dcu;
 	cu->dfops = &dwarf__ops;
 
+	cu->id = dcus->nr_cus_created;
+	dcus->nr_cus_created++;
+
 	return dcu;
 }
 
@@ -3783,6 +3787,7 @@  static int cus__load_module(struct cus *cus, struct conf_load *conf,
 			.type_dcu = type_cu ? &type_dcu : NULL,
 			.build_id = build_id,
 			.build_id_len = build_id_len,
+			.nr_cus_created = 0,
 		};
 		res = dwarf_cus__process_cus(&dcus);
 	}
diff --git a/dwarves.h b/dwarves.h
index 0a4d5a2..b28a66e 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -290,6 +290,7 @@  struct cu {
 	struct ptr_table functions_table;
 	struct ptr_table tags_table;
 	struct rb_root	 functions;
+	uint32_t	 id;
 	const char	 *name;
 	char		 *filename;
 	void 		 *priv;