GDB debugging (5) Checking file search and view Assembly commands

Source: Internet
Author: User
Tags builtin

 

1. source code file search

You can use the following three commands to find the source file for GDB debugging.

 

Forward-searchRegexp

Search for the keyword Regexp from the first line of the source file and record the row number. This record can be referenced by the next GDB command.

 

Example: for void

Search Result: 38 void

Next, run the command: List to display 10 lines of content centered on 38 behaviors. (The number of rows to be displayed can be specified)

 

Search Regexp

Search down from the current row.

 

Reverse-search Regexp

Search from the last line.

 

2. View machine commands (assembly)

 

Disassemble

Disassemble/M hexadecimal display Assembly command

Disassemble/R

Disassemble start, end specifies the start and end addresses

Disassemble start, + length specifies the start address and display Length

 

You can obtain the address using the following column:

(GDB) info line main

Line 895 of "builtin. c" starts at PC 0x634c and ends at 0x6350.

 

(GDB) info line * 0x63ff

Line 926 of "builtin. c" starts at PC 0x63e4 and ends at 0x6404.

 

     (gdb) disas 0x634c, 0x6404
 
     Dump of assembler code from 0x32c4 to 0x32e4:
        0x32c4 <main+204>:      addil 0,dp
        0x32c8 <main+208>:      ldw 0x22c(sr0,r1),r26
        0x32cc <main+212>:      ldil 0x3000,r31
        0x32d0 <main+216>:      ble 0x3f8(sr4,r31)
        0x32d4 <main+220>:      ldo 0(r31),rp
        0x32d8 <main+224>:      addil -0x800,dp
        0x32dc <main+228>:      ldo 0x588(r1),r26
        0x32e0 <main+232>:      ldil 0x3000,r31
     End of assembler dump.

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.