0

straceを使用してアプリをトレースしましたが、システムコール「poll」でブロックされていることがわかりました。このシステムコールを呼び出している関数を特定したいのですが、どうすればよいですか?</ p>

4

2 に答える 2

3

デバッグ情報(-ggccのフラグ)を使用してプログラムをコンパイルしましたか?デバッガーを起動して、スタックトレースを取得します。

サンプルプログラム(example.c):

#include <poll.h>

void f2(void)
{
  struct pollfd fd = {0, POLLERR, POLLERR};
  poll(&fd, 1, -1);
}

void f1(void)
{
  f2();
}

int main(int argc, char **argv[])
{
  f1();    
  return 0;
}

ビルドとバックトレースの例:

$ CFLAGS=-g make example
cc -g    example.c   -o example
$ gdb example    
(gdb) run
Starting program: example 
Reading symbols for shared libraries +. done
^C
Program received signal SIGINT, Interrupt.
0x00007fff821751a6 in poll ()
(gdb) bt
#0  0x00007fff821751a6 in poll ()
#1  0x0000000100000ea6 in f2 () at example.c:6
#2  0x0000000100000eb1 in f1 () at example.c:11
#3  0x0000000100000ec7 in main (argc=1, argv=0x7fff5fbff750) at example.c:16
(gdb) 
于 2011-03-21T00:48:58.463 に答える
1

次のように入力するだけです。

gstack pid

指定されたプロセスIDを持つプログラムのスタックトレースを取得します。

于 2011-03-21T01:06:56.940 に答える