Skip to content

Instantly share code, notes, and snippets.

View mmarchini's full-sized avatar
🛑
taking a break

mary marchini mmarchini

🛑
taking a break
View GitHub Profile
@mmarchini
mmarchini / v8-heap-snapshot-schema.md
Last active March 10, 2020 14:12
V8 Heap Snapshot Schema

V8 Heap Snapshot Schema

Key Description
snapshot Metadata from the snapshot. See snapshot
nodes List of heap nodes. See nodes
edges List of heap edges between nodes. See edges
trace_function_infos ???
trace_tree ???
@mmarchini
mmarchini / build.sh
Created November 27, 2019 18:33
Building libc6 with frame pointers
# Uncomment deb-src lines on /etc/apt/sources.list
sudo apt-get update
# Or replace ~/glibc with preferred path to store libc source
mkdir -p ~/glibc
cd ~/glibc
sudo apt-get install -y dpkg-dev
sudo apt-get build-deps libc6
apt-get source libc6
@mmarchini
mmarchini / v10-json-parse-size-load-constants.bt
Last active November 3, 2019 05:32
Node.js v10 -> v12 bpftrace programs
// Node v10.15.3
uprobe:/home/mmarchini/.nvm/versions/node/v10.15.3/bin/node:_ZN2v88internal17Builtin_JsonParseEiPPNS0_6ObjectEPNS0_7IsolateE
{
// Load constants
$kPointerSize = (uint32)(1 << (*uaddr("v8dbg_PointerSizeLog2")));
$stringLengthOffset = (uint32)*uaddr("v8dbg_class_String__length__SMI");
$kTag = (uint32)*uaddr("v8dbg_HeapObjectTag");
$kTagMask = (uint32)*uaddr("v8dbg_SmiTagMask");
$kShiftSize = (uint32)*uaddr("v8dbg_SmiShiftSize");
$ make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
BUILD: Doing 'make -j8' parallel build
HOSTCC fixdep.o
HOSTLD fixdep-in.o
LINK fixdep
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
@mmarchini
mmarchini / lldb-diagnose-undiwnd-output
Last active October 3, 2019 05:24
llnode weird <adaptor> stack behavior on Node.js v12
(lldb) target create "/home/mmarchini/.nvm/versions/node/v12.3.0/bin/node" --core "core.frame-scenario.1"
Core file '/home/mmarchini/workspace/nodejs/llnode/core.frame-scenario.1' (x86_64) was loaded.
(lldb) plugin load '/home/mmarchini/workspace/nodejs/llnode/llnode.so'
(lldb) settings set prompt '(llnode) '
(llnode) command script import diagnose_unwind
bind: Invalid command `enable-meta-key'.
The "diagnose-unwind" command has been installed, type "help diagnose-unwind" for detailed help.
(llnode) diagnose-unwind
LLDB version lldb version 6.0.1
Unwind diagnostics for thread 1
@mmarchini
mmarchini / docker-env
Created June 5, 2017 15:49
Docker Env converter from Windows to WSL
#!/usr/bin/env python3
from subprocess import run, PIPE
completed_process = run(["docker-machine.exe", "env", "--shell", "bash"], stdout=PIPE)
docker_env = completed_process.stdout.decode("ascii")
for line in docker_env.split("\n"):
if "DOCKER_CERT_PATH" in line:
@mmarchini
mmarchini / README.md
Last active October 17, 2018 17:41
State of Postmortem with Promises in Node.js

Goals

When a promise is rejected with no catch handler attached, it should:

  • Aborting with error code for unhandled rejection to generate core-dump
  • Get stack trace from the point where the error was thrown
  • Inspecting arguments, closures and variables

Current State

@mmarchini
mmarchini / debugger.cc
Last active September 3, 2018 14:49
V8 Postmortem API Usage Example
#include <v8.h>
#include <v8-postmortem.h>
#include <napi.h>
#include <lldb/API/SBDebugger.h>
#include <lldb/API/SBTarget.h>
#include <lldb/API/SBProcess.h>
#include <iostream>
using lldb::addr_t;
@mmarchini
mmarchini / index.js
Created June 15, 2018 23:29
Taming the Dragon example
'use strict';
const http = require('http');
const port = 3000;
class Visit {
constructor(visit_id, headers) {
this.visit_id = visit_id;
this.headers = headers;
}
@mmarchini
mmarchini / my.zsh-theme
Created March 27, 2018 18:30
My ZSH theme, inspired on lambda-gister and lambda-mod
#!/usr/bin/env zsh
local LAMBDA="%(?,%{$fg_bold[green]%}λ,%{$fg_bold[red]%}λ)"
function get_pwd(){
git_root=$PWD
while [[ $git_root != / && ! -e $git_root/.git ]]; do
git_root=$git_root:h
done
if [[ $git_root = / ]]; then