Jonathan Adams's Weblog
Debugging smf(5)-managed processes
Recently, I've seen a couple questions (internally and externally) about the best way to debug something controlled by smf(5); since the process isn't started up directly, the usual ways of running things under a debugger aren't effective. If you don't need to debug the initialization process, it's also easy; just attach the debugger after the daemon is running.
If you need to debug the initialization, however, you need some way to stop the process before it does so. The easiest way is to use dtrace(1M). The following script:
# cat > stop_daemon.d <<\EOF
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option destructive
BEGIN
{
printf("READY\n");
}
proc:::start
/execname == $$1/
{
stop();
printf("stopped %d\n", pid);
exit(0);
}
EOF
# chmod +x stop_daemon.d
Will let you grab the *daemon* process (i.e. at the time of the second fork()). If you need to grab the parent process, change
proc:::start to proc:::exec-success. It takes the "execname" of the daemon (i.e. the first 16 characters of the executable name, which you can get using "pgrep -l daemon") as its argument. For example, if you wanted to debug the fault manager, you can do:
# ./stop_daemon fmd & # READY svcadm restart fmd # stopped 5678 mdb -p 5678 Loading modules: [ fmd ld.so.1 ... ] >Any debugger which can attach to processes will work; mdb(1), dbx(1), gdb(1), etc.
Technorati Tag: Solaris
Technorati Tag: Dtrace
Posted at 10:45AM May 19, 2005 by jwadams in Solaris | Comments[2]
Posted by fdasfdsa on October 12, 2006 at 06:51 AM PDT #
[url=http://www.74yy.cn/2007/tingyuanweirendanjita/3090/]听袁惟仁弹[/url][url=http://www.74yy.cn/2007/nanianxiatianningjingdehai/3704/]那年夏天宁[/url][url=http://www.74yy.cn/2007/mimihuayuan/3086/]秘密花园[/url][url=http://www.74yy.cn/2007/dongwo/3394/]懂我[/url][url=http://www.74yy.cn/2007/riguangqingcheng/3786/]日光倾城[/url][url=http://www.74yy.cn/2007/qianchengjinxiu/3032/]前程锦绣[/url][url=http://www.74yy.cn/2007/shouwang/3314/]手望[/url][url=http://www.74yy.cn/2007/kuailenansheng/3310/]快乐男生[/url][url=http://www.74yy.cn/2007/nulinuli/3664/]努力努力[/url][url=http://www.74yy.cn/2007/maidangnayiwen/3476/]麦当娜一吻[/url][url=http://www.74yy.cn/2007/hongqunbai/3472/]红裙摆[/url][url=http://www.74yy.cn/2007/diyibailingyigedaan/3331/]第一百零一[/url][url=http://www.74yy.cn/2007/kuailenansheng/4167/]快乐男声[/url][url=http://www.74yy.cn/2007/feichangyouxi/4164/]非常有戏[/url][url=http://www.74yy.cn/2007/shuishuonichangdebushihenmei/3077/]谁说你长得[/url][url=http://www.74yy.cn/2007/laozishuo/3076/]老子说[/url][url=http://www.74yy.cn/2007/taotai/3075/]淘汰[/url]
Posted by abc on November 11, 2008 at 07:27 AM PST #