dwire-debug icon indicating copy to clipboard operation
dwire-debug copied to clipboard

Integrate amazing GDB mode from @kadamski

Open dcwbrown opened this issue 8 years ago • 8 comments

@kadamski has proposed a gdb supportmode and supplied an initial pull request.

Merge this code and adapt if necessary for cross platform support.

dcwbrown avatar Jan 28 '17 20:01 dcwbrown

@kadamski's gdb server has been integrated to work on both Linux and Windows.

@kadamski: I believe this now works as well ass your protoype, and has the following minor improvements:

  • The info registers command now picks up the PC correctly.
  • dwdebug gdbserver mode exits cleanly when quitting GDB.

Note that the gdbserver mode is now a dwdebug command rather than a special '-' parameter.

This is to allow the port and baud rate to be selected before entering gdb server mode.

For example:

$ ./dwdebug device ttyUSB0 7840, gdbserver, q

Connected to DebugWIRE device on USB serial port COM4 at baud rate 7840
Device recognised as ATtiny85
Target ready, waiting for GDB connection.
Use 'target remote :4444'

Note that Windows sockets support uses a WinSock implementation which is slightly different in API from Linux. Apologies for a few grubby casts this causes.

For example file handles need casting as (FileHandle) before passing to Read/Write.

dcwbrown avatar Feb 01 '17 12:02 dcwbrown

That is cool, I'll take a look at this as soon as I can.

kadamski avatar Feb 01 '17 21:02 kadamski

I'm just starting to explore the possibilities here, and it looks like this is going to be quite useful. I still have to learn how to deal with complications like being able to single step without stepping into interrupt routines, but I imagine that's a matter of spending more time with gdb.

To avoid casting, what do you think of declaring handles as FileHandle even in the gdbserver directory? That might eliminate much of the casting (but it doesn't look like there's all that much to begin with). In fact, it looks quite clean to me.

plasticassius avatar Feb 07 '17 21:02 plasticassius

Sounds fine to me. Although it may not look it I was trying not to change too much of @kadamski's code.

dcwbrown avatar Feb 08 '17 14:02 dcwbrown

I guess the important thing is that it's working well.

plasticassius avatar Feb 10 '17 18:02 plasticassius

Hi.So I can use for example Eclipse for debugging my C code?

zoon81 avatar Mar 19 '17 07:03 zoon81

@zoon81: that should be possible. Why don't you give it a try and let us know? Watch out for breakpoints however. You don't want to use software breakpoints (which may be default for eclipse) but hardware breakpoint.

kadamski avatar Mar 19 '17 08:03 kadamski

Thanks.I going to get an ft232 based converter and I give it a try.

zoon81 avatar Mar 19 '17 09:03 zoon81