Services - tools - models - for embedded software development
Embecosm divider strip
Prev  Next

3.2.10.  The detach and disconnect Commands

The rules for detach mandate that it breaks the connection with the target, and allows the target to resume execution. By contrast, the disconnect command simply breaks the connection. A reconnection (using the target remote command) should be able to resume debugging at the point where the previous connection was broken.

The disconnect command just closes the serial connection. It is up to the target server to notice the connection has broken, and to try to re-establish a connection.

The detach command requires a RSP exchange with the target for a clean shutdown. The RSP packet exchanges to implement the command are shown as a sequence diagram in Figure 3.8.

RSP packet exchanges for the GDB detach command

Figure 3.8.  RSP packet exchanges for the GDB detach command


The exchange is a simple D packet to which the target responds with an OK packet, before closing the connection.

Through this exchange, the GDB client shows the following output:

(gdb) detach
Ending remote debugging.
(gdb)
	

The disconnect command has no dialog of itself. The GDB client shows the following output in a typical session. However there are no additional packet exchanges due to the disconnect.

(gdb) target remote :51000
Remote debugging using :51000
0x00000100 in _start ()
(gdb) load hello
Loading section .text, size 0x1290 lma 0x0
Loading section .rodata, size 0xe lma 0x1290
Start address 0x100, load size 4766
Transfer rate: 5 KB/sec, 238 bytes/write.
(gdb) break main
Breakpoint 1 at 0x1264: file hello.c, line 41.
(gdb) c
Continuing.

Breakpoint 1, main () at hello.c:41
41        simputs( "Hello World!\n" );
(gdb) disconnect
Ending remote debugging.
(gdb) target remote :51000
Remote debugging using :51000
main () at hello.c:41
41        simputs( "Hello World!\n" );
(gdb) c
Continuing.
Remote connection closed
(gdb) 
	

Unlike with the detach command, when debugging is reconnected through target remote, the target is still at the point where execution terminated previously.

Embecosm divider strip