linux-c/c++ Debugging tool GDB, DDD small test

Source: Internet
Author: User

linux-c/c++ Debugging tool GDB, DDD small test

Original link: http://deepfuture.iteye.com/blog/749148

Blog Category:
    • C++/c/lisp
Cc++c#linuxubuntu

One, GDB, debugging in the Shell window

MAIN.C content:

Main.c

#include <stdio.h>

int main ()

{

int y=0;

for (int i=0;i<10;i++) {

Y+=i;

}

return 0;

}

Deep future technical original articles, such as reproduced, please specify the source http://deepfuture.iteye.com/

Compile:

[Email protected]:~/test$ gcc-ggdb-std=c99-o main MAIN.C

Start GDB

1. gdb Execution file name

[Email protected]:~/test$ gdb Main

GNU gdb (GDB) 7.1-ubuntu

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 "I486-linux-gnu".

For bugs reporting instructions, please see:

Reading symbols From/home/deepfuture/test/main...done.

2, list for listing source code

(GDB) List

1

2 #include <stdio.h>

3 int main ()

4 {

5 int y=0;

6 for (int i=0;i<10;i++) {

7 y+=i;

8 }

9 return 0;

Ten }

3, run (GDB) runstarting program:/home/deepfuture/test/main program exited normally.4, Exit gdb (GDB) quit5, start gdb, and then set the file to be loaded (gdb) file mainreading symbols From/home/deepfuture/test/main...done. 6. Set breakpoints, use break line number (GDB) Listwarning:source file is more recent than executable.12#include <stdio.h>3int main ()4 {5int y=0;6for (int i=0;i<10;i++) {7y+=i;8 }9return 0;10 }(GDB) Break 7Breakpoint 1 at 0x80483ca:file main.c, line 7. 7, running, run (GDB) runstarting Program:/home/deepfuture/test/main Breakpoint 1, Main () at main.c:77y+=i;8, leave this breakpoint, continue to run (GDB) ccontinuing.9, watch variable (gdb) watch Yhardware watchpoint 2:y10, check variable (gdb) ccontinuing.hardware Watchpoint 2:yOld value = 1New value = 3Main () at main.c:66for (int i=0;i<10;i++) {(GDB) ccontinuing. Breakpoint 1, Main () at main.c:77y+=i;(gdb) Ccontinuing.hardware watchpoint 2:yOld value = 3New value = 6Main () at main.c:66for (int i=0;i<10;i++) {Second, DDD, can be used in the selection of a row or a variable, watch,break and other buttons, very convenient right middle of the panel is some process debugging

Graphical mode debugging

linux-c/c++ Debugging tool GDB, DDD small test

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.