Last active
December 27, 2015 08:39
-
-
Save tjfontaine/7298214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var lstream = require('lstream'); | |
var ls = new lstream(); | |
process.stdin.pipe(ls); | |
var symbolTable = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')); | |
ls.on('line', function(line) { | |
var l = line.trim(); | |
if (l.match(/^0x[a-f0-9]{8}/) && symbolTable[l]) { | |
line = line.replace(/0x[a-f0-9]{8}/, symbolTable[l]); | |
} | |
console.log(line); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -s | |
pid$1::umem_alloc:entry | |
/arg0 > 2048 && arg0 <= 4096/ | |
{ | |
self->cache = arg0; | |
} | |
pid$1::umem_cache_alloc:entry | |
/self->cache/ | |
{ | |
printf("\n>>>>>>>>\n"); | |
jstack(200, 8000); | |
ustack(200); | |
printf("\n<<<<<<<<\n"); | |
self->cache = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var lstream = require('lstream'); | |
var ls = new lstream(); | |
process.stdin.pipe(ls); | |
var jstack = undefined; | |
var ustack = undefined; | |
var cur = undefined; | |
var symbolTable = {}; | |
ls.on('line', function(line) { | |
if (line.match(/>>>>>>>>/)) { | |
cur = jstack = []; | |
ustack = []; | |
} else if (line.match(/<<<<<<<</)) { | |
ustack.forEach(function(frame, index) { | |
frame = frame.trim(); | |
if (frame.match(/^0x[a-f0-9]{8}/)) { | |
var jframe = jstack[index].trim(); | |
if (!symbolTable[frame]) { | |
symbolTable[frame] = jframe; | |
} else { | |
assert.strictEqual(symbolTable[frame], jframe); | |
} | |
} | |
}); | |
jstack = undefined; | |
ustack = undefined; | |
} else if (jstack) { | |
if (!jstack || (jstack.length === 0 && !line.trim())) | |
return; | |
if (!line.trim()) { | |
cur = ustack; | |
} else { | |
cur.push(line); | |
} | |
} | |
}); | |
function printit() { | |
console.log(JSON.stringify(symbolTable, null, ' ')); | |
} | |
process.on('exit', printit); | |
process.on('SIGUSR2', printit); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment