디버깅 디버깅 디버깅
글쓴이: 익명 사용자 / 작성시간: 일, 2002/03/10 - 10:20오전
데몬을 하나 만들어서 inetd가 서비스할수 있도록
만들어 놨는데요...
단순한 서버/클라이언트 모형이거든요... 근데 이놈이 invoking되면서
패킷을 받으면 그걸 가지고 제대로 돌아가는지 디버깅을 하기가
참 힘들더군요...
첫번째 패킷을 받으면,
1초만에 떴다가 죽게 되어있어서요... -_-;
어떤분이 gdb /usr/sbin/in.myprogd 이렇게 사용해보라고
했는데, 음... 이런식으로 쓰기엔 너무 데몬이 빨리떴다가
가라앉습니다.
어떤 좋은 방법이 없을까요...
Forums:
Re: 디버깅 디버깅 디버깅
gdb메뉴얼에 보면 이런말이 있네요
스립을 주세요..
프로그램 시작하기 직전에,,
Debugging programs with multiple processes
GDB has no special support for debugging programs which create
additional processes using the fork function. When a program forks,
GDB will continue to debug the parent process and the child process
will run unimpeded. If you have set a breakpoint in any code which
the child then executes, the child will get a SIGTRAP signal which
(unless it catches the signal) will cause it to terminate.
However, if you want to debug the child process there is a
workaround which isn't too painful. Put a call to sleep in the code
which the child process executes after the fork. It may be useful to
sleep only if a certain environment variable is set, or a certain
file exists, so that the delay need not occur when you don't want to
run GDB on the child. While the child is sleeping, use the ps
program to get its process ID. Then tell GDB (a new invocation of
GDB if you are also debugging the parent process) to attach to the
child process (see section Debugging an already-running process).
From that point on you can debug the child process just like any
other process which you attached to.
댓글 달기