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] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) Using and debugging my own library (Read 20857 times)
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Using and debugging my own library
Feb 20th, 2017 at 9:29pm
Print Post  
I've read everything (I think) there is on your site about creating your own library and debugging it .. but I still cannot get it to work Sad 

I have my main project in the solution, I've added a local library project to my solution, added my own library source files to it, added the reference to the library project the main project and everything compiles and runs fine on my Arduino Mega. 

I can also set breakpoints in my main project code and they are working.

But when i set a breakpoint on a library source line, it does not work. As I understood it, a of version 1702.18.0 of the extension this should work.

What am i doing wrong?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #1 - Feb 20th, 2017 at 9:41pm
Print Post  
Hi,

Debug of local libs has been working for a long time (supposedly).

It's possible something broke with libs in the src\_micro-api\libraries folder if debug isn't working. I assume that's where your library is?

Recent versions of visual micro support shared c++ projects as arduino libraries so you can put the libs anywhere and still debug them. The way they work is much better and you still work with standard format arduino library code.

There is an initial doc here. http://www.visualmicro.com/post/2017/01/16/Arduino-Cross-Platform-Library-Develo...

There are many benefits to this new approach. For example

  • the solution explorer is easier to use/organize because libraries show as projects
  • multiple projects can use the same library
  • your own or arduino libraries can be debugged
  • allows arduino libraries to be used from any location and version
  • integrates better with source control

I will test debug of old style local libs but I highly recommend this new way of working. It takes advantage of core visual studio functionality instead of jamming the files in a "special" folder below the project.

« Last Edit: Feb 20th, 2017 at 9:46pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #2 - Feb 20th, 2017 at 9:46pm
Print Post  
Thanks for your quick reply!

I have already read the link you provided but it still didnt work. Obviously im doing somethig wrong here. I'm a professional software developer (using Eclipse and Embarcadero RAD Stuido), but have never worked with Visual Studio so I guess thats were my challenge lies Smiley.

I'll try following the steps in that page again, see if I forgot something and will get back to you.

In the meantime any tips are welcome Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #3 - Feb 20th, 2017 at 9:50pm
Print Post  
Can you create a zip with a solution you have saved along with a test empty master project and test library. So I can see the configuration and spot the issue.

If you can email to info[at]visualmicro.com along with a link to this post

Also confirm the library break-point is in a .cpp file?

Thanks

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #4 - Feb 20th, 2017 at 11:58pm
Print Post  
Thanks for sending the code. Yes all code I receive is private and deleted after use has ended.

The solution needs to be saved otherwise it doesn't contain any breakpoints.

Can you tell me which file and line number you added a breakpoint to?

I did just run a simple test with a standard .cpp class in a shared library but that was not inherited. I put a breakpoint on i++ and called the setup from the .ino code. The breakpoint was hit correctly.

void TestLib1::setup() {
     int i = 0;
     i++;
};

Your project appears configured correctly so there must be some issue with break point location. Is the breakpoint code line a simple line or an if/condition?

If the breakpoint where a Serial.print() line could work?

  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #5 - Feb 21st, 2017 at 7:19am
Print Post  
Hi Tim,

I did save the solution (CSense.sln), at least when I reopen Visual Studio my breakpoints are still there.

I've put one in CSense2.ino on line 35, one onf CSense.cpp line 37 and one on Sense.cpp line 19.

CSense2.ino::setup()  will call CSense::setup() which will call Sense::setup() so they all three should be reached.

I'm not with the hardware at the moment so I can't test any alternatives util tonight.
  
Back to top
 
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #6 - Feb 21st, 2017 at 7:20pm
Print Post  
Tim, I just sent you another rar, including a simple test project in the solution ...
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #7 - Feb 21st, 2017 at 8:13pm
Print Post  
Thanks for sending the files. Sorry for the confusion. I think microsoft have moved the breakpoints to a file in the .vs sub folder.

What libraries have you installed and from which location?

Thanks

ps: the breakpoint in the .h will be ignored
« Last Edit: Feb 21st, 2017 at 8:13pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #8 - Feb 21st, 2017 at 8:17pm
Print Post  
All libs are installed in the Arduino installfolder, which is D:\Arduino.

As far as I know, I didnt set a breakpoint in a .h file .. did I?

Breakpoints are saved in a .suo file located in the .vs folder next to the solution file, according to recent VS documentation
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #9 - Feb 21st, 2017 at 8:25pm
Print Post  
Are you saying the TinyGPSSensor was installed with the IDE and that you didn't install it yourself?


It's not an issue because the breakpoint should be ignored but the last upload shows this break-point at line 24

It's also invalid because serial.print can not work in this location

Code
Select All
 <BreakPoint Index="3" Name="CSense.h, line 24" Id="1d008f83-ca3e-4390-9a5b-04dbcdb8b8da" Enabled="1" Message="" MessageTextType="2" PreProcessedMessage="" Condition="" ConditionType="1" CurrentHits="0" File="d:\developme.................\csense2\csense.h" FileLine="24" FileColumn="1" FunctionName="" FunctionLineOffset="1" FunctionColumnOffset="1" HitCountTarget="1" HitCountType="1" Language="C++" LocationType="3" Tag="&lt;vmbp Id='bb2bb496-bdae-47ce-8f1e-830ae163fc72'/&gt;" Type="1" ToString="System.__ComObject" BreakWhenHit="1">
        <Source>17	#include &lt;ThermistorSensor.h&gt;
18	#include &lt;RealtimeClockSensor.h&gt;
19	//#include "TinyGPSSensor.h"
20
21	class CSense : public Sense {
22	public:
23
--&gt;24		ThermistorSensor fridgeTemp{ ..............
27
</Source>
      </BreakPoint> 

« Last Edit: Feb 21st, 2017 at 8:26pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #10 - Feb 21st, 2017 at 8:25pm
Print Post  
Rar with the lib files needed
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #11 - Feb 21st, 2017 at 8:28pm
Print Post  
Tim@Visual Micro wrote on Feb 21st, 2017 at 8:25pm:
Are you saying the TinyGPSSensor was installed with the IDE and that you didn't install it yourself?


TinyGPSSensor.cpp and .h are files I wrote, and are part of the SenseFrameWork local library
« Last Edit: Feb 21st, 2017 at 8:29pm by Bas »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #12 - Feb 21st, 2017 at 8:32pm
Print Post  
Ok thanks. I will have a run through it in a few hours
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #13 - Feb 21st, 2017 at 9:53pm
Print Post  
How about StandardCplusplus.h

Where should that be located?

I have found a few confusing things with shared lib compilation. Possibly not directly related to debug but made them hard to configure. I will write more in the release notes when we find this issue.
  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #14 - Feb 21st, 2017 at 9:54pm
Print Post  
StandardCPlusplus should be in Arduino\libraries
  
Back to top
 
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #15 - Feb 21st, 2017 at 10:04pm
Print Post  
I'm having another problem, but maybe I should create a new thread for this ....

If I look at the file properties of the SenseFramework files that are in the "External Depencies" group of my master project, they are referenced by absolute path.

If I move the complete solution, including all subfolders and hidden folders somewhere else, it doesnt compile anymore because it cannot find the absolutely referenced files. How can I refresh the references to my own lib files in the Extrernal dependencies folder of my main project?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #16 - Feb 21st, 2017 at 10:09pm
Print Post  
I found your earlier rar thanks so can see the libs.

Can you please switch on vMicro>compiler>verbose and also the "show build properties" setting on same menu.

Then build and email the output as a .txt to info[at]visualmicro.com

Thanks
  
Back to top
WWW  
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #17 - Feb 21st, 2017 at 10:15pm
Print Post  
mailed the log!
  
Back to top
 
IP Logged
 
Bas
Junior Member
**
Offline


Posts: 50
Joined: Feb 20th, 2017
Re: Using and debugging my own library
Reply #18 - Feb 21st, 2017 at 10:26pm
Print Post  
(while waiting .. and browsing around a bit ...)
I noticed that all paths in the XML files in the _vm folder are absolute paths. Could this be the cause that moving a solution to another location on the disc will create all kinds of problems?

Edit: mmm now I remember I read somewhere that  the sketchbook folder set in the Arduino IDE is used for locating local libraries .....
« Last Edit: Feb 21st, 2017 at 10:33pm by Bas »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using and debugging my own library
Reply #19 - Feb 21st, 2017 at 11:46pm
Print Post  
Hi,

I think this just might be a whole load of confusion because of some conflict between new visual micro features and some lack of understanding about the quirks of arduino.

1)
First of all remove the "src\_micro-api-readonly" branch from your main project. That folder was added via "Micro>Toggle Hidden Files" and you are more advanced + want edit debug to the "src\_micro-api-readonly" section is causing a lot of confusion. The toggle hidden files has some cross over with using shared library projects which visual micro will work around more seamlessly in future versions. For your current test you do not want that code toggled in.

2)
Arduino does not have concept of local libraries. It has libraries supplied with the ide and libraries in the sketchBook\libraries folder that you install yourself manually or via the library manager .

Visual micro will use the sketchbook path that is configured in the arduino ide unless you override it in visual micro. It defaults to myDocuments\Arduino therefore "user libraries" are in myDocuments\Arduino\Libraries

It doesn't matter if libs are placed below id or sketchbook but it's best to use sketchBook for your user installed libs

3)

You can forget the term local libraries. Visual Micro docs will soon remove the words. With the addition of c++ shared projects (as you have used for your library) a library can be located anywhere. So that can be a parent folder to the project, sketchbook\libraries, ide\libraries. 

The libraries can be easily discovered/known because they are added as References to the project as you have done. That is why they can be located outside of the "known arduino" locations.

4)

I have just built your project with debug in the Sense.cpp. It's easy to see if debug commands are being added to the compiler source if you switch on verbose compile or the show build folder compiler property. In that case the build output will show the temp folder used for the build. Your library will be in a sub folder below and a copy of sensor.cpp in the \src folder below that. In sensor.cpp you should see an extra include for vm_dbg.h and some debug commands where you requested the breakpoint to be located.

If you are not seeing the debug command I suspect that visual micro has detected "toggle hidden files" containing the same library and assumed it is read-only and not a candidate for debug. This is why I suggested removing the src\_micro-api folder for now.


5)

I found a bug that you have worked around and actually its caused you to improve compile speed. With the new shared library system you had to switch off "vMicro>Compiler>Deep Search" unless the header that has the same name as the shared library was #included above other headers from the same library. So #include <SenseFramework.h> would have need to be before the first include which is <TinyGPSSensor.h>

6)

With a paid license you can switch on "vMicro>Compiler>parallel build". This will improve compile time when lots of files have to be rebuilt.

  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint