GDB Client and Server: Unlocking GDB

In case you face problems with launching GDB: Then I have a quick solution (well: workaround): kill the GDB server and or client process. The problem can show up in many way, but in general gdb is stuck or does not respond:

GDB stuck?

GDB stuck?

But it could be an error message like this too:

Error in services launch sequence
Starting J-Link GDB Server timed out.

In many cases it helps to repower the debug probe and/or target board (see “Debugging Failure: Check List and Hints“). Other than that, what helps most of the time for me is to kill the gdb client and/or gdb server tasks.

GDB Client

What happens if I press ‘debug’ in Eclipse is: Eclipse launches the gdb client. For ARM this is arm-none-eabi-gdb and in the case of Kinetis Design Studio v3.0.0 it is located here:

C:\Freescale\KDS_3.0.0\toolchain\bin\arm-none-eabi-gdb.exe

You can identify the gdb client easily in the Windows task manager:

arm-none-eabi-gdb.exe

arm-none-eabi-gdb.exe

Where to find the gdb client is configured in the Eclipse launch configuration:

GDB Client Setup

GDB Client Setup

The executable is specified with variables like ${cross_prefix}:

 ${cross_prefix}gdb${cross_suffix}

You can inspect the variables with the menu Window > Preferences > C/C++ > Build > Build Variables (make sure you enable ‘Show system variables’):

Eclipse System Build Variables

Eclipse System Build Variables

Segger J-Link GDB Server

Both gdb client and gdb server are launched from Eclipse. The gdb client then communicates with the gdb server. Which is JLinkGDBServerCL.exe in case of Segger J-Link:

JLink GDB Server

JLink GDB Server

That Segger gdb server executable can be found in Kinetis Design Studio v3.0.0 here:

C:\Freescale\KDS_3.0.0\segger\JLinkGDBServerCL.exe

This is configured in the Eclipse debug configuration:

Calling J-Link Server

Calling J-Link Server

OpenOCD GDB Server

OpenOCD works the same way:

OpenOCD gdb server

OpenOCD gdb server

The OpenOCD server binary is located here:

C:\Freescale\KDS_3.0.0\openocd\bin\openocd.exe

P&E GDB Server

Both Segger J-Link and OpenOCD server used with Eclipse are executables outside of the Eclipse plugins folder. The path to the P&E GDB server binary is not configurable in the P&E debug panel and is present inside the Eclipse plugins folder. In the case of Windows and Kinetis Design Studio v3.0.0 it is located here:

C:\Freescale\KDS_3.0.0\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.0.8.201504092111\win32\pegdbserver_console.exe\

Having the server inside the Eclipse plugins folder makes it possible that I can update it using the usual Eclipse updates.

The P&E GDB server can be easily identified in the process list as pegdbserver_console:

P&E GDB Server

P&E GDB Server

Summary

So if something went wrong, then usually what works is to terminate/kill gdb server and client in the Windows task manager:

  • GDB Client: arm-none-eabi-gdb
  • Segger J-Link GDB Server: JLinkGDBServerCL
  • P&E Multilink GDB Server: pegdbserver_console
  • OpenCD GDB Server: openocd

In a similar way, things work as well on Linux or Mac OS.

Happy Killing 🙂

16 thoughts on “GDB Client and Server: Unlocking GDB

  1. Hi Erich,

    Have you ever come across an example which implements GDB debugging in a custom programming environment? For example, I’m developing my own IDE as part of a visual programming package and I want to be able to start and debug the source created by my tool.

    I’m at the stage now where I can compile and program the micro-controller through a Segger J-Link however I’d like to take the next step and get debugging going.

    Hope this makes sense!
    Regards,
    Kevin

    Like

  2. Pingback: Troubleshooting Tips: Failed Debugging with GDB | MCU on Eclipse

  3. Pingback: Tutorial: MCUXpresso SDK with Linux, Part 2: Commandline Debugging with GDB | MCU on Eclipse

  4. Pingback: Eclipse JTAG Debugging the ESP32 with a SEGGER J-Link | MCU on Eclipse

  5. Pingback: Debugging Embedded Targets with pyOCD and Eclipse #Embedded @McuOnEclipse « Adafruit Industries – Makers, hackers, artists, designers and engineers!

  6. Thank you for an excellent article – well done and thank you

    i am trying these similare examples and have run in to a problem:

    both on Linux and Window 11 using Eclipse and Segger J-LINK

    —————————————————————————-

    Error in final launch sequence
    Failed to execute MI command:
    -target-select remote localhost:2331
    Error message from debugger back end:
    Truncated register 16 in remote ‘g’ packet
    Failed to execute MI command:
    -target-select remote localhost:2331
    Error message from debugger back end:
    Truncated register 16 in remote ‘g’ packet
    Truncated register 16 in remote ‘g’ packet

    SEGGER J-Link GDB Server V8.10a Command Line Version

    JLinkARM.dll V8.10a (DLL compiled Oct 2 2024 14:18:10)

    Command line: -if swd -device RP2040_M0_0 -endian little -speed auto -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -log /home/walter/Jbug.log -singlerun -strict -timeout 0 -nogui
    —–GDB Server start settings—–
    GDBInit file: none
    GDB Server Listening port: 2331
    SWO raw output listening port: 2332
    Terminal I/O port: 2333
    Accept remote connection: localhost only
    Generate logfile: off
    Verify download: on
    Init regs on start: on
    Silent mode: off
    Single run mode: on
    Target connection timeout: 0 ms
    ——J-Link related settings——
    J-Link Host interface: USB
    J-Link script: none
    J-Link settings file: none
    ——Target related settings——
    Target device: RP2040_M0_0
    Target device parameters: none
    Target interface: SWD
    Target interface speed: auto
    Target endian: little

    Connecting to J-Link…
    J-Link is connected.
    Firmware: J-Link V11 compiled Oct 1 2024 13:26:26
    Hardware: V11.00
    S/N: XXXXXXXXX
    Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    Checking target voltage…
    Target voltage: 3.32 V
    Listening on TCP/IP port 2331
    Connecting to target…
    Initializing CPU registers…Connected to target
    Waiting for GDB connection…Connected to 127.0.0.1
    GDB client (conn. 12) requested target.xml from GDB Server
    Reading common registers: Read register ‘r0’ (4 bytes) from hardware: 0x00000000
    Read register ‘r1’ (4 bytes) from hardware: 0x00000000
    Read register ‘r2’ (4 bytes) from hardware: 0x00000000
    Read register ‘r3’ (4 bytes) from hardware: 0x00000000
    Read register ‘r4’ (4 bytes) from hardware: 0x00000000
    Read register ‘r5’ (4 bytes) from hardware: 0x00000000
    Read register ‘r6’ (4 bytes) from hardware: 0x00000000
    Read register ‘r7’ (4 bytes) from hardware: 0x00000000
    Read register ‘r8’ (4 bytes) from hardware: 0x00000000
    Read register ‘r9’ (4 bytes) from hardware: 0x00000000
    Read register ‘r10’ (4 bytes) from hardware: 0x00000000
    Read register ‘r11’ (4 bytes) from hardware: 0x00000000
    Read register ‘r12’ (4 bytes) from hardware: 0x00000000
    Read register ‘sp’ (4 bytes) from hardware: 0x00000000
    Read register ‘lr’ (4 bytes) from hardware: 0x00000000
    Read register ‘pc’ (4 bytes) from hardware: 0x00000000
    Read register ‘xpsr’ (4 bytes) from hardware: 0x00000001
    GDB closed TCP/IP connection (Socket 12)
    Restoring target state and closing J-Link connection…
    Shutting down…

    Like

Leave a reply to Karibe Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.