Skip to content

Instantly share code, notes, and snippets.

View jimblandy's full-sized avatar

Jim Blandy jimblandy

View GitHub Profile
#!/usr/bin/env bash
# Like find, but automatically ignore Mercurial metadata and build trees
# Skip initial path arguments, so we can insert our magic at the start
# of the options.
paths=()
while case "${1--}" in (-* | !) false;; (*) true;; esac do
paths=("${paths[@]}" "$1")
shift
done
@jimblandy
jimblandy / aab.cpp.transcript
Created October 8, 2012 21:11
works for me!
play$ cat aab.cpp
void AAA();
void AAA(int);
void AAA2();
bool f(int *p, AAB obj);
play$ clang++ aab.cpp
aab.cpp:4:16: error: unknown type name 'AAB'
bool f(int *p, AAB obj);
^
1 error generated.
@jimblandy
jimblandy / bump.c
Created November 1, 2012 18:58
Microbenchmark for bump allocators with guard pages or limit pointer checks
#define _GNU_SOURCE // for gregset_t indices
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <setjmp.h>
@jimblandy
jimblandy / transport-comment.patch
Created November 13, 2012 19:47
DebuggerTransport comment patch
# HG changeset patch
# Parent ac0d8052d26c75b44c5a25ea227c08d0446dc2a2
diff --git a/toolkit/devtools/debugger/dbg-transport.js b/toolkit/devtools/debugger/dbg-transport.js
--- a/toolkit/devtools/debugger/dbg-transport.js
+++ b/toolkit/devtools/debugger/dbg-transport.js
@@ -14,7 +14,7 @@ Cu.import("resource://gre/modules/NetUti
*
* @param aInput nsIInputStream
* The input stream.
@jimblandy
jimblandy / gist:4543764
Last active December 11, 2015 04:18
Operation callback testing API
triggerOperationCallback([delay])
Trigger an operation callback.
If 'delay' is given, it must be a positive integer; wait that many operation
callback opportunities to trigger the callback. (Note that delay counts only
work when we are running a body function from 'withOperationCallback'.)
withOperationCallback(body, [callback])
Call the function 'body', establishing the function 'callback' as the
operation callback while 'body' runs. Once 'body' completes, restore the
@jimblandy
jimblandy / gist:4567915
Last active December 11, 2015 07:39
Patch to SpiderMonkey GDB support: define AggregateMap utility class.
# HG changeset patch
# Parent 07b885dd9d132c648f49eac357faa3e90e8741a8
diff --git a/js/src/gdb/mozilla/prettyprinters.py b/js/src/gdb/mozilla/prettyprinters.py
--- a/js/src/gdb/mozilla/prettyprinters.py
+++ b/js/src/gdb/mozilla/prettyprinters.py
@@ -312,6 +312,211 @@ class Pointer(object):
def summary(self):
raise NotImplementedError
import gdb
import mozilla.prettyprinters as prettyprinters
from mozilla.prettyprinters import ptr_pretty_printer, pretty_printer
prettyprinters.clear_module_printers(__name__)
@pretty_printer('js::analyze::SSAValue')
class SSAValuePrinter(object):
def __init__(self, value, cache):
self.value = value
js> var parentMM = Components.classes['@mozilla.org/parentprocessmessagemanager;1'].getService(Components.interfaces.nsIMessageBroadcaster)
js> parentMM.loadFrameScript
function loadFrameScript() {
[native code]
}
js> parentMM.loadFrameScript('file:///home/jimb/moz/printfoo.js')
[Parent 31198] ###!!! ASSERTION: hmm? CanCallNow failed in XPCWrappedNative::CallMethod. We are finding out about this late!: 'rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO', file /home/jimb/moz/dbg/js/xpconnect/src/XPCWrappedNative.cpp, line 2344
typein:18: NS_NOINTERFACE: Component does not have requested interface [nsIFrameScriptLoader.loadFrameScript]
js>

So you want to write an actor

Starting out with primitive types

So you have an idea for a Firefox developer tool. You (obviously) want it to work on Fennec and Firefox OS, so it needs to use the remote debugging protocol. You have a backend:

function SimpleBackend(target) { this.target() }

SimpleBackend.prototype = {

Add support for Unix-domain sockets to nsIServerSocket.idl and @mozilla.org/network/server-socket;1.
diff --git a/netwerk/base/public/nsIServerSocket.idl b/netwerk/base/public/nsIServerSocket.idl
--- a/netwerk/base/public/nsIServerSocket.idl
+++ b/netwerk/base/public/nsIServerSocket.idl
@@ -95,6 +95,54 @@ interface nsIServerSocket : nsISupports
[noscript] void initWithAddress([const] in PRNetAddrPtr aAddr, in long aBackLog);
/**
+ * initWithFilename