@ GDB 로 STL 컨테이너들의 내용을 보여주는 gdb macro 파일을 다운 받아 설치합니다.
- 다운로드 : gdb_stl_view
- 설치 : 다운로드한 파일을 ~/.gdbinit 파일명으로 복사
@ 사용 방법
Data type | GDB command |
---|---|
std::vector<T> | pvector stl_variable |
std::list<T> | plist stl_variable T |
std::map<T,T> | pmap stl_variable |
std::multimap<T,T> | pmap stl_variable |
std::set<T> | pset stl_variable T |
std::multiset<T> | pset stl_variable |
std::deque<T> | pdequeue stl_variable |
std::stack<T> | pstack stl_variable |
std::queue<T> | pqueue stl_variable |
std::priority_queue<T> | ppqueue stl_variable |
std::bitset<n>td> | pbitset stl_variable |
std::string | pstring stl_variable |
std::widestring | pwstring stl_variable |
@ 사용 예제
- 예제 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <iostream.h> #include <string> #include <map> #include <vector> using namespace std; int main() { string strSource; vector< int > stNumList; map< int , string= "" > mapList; map< int , string= "" >::iterator itr; strSource = "SOURCE STRING" ; stNumList.push_back(1); stNumList.push_back(3); stNumList.push_back(4); mapList[2] = "Two" ; mapList[1] = "One" ; mapList[5] = "Five" ; mapList[10] = "Ten" ; mapList[7] = "Seven" ; cout << "Source string : " << strSource << endl; itr = mapList.find(7); if ( itr != mapList.end() ) { cout << "mapList(7) = " << itr->second << endl; } return 1; } </ int ,></ int ,></ int ></vector></map></string></iostream.h> |
- gdb 실행 예제
# gdb test Breakpoint 1, main () at test.cpp:27
(gdb) pstring strSource
(gdb) pvector stNumList
(gdb) pmap mapList |
- 사용법 예제
(gdb) pvector |
@ map iterator 를 gdb 로 보기 위해 추가한 매크로(.gdbinit 파일에 추가)
# define pmapitr
document pmapitr |
- gdb 실행 예제
# gdb test Breakpoint 1, main () at test.cpp:30
|
@ 참고한 URL
'Development' 카테고리의 다른 글
오라클 데이타베이스 사용시 NLS_LANG 환경 변수에 대한 설명 (0) | 2014.07.11 |
---|---|
프로그램 코딩시 사용되는 vi 의 유용한 기능들 (0) | 2014.07.11 |