gdbでデバッグができません
gdbでのデバッグについて
最近c++を勉強し始めました。cygwin上でgccをコンパイラとして使っています。その際、デバッグをしようと思い、gdbでデバッグしていると、ブレイクポイントを付けようとすると、ほかのよくわからないヘッダファイルにブレイクポイントがついてしまい上手くデバッグができません。
(c++ソースファイル名はb.ccです)
発生している問題・エラー
(gdb) b 21
Breakpoint 1 at 0x100401090: file /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/stl_algobase.h, line 21.
(gdb) r
Starting program: C:\users\at-sh\documents\program\at\a.exe
[New Thread 19564.0x13d8]
[New Thread 19564.0x4c88]
[New Thread 19564.0x4290]
[New Thread 19564.0x47b0]
warning: cYgFFFFFFFF 18026A780 0
[New Thread 19564.0x4f48]
[New Thread 19564.0x4f70]
[New Thread 19564.0xbfc]
warning: cYgstd 0xffffcb80 d 3
Thread 1 "a" hit Breakpoint 1, main ()
at /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/stl_algobase.h:21
21 /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/stl_algobase.h: No such file or directory.
(gdb) s
[New Thread 19564.0x5e4]
std::allocator<int>::allocator (this=0xffffcbe7)
at assignment.cpp:156
(gdb) s
__gnu_cxx::new_allocator<int>::new_allocator (
this=0xffffcbe7)
at /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/stl_vector.h:79
79 /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/stl_vector.h: No such file or directory.
該当するソースコード
#include <iostream> // cout, endl, cin
#include <vector> // vector
using namespace std;
int main() {
vector<int> nums(4);
for(int i = 0; i < 4; i++) {
cin >> nums.at(i);
}
for(int i = 0; i < 4; i++) {
cout << nums.at(i) << endl;
}
}
自分で試したこと
ほかのc++ファイルではデバックできました。↓
#include <iostream> // cout, endl, cin
using namespace std;
int main(){
int n;
cin >> n;
char n1 = n;
cout << n1 << endl;
}
以下環境です。
os windows11
cygwin gcc-g++ 11.3.0-1
初心者なので、間違ったことを書いているかもしれません。
よろしくお願いします。
0 likes