NO

Author Topic: quick tutorial on using the debugger  (Read 8873 times)

BluesMatt

  • Guest
quick tutorial on using the debugger
« on: May 17, 2013, 03:13:12 PM »
Hello everyone.

Is there a tutorial that gives the basics of using the debugger?

I am a new C programmer just starting out writing simple console applications for a Windows (DOS) PC (Vista sp2).  I have written a very simple program that generates a list of random numbers and then sorts them lowest to highest. The code works so now I'd like to learn to use the debugger using this code.

thanks in advance

BluesMatt

  • Guest
Re: quick tutorial on using the debugger
« Reply #1 on: May 18, 2013, 02:13:46 PM »
Still looking for help here. 

Is anybody using the debugger?

How do I add a variable to watch?

How do I run the program in debug mode until a certain point in the C source file (not the assembly language file)?

thanks

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: quick tutorial on using the debugger
« Reply #2 on: May 18, 2013, 04:19:28 PM »
Have you tyied to simply click on help menu?
Select contents->poIDE integrated environment
Debugger
Introduction .....  >:(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

BluesMatt

  • Guest
Re: quick tutorial on using the debugger
« Reply #3 on: May 19, 2013, 01:14:48 AM »
Yes of course I clicked on Help>Contents>Integrated Environment >POIDE integrated environment>Debugger>Introduction.  From the words there and in the other related sections, I learned that there is a debugger but not how to use it.  I am also confident that it will meet my needs when I know how to use it.

Starting from the beginning, with a project open, when I press F5 to debug, a dialog box appears telling me that the project's .exe file contains no debugging information.  I don't know if this is a real problem or if there is something I should be doing different when I build the project.

If I continue and rebuild with debugging info, I'm presented with a screen of assembly language code that I can't relate to my C source.  How do I "watch" a variable in my C source? How do I single step my C source (not the assembly)?

I feel like I am stumbling around in the dark.  Care to shed some light?

BluesMatt

  • Guest
Re: quick tutorial on using the debugger
« Reply #4 on: May 19, 2013, 03:58:12 AM »
So with some help from another forum, I was able to get the Codeblocks debugger working. 

What I was doing wrong was not building the project with debugging information (-g compiler switch).  I can't find anything like that in Pelles C.  When I build the project and then try to add watch variables, none are listed.

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: quick tutorial on using the debugger
« Reply #5 on: May 19, 2013, 07:46:43 AM »
Did you follow the link at the end of the paragraph shown below?
Quote
The debugger is used to debug programs. The program must contain debug information in either CodeView or COFF format. See also Debugging projects.

There you find the following paragraph with three additional links to the needed information.
Quote
To be able to debug an executable it must contain debug information; see Compiler project options, Assembler project options, and Linker project options.
Each of these links allows you to set up the debugging information creation manually.

The following paragraph just below the one mentioned above is very useful too.
Quote
There is an add-in sample in the Add-In SDK, available from the download page, that helps you automate the task of switching between a debug build (with debug information), and a release build (without debug information).

If you don't follow all the links, you will miss important information.
---
Stefan

Proud member of the UltraDefrag Development Team

Offline DMac

  • Member
  • *
  • Posts: 272
Re: quick tutorial on using the debugger
« Reply #6 on: May 20, 2013, 05:50:38 PM »
Using the Peles C debugger is not to difficult.  I prefer to use one of the standard  add-ins for switching between build types and I strongly recommend it.

You can enable the add-in by doing the following:

Tools>Customise>Add-ins tab and select "Switch between debug, release, and profile build" from the list.

Click OK.

Now look in the space above the project tree.  There are three new buttons there labled "REL", "DBG", and "PRF".

Click on them to quickly switch between project builds.

As far as the assembly view is concerned.  You got this because you did not set a break point somewhere in the code initially and so the debugger stopped on the first instruction.

You will want to put in some breakpoints before running the debugger.  You can enable and disable breakpoints in the breakpoints window.

The debugger also will drop into the assembler view if the application throws an unhandled exception (null pointer etc...).  If that should happen you can simply step over the code until the display pops back to the source and you can see where in the code the exception occurred.
No one cares how much you know,
until they know how much you care.

ghn

  • Guest
Re: quick tutorial on using the debugger
« Reply #7 on: October 06, 2013, 07:13:51 AM »
Did you follow the link at the end of the paragraph shown below?
Quote
The debugger is used to debug programs. The program must contain debug information in either CodeView or COFF format. See also Debugging projects.

There you find the following paragraph with three additional links to the needed information.
Quote
To be able to debug an executable it must contain debug information; see Compiler project options, Assembler project options, and Linker project options.
Each of these links allows you to set up the debugging information creation manually.

The following paragraph just below the one mentioned above is very useful too.
Quote
There is an add-in sample in the Add-In SDK, available from the download page, that helps you automate the task of switching between a debug build (with debug information), and a release build (without debug information).

If you don't follow all the links, you will miss important information.

Thank you for the details. I missed so much important info. A good lesson.

ghn

  • Guest
Re: quick tutorial on using the debugger
« Reply #8 on: October 06, 2013, 07:17:51 AM »
Using the Peles C debugger is not to difficult.  I prefer to use one of the standard  add-ins for switching between build types and I strongly recommend it.

You can enable the add-in by doing the following:

Tools>Customise>Add-ins tab and select "Switch between debug, release, and profile build" from the list.

Click OK.

Now look in the space above the project tree.  There are three new buttons there labled "REL", "DBG", and "PRF".

Click on them to quickly switch between project builds.

As far as the assembly view is concerned.  You got this because you did not set a break point somewhere in the code initially and so the debugger stopped on the first instruction.

You will want to put in some breakpoints before running the debugger.  You can enable and disable breakpoints in the breakpoints window.

The debugger also will drop into the assembler view if the application throws an unhandled exception (null pointer etc...).  If that should happen you can simply step over the code until the display pops back to the source and you can see where in the code the exception occurred.
thx. I've gone through the debugging process follow your instructions. Thx again.

ghn

  • Guest
Re: quick tutorial on using the debugger
« Reply #9 on: October 06, 2013, 07:33:46 AM »
according to [1]DMac(in this post) & [2]Stefan Pendl(in this post) & [3]commontaterhttp://cboard.cprogramming.com/c-programming/131377-help-debugging-pelles-c-ide.html

1) setup  Add-In SDK  from http://www.smorgasbordet.com/pellesc/ [2]
2)Tools>Customise>Add-ins tab and select "Switch between debug, release, and profile build" from the list.Click OK.[1]
3) make sure that three options are suitable for debugging[2]
<quote>To be able to debug an executable it must contain debug information; see Compiler project options, Assembler project options, and Linker project options.</quote>
4)switch to the debugging build before your debugging.There are  icons at the top of your project tree that lets you select which kind of build you want right off the bat. [3]