예제 #1
0
/* Enable shared library breakpoint for the
   OpenCL runtime running on the SPU.  */
static void
ocl_enable_break (struct objfile *objfile)
{
  struct bound_minimal_symbol event_sym;
  struct bound_minimal_symbol addr_sym;

  /* The OpenCL runtime on the SPU will call __opencl_program_update_event
     whenever an OpenCL program is loaded.  */
  event_sym = lookup_minimal_symbol ("__opencl_program_update_event", NULL,
				     objfile);
  /* The PPU address of the OpenCL program can be found
     at opencl_elf_image_address.  */
  addr_sym = lookup_minimal_symbol ("opencl_elf_image_address", NULL, objfile);

  if (event_sym.minsym && addr_sym.minsym)
    {
      /* Place a solib_event breakpoint on the symbol.  */
      CORE_ADDR event_addr = BMSYMBOL_VALUE_ADDRESS (event_sym);
      create_solib_event_breakpoint (get_objfile_arch (objfile), event_addr);

      /* Store the address of the symbol that will point to OpenCL program
         using the per-objfile private data mechanism.  */
      if (objfile_data (objfile, ocl_program_data_key) == NULL)
        {
          CORE_ADDR *ocl_program_addr_base = OBSTACK_CALLOC (
		  &objfile->objfile_obstack,
		  objfile->sections_end - objfile->sections,
		  CORE_ADDR);
	  *ocl_program_addr_base = BMSYMBOL_VALUE_ADDRESS (addr_sym);
	  set_objfile_data (objfile, ocl_program_data_key,
			    ocl_program_addr_base);
        }
    }
}
예제 #2
0
static htab_t
syscm_get_symbol_map (struct symbol *symbol)
{
  htab_t htab;

  if (SYMBOL_OBJFILE_OWNED (symbol))
    {
      struct objfile *objfile = symbol_objfile (symbol);

      htab = objfile_data (objfile, syscm_objfile_data_key);
      if (htab == NULL)
	{
	  htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob,
						     syscm_eq_symbol_smob);
	  set_objfile_data (objfile, syscm_objfile_data_key, htab);
	}
    }
  else
    {
      struct gdbarch *gdbarch = symbol_arch (symbol);
      struct syscm_gdbarch_data *data = gdbarch_data (gdbarch,
						      syscm_gdbarch_data_key);

      htab = data->htab;
    }

  return htab;
}
예제 #3
0
파일: jv-lang.c 프로젝트: NalaGinrut/gdb
static struct objfile *
get_dynamics_objfile (struct gdbarch *gdbarch)
{
  struct objfile *dynamics_objfile;

  dynamics_objfile = program_space_data (current_program_space,
					 jv_dynamics_progspace_key);

  if (dynamics_objfile == NULL)
    {
      struct jv_per_objfile_data *data;

      /* Mark it as shared so that it is cleared when the inferior is
	 re-run.  */
      dynamics_objfile = allocate_objfile (NULL, NULL,
					   OBJF_SHARED | OBJF_NOT_FILENAME);
      dynamics_objfile->per_bfd->gdbarch = gdbarch;

      data = XCNEW (struct jv_per_objfile_data);
      set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key, data);

      set_program_space_data (current_program_space,
			      jv_dynamics_progspace_key,
			      dynamics_objfile);
    }
  return dynamics_objfile;
}
예제 #4
0
/* Return a borrowed reference to the Python object of type Objfile
   representing OBJFILE.  If the object has already been created,
   return it.  Otherwise, create it.  Return NULL and set the Python
   error on failure.  */
PyObject *
objfile_to_objfile_object (struct objfile *objfile)
{
    objfile_object *object;

    object = objfile_data (objfile, objfpy_objfile_data_key);
    if (!object)
    {
        object = PyObject_New (objfile_object, &objfile_object_type);
        if (object)
        {
            PyObject *dict;

            object->objfile = objfile;

            object->printers = PyList_New (0);
            if (!object->printers)
            {
                Py_DECREF (object);
                return NULL;
            }

            set_objfile_data (objfile, objfpy_objfile_data_key, object);
        }
    }

    return (PyObject *) object;
}
예제 #5
0
void
gdbscm_remove_objfile_ref (struct objfile *objfile,
			   const struct objfile_data *data_key,
			   chained_gdb_smob *g_smob)
{
  if (g_smob->prev)
    g_smob->prev->next = g_smob->next;
  else if (objfile != NULL)
    set_objfile_data (objfile, data_key, g_smob->next);
  if (g_smob->next)
    g_smob->next->prev = g_smob->prev;
}
예제 #6
0
/* Given a symtab, and a symtab_object that has previously been
   allocated and initialized, populate the symtab_object with the
   struct symtab data.  Also, register the symtab_object life-cycle
   with the life-cycle of the object file associated with this
   symtab, if needed.  */
static void
set_symtab (symtab_object *obj, struct symtab *symtab)
{
    obj->symtab = symtab;
    obj->prev = NULL;
    if (symtab)
    {
        obj->next = objfile_data (symtab->objfile, stpy_objfile_data_key);
        if (obj->next)
            obj->next->prev = obj;
        set_objfile_data (symtab->objfile, stpy_objfile_data_key, obj);
    }
    else
        obj->next = NULL;
}
예제 #7
0
static htab_t
syscm_objfile_symbol_map (struct symbol *symbol)
{
    struct objfile *objfile = SYMBOL_SYMTAB (symbol)->objfile;
    htab_t htab = objfile_data (objfile, syscm_objfile_data_key);

    if (htab == NULL)
    {
        htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob,
                syscm_eq_symbol_smob);
        set_objfile_data (objfile, syscm_objfile_data_key, htab);
    }

    return htab;
}
예제 #8
0
static htab_t
stscm_objfile_symtab_map (struct symtab *symtab)
{
  struct objfile *objfile = SYMTAB_OBJFILE (symtab);
  htab_t htab = objfile_data (objfile, stscm_objfile_data_key);

  if (htab == NULL)
    {
      htab = gdbscm_create_eqable_gsmob_ptr_map (stscm_hash_symtab_smob,
						 stscm_eq_symtab_smob);
      set_objfile_data (objfile, stscm_objfile_data_key, htab);
    }

  return htab;
}
예제 #9
0
static void
stpy_dealloc (PyObject *obj)
{
  symtab_object *symtab = (symtab_object *) obj;

  if (symtab->prev)
    symtab->prev->next = symtab->next;
  else if (symtab->symtab)
    {
      set_objfile_data (SYMTAB_OBJFILE (symtab->symtab),
			stpy_objfile_data_key, symtab->next);
    }
  if (symtab->next)
    symtab->next->prev = symtab->prev;
  symtab->symtab = NULL;
}
예제 #10
0
static void
sympy_dealloc (PyObject *obj)
{
    symbol_object *sym_obj = (symbol_object *) obj;

    if (sym_obj->prev)
        sym_obj->prev->next = sym_obj->next;
    else if (SYMBOL_SYMTAB (sym_obj->symbol))
    {
        set_objfile_data (SYMBOL_SYMTAB (sym_obj->symbol)->objfile,
                          sympy_objfile_data_key, sym_obj->next);
    }
    if (sym_obj->next)
        sym_obj->next->prev = sym_obj->prev;
    sym_obj->symbol = NULL;
}
static void
blpy_dealloc (PyObject *obj)
{
  block_object *block = (block_object *) obj;

  if (block->prev)
    block->prev->next = block->next;
  else if (block->objfile)
    {
      set_objfile_data (block->objfile, blpy_objfile_data_key,
			block->next);
    }
  if (block->next)
    block->next->prev = block->prev;
  block->block = NULL;
}
예제 #12
0
void
gdbscm_add_objfile_ref (struct objfile *objfile,
			const struct objfile_data *data_key,
			chained_gdb_smob *g_smob)
{
  g_smob->prev = NULL;
  if (objfile != NULL)
    {
      g_smob->next = objfile_data (objfile, data_key);
      if (g_smob->next)
	g_smob->next->prev = g_smob;
      set_objfile_data (objfile, data_key, g_smob);
    }
  else
    g_smob->next = NULL;
}
예제 #13
0
파일: py-symtab.c 프로젝트: ibuclaw/gdb
/* Given a symtab, and a symtab_object that has previously been
   allocated and initialized, populate the symtab_object with the
   struct symtab data.  Also, register the symtab_object life-cycle
   with the life-cycle of the object file associated with this
   symtab, if needed.  */
static void
set_symtab (symtab_object *obj, struct symtab *symtab)
{
  obj->symtab = symtab;
  obj->prev = NULL;
  if (symtab)
    {
      obj->next
	= ((struct stpy_symtab_object *)
	   objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key));
      if (obj->next)
	obj->next->prev = obj;
      set_objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj);
    }
  else
    obj->next = NULL;
}
/* Given a block, and a block_object that has previously been
   allocated and initialized, populate the block_object with the
   struct block data.  Also, register the block_object life-cycle
   with the life-cycle of the the object file associated with this
   block, if needed.  */
static void
set_block (block_object *obj, struct block *block,
	   struct objfile *objfile)
{
  obj->block = block;
  obj->prev = NULL;
  if (objfile)
    {
      obj->objfile = objfile;
      obj->next = objfile_data (objfile, blpy_objfile_data_key);
      if (obj->next)
	obj->next->prev = obj;
      set_objfile_data (objfile, blpy_objfile_data_key, obj);
    }
  else
    obj->next = NULL;
}
예제 #15
0
/* Given a symbol, and a symbol_object that has previously been
   allocated and initialized, populate the symbol_object with the
   struct symbol data.  Also, register the symbol_object life-cycle
   with the life-cycle of the the object file associated with this
   symbol, if needed.  */
static void
set_symbol (symbol_object *obj, struct symbol *symbol)
{
    obj->symbol = symbol;
    obj->prev = NULL;
    if (SYMBOL_SYMTAB (symbol))
    {
        obj->next = objfile_data (SYMBOL_SYMTAB (symbol)->objfile,
                                  sympy_objfile_data_key);

        if (obj->next)
            obj->next->prev = obj;
        set_objfile_data (SYMBOL_SYMTAB (symbol)->objfile,
                          sympy_objfile_data_key, obj);
    }
    else
        obj->next = NULL;
}
예제 #16
0
static void
salpy_dealloc (PyObject *self)
{
  sal_object *self_sal = (sal_object *) self;

  if (self_sal->prev)
    self_sal->prev->next = self_sal->next;
  else if (self_sal->symtab != (symtab_object * ) Py_None)
    set_objfile_data (SYMTAB_OBJFILE (self_sal->symtab->symtab),
		      salpy_objfile_data_key, self_sal->next);

  if (self_sal->next)
    self_sal->next->prev = self_sal->prev;

  Py_DECREF (self_sal->symtab);
  xfree (self_sal->sal);
  Py_TYPE (self)->tp_free (self);
}
예제 #17
0
파일: py-symtab.c 프로젝트: ibuclaw/gdb
/* Given a sal, and a sal_object that has previously been allocated
   and initialized, populate the sal_object with the struct sal data.
   Also, register the sal_object life-cycle with the life-cycle of the
   object file associated with this sal, if needed.  If a failure
   occurs during the sal population, this function will return -1.  */
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
set_sal (sal_object *sal_obj, struct symtab_and_line sal)
{
  symtab_object *symtab_obj;

  if (sal.symtab)
    {
      symtab_obj = (symtab_object *) symtab_to_symtab_object  (sal.symtab);
      /* If a symtab existed in the sal, but it cannot be duplicated,
	 we exit.  */
      if (symtab_obj == NULL)
	return -1;
    }
  else
    {
      symtab_obj = (symtab_object *) Py_None;
      Py_INCREF (Py_None);
    }

  sal_obj->sal = ((struct symtab_and_line *)
		  xmemdup (&sal, sizeof (struct symtab_and_line),
			   sizeof (struct symtab_and_line)));
  sal_obj->symtab = symtab_obj;
  sal_obj->prev = NULL;

  /* If the SAL does not have a symtab, we do not add it to the
     objfile cleanup observer linked list.  */
  if (sal_obj->symtab != (symtab_object *)Py_None)
    {
      sal_obj->next
	= ((struct salpy_sal_object *)
	   objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab),
			 salpy_objfile_data_key));
      if (sal_obj->next)
	sal_obj->next->prev = sal_obj;

      set_objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab),
			salpy_objfile_data_key, sal_obj);
    }
  else
    sal_obj->next = NULL;

  return 0;
}
예제 #18
0
/* Given a sal, and a sal_object that has previously been allocated
   and initialized, populate the sal_object with the struct sal data.
   Also, register the sal_object life-cycle with the life-cycle of the
   object file associated with this sal, if needed.  If a failure
   occurs during the sal population, this function will return
   NULL.  */
static int
set_sal (sal_object *sal_obj, struct symtab_and_line sal)
{
    symtab_object *symtab_obj;

    if (sal.symtab)
    {
        symtab_obj = (symtab_object *) symtab_to_symtab_object  (sal.symtab);
        /* If a symtab existed in the sal, but it cannot be duplicated,
        we exit.  */
        if (symtab_obj == NULL)
            return 0;
    }
    else
    {
        symtab_obj = (symtab_object *) Py_None;
        Py_INCREF (Py_None);
    }

    sal_obj->sal = xmemdup (&sal, sizeof (struct symtab_and_line),
                            sizeof (struct symtab_and_line));
    sal_obj->symtab = symtab_obj;
    sal_obj->prev = NULL;

    /* If the SAL does not have a symtab, we do not add it to the
       objfile cleanup observer linked list.  */
    if (sal_obj->symtab != (symtab_object *)Py_None)
    {
        sal_obj->next = objfile_data (sal_obj->symtab->symtab->objfile,
                                      salpy_objfile_data_key);
        if (sal_obj->next)
            sal_obj->next->prev = sal_obj;

        set_objfile_data (sal_obj->symtab->symtab->objfile,
                          salpy_objfile_data_key, sal_obj);
    }
    else
        sal_obj->next = NULL;

    return 1;
}
예제 #19
0
static struct mdebug_extra_func_info *
non_heuristic_proc_desc (CORE_ADDR pc, CORE_ADDR *addrptr)
{
    CORE_ADDR startaddr;
    struct mdebug_extra_func_info *proc_desc;
    struct block *b = block_for_pc (pc);
    struct symbol *sym;
    struct obj_section *sec;
    struct mips_objfile_private *priv;

    find_pc_partial_function (pc, NULL, &startaddr, NULL);
    if (addrptr)
        *addrptr = startaddr;

    priv = NULL;

    sec = find_pc_section (pc);
    if (sec != NULL)
    {
        priv = (struct mips_objfile_private *) objfile_data (sec->objfile, mips_pdr_data);

        /* Search the ".pdr" section generated by GAS.  This includes most of
           the information normally found in ECOFF PDRs.  */

        the_bfd = sec->objfile->obfd;
        if (priv == NULL
                && (the_bfd->format == bfd_object
                    && bfd_get_flavour (the_bfd) == bfd_target_elf_flavour
                    && elf_elfheader (the_bfd)->e_ident[EI_CLASS] == ELFCLASS64))
        {
            /* Right now GAS only outputs the address as a four-byte sequence.
               This means that we should not bother with this method on 64-bit
               targets (until that is fixed).  */

            priv = obstack_alloc (&sec->objfile->objfile_obstack,
                                  sizeof (struct mips_objfile_private));
            priv->size = 0;
            set_objfile_data (sec->objfile, mips_pdr_data, priv);
        }
        else if (priv == NULL)
        {
            asection *bfdsec;

            priv = obstack_alloc (&sec->objfile->objfile_obstack,
                                  sizeof (struct mips_objfile_private));

            bfdsec = bfd_get_section_by_name (sec->objfile->obfd, ".pdr");
            if (bfdsec != NULL)
            {
                priv->size = bfd_section_size (sec->objfile->obfd, bfdsec);
                priv->contents = obstack_alloc (&sec->objfile->objfile_obstack,
                                                priv->size);
                bfd_get_section_contents (sec->objfile->obfd, bfdsec,
                                          priv->contents, 0, priv->size);

                /* In general, the .pdr section is sorted.  However, in the
                   presence of multiple code sections (and other corner cases)
                   it can become unsorted.  Sort it so that we can use a faster
                   binary search.  */
                qsort (priv->contents, priv->size / 32, 32,
                       compare_pdr_entries);
            }
            else
                priv->size = 0;

            set_objfile_data (sec->objfile, mips_pdr_data, priv);
        }
        the_bfd = NULL;

        if (priv->size != 0)
        {
            int low, mid, high;
            char *ptr;
            CORE_ADDR pdr_pc;

            low = 0;
            high = priv->size / 32;

            /* We've found a .pdr section describing this objfile.  We want to
               find the entry which describes this code address.  The .pdr
               information is not very descriptive; we have only a function
               start address.  We have to look for the closest entry, because
               the local symbol at the beginning of this function may have
               been stripped - so if we ask the symbol table for the start
               address we may get a preceding global function.  */

            /* First, find the last .pdr entry starting at or before PC.  */
            do
            {
                mid = (low + high) / 2;

                ptr = priv->contents + mid * 32;
                pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr);
                pdr_pc += ANOFFSET (sec->objfile->section_offsets,
                                    SECT_OFF_TEXT (sec->objfile));

                if (pdr_pc > pc)
                    high = mid;
                else
                    low = mid + 1;
            }
            while (low != high);

            /* Both low and high point one past the PDR of interest.  If
               both are zero, that means this PC is before any region
               covered by a PDR, i.e. pdr_pc for the first PDR entry is
               greater than PC.  */
            if (low > 0)
            {
                ptr = priv->contents + (low - 1) * 32;
                pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr);
                pdr_pc += ANOFFSET (sec->objfile->section_offsets,
                                    SECT_OFF_TEXT (sec->objfile));
            }

            /* We don't have a range, so we have no way to know for sure
               whether we're in the correct PDR or a PDR for a preceding
               function and the current function was a stripped local
               symbol.  But if the PDR's PC is at least as great as the
               best guess from the symbol table, assume that it does cover
               the right area; if a .pdr section is present at all then
               nearly every function will have an entry.  The biggest exception
               will be the dynamic linker stubs; conveniently these are
               placed before .text instead of after.  */

            if (pc >= pdr_pc && pdr_pc >= startaddr)
            {
                struct symbol *sym = find_pc_function (pc);

                if (addrptr)
                    *addrptr = pdr_pc;

                /* Fill in what we need of the proc_desc.  */
                proc_desc = (struct mdebug_extra_func_info *)
                            obstack_alloc (&sec->objfile->objfile_obstack,
                                           sizeof (struct mdebug_extra_func_info));
                PROC_LOW_ADDR (proc_desc) = pdr_pc;

                PROC_FRAME_OFFSET (proc_desc)
                    = bfd_get_signed_32 (sec->objfile->obfd, ptr + 20);
                PROC_FRAME_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd,
                                             ptr + 24);
                PROC_REG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd,
                                                        ptr + 4);
                PROC_FREG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd,
                                             ptr + 12);
                PROC_REG_OFFSET (proc_desc)
                    = bfd_get_signed_32 (sec->objfile->obfd, ptr + 8);
                PROC_FREG_OFFSET (proc_desc)
                    = bfd_get_signed_32 (sec->objfile->obfd, ptr + 16);
                PROC_PC_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd,
                                                      ptr + 28);
                proc_desc->pdr.isym = (long) sym;

                return proc_desc;
            }
        }
    }

    if (b == NULL)
        return NULL;

    if (startaddr > BLOCK_START (b))
    {
        /* This is the "pathological" case referred to in a comment in
           print_frame_info.  It might be better to move this check into
           symbol reading.  */
        return NULL;
    }

    sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, 0);

    /* If we never found a PDR for this function in symbol reading, then
       examine prologues to find the information.  */
    if (sym)
    {
        proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE (sym);
        if (PROC_FRAME_REG (proc_desc) == -1)
            return NULL;
        else
            return proc_desc;
    }
    else
        return NULL;
}