Preface gdb is a very useful debugging tool under Linux. Although it is a debugging tool in command line mode, its functions are more powerful than you can imagine. Here is a brief introduction to the use of gdb. Friends in need can take a look at the detailed introduction below. Breakpoints Break at a specified location in the code, causing the program to break there.
Examples: (gdb) break sc_smartcontract_handler.cpp:45 Breakpoint 4 at 0x424d42: file sc_smartcontract_handler.cpp, line 45. Breakpoint related operations
Observation Point Capture points are used to capture some events when the program is running. Such as: loading shared libraries (dynamic link libraries), C++ exceptions, etc. It is often used to locate bugs. The command format for capturing a point is: catch <event>, where event can be the following:
You can use the info watchpoints [n] command to view the current watchpoint information. View variables The most common way to view variables is
(gdb) print argc $1 = 1 If you print an array, the tail of the printed array may not be displayed due to the default settings. You can set the maximum length of the printed array with the following command:
View code during debugging
Although the list is very convenient, it is still not satisfactory. It would be nice if the code can be displayed while running. The answer is yes. Use the following command to start gdb: gdb -tui project name or after starting gdb, enter the command focus, as shown in the figure: Resume program execution and single-step debugging In gdb, the commands related to debugging stepping are mainly as follows:
Interrupt in a specific thread You can define whether your breakpoint should be on all threads, or on a specific thread. GDB can easily help you do this.
linespec specifies the source line number where the breakpoint is set. threadno specifies the thread ID. Note that this ID is assigned by GDB. You can view thread information in the running program through the "info threads" command. If you do not specify thread <threadno>, it means your breakpoint is set on all threads. You can also specify breakpoint conditions for a thread. like: (gdb) break frik.c:13 thread 28 if bartab > lim When your program is stopped by GDB, all running threads are stopped as well. This allows you to see the overall status of the running program. When you resume the program, all threads will be resumed. Even when the main process is being single-step debugged. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL 5.7.18 installation and configuration tutorial under Windows
>>: How to use JSX to implement Carousel components (front-end componentization)
Table of contents 1. Operator 1.1 Arithmetic oper...
Table of contents Summarize Summarize When the ar...
Solution to Ubuntu dual system stuck when startin...
public function json_product_list($where, $order)...
Problem description: structure: test has two fiel...
This article introduces Nginx from compilation an...
background We often use Chrome Dev Tools for deve...
1. Install and start nginx # Install nginx sudo a...
Welcome to the previous canvas game series: 《VUE ...
What to do if you forget Windows Server 2008R2 So...
I recently encountered a problem when doing IM, a...
The error "mysql is not an internal command&...
This article summarizes some simple principles of...
Table of contents Storage Engine Storage engines ...
IMG tag basic analysis In HTML5, the img tag has ...