디버깅 너무 어렵네요..

qufdl113의 이미지

전에도 한번 올렸지만 정말 안되네요. 아시는분 제발 자세히점 가르쳐 주셨으면 합니다.

// 서버 초기화 
bool Init_Server() 
{ 
   // 데몬화 작업 
       pid_t pid; 
    
   // parent terminates 

   if((pid = fork()) != 0 )    
   { 
      printf("pid = %ld \n", pid); 
      exit(0); 
   } 
    
   // first child continues 
       
   setsid(); 
       
   signal(SIGHUP, SIG_IGN); 
    
   // first child terminates 

   if( (pid = fork()) != 0 )     
   { 
       printf("pid = %ld \n", pid); 
   exit(0); 
   } 

umask(0);
:
: 
:
pid 구분해서 따로 돌리는 코딩은 없습니다.
:
:
...... 
} 

위와 같이 프로세스가 생성되는 서버입니다.
디버깅을 하기 위해서.
처음엔 gdb에서 그냥 돌렸습니다. 그냥 죽더군요.
두번째엔, ps 명령어를 한후 서버 pid를 알아내서.
gdb attatch pid하니까.
Assertion 'proc_handle.pid==0' failed ...이런저런말... Quit this debuggin session?(y/n)
라고 떠서 Yes하면 그냥 죽길래 N를 누르니까. gdb로 들어가지긴 하더군요.,
다음에 일단 들어가면 breakpoint도 걸리고, 리스트로 코딩라인이 출력되는거까지는 되더군요.
그런데, breakpoint로 함수하나(select포함된함수)를 잡은후 n누르면,
[New Thread 8192 (LWP 2043]
이라는거 뜨면서 다음으로 넘어가질 않고 작동이 않됩니다.

죄송하지만,,,
디버깅을 어떻게 해야 하는지 자세히점 갈켜주셨으면 합니다.
다른 Q/A아무리 뒤져봐도 해결 할 수가 없네요.

aniseeker의 이미지

죽을 때, 코어파일 생성하는지 확인하시고, 코어파일 생성 안되면 생성되도록 환경변수 설정하신 다음에 코어파일과 함께 디버깅을 해보시면 쉬울 듯합니다.

bt 명령으로 뭐하다 죽었는지 알 수 있으니 죽는 원인을 파악하기에 상당히 편리합니다.

gdb의 사용방법은 man 페이지나 검색을 통해서 확인해보세요. :)

어두운 밤에 움직이지 않는 꽃과 개와 물,
어두운 밤에 꽃과 짖는개와 물.

qufdl113의 이미지

답변감사합니다.

프로그램내에서 값이 어떻게 처리 되는지 비줠스튜디오에서 디버깅하듯 차근차근 볼부분이 있습니다. 값도 변화시켜 보고 싶구여.

지금처럼 로그파일 남기고, 강제로 코드에서 값 변화시켜두 되지만,
언제까지나 그렇게 할 수는 없자나요.

feanor의 이미지

gdb 에서도 가능합니다.

--feanor

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.