aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2024-03-26 15:20:40 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2024-04-15 14:50:14 -0300
commit7a2509e7ea639014d653fcbd1c32bcf7b71306f2 (patch)
tree776aedc551c51ea48c4f7cf4de9c41b7465419e4
parent2d633d93cd4faf19b49c60696f0faaa414b73abd (diff)
downloadpahole-7a2509e7ea639014d653fcbd1c32bcf7b71306f2.tar.gz
dwarf_loader: Separate creating the cu/dcu pair from processing it
We will need it so that we add the dcu to a list in the same order as the CUs are in the DWARF file (vmlinux mostly). Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Tested-by: Alan Maguire <alan.maguire@oracle.com> Cc: Kui-Feng Lee <kuifeng@fb.com> Cc: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/lkml/20240412211604.789632-4-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarf_loader.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/dwarf_loader.c b/dwarf_loader.c
index 1dffb3f4..125e361e 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -3207,8 +3207,7 @@ struct dwarf_thread {
void *data;
};
-static int dwarf_cus__create_and_process_cu(struct dwarf_cus *dcus, Dwarf_Die *cu_die,
- uint8_t pointer_size, void *thr_data)
+static struct dwarf_cu *dwarf_cus__create_cu(struct dwarf_cus *dcus, Dwarf_Die *cu_die, uint8_t pointer_size)
{
/*
* DW_AT_name in DW_TAG_compile_unit can be NULL, first seen in:
@@ -3218,17 +3217,32 @@ static int dwarf_cus__create_and_process_cu(struct dwarf_cus *dcus, Dwarf_Die *c
const char *name = attr_string(cu_die, DW_AT_name, dcus->conf);
struct cu *cu = cu__new(name ?: "", pointer_size, dcus->build_id, dcus->build_id_len, dcus->filename, dcus->conf->use_obstack);
if (cu == NULL || cu__set_common(cu, dcus->conf, dcus->mod, dcus->elf) != 0)
- return DWARF_CB_ABORT;
+ return NULL;
struct dwarf_cu *dcu = dwarf_cu__new(cu);
- if (dcu == NULL)
- return DWARF_CB_ABORT;
+ if (dcu == NULL) {
+ cu__delete(cu);
+ return NULL;
+ }
dcu->type_unit = dcus->type_dcu;
cu->priv = dcu;
cu->dfops = &dwarf__ops;
+ return dcu;
+}
+
+static int dwarf_cus__create_and_process_cu(struct dwarf_cus *dcus, Dwarf_Die *cu_die,
+ uint8_t pointer_size, void *thr_data)
+{
+ struct dwarf_cu *dcu = dwarf_cus__create_cu(dcus, cu_die, pointer_size);
+
+ if (dcu == NULL)
+ return DWARF_CB_ABORT;
+
+ struct cu *cu = dcu->cu;
+
if (die__process_and_recode(cu_die, cu, dcus->conf) != 0 ||
cus__finalize(dcus->cus, cu, dcus->conf, thr_data) == LSK__STOP_LOADING)
return DWARF_CB_ABORT;