Linux gdb commands

Source: Internet
Author: User
Linux gdb Command 1. regular debugging gdb is a common program debugging tool in Linux, provided that the-g parameter is added during gcc/g ++ compilation, in this way, the compiled executable program will add gdb debugging information. There are many gdb commands, but the following commands are commonly used :... linux gdb Command 1. regular debugging gdb is a common program debugging tool in Linux, provided that the-g parameter is added during gcc/g ++ compilation, in this way, the compiled executable program will add gdb debugging information. There are many gdb commands, but the following commands are commonly used: (1) list [file:] The abbreviation of functuon is l. check the source code. If no parameter is added, the source code is displayed below, when the-l parameter is added, the source code is displayed up. 10 lines are displayed by default. You can also set the source code to be listed in a function. Note that if a non-member function is used, use file: function. if it is a class member function, use class: functuon. (2) edit [file:] The function command is abbreviated as e. you can edit the current row or the source code of a function (the rule is the same as the list ). (3) break [file:] The function command is abbreviated as B. You can set a breakpoint in a row or function (the rule is the same as the list). In addition, you can also directly use the file name: line number to set the breakpoint. (4) The info command is abbreviated as I. It lists information about the gdb sub-commands, such as info break, info variables, and info stack. (5) the run [arglist] command is abbreviated as r. it stops running the program at the breakpoint. after the run command, you can add the parameters required for debugging the program. (6) the "next" command is abbreviated as "n". it is a single-step debugging and execution statement. if a function is encountered, it is also a single-step statement without entering the function, similar to F10 in VC. (7) the step command is abbreviated as "s". a single-step debugging and execution statement directly enters the function if a function is encountered, similar to F11 in VC. (8) the abbreviation of continue fame and fortune is c. continue to run the program to the next breakpoint. (9) what to view the variable type. (10) The print command is abbreviated as p, which prints the value of the variable. (11) the backtrace command is abbreviated as bt to view the stack information. (12) enter the enter key and run the previous debugging command again. (13) help [name] displays the help information of the specified gdb command. (14) The quit command stands for q and exits gdb. When you debug and run the program, use gdb. exe to load the program. when you debug the core dump, use gdb. exe. core to load the program. run the r command to start running the program. After the code is edited in gdb, you do not need to exit gdb, but directly make it in gdb. otherwise, all the previously set breakpoints and other information will be burned. II. multi-thread debugging (1) the info threads command is abbreviated as info thr, which displays all the threads currently debuggable. each thread has an ID allocated to it by gdb, this ID will be used for subsequent operations on the thread. the preceding * is the thread currently being debugged. (2) the thread ID command is abbreviated as thr, and the thread currently being debugged is the thread with the specified ID. (3) the rule for the short thread apply ID1 ID2 command is the same as that for the same rule, so that one or more threads can execute the gdb command. (4) the rule for the short thread apply all command is the same as the rule for all debugging threads to execute the gdb command. (5) set scheduler-locking off | on | when a multi-threaded program is debugged by a step or continue command, other threads are also executing concurrently, this command can use off | on | step to control thread execution, that is, off: no thread is locked, that is, all threads are executed. this is the default value. On: only the program being debugged will be executed. Step: in a single step, except for the next function, only the current thread will execute.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.