Skip to content

Instantly share code, notes, and snippets.

View dalehamel's full-sized avatar

Dale Hamel dalehamel

View GitHub Profile
@dalehamel
dalehamel / dmi.rb
Last active February 5, 2020 07:15
Ruby dmidecode
require 'json'
def standardize_key(k)
k.downcase.gsub(/\s+/,'_')
end
def read_dmi
data=`dmidecode`
dict={}
@dalehamel
dalehamel / android-bionic-poll-t.patch
Last active January 9, 2020 03:56
BCC patches to build embedded for android
--- 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 January 9, 2020 02:45
Patches to build libelf with clang toolchain
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 January 8, 2020 16:22
Argp android build diff
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 November 27, 2019 20:24
mctop bcc/bpftrace implementations
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 && \
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
BEGIN
{
printf("%-20s %10s %10s %10s\n", "MEMCACHED KEY", "CALLS", "OBJSIZE", "REQ/s");
@start = nsecs;
}
// NOTE - this presently omits incr, decr, and delete because they have a
// different signature
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.0.0 Kernel Configuration
#
#
# Compiler: gcc (Gentoo 8.2.0-r6 p1.7) 8.2.0
#
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=80200
# First install https://github.com/postmodern/ruby-install
# Patches are below just download them
# After you have installed with ruby-install, you can chruby to use it
ruby-install ruby 2.6.3 -p 0001-RubyVM-InstructionSequence-eval_with.patch -p 0002-Update-iseq.eval-to-accept-optional-binding-Feature-.patch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_libbcc is a Catch v1.4.0 host application.
Run with -? for options
-------------------------------------------------------------------------------
test bpf stack_id table
-------------------------------------------------------------------------------
/home/dale.hamel/workspace/bcc/tests/cc/test_bpf_table.cc:226
...............................................................................