This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
Dev docs
Serge edited this page Jul 11, 2015
·
7 revisions
https://github.com/runtimejs/runtime-cli
npm install runtime-cli -g
Build OK: 4.8.0, 4.8.1, 4.8.3, 4.9.1, 5.1
Build FAIL: 4.9.0 (gcc bug when compiling libc++)
GDB install:
export PREFIX="$HOME/opt/cross"
export PATH="$PREFIX/bin:$PATH"
wget https://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz
tar -xf gdb-7.8.tar.gz
rm gdb-7.8.tar.gz
mkdir build-gdb
cd build-gdb
../gdb-7.8/configure --target=x86_64-pc-linux-gnu --prefix="$PREFIX"
make
make install
Connect to running QEMU:
x86_64-pc-linux-gnu-gdb
(gdb) target remote localhost:1234
(gdb) symbol-file runtimejs
var u8array = kernel.takeHeapSnapshot();
// returns array of snapshot Uint8Array chunks
Example to send snapshot over TCP for inspection:
console.log('taking snapshot...');
var bufs = kernel.takeHeapSnapshot();
console.log('connecting...');
var socket = new runtime.net.TCPSocket();
socket.onopen = function() {
console.log('pushing snapshot into socket...');
for (let buf of bufs) {
socket.send(buf);
}
socket.close();
console.log('done');
};
socket.open('192.168.1.2', 5555);
It might take a while for TCP to transmit full snapshot depending on heap size.
Snapshot receiver:
nc -l 5555 > 1.heapsnapshot
Snapshot could be loaded into Chrome's profiles tab for inspection.
kernel.memoryInfo();
Returns kernel memory usage.
heapUsed
- js heap used
heapTotal
- js heap size
pmUsed
- physical memory used
pmTotal
- physical memory total (available for allocation)
buffersCount
- number of allocated ArrayBuffers
buffersSize
- total size of ArrayBuffers