Skip to content

Instantly share code, notes, and snippets.

@primiano
primiano / tracing_macros_constexpr.cc
Created April 6, 2017 11:51
tracing_macros_constexpr.cc
#include <stdint.h>
#include <stdio.h>
#include <string.h>
struct Category {
const char *name;
uint8_t is_enabled;
};
constexpr uint32_t N = 100;
#!/bin/bash
PKG="com.chrome.canary"
function write_proc_line {
LINE="$1"
TYPE=$(echo $LINE | cut -d, -f2)
PROC=$(echo $LINE | cut -d, -f3)
PID=$(echo $LINE | cut -d, -f4)
OOM_SCORE=$(adb shell cat /proc/$PID/oom_score)
OOM_ADJ=$(adb shell cat /proc/$PID/oom_adj)
$ g++ -o test test.cc --std=c++11 && ./test
<blink_gc>
<allocated_objects>
<net>
<url_request_context>
<app_request, extensions, isolated_media>
<0x?>
<http_cache>
<http_network_session>
<sdch_manager>
@primiano
primiano / test.c
Created March 15, 2017 11:04
proof that mlock doesn't prevent dirty writeback
$cat test.cc
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct Foo {
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
};
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct MallocFunctions {
void* malloc_fn;
void* zone;
};
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <signal.h>
typedef void(*Callback)(uintptr_t /*start*/, unsigned long/*size*/, const char* /*prot flags*/, const char* /*fname*/, unsigned long /*pss*/);
void ForEachMapEntry(Callback callback) {
@primiano
primiano / memory-infra-dump-devtools.py
Last active March 10, 2025 04:56
Creates a memory-infra dump using the Chrome Remote Debugging protocol
#!/usr/bin/env python
import argparse
import json
import os
import sys
import tempfile
import time
try:
import websocket
Ubuntu 14.04 on X86_64:
-----------------------
PID 34611 about to die jump 0x0
PID 34611 died with sig 11 Segmentation fault
PID 34612 about to die jump 0x12341230
PID 34612 died with sig 11 Segmentation fault
PID 34613 about to die with __builtin_trap
PID 34613 died with sig 4 Illegal instruction
Android 32 bit binary on armv7:
#!/usr/bin/env python
import json
import gzip
import collections
import os
import re
import sys
def sizeof_fmt(num):