contrib/gdb-7/gdb/jit.c
static void
jit_read_code_entry (struct gdbarch *gdbarch,
		     CORE_ADDR code_addr, struct jit_code_entry *code_entry)
{
  int err, off;
  struct type *ptr_type;
  int ptr_size;
  int entry_size;
  int align_bytes;
  gdb_byte *entry_buf;
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

  /* Figure out how big the entry is on the remote and how to read it.  */
  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
  ptr_size = TYPE_LENGTH (ptr_type);
  entry_size = 3 * ptr_size + 8;  /* Three pointers and one 64-bit int.  */
  entry_buf = alloca (entry_size);

  /* Read the entry.  */
  err = target_read_memory (code_addr, entry_buf, entry_size);
  if (err)
    error (_("Unable to read JIT code entry from remote memory!"));

  /* Fix the endianness to match the host.  */
  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
  code_entry->next_entry = extract_typed_address (&entry_buf[0], ptr_type);
  code_entry->prev_entry =
      extract_typed_address (&entry_buf[ptr_size], ptr_type);
  code_entry->symfile_addr =
      extract_typed_address (&entry_buf[2 * ptr_size], ptr_type);

  align_bytes = gdbarch_long_long_align_bit (gdbarch) / 8;
  off = 3 * ptr_size;
  off = (off + (align_bytes - 1)) & ~(align_bytes - 1);

  code_entry->symfile_size =
      extract_unsigned_integer (&entry_buf[off], 8, byte_order);
}
/* Helper function for reading a JITed code entry from remote memory.  */
Helper function for reading a JITed code entry from remote memory.
Helper function for reading a JITed code entry from remote memory .
static void
jit_read_code_entry (struct gdbarch *gdbarch,
		     CORE_ADDR code_addr, struct jit_code_entry *code_entry)
{
  int err, off;
  struct type *ptr_type;
  int ptr_size;
  int entry_size;
  int align_bytes;
  gdb_byte *entry_buf;
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
  ptr_size = TYPE_LENGTH (ptr_type);
  entry_size = 3 * ptr_size + 8;  
  entry_buf = alloca (entry_size);
  err = target_read_memory (code_addr, entry_buf, entry_size);
  if (err)
    error (_("Unable to read JIT code entry from remote memory!"));
  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
  code_entry->next_entry = extract_typed_address (&entry_buf[0], ptr_type);
  code_entry->prev_entry =
      extract_typed_address (&entry_buf[ptr_size], ptr_type);
  code_entry->symfile_addr =
      extract_typed_address (&entry_buf[2 * ptr_size], ptr_type);
  align_bytes = gdbarch_long_long_align_bit (gdbarch) / 8;
  off = 3 * ptr_size;
  off = (off + (align_bytes - 1)) & ~(align_bytes - 1);
  code_entry->symfile_size =
      extract_unsigned_integer (&entry_buf[off], 8, byte_order);
}
static void jit_read_code_entry ( struct gdbarch * gdbarch , CORE_ADDR code_addr , struct jit_code_entry * code_entry ) { int err , off ; struct type * ptr_type ; int ptr_size ; int entry_size ; int align_bytes ; gdb_byte * entry_buf ; enum bfd_endian byte_order = gdbarch_byte_order ( gdbarch ) ; ptr_type = builtin_type ( gdbarch ) -> builtin_data_ptr ; ptr_size = TYPE_LENGTH ( ptr_type ) ; entry_size = 3 * ptr_size + 8 ; entry_buf = alloca ( entry_size ) ; err = target_read_memory ( code_addr , entry_buf , entry_size ) ; if ( err ) error ( _ ( " " ) ) ; ptr_type = builtin_type ( gdbarch ) -> builtin_data_ptr ; code_entry -> next_entry = extract_typed_address ( & entry_buf [ 0 ] , ptr_type ) ; code_entry -> prev_entry = extract_typed_address ( & entry_buf [ ptr_size ] , ptr_type ) ; code_entry -> symfile_addr = extract_typed_address ( & entry_buf [ 2 * ptr_size ] , ptr_type ) ; align_bytes = gdbarch_long_long_align_bit ( gdbarch ) / 8 ; off = 3 * ptr_size ; off = ( off + ( align_bytes - 1 ) ) & ~ ( align_bytes - 1 ) ; code_entry -> symfile_size = extract_unsigned_integer ( & entry_buf [ off ] , 8 , byte_order ) ; }
Helper function for reading a JITed code entry from remote memory.
Helper function for reading a JITed code entry from remote memory .
/* Figure out how big the entry is on the remote and how to read it.  */ /* Three pointers and one 64-bit int.  */ /* Read the entry.  */ /* Fix the endianness to match the host.  */