Debugging on ESP32 for Arduino IDE

Hi

I have ESP32 board and Arduino IDE. I want to use debugger as much as possible to test code. Can anyone help me who test code using hardware debugger on ESP32. How do you use debugger to test logic of your code

one standardmethod for debugging is to add serial output to your code.

if you open the serial monitor you can see the printed values and messages.
Best regards Stefan

not sure which type of "debugger" you had it mind

i add pcRead() to almost all my code to help test individual functions and debug. it accepts single letter commands that may be preceded by a numeric value

// pcRead - debugging using serial monitor

const char version [] = "PcRead 201114a";

int debug = 0;

// ---------------------------------------------------------
// toggle output bit
int
readString (
    char *s,
    int   maxChar )
{
    int  n = 0;

    Serial.print ("> ");
    do {
        if (Serial.available()) {
            int c    = Serial.read ();

            if ('\n' == c)
                break;

            s [n++] = c;
            if (maxChar == n)
                break;
        }
    } while (true);

    return n;
}

// -----------------------------------------------------------------------------
// process single character commands from the PC
#define MAX_CHAR  10
char s [MAX_CHAR] = {};

int  analogPin = 0;

void
pcRead (void)
{

    static int  val = 0;

    if (Serial.available()) {
        int c = Serial.read ();

        switch (c)  {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            val = c - '0' + (10 * val);
            break;

        case 'A':
            analogPin = val;
            Serial.print   ("analogPin = ");
            Serial.println (val);
            val = 0;
            break;

        case 'D':
            debug ^= 1;
            break;

        case 'I':
            pinMode (val, INPUT);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" INPUT");
            val = 0;
            break;

        case 'O':
            pinMode (val, OUTPUT);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" OUTPUT");
            val = 0;
            break;

        case 'P':
            pinMode (val, INPUT_PULLUP);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" INPUT_PULLUP");
            val = 0;
            break;


        case 'a':
            Serial.print   ("analogRead: ");
            Serial.println (analogRead (val));
            val = 0;
            break;

        case 'c':
            digitalWrite (val, LOW);
            Serial.print   ("digitalWrite: LOW  ");
            Serial.println (val);
            val = 0;
            break;

        case 'p':
#if !defined(ARDUINO_ARCH_ESP32)
            analogWrite (analogPin, val);
            Serial.print   ("analogWrite: pin ");
            Serial.print   (analogPin);
            Serial.print   (", ");
            Serial.println (val);
            val = 0;
#endif
            break;

        case 'r':
            Serial.print   ("digitalRead: pin ");
            Serial.print   (val);
            Serial.print   (", ");
            Serial.println (digitalRead (val));
            val = 0;
            break;

        case 's':
            digitalWrite (val, HIGH);
            Serial.print   ("digitalWrite: HIGH ");
            Serial.println (val);
            val = 0;
            break;

        case 't':
            Serial.print   ("pinToggle ");
            Serial.println (val);
            digitalWrite (val, ! digitalRead (val));
            val = 0;
            break;

        case 'v':
            Serial.print ("\nversion: ");
            Serial.println (version);
            break;

        case '\n':          // ignore
            break;

        case '"':
            while ('\n' != Serial.read ())     // discard linefeed
                ;

            readString (s, MAX_CHAR-1);
            Serial.println (s);
            break;

        case '?':
            Serial.println ("\npcRead:\n");
            Serial.println ("    [0-9] append to #");
            Serial.println ("    A # - set analog pin #");
            Serial.println ("    D # - set debug to #");
            Serial.println ("    I # - set pin # to INPUT");
            Serial.println ("    O # - set pin # to OUTPUT");
            Serial.println ("    P # - set pin # to INPUT_PULLUP");
            Serial.println ("    a # - analogRead (pin #)");
            Serial.println ("    c # - digitalWrite (pin #, LOW)");
            Serial.println ("    p # -- analogWrite (analogPin, #)");
            Serial.println ("    r # - digitalRead (pin #)");
            Serial.println ("    s   - digitalWrite (pin #, HIGH)");
            Serial.println ("    t   -- toggle pin # output");
            Serial.println ("    v   - print version");
            Serial.println ("    \"   - read string");
            Serial.println ("    ?   - list of commands");
            break;

        default:
            Serial.print ("unknown char ");
            Serial.println (c,HEX);
            break;
        }
    }
}

// -----------------------------------------------------------------------------
void
loop (void)
{
    pcRead ();
}

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin(115200);

    Serial.println (version);
#if defined(ARDUINO_ARCH_ESP32)
    Serial.println ("esp32");
#endif
}

There was a previous question about using the Arduino IDE 2.x integrated debugger here:

My answer consists mainly of questions itself, so certainly there's no solution to be found there, but perhaps you'll find it interesting, and maybe worth watching that topic in case there is eventually a useful reply there.

I have posted a thread with two serial debug-output macros.

Your question is very general and you are asking for a hardware-debugger.

But you have not described what your actual problem is.
As long as you want to debug a logic of any code which does not need to execute with a low latency in the microsecond-range serial debug-output will do the job very well.

And there is a very special kind of "debugger" available here:
the experience and the knowledge of the users here in this forum.

best regards Stefan

The ESP32 is not an Arduino, so are the Arduino guys activly developing the new IDE including support for ESP32 ?

There's no need for Arduino to provide specific support in any IDE for ESP32. They did something far better by creating a framework that allows anyone to add support for any board! Arduino uses that system for their own boards and the amazing Arduino community uses it to add support for millions (once you account for all the possible configurations) of other boards, including many many ESP32 boards:

So you have support for ESP32 in the classic Arduino IDE and you have support for ESP32 in Arduino IDE 2.x and you have support for ESP32 in Arduino CLI. They did have to specifically add support for ESP32 in Arduino Web Editor and Arduino IoT Cloud because users are not permitted to install arbitrary boards platforms on the Arduino Create servers, but they still use the same framework and the same community maintained ESP32 boards platform, just like we use in the IDEs and Arduino CLI.