How to activate sh DTrace Provider?

此生再无相见时 提交于 2020-01-06 21:47:10

问题


I've found out about patches (and updates) for an x86 sh binary in 2007 to support sh DTrace provider.

However I can't find any probes on OS X. I'm checking by:

$ sudo dtrace -l | grep command-entry

See: /bin/sh DTrace Provider at Oracle site (same article on blog)

Maybe because my sh is the same as GNU bash?

$ /bin/sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)

Where these probes were implemented, how I can find them or how I can activate them?

Were there only implemented on Solaris?


回答1:


The patches you refer to were specific to the bourne shell on Solaris, and as far as I know nothing like it has ever been ported to other shells.

In the illumos (née OpenSolaris) commit history, we can see that /bin/sh was changed to be a symlink to ksh93 in commit ead1f93 on March 2, 2010. Considering that Alan's blog post is dated 2007, this wasn't included in Solaris 10, at least not initially since Solaris 10 was released in 2005. It may be in one of the updates post 2007 but I sort of doubt it. From the existing code, I can't even find what provided /bin/sh before the switch to ksh, which might mean it was one of the closed bits.

Either way, it was never part of any illumos release and I don't see any references to dtrace probes for command-entry in the illumos commit history. Unless Alan or somebody else close to the matter can speak up, it's probably lost to time.

In summary, as near as I can tell these patches were never included in any released product from Sun or otherwise. It will almost certainly have to be reimplemented from scratch on any existing open source shell.




回答2:


I never added it to the bourne shell in a public Solaris (although I got the PSARC approval for it) as while testing I found some major performance hits in the way that the bourne shell forks. In order to address this I'd have to migrate it to using posix_spawn(). Given that we were moving away from using this shell in Solaris 11, this was an amount of work that would have been pretty fruitless. I haven't given up on going to other shells, but it's not one of my immediate priorities.

Moving the probes to another shell should be pretty painless, except for deciding what to return as the prior value in "variable-assign", when we have compound variables.



来源:https://stackoverflow.com/questions/36496670/how-to-activate-sh-dtrace-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!