node.js 内部:我怎样才能找出`process.binding('eval')` 的定义位置? [英] node.js Internals: How can I find out where `process.binding('eval')` gets defined?
本文介绍了node.js 内部:我怎样才能找出`process.binding('eval')` 的定义位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 如何找出 node.js 的 C++ 源代码中定义 JavaScript 对象的位置,我可以通过
process.binding('eval')
访问该对象?- 在这种特殊情况下,我已经发现它在/src/node_script.cc
中,但是:当我刚查看/src/
目录概述?我不想为了查找模块而遍历/src/
中的所有文件. - 在哪里可以找到有关
process.binding()
s 内部结构的深入信息?
- How can I find out where in the C++ source code of node.js the JavaScript object gets defined which I can access through
process.binding('eval')
? - I already found out that it's in/src/node_script.cc
in this special case, but: How can I know where I can find that module just when I just take a look on the/src/
directory overview? I don't want to step through all the files in/src/
in order to look for a module. - Where can I find some deep going information about the internals of
process.binding()
s?
谢谢.
推荐答案
我今天也在寻找同样的方案.我不能保证没有更多,但这是我发现的.
I was looking for the same myself today. I cannot guarantee that there isn't more to it, but this is what I discovered.
src/node_extensions.h 包含一个内置模块列表,定义如下:
src/node_extensions.h contains a list of built-in modules, defined like:
ITEM(node_module_name)
其中 module_name 是模块的名称(显然)
where module_name is the name of the module (obviously)
您可以通过搜索哪个文件中包含以开头的行来找出哪个文件定义了该模块
You can find out which file defines that module by searching for which file has a line that starts with
NODE_MODULE(node_module_name,
因此,要找到为 process.bindings 定义evals"模块的文件:
So, to find the file that defines the 'evals' module for process.bindings:
$ grep "NODE_MODULE(node_evals" src/*.cc
src/node_script.cc:NODE_MODULE(node_evals, node::InitEvals)
这篇关于node.js 内部:我怎样才能找出`process.binding('eval')` 的定义位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文