[lldb-dev] NetBSD core(5) files for LLDB's test-suite
Pavel Labath via lldb-dev
lldb-dev at lists.llvm.org
Tue May 2 07:50:58 PDT 2017
Sorry it took me so long. I think it's fine to check a couple of those
in. When zipped, they will still be orders of magnitude smaller then
the windows minidump exe we are carrying around.
For the long term though, I'd like to add the necessary support to
llvm's obj2yaml to be able to generate these. As far as I can tell, it
just needs program header support added. Then we will be able to
generate truly small unit tests (e.g. by removing all the memory
segments for tests that only need threads signal or registers and
such).
pl
On 22 April 2017 at 01:59, Kamil Rytarowski <n54 at gmx.com> wrote:
> Hello,
>
> I've prepared two sets of core(5) files with the following programs:
> - 1lwp_SIGSEGV (signal SIGSEGV emitted for thread)
> - 1lwp_busyloop (signal SIGABRT emitted for the whole process)
>
> My compiler is GCC 5.4.0 and host NetBSD/amd64 7.99.70.
>
> The first set is written with a custom startup assembly without usage of
> libc. I used -nostdlib option for the compiler. The second set is plain
> C implementation.
>
> The first set generates files of size 6752 bytes/core. After compressing
> with the default options of bzip2, the size is respectively 1035 and 990
> bytes.
>
> The second set in C with regular system libraries gives core(5) files of
> size 103488 and 103472 bytes. bzip2 with the default options reduces
> their size to 15212 and 15040 bytes.
>
>
> Writing bare code starting additional LWP in the first approach is more
> difficult, especially since it will need to be ported to more platforms.
> I decided to implement just the libc version and go for native lwp
> interfaces and without usage of libpthread.
>
> The size of core(5) files is as follows: 131800 and 131784 bytes.
> Compressed with the default options of bzip2: 16345 and 16243 bytes.
>
>
> I propose to go for regular libc code version and optionally compress
> the binary files. I request to include Makefile and source code of files
> to LLDB. I propose to ship 4 core files per supported target architecture.
>
>
> I put the source code and NetBSD/amd64 core(5) files ready to pick-up here:
> http://www.netbsd.org/~kamil/lldb/netbsd-core/
>
>
> For the reference, I include the used source code below:
>
> Source C code:
> $ cat 1lwp_SIGSEGV.c
> void main(void)
> {
> volatile int *a = 0;
> *a = 100;
> }
> $ cat 1lwp_busyloop.c
> int main(int argc, char **argv)
> {
> for(;;)
> continue;
> }
>
>
> Startup assembly (there is replaced @VERSION@ with __NetBSD_Version__
> from /usr/include/sys/param.h):
> .globl _start
>
> .section ".note.netbsd.ident", "a", @note
> .long 2f-1f
> .long 4f-3f
> .long 1
> 1: .asciz "NetBSD"
> 2: .p2align 2
> 3: .long @VERSION@
> 4: .p2align 2
>
> .section .text
> _start:
> andq $0xfffffffffffffff0, %rsp
> subq $0x8, %rsp
> call main
>
>
>
> Source code with two LWPs (without libpthread):
> #include <lwp.h>
> #include <stdlib.h>
> #include <stddef.h>
>
> static void
> lwp_main_func(void *arg)
> {
> #if 1
> volatile int *a = 0;
> *a = 100;
> #else
> for(;;)
> continue;
> #endif
> }
>
> int
> main(int argc, char **argv)
> {
> ucontext_t uc;
> lwpid_t lid;
> static const size_t ssize = 16*1024;
> void *stack;
>
> stack = malloc(ssize);
I wonder if this thing would be smaller if you put the stack in the
bss section (then you could avoid pulling malloc in, potentially).
> _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
> _lwp_create(&uc, 0, &lid);
> _lwp_wait(lid, NULL);
> }
>
More information about the lldb-dev
mailing list