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

3.2.2.  The load Command

The RSP packet exchanges to implement the GDB load command are shown as a sequence diagram in Figure 3.2. In this example a program with a text section of 4752 (0x1290) bytes at address 0x0 and data section of 15 (0xe) bytes at address 0x1290 is loaded.

RSP packet exchanges for the GDB load command

Figure 3.2.  RSP packet exchanges for the GDB load command


The first packet is a binary write of zero bytes (X0,0:). A reply of "OK" indicates the target supports binary writing, an empty reply indicates that binary write is not supported, in which case the data will be loaded using M packets.

[Note]Note

This initial dialog is 7-bit clean, even though it uses the X packet. It can therefore safely be used with connections that are not 8-bit clean.

[Caution]Caution

The use of a null reply to indicate that X packet transfers are not supported is not documented in the GDB User Guide.

Having established in this case that binary transfers are permitted, each section of the loaded binary is transmitted in blocks of up to 256 binary data bytes.

Had binary transfers not been permitted, the sections would have been transferred using M packets, using pairs of hexadecimal digits for each byte.

Finally the client sets the value of the program counter to the entry point of the code using a P packet. In this example the program counter is general register 33 and the entry point is address 0x100.

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

(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)
	
Embecosm divider strip