Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54c38eb

Browse filesBrowse files
indutnyMyles Borins
authored andcommitted
tickprocessor: apply c++filt manually on mac
`/bin/sh -c` trick wasn't working for several reasons: * `/bin/sh -c "..."` expects the first argument after `"..."` to be a `$0`, not a `$1`. Previously `-n` wasn't passed to `nm` because of this, and many symbols were ordered improperly * `c++filt` was applied not only to the names of the functions but to their `nm` prefixes like `t` and `a` (`t xxx` turns into `unsigned char xxx`). Instead of applying `c++filt` wide and using `sh -c`, execute `nm` as requested by `deps/v8/tools/tickprocessor.js` and apply `c++filt` to all matching entries manually. Included test demonstrates where previous approach failed: all builtins were merged into `v8::internal::Builtins::~Builtins`, because they were prefixed by `t` in `nm` output. PR-URL: #8480 Reviewed-By: Matthew Loring <mattloring@google.com>
1 parent 50a4471 commit 54c38eb
Copy full SHA for 54c38eb

File tree

Expand file treeCollapse file tree

3 files changed

+41
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+41
-6
lines changed
Open diff view settings
Collapse file

‎lib/internal/v8_prof_polyfill.js‎

Copy file name to clipboardExpand all lines: lib/internal/v8_prof_polyfill.js
+32-4Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ const os = {
3838
/^[0-9a-f]+-[0-9a-f]+$/.test(arg)) {
3939
return '';
4040
}
41-
} else if (process.platform === 'darwin') {
42-
args.unshift('-c', name);
43-
name = '/bin/sh';
4441
}
45-
return cp.spawnSync(name, args).stdout.toString();
42+
var out = cp.spawnSync(name, args).stdout.toString();
43+
// Auto c++filt names, but not [iItT]
44+
if (process.platform === 'darwin' && name === 'nm')
45+
out = macCppfiltNm(out);
46+
return out;
4647
}
4748
};
4849
const print = console.log;
@@ -100,3 +101,30 @@ function versionCheck() {
100101
}
101102
}
102103
}
104+
105+
function macCppfiltNm(out) {
106+
// Re-grouped copy-paste from `tickprocessor.js`
107+
const FUNC_RE = /^([0-9a-fA-F]{8,16} [iItT] )(.*)$/gm;
108+
var entries = out.match(FUNC_RE);
109+
if (entries === null)
110+
return out;
111+
112+
entries = entries.map((entry) => {
113+
return entry.replace(/^[0-9a-fA-F]{8,16} [iItT] /, '')
114+
});
115+
116+
var filtered;
117+
try {
118+
filtered = cp.spawnSync('c++filt', [ '-p' , '-i' ], {
119+
input: entries.join('\n')
120+
}).stdout.toString();
121+
} catch (e) {
122+
return out;
123+
}
124+
125+
var i = 0;
126+
filtered = filtered.split(/\n/g);
127+
return out.replace(FUNC_RE, (all, prefix, postfix) => {
128+
return prefix + (filtered[i++] || postfix);
129+
});
130+
}
Collapse file

‎lib/internal/v8_prof_processor.js‎

Copy file name to clipboardExpand all lines: lib/internal/v8_prof_processor.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ scriptFiles.forEach(function(s) {
2020

2121
var tickArguments = [];
2222
if (process.platform === 'darwin') {
23-
const nm = 'foo() { nm "$@" | (c++filt -p -i || cat) }; foo $@';
24-
tickArguments.push('--mac', '--nm=' + nm);
23+
tickArguments.push('--mac');
2524
} else if (process.platform === 'win32') {
2625
tickArguments.push('--windows');
2726
}
Collapse file

‎test/parallel/test-tick-processor.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tick-processor.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ runTest(/RunInDebugContext/,
4343
setTimeout(function() { process.exit(0); }, 2000);
4444
f();`);
4545

46+
runTest(/Runtime_DateCurrentTime/,
47+
`function f() {
48+
this.ts = Date.now();
49+
setImmediate(function() { new f(); });
50+
};
51+
setTimeout(function() { process.exit(0); }, 2000);
52+
f();`);
53+
4654
function runTest(pattern, code) {
4755
cp.execFileSync(process.execPath, ['-prof', '-pe', code]);
4856
var matches = fs.readdirSync(common.tmpDir);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.