This is the mail archive of the gdb-patches@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]

Re: The gdb x86 function prologue parser


   Date: Wed, 8 Jun 2005 23:25:56 -0700
   From: Jason Molenda <jason-swarelist@molenda.com>

   Hi Andreas,

   On Wed, Jun 08, 2005 at 09:58:12PM +0200, Andreas Schwab wrote:

   > >> +#include <stdint.h>
   > 
   > Since this is a target (not native) file it needs to use types portable to
   > all hosts.

   I'll drop stdint.h because it requires ISO C99, but I don't understand
   your comment.  Is there some environment where uint32_t isn't 4 bytes?  
   This is how I was using uint32_t and uint8_t:

   +      /* 81 /5 id    SUB r/m32, imm32 */
   +      if (op == 0x81 && next_op == 0xec)
   +        {
   +          uint32_t imm32 = read_memory_integer (pc + 2, 4);
   +          esp_change -= imm32;
   +          pc += 6;
   +          continue;
   +        }

   If code like this is wrong, I'd like to know.

Oh yes, it's very wrong ;-).  The function read_memory_integer returns
a signed integer which you're assigning to an unsigned integer type.

Conceptually, if we could assume int32_t was available on all systems,
that would be fine.  But since we cannot, using LONGEST is the safest
thing to do.

Mark


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