Skip to content

Commit 99611bc

Browse files
committed
llext_manager: [TMP] add debugging code
Add debugging code for comparing memory copy operations between previous and current situations. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent ce254e3 commit 99611bc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/library_manager/llext_manager.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,31 @@ static int llext_manager_load_data_from_storage(const struct llext_loader *ldr,
8686
return ret;
8787
}
8888

89+
/* DEBUG */
90+
size_t init_offset = 0;
91+
const elf_shdr_t *shdr;
92+
93+
/* Need to copy sections within regions individually, offsets may differ */
94+
for (i = 0, shdr = llext_section_headers(ext); i < llext_section_count(ext); i++, shdr++) {
95+
if ((uintptr_t)shdr->sh_addr < (uintptr_t)vma ||
96+
(uintptr_t)shdr->sh_addr >= (uintptr_t)vma + size)
97+
continue;
98+
99+
if (!init_offset)
100+
init_offset = shdr->sh_offset;
101+
102+
/* found a section within the region */
103+
size_t offset = shdr->sh_offset - init_offset;
104+
105+
tr_info(&lib_manager_tr, "old %u: %p -> %p, %u", i,
106+
(void *)shdr->sh_addr,
107+
(const uint8_t *)ext->mem[region] + offset, shdr->sh_size);
108+
}
109+
89110
llext_get_region_info(ldr, ext, region, NULL, &region_addr, NULL);
90111

91112
/* Need to copy sections within regions individually, offsets may differ */
92113
for (i = 0; i < llext_section_count(ext); i++) {
93-
const elf_shdr_t *shdr;
94114
enum llext_mem s_region = LLEXT_MEM_COUNT;
95115
size_t s_offset = 0;
96116

@@ -99,6 +119,10 @@ static int llext_manager_load_data_from_storage(const struct llext_loader *ldr,
99119
if (s_region != region)
100120
continue;
101121

122+
tr_info(&lib_manager_tr, "%u: %p -> %p, %u", i,
123+
(void *)shdr->sh_addr,
124+
(const uint8_t *)region_addr + s_offset, shdr->sh_size);
125+
102126
ret = memcpy_s((__sparse_force void *)shdr->sh_addr, size - s_offset,
103127
(const uint8_t *)region_addr + s_offset, shdr->sh_size);
104128
if (ret < 0)

0 commit comments

Comments
 (0)