NO

Author Topic: Debug through include file  (Read 5260 times)

blairon

  • Guest
Debug through include file
« on: February 04, 2012, 04:30:22 PM »
Hello,
in some consol application I can't debug through the include file.
I only debug through the main file.

CommonTater

  • Guest
Re: Debug through include file
« Reply #1 on: February 04, 2012, 04:37:29 PM »
Are these include files also part of your project?

You cannot internally debug library functions (such as printf()) because they are extracted from pre-compiled code in library files that have no debugging symbols.

If the files in question are part of your own project, make sure you've set both the compiler and linker to include debugging symbols for your project and then rebuild the whole project before debugging.



blairon

  • Guest
Re: Debug through include file
« Reply #2 on: February 05, 2012, 09:59:42 AM »
Yes these include files are part of the project and both the compiler and the linker include debugging information.
But still in debug mode, the debugger don't want to step into functions defined in the included files.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Debug through include file
« Reply #3 on: February 05, 2012, 11:58:25 AM »
Example for that.
Code: [Select]
#include <stdio.h>
#include "foo3.c"
int main(void)
{
printf("from main\n");
#include "foo2.c"
foo3();
return 0;
}
Code: [Select]
// foo2.c
printf("from foo2.c\n");
Code: [Select]
// foo3.c
void foo3(void)
{
printf("from foo3\n");
}
May the source be with you

CommonTater

  • Guest
Re: Debug through include file
« Reply #4 on: February 05, 2012, 03:39:02 PM »
Yes these include files are part of the project and both the compiler and the linker include debugging information.
But still in debug mode, the debugger don't want to step into functions defined in the included files.

Ok... lets double check...

On your main menu click Project -> Project Options
On the Compiler tab select Debug Information = Full
On the Linker tab select Debug Information  = Code View & Coff (for x86) or Code View (for x64)
Close the dialog with the OK button.

Now select Project -> Rebuild <project name>

You should now be able to run your entire project in the debugger.  It should step into your project's  files but it will not step into library calls; such as functions from stdio.h or stdlib.h ...

If this still doesn't work, use Project -> Zip Files, and upload the zipped project here... so we can see the problem for ourselves.
« Last Edit: February 05, 2012, 03:45:38 PM by CommonTater »

blairon

  • Guest
Re: Debug through include file
« Reply #5 on: February 05, 2012, 04:21:25 PM »
OK,
I made a simple test,
here it is

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Debug through include file
« Reply #6 on: February 05, 2012, 05:00:41 PM »
OK,
I made a simple test,
here it is
Sorry, but that doesn't make any sense.

For one, you did not include actually your include file into the hw2 project.

Ans second, you seem to have in general misunderstanding about the used of  "#include" in C.
It is not supposed to use to include files like other (mainly interpreted languages), it's intended to be used for "header" fiiles (hence the usual .h extension!), which should contain only definitions for functions, types and variables defined "elsewhere" as well as macros. But never actual code. For that, there should be not even a reason to trace into an "include" file in the first place...

Ralf

blairon

  • Guest
Re: Debug through include file
« Reply #7 on: February 05, 2012, 06:13:37 PM »
OK,
what do you mean by hw2 project,
how do you share a reusable code portion with a lot of different programs?
thanks

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Debug through include file
« Reply #8 on: February 06, 2012, 10:41:54 AM »
This is a known limitation of PellesC IDE.
Unlike M$ VC++, and maybe other debuggers, PellesC doesn't consider source code in header files.
Maybe Pelle will change his mind on next release.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide