GDB core,gdb Debug Daquan, Core file debugging

Source: Internet
Author: User
Tags stack trace

Compile:GCC-G-o Hello hello.c gdb debug: Basic gdb command. Command Description Summary: Common GDB command backtrace displays the current position in the program and the stack trace that represents how to get to the current location (synonym: where) bre Akpoint setting a breakpoint in the program CD changes the current working directoryClearWhen you delete a breakpoint that was just stopped, commands a breakpoint, list the command to be executed continue continue execution from the breakpoint delete Deletes a break point or a checkpoint, or can be used with other commands The display program stops displaying variables and expressions when down moves the stack frame so that another function becomes the current function frame Select the next continue commandInfodisplays various information related to the program jump starts running at another point in the source programKillabnormally terminating a program running under GDB Control List lists the contents of the original file corresponding to the program being executed next executes the next source line, thus performing a function in its entirety print displays the value of a variable or an expression pwddisplays the current working directory Pype displays a data structure such as a struct or C++the contents of the Class) quit the GDB reverse-Search Reverse Lookup in source file normal expression run executes the program search searches the source file for the regular expression set variable assigns a value to the variable signal a letter Send to the running process step executes the next source line and, if necessary, into the next function undisplay the display command's anti-command, do not show the expressionuntilends the current loop up moves the stack frame so that another function becomes the current function watch sets a monitoring point (that is, a data breakpoint) in the program whatis display variable or function type GDB./Hello #载入程序 Set args1 2 3#设置参数 Run basic GDB command: Core file:1. See if the system allows you to generate a core file #ulimit-a2use the following command to remove the limit so that the system can generate a core file Ulimit-c Unlimited or specify the core file size, such as 1Kulimit-C1024x768gdb debugs The core file. Use GDB to view the core file: Below we can take the core dump in the event of a run-time signal error. After core dump occurs, use GDB to view the contents of the core file to locate the file that is causing the core The row of the dump. GDB [EXECfile] [Corefile] such as: GDB./test Test.core After entering GDB, use the BT command to view BackTrace to check where the program is running to locate the core dump file-line.5To observe a process crash information startup process with GDB in real time gdb-p PIDC Run process to CRASHGDB will display crash information BT in short, the resulting segment error is to access the wrong memory segment, generally you do not have permissions, or there is no corresponding physical memory, especially the access to 0 address. In general, A segment error means that the memory accessed exceeds the memory space given to the program by the system, usually this value is saved by GDTR, which is a 48-bit register, where 32 bits are saved by the GDT that it points to, and the last 13 bits are stored accordingly to the GDT, The last 3 bits include whether the program is in memory and the program's operating level in the CPU, and the GDT that points to is a table with 64 bits in one unit. In this table, you save the code snippet that the program runs and the starting address of the data segment, as well as information about the corresponding segment limit, the page exchange, the program run level, the granularity of the memory, and so on. Once a program has crossed access, the CPU will have the corresponding exception protection, so segmentation fault appeared. The following types of practices in programming tend to lead to segment errors, which are basically caused by using pointers incorrectly1access to the system data area, especially to system-protected memory address write data The most common is to give a pointer to 0 address2) Memory out of bounds (array out of bounds, variable type inconsistent, etc.) access to areas of memory that do not belong to you

GDB core,gdb Debug Daquan, Core file debugging

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.