Browse Source

mdb_v8: update for v0.12

Bugs fixed:

* v0.12 and later: in-object properties not printing correctly.
* 64-bit: not printing external strings correctly (offset was hardcoded
for 32-bit). This would happen with "::jsstack -vn0" because the
script "node.js" wasn't printed correctly, at least with 0.10 core
files.
* 64-bit: printing JS source (via "::jsstack -v") emits errors and shows
the wrong code.
* Several build warnings.
* Two-byte strings are unnecessarily truncated.
* Could print friendlier note when given obviously bogus function token
positions.

New features:

* ::jsstack prints much cleaner output by default.
* ::jsprint keys are now quoted.
* ::jsstack -v includes "this" value for each function on the stack.
* ::jsstack -v includes more details about each argument (constructor
names for each object).
* new commands: ::jsconstructor, ::jsfunctions, ::jssource, ::nodebuffer
and ::v8internal.
* ::findjsobjects and ::jsprint hidden flags for developers to measure
and improve test coverage.
* internal jsobj_properties() function is much better documented.

Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
v0.12.0-release
Dave Pacheco 10 years ago
committed by Julien Gilli
parent
commit
4312f8d760
  1. 1484
      deps/mdb_v8/mdb_v8.c
  2. 2
      deps/mdb_v8/mdb_v8.gyp
  3. 5
      deps/mdb_v8/v8dbg.h
  4. 6
      deps/v8/tools/gen-postmortem-metadata.py
  5. 210
      test/pummel/test-postmortem-details.js
  6. 8
      test/pummel/test-postmortem-findjsobjects.js
  7. 1
      test/pummel/test-postmortem-jsstack.js

1484
deps/mdb_v8/mdb_v8.c

File diff suppressed because it is too large

2
deps/mdb_v8/mdb_v8.gyp

@ -4,7 +4,7 @@
'target_name': 'mdb_v8', 'target_name': 'mdb_v8',
'product_prefix': '', 'product_prefix': '',
'type': 'loadable_module', 'type': 'loadable_module',
'cflags': [ '-fPIC' ], 'cflags': [ '-fPIC', '-Wno-missing-field-initializers', '-Wno-sign-compare' ],
'sources': [ 'sources': [
'mdb_v8.c', 'mdb_v8.c',
'mdb_v8_cfg.c', 'mdb_v8_cfg.c',

5
deps/mdb_v8/v8dbg.h

@ -48,6 +48,8 @@
* using the upper 31 bits. * using the upper 31 bits.
*/ */
#define V8_SMI_VALUE(smi) ((smi) >> (V8_SmiValueShift + V8_SmiShiftSize)) #define V8_SMI_VALUE(smi) ((smi) >> (V8_SmiValueShift + V8_SmiShiftSize))
#define V8_VALUE_SMI(value) \
((value) << (V8_SmiValueShift + V8_SmiShiftSize))
/* /*
* Determine the encoding and representation of a V8 string. * Determine the encoding and representation of a V8 string.
@ -77,4 +79,7 @@
#define V8_DESC_ISFIELD(x) \ #define V8_DESC_ISFIELD(x) \
((V8_SMI_VALUE(x) & V8_PROP_TYPE_MASK) == V8_PROP_TYPE_FIELD) ((V8_SMI_VALUE(x) & V8_PROP_TYPE_MASK) == V8_PROP_TYPE_FIELD)
#define V8_PROP_FIELDINDEX(value) \
((V8_SMI_VALUE(value) & V8_FIELDINDEX_MASK) >> V8_FIELDINDEX_SHIFT)
#endif /* _V8DBG_H */ #endif /* _V8DBG_H */

6
deps/v8/tools/gen-postmortem-metadata.py

@ -121,6 +121,10 @@ consts_misc = [
'value': 'Map::ElementsKindBits::kShift' }, 'value': 'Map::ElementsKindBits::kShift' },
{ 'name': 'bit_field3_dictionary_map_shift', { 'name': 'bit_field3_dictionary_map_shift',
'value': 'Map::DictionaryMap::kShift' }, 'value': 'Map::DictionaryMap::kShift' },
{ 'name': 'fieldindex_mask',
'value': 'PropertyDetails::FieldIndexField::kMask' },
{ 'name': 'fieldindex_shift',
'value': 'PropertyDetails::FieldIndexField::kShift' },
{ 'name': 'off_fp_context', { 'name': 'off_fp_context',
'value': 'StandardFrameConstants::kContextOffset' }, 'value': 'StandardFrameConstants::kContextOffset' },
@ -146,7 +150,7 @@ extras_accessors = [
'Map, instance_size, int, kInstanceSizeOffset', 'Map, instance_size, int, kInstanceSizeOffset',
'Map, bit_field, char, kBitFieldOffset', 'Map, bit_field, char, kBitFieldOffset',
'Map, bit_field2, char, kBitField2Offset', 'Map, bit_field2, char, kBitField2Offset',
'Map, bit_field3, SMI, kBitField3Offset', 'Map, bit_field3, int, kBitField3Offset',
'Map, prototype, Object, kPrototypeOffset', 'Map, prototype, Object, kPrototypeOffset',
'NameDictionaryShape, prefix_size, int, kPrefixSize', 'NameDictionaryShape, prefix_size, int, kPrefixSize',
'NameDictionaryShape, entry_size, int, kEntrySize', 'NameDictionaryShape, entry_size, int, kEntrySize',

210
test/pummel/test-postmortem-details.js

@ -0,0 +1,210 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var os = require('os');
var path = require('path');
var util = require('util');
if (os.type() != 'SunOS') {
console.error('Skipping because postmortem debugging not available.');
process.exit(0);
}
/*
* We're going to look specifically for this function and buffer in the core
* file.
*/
function myTestFunction()
{
[ 1 ].forEach(function myIterFunction(t) {});
return (new Buffer(bufstr));
}
var bufstr, mybuffer;
/*
* Run myTestFunction() three times to create multiple instances of
* myIterFunction.
*/
bufstr = 'Hello, test suite!';
mybuffer = myTestFunction(bufstr);
mybuffer = myTestFunction(bufstr);
mybuffer = myTestFunction(bufstr);
mybuffer.my_buffer = true;
/*
* Now we're going to fork ourselves to gcore
*/
var spawn = require('child_process').spawn;
var prefix = '/var/tmp/node';
var corefile = prefix + '.' + process.pid;
var tmpfile = '/var/tmp/node-postmortem-func' + '.' + process.pid;
var gcore = spawn('gcore', [ '-o', prefix, process.pid + '' ]);
var output = '';
var unlinkSync = require('fs').unlinkSync;
var args = [ corefile ];
var mybuffer;
if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '')
args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]);
gcore.stderr.on('data', function (data) {
console.log('gcore: ' + data);
});
gcore.on('exit', function (code) {
if (code != 0) {
console.error('gcore exited with code ' + code);
process.exit(code);
}
var mdb = spawn('mdb', args, { stdio: 'pipe' });
mdb.on('exit', function (code) {
unlinkSync(tmpfile);
var retained = '; core retained as ' + corefile;
if (code != 0) {
console.error('mdb exited with code ' + util.inspect(code) + retained);
process.exit(code);
}
var lines = output.split(/\n/);
var current = null, testname = null;
var whichtest = -1;
var i;
for (i = 0; i < lines.length; i++) {
if (lines[i].indexOf('test: ') === 0) {
if (current !== null) {
console.error('verifying ' + testname + ' using ' +
verifiers[whichtest].name);
verifiers[whichtest](current);
}
whichtest++;
current = [];
testname = lines[i];
continue;
}
if (current !== null)
current.push(lines[i]);
}
console.error('verifying ' + testname + ' using ' +
verifiers[whichtest].name);
verifiers[whichtest](current);
unlinkSync(corefile);
process.exit(0);
});
mdb.stdout.on('data', function (data) {
output += data;
});
mdb.stderr.on('data', function (data) {
console.log('mdb stderr: ' + data);
});
var verifiers = [];
var buffer;
verifiers.push(function verifyConstructor(testlines) {
assert.deepEqual(testlines, [ 'Buffer' ]);
});
verifiers.push(function verifyNodebuffer(testlines) {
assert.equal(testlines.length, 1);
assert.ok(/^[0-9a-fA-F]+$/.test(testlines[0]));
buffer = testlines[0];
});
verifiers.push(function verifyBufferContents(testlines) {
assert.equal(testlines.length, 1);
assert.equal(testlines[0], '0x' + buffer + ': Hello');
});
verifiers.push(function verifyV8internal(testlines) {
assert.deepEqual(testlines, [ buffer ]);
});
verifiers.push(function verifyJsfunctionN(testlines) {
assert.equal(testlines.length, 2);
var parts = testlines[1].trim().split(/\s+/);
assert.equal(parts[1], 1);
assert.equal(parts[2], 'myTestFunction');
assert.ok(parts[3].indexOf('test-postmortem-details.js') != -1);
});
verifiers.push(function verifyJsfunctionS(testlines) {
var foundtest = false, founditer = false;
assert.ok(testlines.length > 1);
testlines.forEach(function (line) {
var parts = line.trim().split(/\s+/);
if (parts[2] == 'myIterFunction') {
assert.equal(parts[1], '3');
founditer = true;
} else if (parts[2] == 'myTestFunction') {
foundtest = true;
assert.equal(parts[1], '1');
}
});
assert.ok(foundtest);
assert.ok(founditer);
});
verifiers.push(function verifyJssource(testlines) {
var content = testlines.join('\n');
assert.ok(testlines[0].indexOf('test-postmortem-details.js') != -1);
assert.ok(content.indexOf('function myTestFunction()\n') != -1);
assert.ok(content.indexOf('return (new Buffer(bufstr));\n') != -1);
});
var mod = util.format('::load %s\n',
path.join(__dirname,
'..',
'..',
'out',
'Release',
'mdb_v8.so'));
mdb.stdin.write(mod);
mdb.stdin.write('!echo test: jsconstructor\n');
mdb.stdin.write('::findjsobjects -p my_buffer | ::findjsobjects | ' +
'::jsprint -b length ! awk -F: \'$2 == ' + bufstr.length + '{ print $1 }\'' +
'| head -1 > ' + tmpfile + '\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::jsconstructor\n');
mdb.stdin.write('!echo test: nodebuffer\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::nodebuffer\n');
mdb.stdin.write('!echo test: nodebuffer contents\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::nodebuffer | ::eval "./ccccc"\n');
mdb.stdin.write('!echo test: v8internal\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::v8print ! awk \'$2 == "elements"{' +
'print $4 }\' > ' + tmpfile + '\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::v8internal 0\n');
mdb.stdin.write('!echo test: jsfunctions -n\n');
mdb.stdin.write('::jsfunctions -n myTestFunction ! cat\n');
mdb.stdin.write('!echo test: jsfunctions -s\n');
mdb.stdin.write('::jsfunctions -s test-postmortem-details.js ! cat\n');
mdb.stdin.write('!echo test: jssource\n');
mdb.stdin.write('::jsfunctions -n myTestFunction ! ' +
'awk \'NR == 2 {print $1}\' | head -1 > ' + tmpfile + '\n');
mdb.stdin.write('::cat ' + tmpfile + ' | ::jssource -n 0\n');
mdb.stdin.end();
});

8
test/pummel/test-postmortem-findjsobjects.js

@ -30,6 +30,9 @@ if (os.type() != 'SunOS') {
process.exit(0); process.exit(0);
} }
function LanguageH(chapter) { this.OBEY = 'CHAPTER ' + parseInt(chapter, 10); }
var obj = new LanguageH(1);
/* /*
* Now we're going to fork ourselves to gcore * Now we're going to fork ourselves to gcore
*/ */
@ -44,9 +47,6 @@ var args = [ corefile ];
if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '') if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '')
args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]); args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]);
function LanguageH(chapter) { this.OBEY = 'CHAPTER ' + parseInt(chapter, 10); }
var obj = new LanguageH(1);
gcore.stderr.on('data', function (data) { gcore.stderr.on('data', function (data) {
console.log('gcore: ' + data); console.log('gcore: ' + data);
}); });
@ -68,7 +68,7 @@ gcore.on('exit', function (code) {
} }
var lines = output.split('\n'); var lines = output.split('\n');
var found = 0, i, expected = 'OBEY: "' + obj.OBEY + '"', nexpected = 2; var found = 0, i, expected = '"OBEY": "' + obj.OBEY + '"', nexpected = 2;
for (var i = 0; i < lines.length; i++) { for (var i = 0; i < lines.length; i++) {
if (lines[i].indexOf(expected) != -1) if (lines[i].indexOf(expected) != -1)

1
test/pummel/test-postmortem-jsstack.js

@ -22,6 +22,7 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var os = require('os'); var os = require('os');
var path = require('path');
var util = require('util'); var util = require('util');
if (os.type() != 'SunOS') { if (os.type() != 'SunOS') {

Loading…
Cancel
Save