Several tips of GDB

Source: Internet
Author: User

[Disas]

Disassembles a command. It can contain zero, one, or two parameters. The first parameter is the start address of the disassembly process, and the second parameter is the end address of the disassembly process.
 
If no parameter exists, the current function is deassembled.


[Memory read/write breakpoint]


Watch * (int x) 0x12345678
In
0x12345678 write-down breakpoint. the breakpoint range is 4 bytes.
GDB supports a wider range of memory write breakpoints.
Rwatch, awatch
The usage is the same as that of watch, which indicates the read breakpoint and read/write breakpoint respectively.
The read/write breakpoint depends on the available hardware registers of GCC.
 
(In fact, a watchpoint is set to monitor whether the value of the expression is read/written)


[Rbreak RegEx]


 
Set breakpoints on all functions that meet the RegEx expression. This command sets an unconditional breakpoint on all matching functions. When this command is complete, it displays information about all configured breakpoints.
 
The breakpoint set by this command is no different from that set by the/"break/" command.
 
In this way, you can delete, enable, and disable the breakpoint set by this command like a breakpoint.
 
When debugging C ++ProgramThis command is very useful when you set breakpoints on the overload function.



[Register window]


(GDB) display
/X $ eax


[Set DisassemblyCodeInstruction sets used]


(GDB) set disas intel
 
Sets the instruction set used by the disassembly code. You can select intel instruction set or at&t instruction set.
This command can only be used on the X86 platform.


 
[Capture "segment error" signal]


(GDB) handle SIGSEGV


[Capture when an exception is thrown]


(GDB) catch
Throw


[Force return]


(GDB) Return
The program jumps directly from the current row to return
. If a function has a return value, it is added after the return command. For example, return 1. Stack balance is automatically maintained during redirection.

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.