[lldb-dev] NetBSD core(5) files for LLDB's test-suite

Kamil Rytarowski via lldb-dev lldb-dev at lists.llvm.org
Fri Apr 21 17:59:03 PDT 2017


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);
	_lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
	_lwp_create(&uc, 0, &lid);
	_lwp_wait(lid, NULL);	
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170422/6d40a853/attachment.sig>


More information about the lldb-dev mailing list