Skip to content

Instantly share code, notes, and snippets.

Avatar

Dale Hamel dalehamel

View GitHub Profile
View 0001-Pull-patch-onto-1.17.8-drop-systemtap-specifics.patch
From d75537062f1f72b8dc6115f1960d6f56a47c3793 Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@shopify.com>
Date: Tue, 10 Mar 2020 18:46:03 -0400
Subject: [PATCH] Pull patch onto 1.17.8, drop systemtap specifics
---
README | 17 +++++++-
auto/make | 43 ++++++++++++++++++
auto/modules | 3 +-
auto/options | 11 ++++-
@dalehamel
dalehamel / mcsnopp.bt
Created Mar 10, 2020
bpftrace script to attach to memcached and probe connections and commands
View mcsnopp.bt
usdt::memcached:command__get,
usdt::memcached:command__set,
usdt::memcached:command__add,
usdt::memcached:command__replace,
usdt::memcached:command__prepend,
usdt::memcached:command__append,
usdt::memcached:command__cas
{
@calls[str(arg1, arg2)]++;
@bytes[str(arg1, arg2)]+= arg3;
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created Feb 7, 2020
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created Feb 7, 2020
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / docker-desktop-headers.sh
Last active Feb 6, 2020
install kernel headers for docker desktop, for BCC
View docker-desktop-headers.sh
#!/bin/bash
set -x
set -e
KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS=- '{ print $1 }')"
major_version="$(echo "${KERNEL_VERSION}" | awk -vFS=. '{ print $1 }')"
apt-get install -y build-essential bc curl flex bison libelf-dev
@dalehamel
dalehamel / android-bionic-poll-t.patch
Last active Jan 9, 2020
BCC patches to build embedded for android
View android-bionic-poll-t.patch
--- embedded_bcc.orig/src/cc/libbpf/include/linux/types.h 2020-01-08 16:33:31.384052137 +0000
+++ embedded_bcc/src/cc/libbpf/include/linux/types.h 2020-01-08 02:22:36.269082225 +0000
@@ -23,7 +23,7 @@
#ifndef __aligned_u64
# define __aligned_u64 __u64 __attribute__((aligned(8)))
#endif
-
+typedef unsigned __bitwise __poll_t;
struct list_head {
struct list_head *next, *prev;
@dalehamel
dalehamel / lib-makefile-warning-clang.patch
Last active Jan 9, 2020
Patches to build libelf with clang toolchain
View lib-makefile-warning-clang.patch
Index: src/embedded_libelf/lib/Makefile.in
===================================================================
--- src.orig/embedded_libelf/lib/Makefile.in
+++ src/embedded_libelf/lib/Makefile.in
@@ -330,9 +330,9 @@ ARFLAGS = cr
# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
# warning
-@HAVE_IMPLICIT_FALLTHROUGH_WARNING_TRUE@IMPLICIT_FALLTHROUGH_WARNING = -Wimplicit-fallthrough=5
+@HAVE_IMPLICIT_FALLTHROUGH_WARNING_TRUE@IMPLICIT_FALLTHROUGH_WARNING = -Wimplicit-fallthrough
@dalehamel
dalehamel / argp-header.patch
Created Jan 8, 2020
Argp android build diff
View argp-header.patch
diff -Naur argp_sources/gllib/argp.h argp_sources/gllib/argp.h.new
--- argp_sources/gllib/argp.h 2019-02-19 20:38:53.000000000 +0000
+++ argp_sources/gllib/argp.h.new 2020-01-08 16:21:42.843277973 +0000
@@ -19,6 +19,17 @@
#ifndef _ARGP_H
#define _ARGP_H
+#ifndef ARGP_EI
+# define ARGP_EI inline
+#endif
@dalehamel
dalehamel / Dockerfile
Last active Nov 27, 2019
mctop bcc/bpftrace implementations
View Dockerfile
FROM alpine:3.10 as builder
# ensure SASL's "libplain.so" is installed as per https://github.com/memcached/memcached/wiki/SASLHowto
RUN apk add --no-cache cyrus-sasl-plain wget binutils
ENV MEMCACHED_VERSION 1.5.19
ENV MEMCACHED_SHA1 14e6a02e743838696fcb620edf6a2fd7e60cabec
# Get dtrace dependencies for alpine in a kinda hacky way
RUN mkdir /build && cd /build && wget http://launchpadlibrarian.net/251391227/systemtap-sdt-dev_2.9-2ubuntu2_amd64.deb && \
View ebpf error
bpf: Failed to load program: Permission denied
0: (b7) r3 = 0
1: (7b) *(u64 *)(r10 -8) = r3
last_idx 1 first_idx 0
regs=8 stack=0 before 0: (b7) r3 = 0
2: (7b) *(u64 *)(r10 -16) = r3
3: (7b) *(u64 *)(r10 -24) = r3
4: (7b) *(u64 *)(r10 -32) = r3
5: (7b) *(u64 *)(r10 -40) = r3
6: (7b) *(u64 *)(r10 -48) = r3
You can’t perform that action at this time.