Skip to content

Instantly share code, notes, and snippets.

View pgoodman's full-sized avatar
🦥

Peter Goodman pgoodman

🦥
View GitHub Profile
#define MAIN static simple_instr *print_dot(simple_instr *inlist, char *proc_name)
# include "dot.cc"
#undef MAIN
#include "include/optimizer.h"
#include "include/opt/cf.h"
#include "include/opt/cp.h"
#include "include/opt/dce.h"
#define MAIN static simple_instr *print_dot(simple_instr *inlist, char *proc_name)
# include "dot.cc"
#undef MAIN
#include "include/optimizer.h"
#include "include/opt/cf.h"
#include "include/opt/cp.h"
#include "include/opt/dce.h"
#define MAIN static simple_instr *print_dot(simple_instr *inlist, char *proc_name)
# include "dot.cc"
#undef MAIN
#include "include/optimizer.h"
#include "include/opt/cf.h"
#include "include/opt/cp.h"
#include "include/opt/dce.h"
@pgoodman
pgoodman / gist:4187056
Created December 2, 2012 05:15
Block execution until the callback to a function returns.
/// based off of: https://gist.github.com/1227319/957809d74d902a4d7fc44c44c946eeed38c1cd1b
/// Need to be running this code somewhere inside of a Fiber.
/// Block execution until a callback to some function is executed.
///
/// Args:
/// context: The object context of the function (which takes a
/// callback) that is being called.
@pgoodman
pgoodman / .gdbinit
Created July 30, 2014 13:21
Trace logger in Granary+
# Print $arg1 instructions starting at address $arg0.
define pi
set $__rip = $arg0
set $__ni = $arg1
python None ; \
rip = str(gdb.parse_and_eval("$__rip")).lower() ; \
ni = str(gdb.parse_and_eval("$__ni")).lower() ; \
gdb.execute( \
"x/%si %s\n" % (ni, rip), \
from_tty=True, to_string=False) ;
/* Copyright 2014 Peter Goodman, all rights reserved. */
#include <granary/granary.h>
using namespace granary;
// TODO(pag): Generic allocators (similar to with meta-data) but for allowing
// multiple tools to register descriptor info.
// TODO(pag): Eventually handle user space syscalls to avoid EFAULTs.
// TODO(pag): Eventually handle user space signals.
/* Copyright 2014 Peter Goodman, all rights reserved. */
#include <granary/granary.h>
using namespace granary;
// Simple tool decoding all blocks in a function.
class WholeFunctionDecoder : public InstrumentationTool {
public:
virtual ~WholeFunctionDecoder(void) = default;
@pgoodman
pgoodman / Use
Created August 14, 2014 18:02
GDB commands for printing Granary's internal `arch::Instruction` structures as x86-like instructions.
(gdb) print-arch-instr &($12->instruction)
MOV_MEMv_GPRv [SLOT:0], R15
(gdb)
// This source code comes from:
// http://stackoverflow.com/questions/8941711/is-is-possible-to-set-a-gdb-watchpoint-programatically
// with additional tricks from:
// https://code.google.com/p/google-breakpad/source/browse/trunk/src/client/linux/handler/exception_handler.cc?r=1361
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@pgoodman
pgoodman / arm64.md
Created December 4, 2017 18:03 — forked from george-hawkins/arm64.md
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key: