Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Debugging Libraries locally? (Read 21871 times)
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Debugging Libraries locally?
Mar 7th, 2013 at 4:53pm
Print Post  
I noted (and read) the question / comment regarding library support but have a question.  If I move the library files (.cpp and .h file) to the same folder that my .ino file resides I am able to set breakpoints in the 'library'. I had to put the full path to the include file to compile properly, if I changed the VS properties value it is lost as soon as you compile. 

Did you expect this behavior? I would hate to move all libraries local but maybe this is an temporary solution to the problem?

Thanks,

Don
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #1 - Mar 7th, 2013 at 5:42pm
Print Post  
Hi,

Yes this makes sense as a temporary solution however it is perfectly normal to have these source codes locally and does not require full path qualification of includes.

You do not need to use any of the c++ settings and as you found this would not work anyway.

The source files should be directly in the sketch folder with the arduino source code then you can add a standard #include "filename.h" without full path.

If you do this you should remove the library from the arduino library folder otherwise this might cause the confusion you encountered.
« Last Edit: Mar 7th, 2013 at 6:04pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #2 - Mar 14th, 2013 at 6:23pm
Print Post  
I am still having issues with the DevS environment. The compiler generates non-sense errors indicating that variables are not defined in modules that do not reference them. If I attempt to compile with the standard Arduino tool chain it works fine. Sometimes exiting the DevS and re-entering will solve the issue; other times it seems that if you keep Serial.XXX commands and OR breakpoints away from the 'offending' code areas the problem goes away. Have you seen this?  I love using the DS however with this behavior I have had to revert back to print debug...


Example output

      0        18956            0        18956         4a0c

Compiling debug version of 'pelco_status_monitor' for 'Arduino Mega 2560 or Mega ADK'
Emonlib.cpp : : In member function 'double EnergyMonitor::calcIrms(int)':
Emonlib.cpp : 'tst' was not declared in this scope
Error compiling

There is not a variable or function (or comment for that matter) in the Emonlib.cpp class.. Or anywhere in my code for that matter.

Thanks for the support,
Don
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #3 - Mar 14th, 2013 at 7:21pm
Print Post  
Hello,

It would help if you could update us as to if you have normal <filename> includes or still using full path qualifications.

Please confirm the following:-

1)

First off please set (Micro Debug) = false and do not use the debugger until VS works the same as the Arduino IDE. This will allow us to compare apples with apples  Smiley

With (Micro Debug) = False breakpoints are ignored so will not need to be considered in our discussion.


2)

May I see the full compiler output please. Can you confirm that project property (Validation Skip = False)?

...

Once we have established these answers I will have a couple more questions that will help us understand why you have this problem.

Thanks
  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #4 - Mar 14th, 2013 at 9:07pm
Print Post  
Thanks for the quick response; before I answer your questions I have some additional information...

I have found that if I delete ALL breakpoints the problem goes away, compilation resumes as expected and the resultant program is loaded to the target.  At that point in time I can begin to add breakpoints again with proper operation until some later point in time (yet to be determined).

So to answer your questions:

0) I am using proper #includes now "x.h" with a small change to the development studio configuration. I configured the 'Additional Include Directories' field of the project properties to point to the proper directory. Even with this setting though sometimes the DevStudio will place the red 'squiggly' lines under the #include statement in the source code. A hover over the line results in a message indicating that the header cannot be located. However a compile results in no errors or warning and the code is operational.

1) With the above revelation(s) RE removing breakpoints do you still need this information. I will certainly do this if (or when) the problem re-occurs.

2) The information I pasted into the last 'report' was the complete output of the compiler (Micro Build window) with the default settings. Do I need to crank up the warnings to get you more? (warning is currently set to the default of Level3 (/W3)

Thanks again for your help, I look forward to using this product...
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #5 - Mar 14th, 2013 at 9:48pm
Print Post  
Hi thanks for all of the info, I am starting to see some reasons for the problems, hopefully the following info starts to help.

1 - VS C++ Settings (should not be altered unless to tweak intellisense/editor/ui controls)

When working in an Arduino projects you must ignore all the VS C++ settings. The   'Additional Include Directories' is automatically maintained by Visual Micro, this is how we make intellisense work correctly for Arduino core and libraries. So you will see erratic results if you are changing this yourself. Further more Visual Micro entirely re-routes the VS compile process. This means that VS C++ warning levels, include directories and everything in VS is ignored when we compile. This is important because Arduino does not compile the same way a VS C++ project compiles and we are 100% compatible with Arduino.

Therefore any changes you have been making to the C++ project settings will only have confused or altered the VS intellisense and will not affect compile.

2 - Compiler Warnings

Should you want to see Arduino warnings there is an option under Tools>Options>Visual Micro>Compiler to enable warnings in all of your Arduino projects. I suggest that you leave warnings off simply because the Arduino core throws quite a few warnings all of which can be ignored.

3 - You have confirmed that if you disable debugging (or remove all breakpoints) Visual Micro compiles the same as the Arduino Ide. Great! and none of the C++ project properties affect this. 

The Arduino Ide does not have such as thing as a "project". When you compile with the Arduino Ide it looks at the files in the sketch folder and performs a compilation based on every valid source file. When you compile Arduino in Visual Studio it does the same. 

This is also why, when you re-open an Arduino project in Visual Studio, the sketch directory is scanned and any new or missing sources are added/removed from the VS solution explorer. This ensures that your VS projects are always Arduino compatible, removes possible confusion associated to using VS project files and allows the sketch/projects to be compiled in either Ide at any time.

4) I asked about the debugger setting "Validation Skip" because the compiler output you posted shows only a debug compile. The standard config for Visual Micro performs two compiles (Release and Debug) when you start debug. 

The reason being that to work the debugger has to inject code into a temp copy of your program. If your Arduino program has an error in it then the injected code will confuse the error messages so for this reason, for newer users, the default is to attempt a release compile and only perform a debug compile if that is successful.

I suggest switching back to default "Validation Skip=False" if you encounter any future issues. Whilst you did check that the program compiled in the Arduino which proves that your program would have validated correctly I thought it might help in the future to explain this.

5)

I think the problem was that a break point pointed to an old source file in a different location. I suspect you might have had a break point on some source or library code with the same name as a source file in the current sketch. That the debugger thought it was safe to process the file when it should have ignored it. Visual Micro does protect for this problem because it has to support multiple projects in a single VS solution.  As you know breakpoints are stored in the VS solution and not with each project. This means that it is possible to have a list of invalid breakpoints but again Visual Micro should have ignored them. I will look at the Visual Micro break point management system to see how that could happen.

Summary

I think/hope this makes sense and that now your project has become stable in terms of libraries and source code locations that the problem isn't a problem any more.

The wiki on the main visual micro web site does contains some documents that might help but needs improving.
  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #6 - Mar 14th, 2013 at 10:50pm
Print Post  
Ok, more information for you...

I have discovered that if I clear breakpoints all is well. I can even start adding breakpoints back into the equation and all is also well..... Sort of..

I think I have discovered the issue; if I set a breakpoint and configure the 'when hit' to print a variable with the {} braces AND if the variable is of a certain type (String is one of them) the VS cannot compile properly resulting in the following:

Compiling 'pelco_status_monitor' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 21610 bytes (of a 258048 byte maximum) (1.9811133 secs)

AVR Memory Usage
----------------
Device: atmega2560

Program:   21610 bytes (8.2% Full)
(.text + .data + .bootloader)

Data:        970 bytes (11.8% Full)
(.data + .bss + .noinit)

text         data          bss          dec          hex      
      0        21610            0        21610         546a

Compiling debug version of 'pelco_status_monitor' for 'Arduino Mega 2560 or Mega ADK'
SDI_Monitor.cpp : : In member function 'bool SDI_Monitor::sendTemperatureStatusMsg(double)':
SDI_Monitor.cpp : call of overloaded 'print(String*&)' is ambiguous
Print.h : print(char) <near match>
Print.h : print(unsigned char, int) <near match>
Print.h : print(int, int) <near match>
Print.h : print(unsigned int, int) <near match>
Print.h : print(long int, int) <near match>
Print.h : print(long unsigned int, int) <near match>
Error compiling

If I turn off 'Micro Debug' as you suggested the compile will succeed. If I modify the 'when  hit' condition to print say an int or simply a string no problem.  Seems like maybe an issue with the Expressions window maybe?

Hope this helps, I certainly appreciate your quick responses.

Don
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #7 - Mar 14th, 2013 at 11:34pm
Print Post  
Hi Don,

Sounds like you might have the wrong version of the debugger installed.

Please uninstall the debugger using Control panel>add/remove features

To see which version of vm you have installed, "Tools>Options>Visual Micro>Version" and install the matching debugger from the beta page.

Does that fix it? What version of vm are you running?

Thanks
  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #8 - Mar 15th, 2013 at 1:35pm
Print Post  
I have version 1.1212.30 installed (as per Tools>Options>Visual Micro>Version) which I downloaded last week from your web site.  A strange note though; the control panel (Uninstall or change a program) indicates version 12.12.3004 (possibly a display issue?), size 2.83 MB installed on 3/6/2013 for 'Visual Micro for Arduino'

Additionally I have 'Visual Micro - Debug Tools and Visualizations' installed version 12.11.1301. (882 KB)

If this is not the latest could you provide me with either the download or a link to the latest?

Thanks,

Don
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #9 - Mar 15th, 2013 at 3:18pm
Print Post  
Hi, the versions sound fine. I'll try a {String} over the weekend but it was used in initials tests. However the data type handling has been extended since then so maybe String objects are now a problem.
  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #10 - Mar 15th, 2013 at 4:04pm
Print Post  
Got some additional info that may be related.

Consider the following:

           char response[32];
           memset(response, 0, 32);

           sprintf(&response[0], "%f", 12.34);

           if (response[0] != '1'){
                 Serial.println(F("0 mismatch"));
                 Serial.println(response[0], HEX);
           }

           if (response[1] != '2'){
                 Serial.println(F("1 mismatch"));
                 Serial.println(response[1], HEX);
           }

           if (response[2] != '.'){
                 Serial.println(F("2 mismatch"));
                 Serial.println(response[2], HEX);
           }

           if (response[3] != '3'){
                 Serial.println(F("3 mismatch"));
                 Serial.println(response[3], HEX);
           }

           if (response[4] != '4'){
                 Serial.println(F("4 mismatch"));
                 Serial.println(response[4], HEX);
           }


Output:

0 mismatch
3F
1 mismatch
0
2 mismatch
0
3 mismatch
0
4 mismatch
0

Seems like a library issue with floating point; may be related to the break point issue?

Thanks,

Don

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #11 - Mar 15th, 2013 at 5:56pm
Print Post  
Hi Don,

I have now tested the debugger with various data types and find it works fine. So something else is going on here.

Would you please zip and email your sketch and try to also include the solution with breakpoints in the places that you have set them. info[at]visualmicro.com

Please also tell me the version of VS and also which version of Arduino you are using.

Thanks
« Last Edit: Mar 15th, 2013 at 5:59pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #12 - Mar 15th, 2013 at 9:16pm
Print Post  
Ok, I have finally created a small example that illustrates the issue.  I have included two modules:

DIAGNOSTIC_UTILS
   Simple helper methods overloading some of the Arduino print functions etc.

CircularBuffer
   Buffer support.

I am sending you (via email) the VS solution and all files I used to create.
I have set several breakpoints (they are set in the solution). If these breakpoints are set AND if the 
'Micro Debug' switch is set to FULL the compile will fail with the following output:

Compiling 'tst' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 11112 bytes (of a 258048 byte maximum) (0.6320362 secs)
Compiling debug version of 'tst' for 'Arduino Mega 2560 or Mega ADK'
tst.ino : : In function 'void loop()':
tst.ino : expected `)' before ';' token
Error compiling

If you disable 'Micro debug' the solution will compile and download with no problems.

My VS version is:

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel

I am using a Arduino Mega 2560 with Arduino 1.0.3

Don


« Last Edit: Mar 15th, 2013 at 10:46pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #13 - Mar 15th, 2013 at 10:43pm
Print Post  
Hi Don,

Okay the problem is that you have a syntax error in your breakpoint at line 42.

Your solution didn't contain any breakpoints when it arrived so I used the log files in the "Visual Micro" folder to manually add your breakpoints one at a time. So thanks for including the sub folders in the zip they are always useful  Smiley

The project compiled fine for debug until I added the Breakpoint at line 42. I think for long breakpoint "when hit expressions" it is a good idea to make sure the "When Hit" column of the BreakPoints list is wide enough to see the code/expression. 

You can see the problem that strlen(buff is missing the closing bracket...

Code
Select All
calling showSprintfFailure(), {status} {strlen(buff} 



Syntax errors in breakpoints are not reported very clearly which is why the default plugin performs both a "Release" and a "Debug" compile. 

As stated previously the default project property setting of "Validation Skip" is False, this means that you will see two complitaions in the output below when you perform a debug/upload compilation.

Notice below that first we get a successful release compile in under half a second with size 9390 bytes. Then we see the debug compile fails.

Code
Select All
Compiling 'tst' for 'Arduino Uno'
Binary sketch size: 9390 bytes (of a 32256 byte maximum) (0.453 secs)
Compiling debug version of 'tst' for 'Arduino Uno'
tst.ino : : In function 'void loop()':
tst.ino : expected `)' before ';' token
Error compiling 



Visual Micro performs these two compilations so that you can know that an error in the "debug" compile is a result of a break point invalid Breakpoint "placement", "when hit" and/or "condition".

I hope this makes sense and that you find everything is working well.

Look forward to hearing your thoughts

Thanks

ps: I noticed you have a VS temp folder called ipch below your sketch. VS creates these automatically which is a pain because they are difficult to delete. This article tells you how to stop ipch folders from being created below C++ projects

pps: I've cleaned up the thread a bit so it is helpful to others. Hope that is okay
« Last Edit: Mar 15th, 2013 at 10:47pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #14 - Mar 19th, 2013 at 1:46pm
Print Post  
Tim,

Yes that seems to 'fix' my problem with the breakpoints. Did you get a chance to determine why the sprintf did not function as expected?

Thanks,

Don
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #15 - Mar 19th, 2013 at 8:28pm
Print Post  
Hi,

In the background Visual Micro uses programs such as avr-gcc to compile in the same way as the Arduino IDE so for a non-debug compile I would not expect to see any difference.

Can you confirm if the sprintf is working okay in non-debug mode?

Thanks

  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #16 - Mar 19th, 2013 at 10:24pm
Print Post  
Testing with the method (showSprintfFailure(void)) in the test solution I sent you I found that the sprintf failed with either 'Micro Debug 'Full' or 'None'.

BTW, having very good luck with the debugger today; nice! Smiley

Don




  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugging Libraries locally?
Reply #17 - Mar 19th, 2013 at 10:59pm
Print Post  
Good to hear the debug is working well.

The plugin doesn't have any control over how sprintf is compiled. When you compile, in the background, the plugin uses exactly the same programs and syntax to compile as the Arduino IDE.

Therefore this must be something else. If you get time to try it again it will be appreciated. Thanks
  
Back to top
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #18 - Mar 20th, 2013 at 1:54pm
Print Post  
You are correct; I have re-tried the code fragment with the standard Ardunio tool chain and the issue must be with either the sprintf library or most  likely the floating point emulation.

I'll try to post this issue to the Arduino forum.

Thanks,

Don
  
Back to top
 
IP Logged
 
Don Moser
Junior Member
**
Offline


Posts: 16
Joined: Mar 7th, 2013
Re: Debugging Libraries locally?
Reply #19 - Mar 20th, 2013 at 2:28pm
Print Post  
BTW, the Arduino forum has reported this issue; apparently there is no floating point support for the sprintf / printf library calls.

Don
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint