Skip to content

feat: added more debug options #2356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions internal/integrationtest/debug/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import (
"testing"

"github.com/arduino/arduino-cli/internal/integrationtest"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
"go.bug.st/testifyjson/requirejson"
)

func TestDebug(t *testing.T) {
Expand All @@ -37,6 +39,7 @@ func TestDebug(t *testing.T) {
integrationtest.CLISubtests{
{"Start", testDebuggerStarts},
{"WithPdeSketchStarts", testDebuggerWithPdeSketchStarts},
{"DebugInformation", testAllDebugInformation},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -88,3 +91,44 @@ func testDebuggerWithPdeSketchStarts(t *testing.T, env *integrationtest.Environm
_, _, err = cli.Run("debug", "-b", fqbn, "-P", programmer, filePde.String(), "--info")
require.NoError(t, err)
}

func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) {
// Create sketch for testing
sketchPath := cli.DataDir().Join("DebuggerStartTest")
defer sketchPath.RemoveAll()
_, _, err := cli.Run("sketch", "new", sketchPath.String())
require.NoError(t, err)

// Install custom core
customHw, err := paths.New("testdata", "hardware").Abs()
require.NoError(t, err)
err = customHw.CopyDirTo(cli.SketchbookDir().Join("hardware"))
require.NoError(t, err)

// Build sketch
fqbn := "my:samd:my"
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--format", "json")
require.NoError(t, err)

// Starts debugger
jsonDebugOut, _, err := cli.Run("debug", "-b", fqbn, "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json")
require.NoError(t, err)
debugOut := requirejson.Parse(t, jsonDebugOut)
debugOut.MustContain(`
{
"toolchain": "gcc",
"toolchain_path": "gcc-path",
"toolchain_prefix": "gcc-prefix",
"server": "openocd",
"server_path": "openocd-path",
"server_configuration": {
"path": "openocd-path",
"scripts_dir": "openocd-scripts-dir",
"scripts": [
"first",
"second",
"third"
]
}
}`)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
my.name=My Cool Board
my.vid.0=0x2341
my.pid.0=0x804e
my.upload_port.0.vid=0x2341
my.upload_port.0.pid=0x804e
my.upload.tool=bossac
my.upload.tool.default=bossac
my.upload.tool.network=arduino_ota
my.upload.protocol=sam-ba
my.upload.maximum_size=262144
my.upload.maximum_data_size=32768
my.upload.use_1200bps_touch=true
my.upload.wait_for_upload_port=true
my.upload.native_usb=true
my.build.mcu=cortex-m0plus
my.build.f_cpu=48000000L
my.build.usb_product="Arduino MKR1000"
my.build.usb_manufacturer="Arduino LLC"
my.build.board=SAMD_MY
my.build.core=arduino:arduino
my.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags}
my.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
my.build.openocdscript=openocd_scripts/arduino_zero.cfg
my.build.variant=arduino:mkr1000
my.build.vid=0x2341
my.build.pid=0x804e

my.debug.toolchain.path=gcc-path
my.debug.toolchain.prefix=gcc-prefix
my.debug.server.openocd.path=openocd-path
my.debug.server.openocd.scripts_dir=openocd-scripts-dir
my.debug.server.openocd.script=
my.debug.server.openocd.scripts.0=first
my.debug.server.openocd.scripts.1=second
my.debug.server.openocd.scripts.2=third