当前位置:网站首页>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
边栏推荐
- How to build a website for ECS? What are the prices of different ECS
- Popularization of children's programming education in specific scenarios
- What are the differences between ECs and virtual hosts? Which is better, ECS or VM?
- Weak current engineer, 25g Ethernet and 40g Ethernet: which do you choose?
- How does ECS select bandwidth? What types of servers do you usually have?
- MySQL - SQL execution process
- Library management backstage
- What is the principle of Ping? How does the server disable Ping?
- 梯度下降法介绍-黑马程序员机器学习讲义
- Use of go testing framework gomock
猜你喜欢

Training methods after the reform of children's programming course

Idea创建Servlet 后访问报404问题

Popularization of children's programming education in specific scenarios

Let children learn the application essence of steam Education

Recognize workplus again, not only im but also enterprise mobile application management expert

SAP MTS/ATO/MTO/ETO专题之十:ETO模式 Q+空模式 未估价库存 策略自定义

Analyzing the superiority of humanoid robot in the post human era

SAP MTS/ATO/MTO/ETO专题之七:ATO模式1 M+M模式策略用82(6892)

阿里云混合云首席架构师张晓丹:政企混合云技术架构的演进和发展

Abnova fluorescence in situ hybridization (FISH) probe solution
随机推荐
Here's all you want to know about takin data (1) startup command
Ext4 file system jam caused by MEM CGroup OOM
IP and traffic reconciliation tool networktrafficview
Idea creates a servlet and accesses the 404 message
How does ECS publish websites? What software tools are needed?
What does IIS mean and what is its function? How does IIS set the size of the web site space on the server?
There are many ways to confirm and modify the remote port number
How to change the IP address of ECS? What are the precautions for changing the IP address
Introduction to vulnerability priority technology (VPT)
Spirit breath development log (15)
What is an evpn switch?
Find the current index of gbase 8C database?
What is the principle of Ping? How does the server disable Ping?
What is the role of ECS? How does FTP connect to ECS configuration?
Weak current engineer, 25g Ethernet and 40g Ethernet: which do you choose?
Shutter - how to copy certain elements from a map to a new map in dart/shutter?
When remote, your resolution is lower than a × B. Some items may not be displayed on the screen
MySQL - SQL execution process
014_ TimePicker time selector
Summary of Android interview questions in 2020 (elementary)