2010-04-24 3 views
8

어설 션 오류가 발생한 프로그램을 종료하지 못하도록 윈도우에서 gdb를 어떻게 설정합니까? 프로그램에서 스택 추적 및 변수를 확인하려고합니다. GDB에는 MinGW 'g++ -g test.cpp -o test'로 컴파일이 Test.cpp에 프로그램 실행 예를 들어윈도우에서 gdb를 사용하여 디버깅하기, 어설 션 실패시 종료하지 않기

:

#include <cassert> 
int main(int argc, char ** argv) { assert(1==2); return 0; } 

을 제공합니다 :

$ gdb test.exe 
GNU gdb 6.8 
Copyright (C) 2008 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "i686-pc-mingw32"... 
(gdb) r 
Starting program: f:\code/test.exe 
[New thread 4616.0x1200] 
Error: dll starting at 0x77030000 not found. 
Error: dll starting at 0x75f80000 not found. 
Error: dll starting at 0x77030000 not found. 
Error: dll starting at 0x76f30000 not found. 
Assertion failed: 1==2, file test.cpp, line 2 

This application has requested the Runtime to terminate it in an unusual way. 
Please contact the application's support team for more information. 

Program exited with code 03. 
(gdb) 
내가 종료에서 프로그램을 중지 할 수 있도록하고 싶습니다

Visual Studio의 디버거와 Linux의 gdb가 어떻게 작동하는지 즉시 알 수 있습니다. 검색을 수행하고 신호를 잡는 것에 대해 발견했지만 gdb를 설정하는 방법에 대한 좋은 게시물을 찾을 수없는 것 같습니다.

답변

5

그냥 종료에 중단 점을 설정합니다

(gdb) b exit

+0

내가 묻는 것을 막는 방법 : 기능 "exit"는로드 된 기호에 정의되어 있지 않습니다. 향후 공유 라이브러리로드시 중단 점을 보류로 설정 하시겠습니까? (y 또는 [n]) y 중단 점 1 (종료) 보류 중입니다. – devil

6

중단 점 라인으로 .gdbinit 파일에 넣을 수 있음을 찾았이 입력 할 필요를 제거

set breakpoint pending on 
b exit 

예 창문. 최근 사용

1

(2017 월) 사용한다 GCC 6.3 gdb를 7.12.1와 msys2 :

break _exit 

_exit하지 exit를 사용합니다. exit이 실제로는 _exit을 호출 할 것이라고 예상하므로 다른 경우에도이 기능이 작동 할 것으로 예상됩니다.