Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB remote protocol: how to analyse packets?

Tags:

gdb

ecos

I have:

  • A proprietary prototype ARM board (Cortex-M3 based) with eCos OS
  • The board has the programmed RedBoot bootloader
  • Serial line (RS-232)
  • GDB debugger for ARM (arm-eabi-gdb)
  • Host OS is Windows/Cygwin and/or Linux (actually, doesn't matter)

Problem: GDB debugger cannot connect to the target over the serial line.

What I want: is to sniff the packets of the GDB remote protocol in order to undestand whether the GDB stub on the target is alive and operating.

Details: RedBoot has an option to pass the target's control to the built-in GDB stub. I know that the RedBoot is alive, I can connect to it and send it commands over the serial line. The RedBoot manual says that the switch to the GDB stub can be made by typing $ or + symbols (which are actually the prefixes of the GDB remote protocol packets). It seems to work for when I send those symbols the terminal dies. But I'm not sure if the RedBoot was compiled with the GDB stub support (don't ask me why :-)).

Then, when I try to connect to the board with my GDB debugger I get the following picture (on Windows):

(gdb) target remote COM3
Remote debugging using COM3
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...

The port is correct, the baudrate as well. Actually the same output I get if I try to do the same with another serial port which is not connected with anything.

What I want to know is does GDB stub send back anything or not?

Intuitively I thought that probably

set verbose on

would help, but GDB manual says it has very a limited effect and my case is beyond it.

May be it is possible to compile GDB debugger with a macro which enables debug logging?

like image 511
krokoziabla Avatar asked Nov 21 '12 15:11

krokoziabla


People also ask

How do I use GDB remote?

To start remote debugging, run GDB on the host machine, and specify as an executable file the program that is running in the remote machine. This tells GDB how to find your program's symbols and the contents of its pure text. Note that the colon is still required here.

What protocol does GDB use?

The GDB Remote Serial Protocol ( RSP ) provides a high level protocol allowing GDB to connect to any target remotely. If a target's architecture is defined in GDB and the target implements the server side of the RSP protocol, then the debugger will be able to connect remotely to that target.

What is GDB target?

A target is the execution environment occupied by your program. Often, GDB runs in the same host environment as your program; in that case, the debugging target is specified as a side effect when you use the file or core commands.

What port does GDB use?

(5) You must use the same port number with the host GDB target remote command. communicates via a TCP connection to port 2345 on host `the-target'. For TCP connections, you must start up gdbserver prior to using the target remote command.


1 Answers

What I want to know is does GDB stub send back anything or not?

Do this (before target remote):

(gdb) set debug remote 1
like image 151
Employed Russian Avatar answered Oct 02 '22 00:10

Employed Russian