Close

GDB debugging

A project log for Debugging on a Teensy, the open source way

There comes a time when debugging your code requires more than Serial.print();

vedranVedran 04/03/2024 at 16:120 Comments

After establishing a connection, I could poke further at the GDB console. Using a simple blinky project for test

#include <Arduino.h>

// Set LED_BUILTIN if it is not defined by Arduino framework
#ifndef LED_BUILTIN
    #define LED_BUILTIN 2
#endif

void setup()
{
  // initialize LED digital pin as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);
  // wait for a second
  delay(1000);
  // turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
   // wait for a second
  delay(1000);
}

I got used to platformIO in VS code, so the example is made through Arduino framework. Before jumping into the platformIO's debugging integration, I thought to give it a test in CLI. Seems like there's no problems with loading the code...

..setting a break point, then running to it...

However, continuing after a first breakpoint seems to fail. Before the failure, windows gives an audible sound that a USB device (Teensy, I assume) has been disconnected.

Any attempts to resume the program, short of full restart ('run' command) fail.

Attempt 2

When pausing the program via ctrl-c during a run, and not using any breakpoints, sessions seems to work fine and there's no errors or device disconnects

Few more tests isolated the error to the use of breakpoints, with the following observations:

Discussions