您当前的位置: 首页 >  linux

linux上使用strace查看C语言级别的php源码【一种方法】

发布时间:2012-11-18 00:06:04 ,浏览量:0

如果你希望看到C语言级别的php代码就需要使用strace

这个默认是安装了的,如果没有安装可以

#yum install strace

查看httpd进程

#ps auxw | grep httpd

有多个,必须停止apache

[root@localhost usr]# /usr/local/webserver/apache2/bin/apachectl stop

启动单进程httpd [root@localhost usr]# /usr/local/webserver/apache2/bin/apachectl -X -k start

再使用#ps auxw | grep httpd查看只有单经常,记下进程id

将strace绑定至apache

#strace -p 28224

算法

快速排序php代码

long tv_sec; /*秒*/
long tv_usec; /*微秒*/
};
timezone 结构定义为:
struct timezone{
int tz_minuteswest; /*和Greenwich 时间差了多少分钟*/
int tz_dsttime; /*日光节约时间的状态*/
};
		

#include
#include
main(){
	struct timeval tv;
	struct timezone tz;
	gettimeofday (&tv , &tz);
	printf("tv_sec; %d\n", tv,.tv_sec) ;
	printf("tv_usec; %d\n",tv.tv_usec);
	printf("tz_minuteswest; %d\n", tz.tz_minuteswest);
	printf("tz_dsttime, %d\n",tz.tz_dsttime);
}
tv_sec: 974857339 tv_usec:136996 tz_minuteswest:-540 tz_dsttime:0

=======================================================================

poll 函数

http://linux.about.com/library/cmd/blcmdl2_poll.htm

Linux / Unix Command: poll

NAME poll - wait for some event on a file descriptor SYNOPSIS #include

int poll(struct pollfd *ufds, unsigned int nfds, int timeout);

DESCRIPTION pollis a variation on the theme of select. It specifies an array of nfdsstructures of type
        struct pollfd {
                int fd;           /* file descriptor */
                short events;     /* requested events */
                short revents;    /* returned events */
        };
-------------------------

write 将数据写入已打开的文件内

定义:
ssize_t write (int fd,const void * buf,size_t count);
表头文件:
#include
说明:
write()会把参数buf所指的内存写入count个字节到参数fd所指的文件内。当然, 文件读写位置也会随之移动。
------------------------------

Linux / Unix Command: writev

http://linux.about.com/library/cmd/blcmdl2_writev.htm

NAME readv, writev - read or write a vector SYNOPSIS #include

ssize_t readv(int fd, const struct iovec *vector, int count); ssize_t writev(int fd, const struct iovec *vector, int count);

struct iovec {
    void *iov_base; /* Starting address */ size_t iov_len; /* Length in bytes  */ }; 
----------------------------

使用man命令查getsockname

其他函数:

ACCEPT()和ACCEPT4()
getuid 取得用户标识
getcwd 获取当前目录
rt_sigaction(2) 检查和改变信号动作,sigaction() 系统调用被用于更改一个进程在接收一个特定信号后的动作。
setitimer 获取设置定时器的值
poll(2) 在文件描述符上等待事件
stat64 获取文件状态
chdir 改变工作目录
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    107766博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.3269s