forked from Minki/linux
81f77fd0de
test_stacktrace_build_id() is added. It accesses tracepoint urandom_read with "dd" and "urandom_read" and gathers stack traces. Then it reads the stack traces from the stackmap. urandom_read is a statically link binary that reads from /dev/urandom. test_stacktrace_build_id() calls readelf to read build ID of urandom_read and compares it with build ID from the stackmap. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
23 lines
337 B
C
23 lines
337 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
|
|
#define BUF_SIZE 256
|
|
int main(void)
|
|
{
|
|
int fd = open("/dev/urandom", O_RDONLY);
|
|
int i;
|
|
char buf[BUF_SIZE];
|
|
|
|
if (fd < 0)
|
|
return 1;
|
|
for (i = 0; i < 4; ++i)
|
|
read(fd, buf, BUF_SIZE);
|
|
|
|
close(fd);
|
|
return 0;
|
|
}
|