当前位置:网站首页>GDB debugging container and command saving
GDB debugging container and command saving
2022-06-24 04:59:00 【mariolu】
One 、gdb Debug the contents of the container or smart pointer
Sometimes we need debug some core A document or program , But if you meet STL Containers ,p What is printed out is some red black trees or original data organizations , This brings us unnecessary trouble in debugging .
gdb Built in Python Support , So it's easy to write a function to print out any stl The content of the structure .gcc 4.5 The required... Has been provided python Script , In order to make gdb Intelligently handle stl data structure .
https://gist.github.com/skyscribe/3978082 A script like this provides some macros for print containers , Or here :http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt
With these macros , You can print out the response container
wget http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt cat dbinit_stl_views-1.03.txt >> ~/.gdbinit
# std::vector<T> -- via pvector command # std::list<T> -- via plist or plist_member command # std::map<T,T> -- via pmap or pmap_member command # std::multimap<T,T> -- via pmap or pmap_member command # std::set<T> -- via pset command # std::multiset<T> -- via pset command # std::deque<T> -- via pdequeue command # std::stack<T> -- via pstack command # std::queue<T> -- via pqueue command # std::priority_queue<T> -- via ppqueue command # std::bitset<n> -- via pbitset command # std::string -- via pstring command # std::widestring -- via pwstring command
We can put these in ~/.gdbinit In file . stay gdb When debugging , Use source ~/.gdbinit Load these macro actions .
If your gdb In operation , You need to restart and enable , These macros take effect .
Read these code macros , It can also help you understand stl structure .
By the way , stay ~/.gdbinit You can put in some of your common gdb Set command . for instance
set print elements 0 // Set to print all elements set print pretty on // Printing structure format is more intuitive set print object on set print static-members on set print vtbl on set print demangle on set demangle-style gnu-v3 set print sevenbit-strings off
Two 、gdb Debugging history saving
Another useful thing is to save gdb Commissioning history ,set history save on A related command is set history remove-duplicates <count>. The order is “ Controls the deletion of duplicate history entries in the command history list . If the count is not zero ,gdb The last counted history entries will be reviewed and the first entry that duplicates the current entry will be deleted . Add to the command history list . If the count is unlimited , Then the hindsight is unbounded . If the count is 0, The deletion of duplicate history entries is disabled ". set history remove-duplicates <count> By default ,gdb Save history to... In the current directory ./.gdb_history In file . If you want the command history to be independent of the directory you are in , Need to include : set history filename ~/.gdb_history
边栏推荐
- Spirit breath development log (16)
- TCPIP协议详解
- Data acquisition gateway intelligent industrial Internet of things
- How to enlarge the ECS page? How to select ECS instance specifications?
- Summary of Android interview questions in 2020 (elementary)
- Shutter - how to copy certain elements from a map to a new map in dart/shutter?
- CTF learning notes 17:iwesec file upload vulnerability-02 file name filtering bypass
- Develop a customized music player from scratch, and your girlfriend will have it?
- Abnova fluorescence in situ hybridization (FISH) probe solution
- What does IIS mean and what is its function? How does IIS set the size of the web site space on the server?
猜你喜欢

Leetcode (question 2) - adding two numbers

SAP mts/ato/mto/eto topic 8: ATO mode 2 d+ empty mode strategy 85

Idea创建Servlet 后访问报404问题

TCPIP协议详解

Loss and optimization of linear regression, machine learning to predict house prices

少儿编程课程改革后的培养方式

Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture
Summary of Android interview questions in 2020 (intermediate)

Leetcode (question 1) - sum of two numbers

Let children learn the application essence of steam Education
随机推荐
Bi-sql where
Mini web framework: adding routes in decorator mode | dark horse programmer
Weak current engineer, 25g Ethernet and 40g Ethernet: which do you choose?
Disaster recovery series (IV) - disaster recovery construction of business application layer
Integration of Alibaba cloud SMS services and reasons for illegal message signing
Database answers build standard, answer as required
Find the current index of gbase 8C database?
Specificity and correlation of Worthington deoxyribonuclease I
问题:sql创建存储过程
How to build an ECS and how to control the server through the local host
Bi-sql - Select
Bi-sql insert into
Precautions for online education and training industry filing
CTF learning notes 18:iwesec file upload vulnerability-03-content-type filtering bypass
There are many ways to confirm and modify the remote port number
SAP mts/ato/mto/eto topic 8: ATO mode 2 d+ empty mode strategy 85
Oracle database prompts no operation permission
解析90后创客教育的主观积极性
When remote, your resolution is lower than a × B. Some items may not be displayed on the screen
Qiming cloud sharing: tips on esp32c3 simple IO and serial port