[C++] 디버깅 문제..

-@Naver의 이미지

프로그램에 문제가 있는지 확인하기 위해 디버깅을 돌려놨는데, 프로그램이 죽지도 않고 멈춰버리는 현상이 발생했습니다..

일단 코드 안에 무한 루프가 있습니다. while(1)로 무한 루프를 돌고, while문 안에서 발생하는 string 문자열 중에 "error " 문자열이 생겨날 때 10초를 멈췄다가 continue로 아래 코드를 무시하고 다시 처음부터 실행합니다.

제가 예상하는 디버깅 멈춤 현상은 이 무한 루프 안에서 발생하는 것인데, 멈춰버려도 어디서 멈춘건지 디버깅에서 찾을 수가 없네요..ㅠㅠ

보통 디버깅 중에 걸리지 않고 프로그램 자체라던지 디버깅 자체라던지에서 멈춰버리면 어디서 멈추었는지 찾을 수 없는건가요..??

아니면 중단점을 걸어놓지 않아도 현재 진행중인 프로세스가 어딘지 위치를 찾는 것은 할 수가 없는건가요..ㅠㅠ

AustinKim의 이미지

1. 아래 코드와 같이 printf과 같인 콘솔 출력 함수를 추가한 다음 while문을 몇 번 도는지 확인합니다.
2. 만약 iteration_time이 110번 이라고 확인될 경우 조건문을 추가하시고 그 안에 브래이크 포인트를 걸어보세요.

while (1) {
	int iteration_time = 0;
 
	iteration_time++;
	printf("Execution time[%d] \n", iteration_time);
 
	if (iteration_time == 110) {
		printf("Program is about to stop [%d] \n", iteration_time);
		printf("Please set break-point here \n");
	}
	/* Code snippset to debug */
}

(개인블로그)
http://rousalome.egloos.com

-@Naver의 이미지

아.. 좋은 생각인 것 같습니다..!
안그래도 저도 지금 while문 안에 error_code == 1004 가 되면 걸리게끔 브레이크 포인트 걸어놨습니다.
아직 한 번도 멈춘 적은 없는데 걸리길 소망해야겠네요..ㅎㅎㅎ 감사합니다!!!

-@Naver의 이미지

확실히 간단하게 해결했네요;
댓글 달아주신 것 처럼 사용하니까 잘 돌아가고 있습니다. 감사합니다!

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.