Ubuntu 22.04 의 현재 최신 GDB 는 12.0.9 버전이다 (22.10.22 기준)
하지만 12.1 버전이 출시는 이미 되어있고 아직 Ubuntu에서는 지원하지 않는다
이로인해 디버깅을 할때 F11을 사용하면 printf, scanf 등을 지날때aborted (core dumped) 발생한다.
이를 해결하기 위해서는 GDB버전을 12.1 버전으로 올려야한다.
아래는 GDB 버전을 업데이트 하는 방법이다.
gcc와 g++가 모두 설치되어있어야합니다.
안되어있으시면
아래 커맨드를 이용해서 설치 부탁드립니다.
sudo apt-get install gcc
sudo apt-get install g++
gdb 업데이트
$ sudo apt-get update // linux 최신버전 패키지 끌고오기
$ sudo apt-get install gdb // gdb 설치
여기는 최신버전이 설치되지 않은 경우 아래 방법으로 설치 (빨간 글씨 부분이 최신파일명으로 이게 귀찮으면 사이트에서 최신파일 --> 마우스 오른쪽 --> 링크복사 해도됨)
$ wget "http://ftp.gnu.org/gnu/gdb/gdb-12.1.tar.gz"
$ sudo apt-get install libgmp-dev
$ tar -xvzf gdb-12.1.tar.gz
$ cd gdb-12.1
gdb-12.1$ ./configure
gdb-12.1$ make
$ make install
$ gdb --version
위 동작을 완료한 후에 version이 업데이트가 되지 않거나 하면 지운 후에 다시 시도하시기 바랍니다.
위 설치를 모두 완료한 후에
sudo apt update
sudo apt upgrade
sudo apt install gdb
를 다시 해보시기 바랍니다. (VS code에 켜져있는 창을 모두 껐다가 다시 키신 후에 시도해보시기 바랍니다.)
gdb 삭제 -- 패키지 설치가 잘못되었거나 구버전인경우
sudo apt-get remove --auto-remove gdb
gdb 최신파일
https://ftp.gnu.org/gnu/gdb/
ref : http://www.gdbtutorial.com/tutorial/how-install-gdb
json file 수정
VScode와 Ubuntu GDB 연결하기
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry":false,
"cwd": "${fileDirname}",
"environment":[],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/local/bin/gdb",
"setupCommands": [
{
"description": "gdb에 자동 서식 지정 사용",
"text": "-enable-pretty-printing",
"ignorefailures": true
},
{
"description": "디스어셈블리 버전을 Intel(으)로 설정",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc build"
}
]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "gcc build",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"${fileDirname}/${fileBasenameNoExtension}.c",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe"
],
"problemMatcher": ["$gcc"],
"group": "build"
},
// 실행
{
"label": "execute",
"command": "cmd",
"group": "test",
"args": [
"${fileDirname}/${fileBasenameNoExtension}.exe"
]
}
]
}
좋은 자료 고맙읍니다...