Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3678920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:23:55+00:00 2026-05-19T03:23:55+00:00

I have looked for documentation on this and found nothing. I have MinGW installed

  • 0

I have looked for documentation on this and found nothing. I have MinGW installed and it works great. I just don’t know how to use the debugger.

Given some simple code, say in a file called “mycode.cpp”:

int main()
{
    int temp = 0;

    for (int i = 0; i < 5; ++i)
        temp += i;

    return 0;
}

…how would I debug this. What are the commands that I use to debug code with MinGW and GDB in windows? Can I step through the code via the command line like in Visual Studio? If so what commands do I use to do that?

Are there any tutorials for using GDB out there? I couldn’t find any, but if anyone could direct me to one that would be great too. I’m tired of writing tons of std::cout statements to debug complex code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:23:55+00:00Added an answer on May 19, 2026 at 3:23 am

    The first step is to compile your program with -g to include debugging information within the executable:

    g++ -g -o myprog.exe mycode.cpp
    

    Then the program can be loaded into gdb:

    gdb myprog.exe
    

    A few commands to get you started:

    • break main will cause the debugger to break when main is called. You can also break on lines of code with break FILENAME:LINENO. For example, break mycode.cpp:4 breaks execution whenever the program reaches line 4 of mycode.cpp.
    • start starts the program. In your case, you need to set breakpoints before starting the program because it exits quickly.

    At a breakpoint:

    • print VARNAME. That’s how you print values of variables, whether local, static, or global. For example, at the for loop, you can type print temp to print out the value of the temp variable.
    • step This is equivalent to “step into”.
    • next or adv +1 Advance to the next line (like “step over”). You can also advance to a specific line of a specific file with, for example, adv mycode.cpp:8.
    • bt Print a backtrace. This is a stack trace, essentially.
    • continue Exactly like a “continue” operation of a visual debugger. It causes the program execution to continue until the next break point or the program exits.

    The best thing to read is the GDB users’ manual.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked, searched, and read documentation and can't really find anything about this.
I have looked at the documentation on MSDN about these 2 functions. However, I
I have looked at the documentation here: http://docs.python.org/dev/library/xml.etree.elementtree.html#xml.etree.ElementTree.SubElement The parent and tag argument seems
I've downloaded the Windows Media Center SDK and have looked through the documentation, but
Composer is a PHP package manager. I have looked through the documentation here: http://getcomposer.org/
I have looked in the official documentation for python, but i cannot seem to
I have looked through several sites for any useful documentation and have come up
Have looked quite hard for this answer but having no luck. I have 3
I have looked at many other threads that show how to use accelerometer values,
I have looked at questions like this , this , this and this ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.