Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
VisualMicro Shared Project and breakpoint debugging (Read 322 times)
new_user
Newbies
*
Offline



Posts: 4
VisualMicro Shared Project and breakpoint debugging
Apr 25th, 2019 at 7:11am
 
Hello Tim,

I'd appreciate your help with this. I've tried many ways unsuccessfully to debug source code contained in a "Shared Project" (not a shared library). It is relatively easy to implement 'Shared Projects', however when doing so, VisualMicro won't break on breakpoints created in .cpp files contained in the external "Shared project". I've come across the following discussions which seem to suggest solutions, however none have worked for me. Could you please explain in step-wise fashion how to get visualmicro breakpoints to break in .cpp code contained in a "Shared Project".

Here are the solutions I've come across but unfortunately none work for me, for reasons I do my best to explain at the bottom.

(1) There is the facility to create shared project code in visual studio. File>new>c++>general>shared project. This will cteate a special/simple type of project in a location you choose. The project does not build on its own, instead you simply right click the References node in an arduino projects and then click "Add reference>shared project". That then gives you a tidy way to group shared code and also gives debug facility.
https://www.visualmicro.com/forums/YaBB.pl?num=1493462145

(2) It's a popular request to share code between Arduino projects. To share code just as if it has been added directly to the project as opposed to using a seperate library.

In Visual Studio use the "Add Existing" options to add existing code from an alternative location. NOTE: Click the "Add as link" option when adding the code.

You should see a link to the source is added to the current project. #include linked code as if it exists in the project folder (without path qualifier).
https://www.visualmicro.com/post/2016/05/27/Sharing-code-between-projects.aspx

(3) As you say, using shared (existing) code links does not provide debugging and might never do.  However he is a slightly better way to work that you might find easier anyway. There is the facility to create shared project code in visual studio. File>new>c++>general>shared project. This will cteate a special/simple type of project in a location you choose. The project does not build on its own, instead you simply right click the References node in an arduino projects and then click "Add reference>shared project". That then gives you a tidy way to group shared code and also gives debug facility.

A shared project is merged into the temp build folder and compiled with the arduino project code just as if you had included the code directly in the arduino project. The folder structure of a shared project is adhered too which is not the case for linked sources which are always copied into the project root in the temporary build folder. Adding a reference to a shared project from an Arduino project automatically makes all code from the shared project available to the Arduino project.
https://www.visualmicro.com/forums/YaBB.pl?num=1493462145

(4) You must not use "Add Existing Item" to add sources to any of your projects. You do not need that feature and I think you might be using it because you are missing a small point.

As I explained previously "Add Existing Item" adds a link to source code that is not deemed a real part of the project code.
[/url]https://www.visualmicro.com/forums/YaBB.pl?num=1493462145[url]

(5) When you have "Show all files" selected you will be able to see a physical file and folder view in the solution explorer. In the view will be the source code you have placed in the respective project folder(s). Some of the source code will have colored icons and some will not. The source that does not is NOT included in the project. You can right click the sources and click "Include in Project".

Using "Include in Project" instead of "Add Existing Item" has major differences. "Include in Project" makes the sources code a part of the project. When you un-select "Show all files" you will see that the sources are included in the solution explorer view as you would have expected.
https://www.visualmicro.com/forums/YaBB.pl?num=1493462145

Here are my experiences after trying to implement your instructions for how to debug "Shared Project" code.

(1) Method 1, unfortunately doesn't work for me. I've done as you've suggested and in my main visualmicro project, I click on 'Solution Explorer', then Right click 'Project', then Left click "Reference' and the "Add Reference' window then opens. However Inside the "Add Reference" window, the 'Projects->Solution' and 'Shared Projects->Solution' links are empty, and it says "No items found". Using this method what do I need to do (or how do I) get my "Shared Projects" to show in the "Add Reference" window?

(2) This works fine for sharing the files, however unfortunately the resulting shared files are not properly debugged, in that, visualmicro debugger won't break on break-points in the Shared Project source code files. Am I doing something incorrectly? Also to be noted, I've tried enabling "vMicro->Debugger->"Allow Library Debugging". however, even then Breakpoints in the "Shared Project" code are not hit.

(3) Same as (1), creating "Shared Project" works fine except visualmicro debugger won't break on breakpoints created in the Shared Project code".

(4) This is confusing, because "Add Existing Item", seems to be the only way to access/reference 'Shared Code'. If this is not the correct way, how ought I add "Shared Project" code to an existing visualMicro project?

(5) This also unfortunately doesn't work for me, for when I click on "Show all file" in the "Solution Explorer" there is no facility to select folders outside the root folder tree of my current project, thus it seems, at least I've not found a way, when using "Show all files" to 'right click on outside sources and click "Include in Project"',  because I'm not able to navigate to where my external 'Shared Files' are located. So I'm stuck for this reason. Thus which ever way I've tried I keep hitting dead ends. I'd much appreciate your help with this.

I can email you an example project if this would be helpful.

Cheers, Greg



Back to top
 
 
IP Logged
 
new_user
Newbies
*
Offline



Posts: 4
Re: VisualMicro Shared Project and breakpoint debugging
Reply #1 - Apr 25th, 2019 at 11:35am
 
Hello again Tim,

Glad to say I've got it working! In next few days, I'll put together a step-by-step description of how to do it and post it to this forum for others who may similarly struggle to get VisualMicro debugger (breakpoints) working with 'Shared Projects'.

All good, thanks.

Cheers,

Greg
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10381
United Kingdom
Re: VisualMicro Shared Project and breakpoint debugging
Reply #2 - Apr 25th, 2019 at 3:42pm
 
Oh! Sorry for the delay but that's really good to hear thanks. We want to make this really simple and obvious so your notes will be very much appreciated and will help us change for the better.

We are in the process of re-making the documentation so it's good timing.

Out of interest, which board are you working with?
Back to top
« Last Edit: Apr 25th, 2019 at 3:43pm by Visual Micro »  
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print