The kprobe package allows construction of dynamic struct based on kprobe event format descriptions.

kprobe

The kprobe package allows construction of dynamic struct based on kprobe event format descriptions.

__probe_ip, REC->arg1, REC->arg2[0], REC->arg2[1], REC->arg2[2], REC->arg2[3], REC->arg2[4], REC->arg2[5], REC->arg2[6], REC->arg2[7] ">
name: p_vfs_read_0
ID: 3842
format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:unsigned long __probe_ip;	offset:8;	size:8;	signed:0;
	field:u64 arg1;	offset:16;	size:8;	signed:0;
	field:u8 arg2[8];	offset:24;	size:8;	signed:0;

print fmt: "(%lx) arg1=0x%Lx arg2={0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x}", REC->__probe_ip, REC->arg1, REC->arg2[0], REC->arg2[1], REC->arg2[2], REC->arg2[3], REC->arg2[4], REC->arg2[5], REC->arg2[6], REC->arg2[7]

gives

struct {
	Common_type          uint16   `ctyp:"unsigned short" name:"common_type"`
	Common_flags         uint8    `ctyp:"unsigned char" name:"common_flags"`
	Common_preempt_count uint8    `ctyp:"unsigned char" name:"common_preempt_count"`
	Common_pid           int32    `ctyp:"int" name:"common_pid"`
	Probe_ip             uint64   `ctyp:"unsigned long" name:"__probe_ip"`
	Arg1                 uint64   `ctyp:"u64" name:"arg1"`
	Arg2                 [8]uint8 `ctyp:"u8[8]" name:"arg2"`
}

kprobe will ensure that fields are correctly padded so that the offsets in the format are reflected in the constructed struct.

__probe_ip, REC->dfd, REC->filename, REC->flags, REC->mode ">
name: myprobe
ID: 780
format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:unsigned long __probe_ip;	offset:12;	size:4;	signed:0;
	field:int __probe_nargs;	offset:16;	size:4;	signed:1;
	field:unsigned long dfd;	offset:20;	size:4;	signed:0;
	field:unsigned long filename;	offset:24;	size:4;	signed:0;
	field:unsigned long flags;	offset:28;	size:4;	signed:0;
	field:unsigned long mode;	offset:32;	size:4;	signed:0;


print fmt: "(%lx) dfd=%lx filename=%lx flags=%lx mode=%lx", REC->__probe_ip,
REC->dfd, REC->filename, REC->flags, REC->mode

gives

struct {
	Common_type          uint16 `ctyp:"unsigned short" name:"common_type"`
	Common_flags         uint8  `ctyp:"unsigned char" name:"common_flags"`
	Common_preempt_count uint8  `ctyp:"unsigned char" name:"common_preempt_count"`
	Common_pid           int32  `ctyp:"int" name:"common_pid"`
	_pad0                [4]uint8
	Probe_ip             uint32 `ctyp:"unsigned long" name:"__probe_ip"`
	Probe_nargs          int32  `ctyp:"int" name:"__probe_nargs"`
	Dfd                  uint32 `ctyp:"unsigned long" name:"dfd"`
	Filename             uint32 `ctyp:"unsigned long" name:"filename"`
	Flags                uint32 `ctyp:"unsigned long" name:"flags"`
	Mode                 uint32 `ctyp:"unsigned long" name:"mode"`
}
Owner
Dan Kortschak
Actually Doing Science
Dan Kortschak
Similar Resources

Provide Go Statistics Handler, Struct, Measure Method

Go Statistics Handler About The gosh is an abbreviation for Go Statistics Handler. This Repository is provided following functions. Go runtime statist

Jan 8, 2023

Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.

gountries Inspired by the countries gem for ruby. Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO

Dec 22, 2022

RTS: request to struct. Generates Go structs from JSON server responses.

RTS: Request to Struct Generate Go structs definitions from JSON server responses. RTS defines type names using the specified lines in the route file

Dec 7, 2022

Align Golang struct tags

Formattag The tool is used to align golang struct's tags. eg.: Before // TestStruct this is a test struct type TestStruct struct { ID stri

Aug 1, 2022

An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported.

go-fsm An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported. usage import github.co

Dec 26, 2021

A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.

A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.

one-file-pdf - A minimalist PDF generator in 2K lines and 1 file The main idea behind this project was: "How small can I make a PDF generator for it

Dec 11, 2022

Go library for Common Lisp format style output

format This library has the goal to bring the Common Lisp format directive to Go. This is work-in-progress, see the summary implementation table below

Jul 7, 2020

Program to solve sudokus given in JSON Format, written in Go

Program to solve sudokus given in JSON Format, written in Go

May 2, 2022

Parse a shell script and output all export declarations in an easy to read format

Find Exports Parse a shell script and output all export declarations in an easy to read format. Usage Example $ findexports ~/.bashrc PATH=$PATH:/usr/

Jan 13, 2022
Related tags
The new home of the CUE language! Validate and define text-based and dynamic configuration

The CUE Data Constraint Language Configure, Unify, Execute CUE is an open source data constraint language which aims to simplify tasks involving defin

Dec 31, 2022
Package fsm allows you to add finite-state machines to your Go code.

fsm Package fsm allows you to add finite-state machines to your Go code. States and Events are defined as int consts: const ( StateFoo fsm.State =

Dec 9, 2022
Lithia is an experimental functional programming language with an implicit but strong and dynamic type system.

Lithia is an experimental functional programming language with an implicit but strong and dynamic type system. Lithia is designed around a few core concepts in mind all language features contribute to.

Dec 24, 2022
Repo Tugas Problem Solving Paradigm (Greedy, D&C, Dynamic Programming) ALTA Immersive BE5
Repo Tugas Problem Solving Paradigm (Greedy, D&C, Dynamic Programming) ALTA Immersive BE5

Cara mengerjakan tugas clone project ini, melalui git clone https://github.com/ALTA-Immersive-BE5/Problem-Solving-Paradigm.git setelah clone selesai,

Dec 23, 2021
FreeSWITCH Event Socket library for the Go programming language.

eventsocket FreeSWITCH Event Socket library for the Go programming language. It supports both inbound and outbound event socket connections, acting ei

Dec 11, 2022
File system event notification library on steroids.

notify Filesystem event notification library on steroids. (under active development) Documentation godoc.org/github.com/rjeczalik/notify Installation

Jan 7, 2023
Idiomatic Event Sourcing in Go
Idiomatic Event Sourcing in Go

Event Sourcing for Go Idiomatic library to help you build Event Sourced application in Go. Please note The library is currently under development and

Oct 27, 2022
An example event-driven application using Atmo and NATS

Atmo + NATS Example Project This repo is an example of using Atmo with NATS as a streaming messaging layer. In this example, Atmo connects to NATS and

Oct 27, 2021
Eye - An easy-use lib for event-driven pattern

?? Eye Eye 是一个简单易用的事件驱动模式库。 Read me in English ?? 功能特性 敬请期待。。。 历史版本的特性请查看 HISTOR

Jan 17, 2022
Random fake data and struct generator for Go.

Faker Random fake data and struct generator for Go. More than 100 generator functions Struct generator Unique data generator Builtin types support Eas

Oct 3, 2022