Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* gdb code review, pointer madness
@ 2006-01-23 20:39 NZG
  2006-01-23 20:48 ` Daniel Jacobowitz
  2006-01-23 20:51 ` Jim Blandy
  0 siblings, 2 replies; 37+ messages in thread
From: NZG @ 2006-01-23 20:39 UTC (permalink / raw)
  To: gdb-patches, uClinux development list

I'm trying to get gdb 6.1's machine interface to work correctly with the m68k 
arch, and I'm having some weird results.

I've noticed that if I do a (frame -1) command on gdb after connecting to 
remote gdb server, but before breaking in the main program, gdb goes crazy 
and starts requesting random memory locations from gdbserver until something 
crashes.

Sooo... I'm using regular gdb to debug the m68k-elf-gdb connection, and I'm 
seeing a problem "extract_unsigned_integer" (pasted below).

Specifically this loop doesn't seem to be executing correctly

 for (p = startaddr; p < endaddr; ++p)
	retval = (retval << 8) | *p;

In the function call I'm watching, 
endaddr = startaddr+4, 
yet, when I step through the function the loop executes 8 times and overshoots 
the array.

I don't see anything wrong with the code.
Can anyone else see anything weird in the pointer math below?

thx,
NZG



ULONGEST
extract_unsigned_integer (const void *addr, int len)
{
  ULONGEST retval;
  const unsigned char *p;
  const unsigned char *startaddr = addr;
  const unsigned char *endaddr = startaddr + len;

  if (len > (int) sizeof (ULONGEST))
    error ("\
That operation is not available on integers of more than %d bytes.",
	   (int) sizeof (ULONGEST));

  /* Start at the most significant end of the integer, and work towards
     the least significant.  */
  retval = 0;
  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
    {
      for (p = startaddr; p < endaddr; ++p)
	retval = (retval << 8) | *p;
    }
  else
    {
      for (p = endaddr - 1; p >= startaddr; --p)
	retval = (retval << 8) | *p;
    }
  return retval;
}


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2006-01-30 17:02 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-23 20:39 gdb code review, pointer madness NZG
2006-01-23 20:48 ` Daniel Jacobowitz
2006-01-23 20:51 ` Jim Blandy
2006-01-24 17:19   ` NZG
2006-01-24 19:29     ` NZG
2006-01-24 21:27       ` Jim Blandy
2006-01-24 21:58         ` NZG
2006-01-24 22:11           ` Daniel Jacobowitz
2006-01-25  0:01           ` Jim Blandy
2006-01-25  4:41             ` Eli Zaretskii
2006-01-25  4:59               ` Jim Blandy
2006-01-25  5:25                 ` Jim Blandy
2006-01-25 17:21                   ` Eli Zaretskii
2006-01-25 18:49                     ` Jim Blandy
2006-01-25 19:58                       ` Eli Zaretskii
2006-01-25 17:15                 ` Eli Zaretskii
2006-01-26 16:19             ` NZG
2006-01-26 16:43               ` Daniel Jacobowitz
2006-01-26 19:55                 ` frame theory, was " NZG
2006-01-26 19:59                   ` Daniel Jacobowitz
2006-01-26 20:17                     ` NZG
2006-01-26 20:22                       ` Daniel Jacobowitz
2006-01-26 21:21                   ` Mark Kettenis
2006-01-26 21:54                     ` NZG
2006-01-26 22:40                       ` Mark Kettenis
2006-01-26 22:44                         ` Daniel Jacobowitz
2006-01-26 23:27                           ` remote connection crash, was frame theory NZG
2006-01-26 23:32                             ` Daniel Jacobowitz
2006-01-26 23:42                             ` Jim Blandy
2006-01-26 23:45                               ` Daniel Jacobowitz
2006-01-26 23:57                                 ` Jim Blandy
2006-01-27  0:04                                   ` NZG
2006-01-30 17:02                                     ` 5282 gdb Eclipse MI support, was remote connection crash NZG
2006-01-26 23:47                           ` frame theory, was pointer madness Accounts
2006-01-26 23:16                   ` Jim Blandy
2006-01-26 23:39                     ` Jim Blandy
2006-01-27  7:19                     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox