Standalone gdb server?

Has anyone encountered a standalone gdb server? That is gdb server that runs on a bare metal.

I've been looking for sources to build one. Doesn't need to be ARM, but that might help.

Maybe someone has come across a document explaining how gdb server really works?

(It might help in reading the 'standard' gdb server code.)

I understand that 'stub' means "gdb server" linked into the executable, but I'd like to have a server with which I could upload programs onto the board for debugging through the network or serial IF.

My main concern is attaching to the program to be debugged, when there is no OS (and no processes).

Parents
  • I like the expression "Simple is good".

    If breaking the "bootloader" up into smaller pieces, I think each piece is not extremely complicated:

    1: Bootloader.

         Must read an ihex file (intel-hex) - I've made a script that wrote ihex; parsing ihex isn't complicated.

         Must decode the ihex and write binary blocks to RAM (temporarily) and when ready, write to flash-memory (if necessary).

    2: Debug facilities; a few handlers that would be required in order to access memory...

         Read an 8-bit word

         Read a 16-bit word

         Read a 32-bit word

         Write an 8-bit word

         Write a 16-bit word

         Write a 32-bit word

    3: Communication.

         Serial interface; should not be too complicated to implement, if you have the peripheral addresses

         Use an interrupt for reading and parsing commands.

    4: Exception vectors.

         Should install all vectors and point to the same handler, before executing the program.

         There might be some trouble here, because the program being debugged has its own exception vectors, and if they overwrite the debugger's exception vectors, there's no way for the debugger to be triggered.

    5: (Anything I forgot to mention)

    Basically, it would be to implement the stub on top of a bootloader.

    Writing the bootloader would probably be the hardest part of it (the part where you find a good place to store the temporary data and where you write to the flash memory).

    -You could probably take a look at RedBoot and disable Ethernet, in order to quickly hack it into position... That way you'd only need to focus on a serial interface.

    ... You could use the "Vetle" method: "If it fails to compile, delete it".

Reply
  • I like the expression "Simple is good".

    If breaking the "bootloader" up into smaller pieces, I think each piece is not extremely complicated:

    1: Bootloader.

         Must read an ihex file (intel-hex) - I've made a script that wrote ihex; parsing ihex isn't complicated.

         Must decode the ihex and write binary blocks to RAM (temporarily) and when ready, write to flash-memory (if necessary).

    2: Debug facilities; a few handlers that would be required in order to access memory...

         Read an 8-bit word

         Read a 16-bit word

         Read a 32-bit word

         Write an 8-bit word

         Write a 16-bit word

         Write a 32-bit word

    3: Communication.

         Serial interface; should not be too complicated to implement, if you have the peripheral addresses

         Use an interrupt for reading and parsing commands.

    4: Exception vectors.

         Should install all vectors and point to the same handler, before executing the program.

         There might be some trouble here, because the program being debugged has its own exception vectors, and if they overwrite the debugger's exception vectors, there's no way for the debugger to be triggered.

    5: (Anything I forgot to mention)

    Basically, it would be to implement the stub on top of a bootloader.

    Writing the bootloader would probably be the hardest part of it (the part where you find a good place to store the temporary data and where you write to the flash memory).

    -You could probably take a look at RedBoot and disable Ethernet, in order to quickly hack it into position... That way you'd only need to focus on a serial interface.

    ... You could use the "Vetle" method: "If it fails to compile, delete it".

Children