[Lldb-commits] [PATCH] D91963: [lldb] [test/Register] Initial tests for regsets in core dumps [WIP]

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 24 06:32:05 PST 2020

labath added a comment.

I can't tell the core sizes from the diff, but my recollection is that even non-freebsd core files are larger than one would like. Even with linux, ones has to go to great lengths to get it to create a small one.

I'd recommend manually splicing the core to only include the data relevant for the tests. I just tried the process on a random core file and it was pretty straight-forward. What I did was:

- change the `e_phnum` to one (the NOTE segment was the first segment in the headers)
- delete everything after the end of the NOTE segment (the NOTE segment data was the first)

Lldb was perfectly happy to open the resulting core file, but I've reduced its size by more than 99%. The file still contains remnants of the discarded program headers, but they are harmless.

It looks like a similar approach could be applied to NetBSD core files. It seems NetBSD places the NOTE segment last in the program headers (not in the file), so one would also need to adjust e_phoff to point to it. If FreeBSD puts the NOTE segment last in the file, then one would also need to adjust `p_offset` in the program header, and splice data out of the middle of the file, which is slightly trickier, but not impossible. (I've also successfully spliced a single note (NT_FILE) out of the note segment, and it was relatively straight-forward, but probably unnecessary).



More information about the lldb-commits mailing list