C , C++, C#

[gdb] 표준 파일 건너뛰기

vhxpffltm 2024. 5. 1. 20:47
반응형

CLion으로 WSL을 통해 gcc 컴파일러의 gdb를 사용하다보면

 

Visual Studio와 다르게 좀 빡센 경험을 할 수 있다.

 

step into시에도 좀 차이가 있는 등 까다롭다.

 

그 중에서 가장 문제가 되는 표준 라이브러리 소스 파일을 계속해서 들어가 함수 호출 스텍 및 확인이 복잡하다.

 

사용자 함수만 확인해서 각 지역 / 로컬 값만 보면 되는데 이게 자꾸 컴파일러의 내부 구현 코드를 보니

문제가 되고 있다.

 

VS는 디버그 옵션에서 설정할 수 있지만, Linux GCC의 경우 
아래와 같은 방법을 사용할 수 있다.

 

https://stackoverflow.com/questions/5676241/tell-gdb-to-skip-standard-files

 

Tell gdb to skip standard files

I'm debugging C++ code with GDB and when it enters a constructor of some object containing standard library objects, it shows me the constructor of these objects (like std::map) and everything that's

stackoverflow.com

 

 

 

WSL 사용자 계정 디렉토리에 .gdbinit 파일을 생성하고 
아래의 내용을 통해 include 파일들의 디버깅을 제외할 수 있다.

 

# Skip debugging through GCC library files
skip -gfile /usr/include/c++/11/bits/*.h
반응형