Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Error when trying to debug according to SDK

Error when trying to debug according to SDK

asti
Member

asti_0-1625402429131.png

I always get an error (see screenshot) when trying to debug the registernode debug example of SDK 1.8. I followed all steps until "-exec delete 1". But when I want to F10 (step over) I get the message 'unable to open 'raise.c'.

What am I doing wrong?

Is there more information on how to debug a snap? 

Please help me 🙂

Thanks

 

5 REPLIES 5

CodeShepherd
Community Moderator
Community Moderator

Please beware that attaching to a running app is at the moment still an experimental feature of snapcraft.
At the moment there is a problem when debugging an app that is running on a ctrlX COREvirtual. So I guess it is the same in your case. Please follow this steps:

  1. Just ignore the raise.c error(s) at the beginning. If they rise.
  2. Make sure that no breakpoints are set (-exec info b). See GDB cheat sheet for further information.
  3. Step until all libraries are loaded.
  4. Add breakpoints and you are good to go

I have observed a similar problem. I'll try to include complete details, so that hopefully someone can reproduce this problem, and/or tell me what I've done wrong.

For this example, I am starting with a clean copy of "samples-cpp/hello.world" from SDK 1.10. I have already configured and tested SSH key-based authentication. The configuration settings below were borrowed/adapted from other SDK examples.

Modify "tasks.json" as follows:

// add to "tasks":

{
    "label": "Launch GDB Server",
    "type": "shell",
    "problemMatcher": "$gcc",
    "command": "ssh ${input:Root-User}@${input:Target-IP} \"sudo snap run --experimental-gdbserver=:12345 helloworld.HelloWorld\" ",
},

// add to "inputs":

{
    "id": "Target-IP",
    "type": "promptString",
    "description": "Remote IP address",
    "default": "192.168.1.1"
},
{
    "id": "Root-User",
    "type": "promptString",
    "description": "Remote user name",
    "default": "myroot"
},

Modify "launch.json" as follows:

// add to "configurations":

{
	"name": "Remote Debug arm64",
	"type": "cppdbg",
	"request": "launch",
	"program": "${workspaceFolder}/generated/linux-gcc-aarch64/Debug/HelloWorld",
	"cwd": "${workspaceFolder}",
	"miDebuggerPath": "/usr/bin/gdb-multiarch",
	"miDebuggerServerAddress": "${input:Target-IP}:12345",
	"stopAtEntry": true,
	"targetArchitecture": "arm64",
	"externalConsole": false,
	"MIMode": "gdb",
	"setupCommands": [
		{
			"description": "Enable pretty-printing for gdb",
			"text": "-enable-pretty-printing",
			"ignoreFailures": true
		}
	]
},
{
	"name": "Remote Debug x64",
	"type": "cppdbg",
	"request": "launch",
	"program": "${workspaceFolder}/generated/linux-gcc-x64/Debug/HelloWorld",
	"cwd": "${workspaceFolder}",
	"miDebuggerPath": "/usr/bin/gdb",
	"miDebuggerServerAddress": "${input:Target-IP}:12345",
	"stopAtEntry": true,
	"targetArchitecture": "x64",
	"externalConsole": false,
	"MIMode": "gdb",
	"setupCommands": [
		{
			"description": "Enable pretty-printing for gdb",
			"text": "-enable-pretty-printing",
			"ignoreFailures": true
		}
	]
},

// add to "inputs":

{
	"id": "Target-IP",
	"type": "promptString",
	"description": "Remote IP address",
	"default": "192.168.1.1"
},

Change the input defaults to match your development environment if you like.

Build the debug snap, and install it on the ctrlX CORE.

In VS Code, open the "Terminal" menu, and select "Run Task". Select "Launch GDB Server". Confirm your remote root user name and remote IP address. You should now see the following in your VS Code Terminal window:

Welcome to "snap run --gdbserver".
You are right before your application is run.

That is followed by instructions for starting GDB manually. Try it, from the WSL command prompt:

$ gdb-multiarch -ex="target remote 192.168.0.123:12345"

At the gdb prompt, type "cont". Doing that repeatedly causes the program to run to completion; you should see the "Hello World" message in the VS Code terminal window. Type "q" to exit GDB.

Launch the GDB server again; but this time, connect to it with VS Code: open the Command Palette, select "Debug: Select and Start Debugging", choose "Remote Debug: arm64", and confirm the remote IP address. It will stop on a "raise" call, just as it did previously. However, at least for me, attempting to continue with the F5 key or "-exec cont" repeatedly produces the error:

ERROR: Command aborted. See the output window for additional details.

I can't find anything relevant in the output window.

I'm not sure of what to do next. Any advice would be appreciated.

GeorgV
Member

In general debugging a snap application works. In the SDK we will provide a better documentation.

Here's a preview of the docu

Thanks. It's now working for me. The important point is to ensure that all breakpoints are deleted before pressing F5 (continue).

The "Remove All Breakpoints" step ensures that you only need to manually remove one breakpoint.

The "Run and Debug" item is found here:

RunRemoteDebug.png

When the debugger initially connects, the "snap" program is running -- not your application. I don't think Visual Studio Code expects this, and perhaps that's why you have to remove all breakpoints now?

RunClearBreakpoints.png

The first three times I press F5, execution stops again inside "snap". The fourth time I press F5, it starts my program. (It says "dash" initially because snap uses wrapper scripts; but a few lines further down, the program starts.)

DebugStartSnap.png

... and stops on the line that calls "raise(SIGSTOP)".

DebugSigStop.png

As expected, the Terminal window now displays the "waiting for debugger" message that precedes the "raise(SIGSTOP)" call.

As the documentation states, it's now possible to add breakpoints and continue or step as needed.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist