aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2024-03-26 16:35:46 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2024-04-15 14:50:18 -0300
commit620d419a430f8fd87f981e60215498a91411662b (patch)
treeb984e33f06faf758064d9a096b01298c1c1d2141
parent941cd9a15d09dd3c15f6f47c7b02cc2740e8b014 (diff)
downloadpahole-620d419a430f8fd87f981e60215498a91411662b.tar.gz
dwarf_loader: Create the cu/dcu pair in dwarf_cus__nextcu()
dwarf_cus__nextcu() is only used in parallel DWARF loading, and we want to make sure that we preserve the order of the CUs in the DWARF file being loaded, so move creating the cu/dcu to under that lock. 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-6-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarf_loader.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/dwarf_loader.c b/dwarf_loader.c
index 50905093..a7a8b2be 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -3254,7 +3254,9 @@ static int dwarf_cus__create_and_process_cu(struct dwarf_cus *dcus, Dwarf_Die *c
return dwarf_cus__process_cu(dcus, cu_die, dcu->cu, thr_data);
}
-static int dwarf_cus__nextcu(struct dwarf_cus *dcus, Dwarf_Die *die_mem, Dwarf_Die **cu_die, uint8_t *pointer_size, uint8_t *offset_size)
+static int dwarf_cus__nextcu(struct dwarf_cus *dcus, struct dwarf_cu **dcu,
+ Dwarf_Die *die_mem, Dwarf_Die **cu_die,
+ uint8_t *pointer_size, uint8_t *offset_size)
{
Dwarf_Off noff;
size_t cuhl;
@@ -3274,6 +3276,15 @@ static int dwarf_cus__nextcu(struct dwarf_cus *dcus, Dwarf_Die *die_mem, Dwarf_D
dcus->off = noff;
}
+ if (ret == 0 && *cu_die != NULL) {
+ *dcu = dwarf_cus__create_cu(dcus, *cu_die, *pointer_size);
+ if (*dcu == NULL) {
+ dcus->error = ENOMEM;
+ ret = -1;
+ goto out_unlock;
+ }
+ }
+
out_unlock:
cus__unlock(dcus->cus);
@@ -3286,13 +3297,13 @@ static void *dwarf_cus__process_cu_thread(void *arg)
struct dwarf_cus *dcus = dthr->dcus;
uint8_t pointer_size, offset_size;
Dwarf_Die die_mem, *cu_die;
+ struct dwarf_cu *dcu;
- while (dwarf_cus__nextcu(dcus, &die_mem, &cu_die, &pointer_size, &offset_size) == 0) {
+ while (dwarf_cus__nextcu(dcus, &dcu, &die_mem, &cu_die, &pointer_size, &offset_size) == 0) {
if (cu_die == NULL)
break;
- if (dwarf_cus__create_and_process_cu(dcus, cu_die,
- pointer_size, dthr->data) == DWARF_CB_ABORT)
+ if (dwarf_cus__process_cu(dcus, cu_die, dcu->cu, dthr->data) == DWARF_CB_ABORT)
goto out_abort;
}