VS Arduino
Visual Micro >> General Board >> Compiler switches for debugging.
https://www.visualmicro.com/forums/YaBB.pl?num=1532444764

Message started by Greg Terrell on Jul 24th, 2018 at 3:06pm

Title: Compiler switches for debugging.
Post by Greg Terrell on Jul 24th, 2018 at 3:06pm
We are working on getting the Segger J-Link to display local variables when debugging.  Our current setup requires we build in VS2107 with VM installed, copy the Object file, then in Atmel Studio (supports Segger) use the Open Object File for Debugging.  Yep... that's quite the process.

Elsewhere it was suggested (yet to be determined if effective) to add "-g3 -gdwarf-2" compiler flags to enable the writing of local variable information to the .elf file.  I don't see a place specifically for "compiler" flags, only for "Micro General (Project Global)" flag.

So questions (sorry 3 here)...

1> Are Micro General (Project Global) flags applicable to the compiler when building (I think they are looking at build output but if anyone can confirm that would be helpful).

2> I see on the "Building libraries ..." lines both -g and my additional "-g3 -gdwarf-2", anyone know which -g setting gets used? 

3> Where could I remove the -g and replace it with "-g3 -gdwarf-2"?

For a grand slam answer, anyone get local variable visibility when building with Visual Micro and debugging with Atmel Studio (Segger J-Link).

Thanks in advance for your suggestions or knowledge,
Greg

Title: Re: Compiler switches for debugging.
Post by Visual Micro on Jul 24th, 2018 at 3:29pm
We will have an integrated gdb option in a few months. It's not very stable at the moment so maybe atmel studio is the best solution

Atmel studio can be clunky and the following might not be of use.... You install visual micro into atmel studio then enable use "vmicro>debugger>use atmel studio debugging". You can also follow the guide to use a projectname.cpp instead of .ino files. This combination might avoid the need to use "open object file". The Visual Micro build should put the object file in the place that atmel expects it. If you use visual micro to build in atmel studio then it is recommended to have "show hidden files" enabled so that atmel can find the sources more easily.

You can override any build pattern that is designed into the core you are using. If you switch on "vmicro>compiler>show build properties" you will see the pattern that is specified when cpp, c or s files are built. Copy the entire pattern line into a local project board.txt and you will have overriden the compiler settings. Where the -g setting is used will be shown in the properties.

The visual micro project properties such as flags are used for build. The "(global)" properties are applied always, the (configurations) properties are for the current configuration such as Release or Debug.

Showing local variables might improve with different optimization settings. You can also push prama settings in the code to affect optimization for certain code without having to switch off optimization for all.

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 24th, 2018 at 3:49pm
Thank you for the detailed answer Tim.  We will revisit the VM under Visual Studio or Atmel Studio question internally again, but our toolchain configuration is heavily influenced by our VSTS (source repo) integrations.

Testing the pattern approach... where do I put the board.txt file (is board.txt the actual file name or is it adjusted to the target, in this case a MKR1000)?

Thanks,
Greg

Title: Re: Compiler switches for debugging.
Post by Visual Micro on Jul 24th, 2018 at 3:53pm
Makes sense.

There is a vMicro>add code menu item and tool bar item that creates the board.txt for you in the project folder and includes it in the solution explorer. or can do manually.

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 24th, 2018 at 9:13pm
Tim... We have looked very seriously at our options for our immediate debugging need, including your suggestion to move to Atmel/VM top-to-bottom (BTW this toolchain does successfully address the local variables visibility). 

Our project is a cross platform driver to hardware devices, with ARM Cortex (Arduino SAMD) being an important segment to our potential market.  Being that we are debugging libraries, the task is more challenging. The project's multi-platform architecture would be very difficult to migrate to Atmel at this stage and to the best I can tell after 2+ days of searching there seems no way to get the GCC toolchain to correctly include local variable symbols in a separate object file (.elf) output, so can't blame Atmel Studio here.

So my question... would VM consider using my company LooUQ as a beta user for the upcoming Visual Micro GDB functionality?  We are using VM on Visual Studio 2017 and a Segger J-Link Plus.  Our debugging targets are MKR1000 and Adafruit Feather M0 Express boards.  Compared with the expected bumps and bruises of being an early adopter other solutions are likely to be much more arduous.

If you would consider my request in a positive way, maybe we should move the conversation offline.  The email on my profile is monitored daily.

Thanks,
Greg

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 25th, 2018 at 3:46pm
Last evening I saw that the VM GDB is preview, not prerelease. We would like to work with VM to see if we can get the Segger J-Link to function with VM, seems like a reasonable stretch as the Atmel SAM-ICE is in fact an OEM version of the Segger J-Link Base.  With the demise of the Arduino Zero, we had to switch to outboard debuggers and move from boards with embedded Atmel-EDBG chipsets. However, authoring with VM-Visual Studio and debugging under VM-Atmel Studio is painful at best.

Didn't get very far before 1st speedbump attempting VM-GDB... 

I am unable to see the get the "Microsoft GDB Debugger" to appear at the top of the vMicro > Debugger menu.  I have uninstalled and reinstalled "Arduino GDB for Visual Micro 2017" (v 15.170821.1).

Checking the registry path Computer\HKEY_CURRENT_USER\Software\Visual Micro\Options\Debug General path, I am able to verify the MicroGdb Location is populated and the directory exists on the filesystem. However there is no microdbg.exe file in that directory (I can find other expected items such as OpenOCD).

Following some other posts, I next uninstalled and reinstalled Visual Micro for VS2017 since there was a comment that VM install copied the microdbg.exe file. Nope, still no microdbg.exe file in the registry referenced location.

Should I try to manual place the microdbg.exe file?
Or... is this a symptom of an upstream problem?
If so, were should I find the file?

Visual Micro ver: 1807.8.0
Visual Studio ver: 15.7.5

Thanks,
Greg

Title: Re: Compiler switches for debugging.
Post by Visual Micro on Jul 25th, 2018 at 4:16pm
Did you install android for vs?

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 25th, 2018 at 4:32pm
yes, it had been previously installed for a different project.  But to be sure I also uninstalled the "Mobile developement with C++" workload and reinstalled it, within Visual Studio Installer.


Title: Re: Compiler switches for debugging.
Post by Visual Micro on Jul 25th, 2018 at 4:45pm
have you added a gdb section to a local board.txt or the platform.txt?

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 25th, 2018 at 4:51pm
I opened up the .vsix (aka renamed to .zip), I noticed that you are targeting community, we are running VS Professional. 

<Installation>
    <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0]" />
</Installation>

Title: Re: Compiler switches for debugging.
Post by Greg Terrell on Jul 25th, 2018 at 4:53pm

Tim@Visual Micro wrote on Jul 25th, 2018 at 4:45pm:
have you added a gdb section to a local board.txt or the platform.txt?


I platform.txt is stock (altered but restored prior to today).  There is no board.txt in the project.

Title: Re: Compiler switches for debugging.
Post by Visual Micro on Jul 25th, 2018 at 5:03pm
Ignore the microsoft vsix chaos, you can see what you have installed in tools>extensions and updates also in help>about. You are get an install message when installed and a no ide's to install in when it fails.

The "vMicro>Help>Install Gdb" page contains a link to 3rd party gdb config settings info

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.