C Basics-GDB Mode tool

Source: Internet
Author: User

installationBrew Install GDBsingle-step and trace function calls
/* MAIN.C--Learn gdb Debug tool */
#include <stdio.h>intAdd_range (intLowintHigh ) { inti, sum; for(i = low, I <= high; i++) Sum= Sum +i; returnsum;}intMainvoid){ intresult[ -]; result[0] = Add_range (1,Ten); result[1] = Add_range (1, -); printf ("result[0]=%d\nresult[1]=%d\n", result[0], result[1]); return 0;}

First step: Generate the target file using-G

Gcc-g Main.c-o Main

? ch02 gdb file nogood.c

GNU gdb (GDB) 8.0.1

Copyright (C) Free Software Foundation, Inc.

License gplv3+: GNU GPL version 3 or later

This was free software:you was free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. Type "Show copying"

and "Show warranty" for details.

This GDB is configured as "x86_64-apple-darwin16.7.0".

Type "Show Configuration" for configuration details.

For bugs reporting instructions, please see:

Find the GDB manual and other documentation resources online at:

For help, type ' help '.

Type "Apropos word" to search for commands related to "word" ...

"/usr/bin/file": Executable format:file format not recognized

"/USERS/DAVID/DESKTOP/C-PRIMER-PLUS-SOURCE-CODE/CH02/NOGOOD.C" is not a core dump:file format not recognized

(GDB)  

C Basics-GDB Mode tool

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.