#import files does not allow the use of break-points during debug

 

I am creating an EA by using several files included in the main one in a tree file structure; the files are also located   in a tree  of directories/sub directories; to avoid long files and to avoid to repeat block of statements. I use the #include statement to include each file with extendion "mqh" in the right position in the calling mqh file. 

As example using statements such as:

#include "\\commonmain\\UpdateIndicatorsV1.mqh"
#include "\\commonmain\\TrendEvaluationV1.2.mqh"
#include "\\commonmain\\StrategyV1.1.mqh"

The same file can be included more than once in the program and in different upper level files such as one for onInit event and for onThick or onTimer events. 

The compilation looks fine and executable is created and can run; "warnings" during compilation does not indicate nothing expecial they are all referring to  implicit data type transformation. The files seem correctly included in the4 nested tree of files, indeed  if I change , for checking the effect, in any "#include" statement  the path of a file,  I got a compilation error that the file cannot be found. Nevertheless if I use debugging and I want to insert breakpoints in some lines of the included files I do not have any effect. The breakpoint doesn't work, the breakpoint azure icon visible when I insert the breakpoint at left of the selected code line, disappears if i start the program in debug mode from the MetaEditor, the program run and the icon simply disappears and I do not get a break.

It looks that  breakpoints are detected only in the main file or in included files that starts with event Handler such as onInit(), onTick() functions (I have included files for  onInit etc.. events: breakpoints set on lines in these files operate correctly during debug).

There can be any reasons for this behaviour on Debugger ? Thanks for help

 
Try using DebugBreak() and see if it works.
 
Dominik Egert:
Try using DebugBreak() and see if it works.

Thanks Dominik, I tried your suggestion.

It seems that the MetaEditor debugger is not able to operate in files where just  blocks of code is present and included with #include statement. Also DebugBreak()   does not work the same as the visual tool of the Debugger.  Whereas, if  DebugBreak() is put within event handler functions or other  custom function, also if these are in separated files and included, it works. More generally it maybe that for breakpoints to effectively operate, they need to be or in the root file or in separated files but within a function;  also within class files they seems to work.

Marco

 
Have you been trying to debug global space?

Or have you been setting breakpoints on lines without execution statement?

Well, both do not work. I don't know any language/compiler/debugger being able of such an operation.


 
Dominik Egert:
Have you been trying to debug global space?

Or have you been setting breakpoints on lines without execution statement?

Well, both do not work. I don't know any language/compiler/debugger being able of such an operation.


I put breakpoints on execution statements and also I tried to use DebugBreak() within the code.  I now embed the various code blocks  inside functions and #include the files containing the functions  instead of  simply code blocks.

Then I just call the functions where I need in the program instead of  using the #include for files with only code blocks. Now the Debugger looks to work properly and I can put breakpoints where I need and stop the program without problem (points where before I was not able to stop the progam). Probably I have tried to do something not allowed, but the compiler was working fine whereas the debugger not.

Instead, by using #include only with files with functions, breakpoints looks to work everywhere inside such functions. Thanks again.

Reason: