Skip to content

Instantly share code, notes, and snippets.

View adrianherrera's full-sized avatar

Adrian Herrera adrianherrera

View GitHub Profile
@adrianherrera
adrianherrera / gdb_stack_trace.py
Created March 9, 2019 06:50
GDB script to serialize a stack trace from a crashed program to JSON
#!/usr/bin/env python
#
# Serializes a stack trace from a crashed program into JSON.
#
# To run:
# BACKTRACE_OUT=out.json gdb --command gdb_stack_trace.py PROG [GDB_ARGS]...
#
import json
import os
@adrianherrera
adrianherrera / producer_consumer.c
Created October 30, 2019 04:01
Simple producer/consumer in C
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#if !defined(BUFFER_SIZE)
#define BUFFER_SIZE 10
#endif
@adrianherrera
adrianherrera / afl_2_libfuzzer_merge.py
Last active July 5, 2020 11:50
Create a libFuzzer-style merge file from afl-showmap
#!/usr/bin/env python3
"""
Create a libFuzzer-style merge from afl-showmap.
Author: Adrian Herrera
"""
from argparse import ArgumentParser
@adrianherrera
adrianherrera / cyclomatic_complexity.py
Last active September 13, 2020 00:00
Calculate the cyclomatic complexity of a DOT file
#!/usr/bin/env python3
"""
Calculate the cyclomatic complexity of a graph in a DOT file.
Author: Adrian Herrera
"""
from argparse import ArgumentParser
@adrianherrera
adrianherrera / gen-clang-ast.py
Last active February 8, 2024 09:44
Generate a Clang AST in JSON format
#!/usr/bin/env python3
"""
Generate a Clang AST (in JSON format) from a compilation database. Adapted from
run-clang-format.py.
I use [bear](https://github.com/rizsotto/Bear) to generate the compilation
database.
Author: Adrian Herrera