This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

remote/1826: Function "target_write_memory_partial" can return an invalid value in "*err".


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]