This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
Re: remote/2158: Memory access error while loading section .text,Escape characters
- From: Ronald Hecht <ronald dot hecht at uni-rostock dot de>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 17 Aug 2006 13:58:01 -0000
- Subject: Re: remote/2158: Memory access error while loading section .text,Escape characters
- Reply-to: Ronald Hecht <ronald dot hecht at uni-rostock dot de>
The following reply was made to PR remote/2158; it has been noted by GNATS.
From: Ronald Hecht <ronald.hecht@uni-rostock.de>
To: Cc: gdb-gnats@sources.redhat.com
Subject: Re: remote/2158: Memory access error while loading section .text,
Escape characters
Date: Thu, 17 Aug 2006 15:59:34 +0200
Hallo Daniel,
Daniel Jacobowitz wrote:
> On Thu, Aug 17, 2006 at 01:24:53PM -0000, ronald.hecht@gmx.de wrote:
>
>
>> While porting to a new target, I found a problem downloading the
>> executable into the SID simulator. I'm getting the following error
>> message:
>>
>> Loading section .text, size 0x45 lma 0x0
>> Memory access error while loading section .text.
>>
>
>
> Could you provide a trace using "set debug remote 1"?
>
>
[...]$ proc8-gdb test
GNU gdb 6.5.50.20060817-cvs
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host= --target=proc8"...
(no debugging symbols found)
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x00000000 in _start ()
(gdb) set debug remote 1
(gdb) load
Loading section .text, size 0x45 lma 0x0
Sending packet: $X0,0:#1e...Ack
Packet received: OK
binary downloading suppported by target
Sending packet: $X0,b:\b\b\001\000=\003@\001\002\000\003#e7...Ack
Packet received: OK
Sending packet: $Xb,b:@\000\e\003@\000\001@\001\e\003#80...Ack
Packet received: OK
Sending packet: $X16,a:@\001\001@\000"\000!\020\000#5b...Ack
Packet received: OK
Sending packet: $X20,0:#50...Ack
Packet received: OK
Sending packet: $X20,0:#50...Ack
Packet received: OK
Memory access error while loading section .text.
(gdb)
When I fix (comment out) up the code I'm getting the following:
Loading section .text, size 0x45 lma 0x0
Sending packet: $X0,0:#1e...Ack
Packet received: OK
binary downloading suppported by target
Sending packet: $X0,b:\b\b\001\000=\003@\001\002\000\003#e7...Ack
Packet received: OK
Sending packet: $Xb,b:@\000\e\003@\000\001@\001\e\003#80...Ack
Packet received: OK
Sending packet: $X16,a:@\001\001@\000"\000!\020\000#5b...Ack
Packet received: OK
Sending packet: $X20,9:>\n}\004\000\r\e\003\200\024#e1...Ack
Packet received: OK
Sending packet: $X29,a:\001@\001\e\003\200\025\002\200\003#04...Ack
Packet received: OK
Sending packet: $X33,a:\200\000\002\000\003\200\000 \000\000#aa...Ack
Packet received: OK
Sending packet: $X3d,8:\uffff\uffff\001\000\001\001\000\000#8e...Ack
Packet received: OK
Start address 0x0, load size 69
Transfer rate: 4451 bits/sec, 9 bytes/write.
>
>
>>> How-To-Repeat:
>>>
>>
>> Difficult, as I'm working on a new target.
>>
>>
>>> Fix:
>>>
>>
>> I tracked down the problem to a possible bug in
>> remote.c/remote_write_bytes(). When sending characters to be escaped
>> the following code is in my opinion wrongly executed:
>>
>
>
> Why wrongly? Do you mean that it shouldn't be executed, or that it is
> executed incorrectly?
>
>
I think it shouldn't be executed. When I remove the code it works for
me. I think the code after it handles "(nr_bytes < todo)".
> I really wouldn't have expected you to be triggering that code with an
> 0x45 byte text section, anyway. That's plenty small enough to fit in
> one packet. Is get_memory_write_packet_size returning something tiny?
>
>
>
It returns 20.
It seems to me, that only 10 bytes are transmitted per packet. I think
the 0x0d character in the binary is escaped (byte stuffed) and results
in the problem.
Regards
Ronald Hecht