This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
remote/1826: Function "target_write_memory_partial" can return an invalid value in "*err".
- From: joe dot bak at rauland dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 6 Dec 2004 17:50:24 -0000
- Subject: remote/1826: Function "target_write_memory_partial" can return an invalid value in "*err".
- Reply-to: joe dot bak at rauland dot com
>Number: 1826
>Category: remote
>Synopsis: Function "target_write_memory_partial" can return an invalid value in "*err".
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Dec 06 17:58:04 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Joe Bak
>Release: gdb-6.3
>Organization:
>Environment:
Windows XP Professional
cygwin 1.5.12-1
This GDB was configured as "--host=i686-pc-cygwin --target=i386-elf".
Redboot Floppy 2.0, I386
>Description:
The function "target_write_memory_partial" in "target.c" is passed a "pointer to int" calling parameter named "err". The referenced integer is not initialized by the calling function and it may or may not be initialized by "target_write_memory_partial" depending on conditional program flow through this function.
>How-To-Repeat:
Connect an X86 PC running Redboot Floppy to COM1 of a PC running GDB 6.3 under Cygwin 1.5.12-1.
At the GDB prompt type:
file <ELF Filename>
target remote /dev/com1
load
Observe the error message during the file transfer.
>Fix:
I propose the following modification to "target_write_memory_partial" in "target.c":
int
target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
{
// NOTE: target_xfer_partial does NOT affect the "err" code. So
// assume that no error occurred.
*err = 0;
if (target_xfer_partial_p ())
{
return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
NULL, buf, memaddr, len);
}
else
{
return target_xfer_memory_partial (memaddr, buf, len, 1, err);
}
}
Alternatively, "target_xfer_partial" could be modified to accept "int *err" as a calling parameter and utilize it in the same manner as the "target_xfer_memory_partial" function.
Honestly, I don't see how this function EVER worked during testing!
>Release-Note:
>Audit-Trail:
>Unformatted: