pstack跟踪程序调用堆栈

/*
 * 跟踪程序调用堆栈
 * gcc -g -o pstack_test pstack_test.c
 * ./pstack_test
 * ps ax | grep pstack_test
 * 5495 pts/0    S+     0:00 ./pstack_test
 * #0  0x0000003a4fedb430 in __read_nocancel () from /lib64/libc.so.6
 * #1  0x0000003a4fe71cf8 in _IO_new_file_underflow () from /lib64/libc.so.6
 * #2  0x0000003a4fe737fe in _IO_default_uflow_internal () from /lib64/libc.so.6
 * #3  0x0000003a4fe5acb0 in _IO_vfscanf_internal () from /lib64/libc.so.6
 * #4  0x0000003a4fe6445d in __isoc99_scanf () from /lib64/libc.so.6
 * #5  0x000000000040056f in fun ()
 * #6  0x00000000004005b6 in main ()
 * addr2line -e pstack_test -i 0x40056f
 * /home/cyf/fy4dts/cpp/pstack_test.c:25
 */
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>

int fun(int x)
{
	printf("before scanf,X=%d\n",x);	
	scanf("%d",&x);
	printf("X=%d\n",x);
	return x;
}

int main(const int argc, const char *argv[])
{
	printf("in main function.");
	fun(10);
	return 0;
}

你可能感兴趣的:(pstack跟踪程序调用堆栈)