您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ value_as_address函数代码示例

51自学网 2021-06-03 09:33:17
  C++
这篇教程C++ value_as_address函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中value_as_address函数的典型用法代码示例。如果您正苦于以下问题:C++ value_as_address函数的具体用法?C++ value_as_address怎么用?C++ value_as_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了value_as_address函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gnuv3_get_vtable

static struct value *gnuv3_get_vtable (struct gdbarch *gdbarch, struct value *container){  struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);  struct type *vtable_pointer_type;  struct value *vtable_pointer;  CORE_ADDR vtable_pointer_address, vtable_address;  /* We do not consult the debug information to find the virtual table.     The ABI specifies that it is always at offset zero in any class,     and debug information may not represent it.  We won't issue an     error if there's a class with virtual functions but no virtual table     pointer, but something's already gone seriously wrong if that     happens.     We avoid using value_contents on principle, because the object might     be large.  */  /* Find the type "pointer to virtual table".  */  vtable_pointer_type = lookup_pointer_type (vtable_type);  /* Load it from the start of the class.  */  vtable_pointer_address = value_as_address (value_addr (container));  vtable_pointer = value_at (vtable_pointer_type, vtable_pointer_address);  vtable_address = value_as_address (vtable_pointer);  /* Correct it to point at the start of the virtual table, rather     than the address point.  */  return value_at_lazy (vtable_type,			vtable_address - vtable_address_point_offset (gdbarch));}
开发者ID:OpenInkpot-archive,项目名称:iplinux-gdb,代码行数:31,


示例2: kgdb_parse_1

/* * Parse an expression and return its value.  If 'quiet' is true, then * any error messages from the parser are masked. */CORE_ADDRkgdb_parse_1(const char *exp, int quiet){	struct ui_file *old_stderr;	struct cleanup *old_chain;	struct expression *expr;	struct value *val;	char *s;	CORE_ADDR n;	old_stderr = gdb_stderr;	if (quiet)		gdb_stderr = parse_gdberr;	n = 0;	s = xstrdup(exp);	old_chain = make_cleanup(xfree, s);	if (gdb_parse_exp_1(&s, NULL, 0, &expr) && *s == '/0') {		make_cleanup(free_current_contents, &expr);		if (gdb_evaluate_expression(expr, &val))		    n = value_as_address(val);	}	do_cleanups(old_chain);	gdb_stderr = old_stderr;	return (n);}
开发者ID:2asoft,项目名称:freebsd,代码行数:29,


示例3: gnuv3_get_vtable

static struct value *gnuv3_get_vtable (struct gdbarch *gdbarch,		  struct type *container_type, CORE_ADDR container_addr){  struct type *vtable_type = gdbarch_data (gdbarch,					   vtable_type_gdbarch_data);  struct type *vtable_pointer_type;  struct value *vtable_pointer;  CORE_ADDR vtable_address;  /* If this type does not have a virtual table, don't read the first     field.  */  if (!gnuv3_dynamic_class (check_typedef (container_type)))    return NULL;  /* We do not consult the debug information to find the virtual table.     The ABI specifies that it is always at offset zero in any class,     and debug information may not represent it.     We avoid using value_contents on principle, because the object might     be large.  */  /* Find the type "pointer to virtual table".  */  vtable_pointer_type = lookup_pointer_type (vtable_type);  /* Load it from the start of the class.  */  vtable_pointer = value_at (vtable_pointer_type, container_addr);  vtable_address = value_as_address (vtable_pointer);  /* Correct it to point at the start of the virtual table, rather     than the address point.  */  return value_at_lazy (vtable_type,			vtable_address			- vtable_address_point_offset (gdbarch));}
开发者ID:nds32,项目名称:binutils,代码行数:35,


示例4: info_mach_region_command

voidinfo_mach_region_command (char *exp, int from_tty){  struct expression *expr;  struct value *val;  vm_address_t address;  expr = parse_expression (exp);  val = evaluate_expression (expr);  if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)    {      val = value_ind (val);    }  /* In rvalue contexts, such as this, functions are coerced into     pointers to functions. */  if (TYPE_CODE (value_type (val)) == TYPE_CODE_FUNC      && VALUE_LVAL (val) == lval_memory)    {      address = VALUE_ADDRESS (val);    }  else    {      address = value_as_address (val);    }  if ((!macosx_status) || (macosx_status->task == TASK_NULL))    {      error ("Inferior not available");    }  macosx_debug_region (macosx_status->task, address);}
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:33,


示例5: get_addr_from_python

intget_addr_from_python (PyObject *obj, CORE_ADDR *addr){  if (gdbpy_is_value_object (obj))    *addr = value_as_address (value_object_to_value (obj));  else    {      PyObject *num = PyNumber_Long (obj);      gdb_py_ulongest val;      if (num == NULL)	return 0;      val = gdb_py_long_as_ulongest (num);      Py_XDECREF (num);      if (PyErr_Occurred ())	return 0;      if (sizeof (val) > sizeof (CORE_ADDR) && ((CORE_ADDR) val) != val)	{	  PyErr_SetString (PyExc_ValueError,			   _("Overflow converting to address."));	  return 0;	}      *addr = val;    }  return 1;}
开发者ID:abidh,项目名称:gdb,代码行数:30,


示例6: gnuv3_get_virtual_fn

static struct value *gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,		      struct type *fntype, int vtable_index){  struct value *vtable, *vfn;  /* Every class with virtual functions must have a vtable.  */  vtable = gnuv3_get_vtable (gdbarch, value_type (container),			     value_as_address (value_addr (container)));  gdb_assert (vtable != NULL);  /* Fetch the appropriate function pointer from the vtable.  */  vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions),                         vtable_index);  /* If this architecture uses function descriptors directly in the vtable,     then the address of the vtable entry is actually a "function pointer"     (i.e. points to the descriptor).  We don't need to scale the index     by the size of a function descriptor; GCC does that before outputing     debug information.  */  if (gdbarch_vtable_function_descriptors (gdbarch))    vfn = value_addr (vfn);  /* Cast the function pointer to the appropriate type.  */  vfn = value_cast (lookup_pointer_type (fntype), vfn);  return vfn;}
开发者ID:nds32,项目名称:binutils,代码行数:28,


示例7: java_class_is_primitive

/* Check if CLASS_IS_PRIMITIVE(value of clas): */static intjava_class_is_primitive (struct value *clas){  struct value *vtable = value_struct_elt (&clas, NULL, "vtable",					   NULL, "struct");  CORE_ADDR i = value_as_address (vtable);  return (int) (i & 0x7fffffff) == (int) 0x7fffffff;}
开发者ID:NalaGinrut,项目名称:gdb,代码行数:10,


示例8: java_class_from_object

struct value *java_class_from_object (struct value *obj_val){  /* This is all rather inefficient, since the offsets of vtable and     class are fixed.  FIXME */  struct value *vtable_val;  if (TYPE_CODE (value_type (obj_val)) == TYPE_CODE_PTR      && TYPE_LENGTH (TYPE_TARGET_TYPE (value_type (obj_val))) == 0)    obj_val = value_at (get_java_object_type (),			value_as_address (obj_val));  vtable_val = value_struct_elt (&obj_val, NULL, "vtable", NULL, "structure");  return value_struct_elt (&vtable_val, NULL, "class", NULL, "structure");}
开发者ID:NalaGinrut,项目名称:gdb,代码行数:15,


示例9: get_addr_from_python

intget_addr_from_python (PyObject *obj, CORE_ADDR *addr){  if (gdbpy_is_value_object (obj))    {      TRY	{	  *addr = value_as_address (value_object_to_value (obj));	}      CATCH (except, RETURN_MASK_ALL)	{	  GDB_PY_SET_HANDLE_EXCEPTION (except);	}      END_CATCH    }
开发者ID:Winter3un,项目名称:ctf_task,代码行数:16,


示例10: value_ptradd

struct value *value_ptradd (struct value *arg1, LONGEST arg2){  struct type *valptrtype;  LONGEST sz;  struct value *result;  arg1 = coerce_array (arg1);  valptrtype = check_typedef (value_type (arg1));  sz = find_size_for_pointer_math (valptrtype);  result = value_from_pointer (valptrtype,			       value_as_address (arg1) + sz * arg2);  if (VALUE_LVAL (result) != lval_internalvar)    set_value_component_location (result, arg1);  return result;}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:17,


示例11: ada_varobj_ind

static voidada_varobj_ind (struct value *parent_value,		struct type *parent_type,		struct value **child_value,		struct type **child_type){  struct value *value = NULL;  struct type *type = NULL;  if (ada_is_array_descriptor_type (parent_type))    {      /* This can only happen when PARENT_VALUE is NULL.  Otherwise,	 ada_get_decoded_value would have transformed our parent_type	 into a simple array pointer type.  */      gdb_assert (parent_value == NULL);      gdb_assert (TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF);      /* Decode parent_type by the equivalent pointer to (decoded)	 array.  */      while (TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF)	parent_type = TYPE_TARGET_TYPE (parent_type);      parent_type = ada_coerce_to_simple_array_type (parent_type);      parent_type = lookup_pointer_type (parent_type);    }  /* If parent_value is a null pointer, then only perform static     dereferencing.  We cannot dereference null pointers.  */  if (parent_value && value_as_address (parent_value) == 0)    parent_value = NULL;  if (parent_value)    {      value = ada_value_ind (parent_value);      type = value_type (value);    }  else    type = TYPE_TARGET_TYPE (parent_type);  if (child_value)    *child_value = value;  if (child_type)    *child_type = type;}
开发者ID:CromFr,项目名称:gdb,代码行数:43,


示例12: get_addr_from_python

intget_addr_from_python (PyObject *obj, CORE_ADDR *addr){  if (gdbpy_is_value_object (obj))    *addr = value_as_address (value_object_to_value (obj));  else if (PyLong_Check (obj))    {      /* Assume CORE_ADDR corresponds to unsigned long.  */      *addr = PyLong_AsUnsignedLong (obj);      if (PyErr_Occurred () != NULL)	return 0;    }  else if (PyInt_Check (obj))    {      long val;      /* Assume CORE_ADDR corresponds to unsigned long.  */      val = PyInt_AsLong (obj);      if (val >= 0)	*addr = val;      else      {	/* If no error ocurred, VAL is indeed negative.  */	if (PyErr_Occurred () != NULL)	  return 0;	PyErr_SetString (PyExc_ValueError,			 _("Supplied address is negative."));	return 0;      }    }  else    {      PyErr_SetString (PyExc_TypeError,		       _("Invalid type for address."));      return 0;    }  return 1;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:41,


示例13: info_mach_region_command

static voidinfo_mach_region_command (char *exp, int from_tty){  struct value *val;  mach_vm_address_t address;  struct inferior *inf;  expression_up expr = parse_expression (exp);  val = evaluate_expression (expr.get ());  if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)    {      val = value_ind (val);    }  address = value_as_address (val);  if (ptid_equal (inferior_ptid, null_ptid))    error (_("Inferior not available"));  inf = current_inferior ();  darwin_debug_region (inf->priv->task, address);}
开发者ID:kraj,项目名称:binutils-gdb,代码行数:21,


示例14: info_embedded_symbol_command

static void info_embedded_symbol_command (char *exp, int from_tty){  struct expression *expr;  struct value *val;  CORE_ADDR address;  struct embedded_symbol *sym;  expr = parse_expression (exp);  val = evaluate_expression (expr);  if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)    val = value_ind (val);  if ((TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC) && (VALUE_LVAL (val) == lval_memory))    address = VALUE_ADDRESS (val);  else    address = value_as_address (val);  sym = search_for_embedded_symbol (address);  if (sym != NULL)    fprintf_unfiltered      (gdb_stderr, "Symbol at 0x%lx is /"%s/"./n", (unsigned long) address, sym->name);  else    fprintf_unfiltered      (gdb_stderr, "Symbol at 0x%lx is unknown./n", (unsigned long) address);}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:24,


示例15: find_function_addr

CORE_ADDRfind_function_addr (struct value *function, struct type **retval_type){  struct type *ftype = check_typedef (value_type (function));  struct gdbarch *gdbarch = get_type_arch (ftype);  struct type *value_type = NULL;  /* Initialize it just to avoid a GCC false warning.  */  CORE_ADDR funaddr = 0;  /* If it's a member function, just look at the function     part of it.  */  /* Determine address to call.  */  if (TYPE_CODE (ftype) == TYPE_CODE_FUNC      || TYPE_CODE (ftype) == TYPE_CODE_METHOD)    funaddr = value_address (function);  else if (TYPE_CODE (ftype) == TYPE_CODE_PTR)    {      funaddr = value_as_address (function);      ftype = check_typedef (TYPE_TARGET_TYPE (ftype));      if (TYPE_CODE (ftype) == TYPE_CODE_FUNC	  || TYPE_CODE (ftype) == TYPE_CODE_METHOD)	funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,						      &current_target);    }  if (TYPE_CODE (ftype) == TYPE_CODE_FUNC      || TYPE_CODE (ftype) == TYPE_CODE_METHOD)    {      value_type = TYPE_TARGET_TYPE (ftype);      if (TYPE_GNU_IFUNC (ftype))	{	  funaddr = gnu_ifunc_resolve_addr (gdbarch, funaddr);	  /* Skip querying the function symbol if no RETVAL_TYPE has been	     asked for.  */	  if (retval_type)	    value_type = find_function_return_type (funaddr);	}    }  else if (TYPE_CODE (ftype) == TYPE_CODE_INT)    {      /* Handle the case of functions lacking debugging info.         Their values are characters since their addresses are char.  */      if (TYPE_LENGTH (ftype) == 1)	funaddr = value_as_address (value_addr (function));      else	{	  /* Handle function descriptors lacking debug info.  */	  int found_descriptor = 0;	  funaddr = 0;	/* pacify "gcc -Werror" */	  if (VALUE_LVAL (function) == lval_memory)	    {	      CORE_ADDR nfunaddr;	      funaddr = value_as_address (value_addr (function));	      nfunaddr = funaddr;	      funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,							    &current_target);	      if (funaddr != nfunaddr)		found_descriptor = 1;	    }	  if (!found_descriptor)	    /* Handle integer used as address of a function.  */	    funaddr = (CORE_ADDR) value_as_long (function);	}    }  else    error (_("Invalid data type for function to be called."));  if (retval_type != NULL)    *retval_type = value_type;  return funaddr + gdbarch_deprecated_function_start_offset (gdbarch);}
开发者ID:ChrisG0x20,项目名称:gdb,代码行数:75,


示例16: ppc64_sysv_abi_push_dummy_call

//.........这里部分代码省略.........	      if (freg <= 13		  && TYPE_CODE (type) == TYPE_CODE_STRUCT		  && TYPE_NFIELDS (type) == 1		  && TYPE_LENGTH (type) <= 16)		{		  /* The ABI (version 1.9) specifies that structs		     containing a single floating-point value, at any		     level of nesting of single-member structs, are		     passed in floating-point registers.  */		  while (TYPE_CODE (type) == TYPE_CODE_STRUCT			 && TYPE_NFIELDS (type) == 1)		    type = check_typedef (TYPE_FIELD_TYPE (type, 0));		  if (TYPE_CODE (type) == TYPE_CODE_FLT)		    {		      if (TYPE_LENGTH (type) <= 8)			{			  if (write_pass)			    {			      gdb_byte regval[MAX_REGISTER_SIZE];			      struct type *regtype				= register_type (gdbarch,						 tdep->ppc_fp0_regnum);			      convert_typed_floating (val, type, regval,						      regtype);			      regcache_cooked_write (regcache,						     (tdep->ppc_fp0_regnum						      + freg),						     regval);			    }			  freg++;			}		      else if (TYPE_LENGTH (type) == 16			       && (gdbarch_long_double_format (gdbarch)				   == floatformats_ibm_long_double))			{			  if (write_pass)			    {			      regcache_cooked_write (regcache,						     (tdep->ppc_fp0_regnum						      + freg),						     val);			      if (freg <= 12)				regcache_cooked_write (regcache,						       (tdep->ppc_fp0_regnum							+ freg + 1),						       val + 8);			    }			  freg += 2;			}		    }		}	      /* Always consume parameter stack space.  */	      gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);	    }	}      if (!write_pass)	{	  /* Save the true region sizes ready for the second pass.  */	  vparam_size = vparam;	  /* Make certain that the general parameter save area is at	     least the minimum 8 registers (or doublewords) in size.  */	  if (greg < 8)	    gparam_size = 8 * tdep->wordsize;	  else	    gparam_size = gparam;	}    }  /* Update %sp.   */  regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);  /* Write the backchain (it occupies WORDSIZED bytes).  */  write_memory_signed_integer (sp, tdep->wordsize, byte_order, back_chain);  /* Point the inferior function call's return address at the dummy's     breakpoint.  */  regcache_cooked_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);  /* Use the func_addr to find the descriptor, and use that to find     the TOC.  If we're calling via a function pointer, the pointer     itself identifies the descriptor.  */  {    struct type *ftype = check_typedef (value_type (function));    CORE_ADDR desc_addr = value_as_address (function);    if (TYPE_CODE (ftype) == TYPE_CODE_PTR	|| convert_code_addr_to_desc_addr (func_addr, &desc_addr))      {	/* The TOC is the second double word in the descriptor.  */	CORE_ADDR toc =	  read_memory_unsigned_integer (desc_addr + tdep->wordsize,					tdep->wordsize, byte_order);	regcache_cooked_write_unsigned (regcache,					tdep->ppc_gp0_regnum + 2, toc);      }  }  return sp;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:101,


示例17: VALADDR

/* Compute the offset of the baseclass which is   the INDEXth baseclass of class TYPE,   for value at VALADDR (in host) at ADDRESS (in target).   The result is the offset of the baseclass value relative   to (the address of)(ARG) + OFFSET.   -1 is returned on error. */static intgnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,			CORE_ADDR address){  struct gdbarch *gdbarch;  struct type *vtable_type;  struct type *ptr_type;  struct value *vtable;  struct type *vbasetype;  struct value *offset_val, *vbase_array;  CORE_ADDR vtable_address;  long int cur_base_offset, base_offset;  int vbasetype_vptr_fieldno;  /* Determine architecture.  */  gdbarch = get_class_arch (type);  vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);  ptr_type = builtin_type (gdbarch)->builtin_data_ptr;  /* If it isn't a virtual base, this is easy.  The offset is in the     type definition.  */  if (!BASETYPE_VIA_VIRTUAL (type, index))    return TYPE_BASECLASS_BITPOS (type, index) / 8;  /* To access a virtual base, we need to use the vbase offset stored in     our vtable.  Recent GCC versions provide this information.  If it isn't     available, we could get what we needed from RTTI, or from drawing the     complete inheritance graph based on the debug info.  Neither is     worthwhile.  */  cur_base_offset = TYPE_BASECLASS_BITPOS (type, index) / 8;  if (cur_base_offset >= - vtable_address_point_offset (gdbarch))    error (_("Expected a negative vbase offset (old compiler?)"));  cur_base_offset = cur_base_offset + vtable_address_point_offset (gdbarch);  if ((- cur_base_offset) % TYPE_LENGTH (ptr_type) != 0)    error (_("Misaligned vbase offset."));  cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type));  /* We're now looking for the cur_base_offset'th entry (negative index)     in the vcall_and_vbase_offsets array.  We used to cast the object to     its TYPE_VPTR_BASETYPE, and reference the vtable as TYPE_VPTR_FIELDNO;     however, that cast can not be done without calling baseclass_offset again     if the TYPE_VPTR_BASETYPE is a virtual base class, as described in the     v3 C++ ABI Section 2.4.I.2.b.  Fortunately the ABI guarantees that the     vtable pointer will be located at the beginning of the object, so we can     bypass the casting.  Verify that the TYPE_VPTR_FIELDNO is in fact at the     start of whichever baseclass it resides in, as a sanity measure - iff     we have debugging information for that baseclass.  */  vbasetype = check_typedef (TYPE_VPTR_BASETYPE (type));  vbasetype_vptr_fieldno = get_vptr_fieldno (vbasetype, NULL);  if (vbasetype_vptr_fieldno >= 0      && TYPE_FIELD_BITPOS (vbasetype, vbasetype_vptr_fieldno) != 0)    error (_("Illegal vptr offset in class %s"),	   TYPE_NAME (vbasetype) ? TYPE_NAME (vbasetype) : "<unknown>");  vtable_address = value_as_address (value_at_lazy (ptr_type, address));  vtable    = value_at_lazy (vtable_type,		     vtable_address - vtable_address_point_offset (gdbarch));  offset_val = value_from_longest (builtin_type_int32, cur_base_offset);  vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);  base_offset = value_as_long (value_subscript (vbase_array, offset_val));  return base_offset;}
开发者ID:OpenInkpot-archive,项目名称:iplinux-gdb,代码行数:73,


示例18: c_value_print

voidc_value_print (struct value *val, struct ui_file *stream, 	       const struct value_print_options *options){  struct type *type, *real_type, *val_type;  int full, top, using_enc;  struct value_print_options opts = *options;  opts.deref_ref = 1;  /* If it is a pointer, indicate what it points to.     Print type also if it is a reference.     C++: if it is a member pointer, we will take care     of that when we print it.  */  /* Preserve the original type before stripping typedefs.  We prefer     to pass down the original type when possible, but for local     checks it is better to look past the typedefs.  */  val_type = value_type (val);  type = check_typedef (val_type);  if (TYPE_CODE (type) == TYPE_CODE_PTR      || TYPE_CODE (type) == TYPE_CODE_REF)    {      /* Hack:  remove (char *) for char strings.  Their         type is indicated by the quoted string anyway.         (Don't use c_textual_element_type here; quoted strings         are always exactly (char *), (wchar_t *), or the like.  */      if (TYPE_CODE (val_type) == TYPE_CODE_PTR	  && TYPE_NAME (val_type) == NULL	  && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)),		      "char") == 0	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))	{	  /* Print nothing.  */	}      else if (options->objectprint	       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))	{	  int is_ref = TYPE_CODE (type) == TYPE_CODE_REF;	  if (is_ref)	    val = value_addr (val);	  /* Pointer to class, check real type of object.  */	  fprintf_filtered (stream, "(");	  if (value_entirely_available (val)) 	    {	      real_type = value_rtti_indirect_type (val, &full, &top,						    &using_enc);	      if (real_type)		{		  /* RTTI entry found.  */		  type = real_type;		  /* Need to adjust pointer value.  */		  val = value_from_pointer (real_type,					    value_as_address (val) - top);		  if (is_ref)		    {		      val = value_ref (value_ind (val));		      type = value_type (val);		    }		  /* Note: When we look up RTTI entries, we don't get		     any information on const or volatile		     attributes.  */		}	    }          type_print (type, "", stream, -1);	  fprintf_filtered (stream, ") ");	  val_type = type;	}      else	{	  /* normal case */	  fprintf_filtered (stream, "(");	  type_print (value_type (val), "", stream, -1);	  fprintf_filtered (stream, ") ");	}    }  if (!value_initialized (val))    fprintf_filtered (stream, " [uninitialized] ");  if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))    {      /* Attempt to determine real type of object.  */      real_type = value_rtti_type (val, &full, &top, &using_enc);      if (real_type)	{	  /* We have RTTI information, so use it.  */	  val = value_full_object (val, real_type, 				   full, top, using_enc);	  fprintf_filtered (stream, "(%s%s) ",//.........这里部分代码省略.........
开发者ID:nds32,项目名称:binutils,代码行数:101,


示例19: java_value_print

//.........这里部分代码省略.........	  set_value_address (v, (address				 + get_java_object_header_size (gdbarch) + 4));	  set_value_address (next_v, value_raw_address (v));	  while (i < length && things_printed < options->print_max)	    {	      fputs_filtered (", ", stream);	      wrap_here (n_spaces (2));	      if (i > 0)		{		  struct value *tmp;		  tmp = next_v;		  next_v = v;		  v = tmp;		}	      else		{		  set_value_lazy (v, 1);		  set_value_offset (v, 0);		}	      set_value_offset (next_v, value_offset (v));	      for (reps = 1; i + reps < length; reps++)		{		  set_value_lazy (next_v, 1);		  set_value_offset (next_v, value_offset (next_v) + TYPE_LENGTH (el_type));		  if (memcmp (value_contents (v), value_contents (next_v),			      TYPE_LENGTH (el_type)) != 0)		    break;		}	      if (reps == 1)		fprintf_filtered (stream, "%d: ", i);	      else		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);	      opts = *options;	      opts.deref_ref = 1;	      common_val_print (v, stream, 1, &opts, current_language);	      things_printed++;	      i += reps;	    }	}      if (i < length)	fprintf_filtered (stream, "...");      fprintf_filtered (stream, "}");      return 0;    }  /* If it's type String, print it */  if (TYPE_CODE (type) == TYPE_CODE_PTR      && TYPE_TARGET_TYPE (type)      && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))      && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),		 "java.lang.String") == 0      && (options->format == 0 || options->format == 's')      && address != 0      && value_as_address (val) != 0)    {      struct type *char_type;      struct value *data_val;      CORE_ADDR data;      struct value *boffset_val;      unsigned long boffset;      struct value *count_val;      unsigned long count;      struct value *mark;      mark = value_mark ();	/* Remember start of new values */      data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);      data = value_as_address (data_val);      boffset_val = value_struct_elt (&val, NULL, "boffset", NULL, NULL);      boffset = value_as_address (boffset_val);      count_val = value_struct_elt (&val, NULL, "count", NULL, NULL);      count = value_as_address (count_val);      value_free_to_mark (mark);	/* Release unnecessary values */      char_type = builtin_java_type (gdbarch)->builtin_char;      val_print_string (char_type, data + boffset, count, stream, options);      return 0;    }  opts = *options;  opts.deref_ref = 1;  return common_val_print (val, stream, 0, &opts, current_language);}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:101,


示例20: gnuv3_rtti_type

static struct type *gnuv3_rtti_type (struct value *value,                 int *full_p, int *top_p, int *using_enc_p){  struct gdbarch *gdbarch;  struct type *values_type = check_typedef (value_type (value));  struct value *vtable;  struct minimal_symbol *vtable_symbol;  const char *vtable_symbol_name;  const char *class_name;  struct type *run_time_type;  LONGEST offset_to_top;  char *atsign;  /* We only have RTTI for class objects.  */  if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)    return NULL;  /* Java doesn't have RTTI following the C++ ABI.  */  if (TYPE_CPLUS_REALLY_JAVA (values_type))    return NULL;  /* Determine architecture.  */  gdbarch = get_type_arch (values_type);  if (using_enc_p)    *using_enc_p = 0;  vtable = gnuv3_get_vtable (gdbarch, value_type (value),			     value_as_address (value_addr (value)));  if (vtable == NULL)    return NULL;  /* Find the linker symbol for this vtable.  */  vtable_symbol    = lookup_minimal_symbol_by_pc (value_address (vtable)                                   + value_embedded_offset (vtable)).minsym;  if (! vtable_symbol)    return NULL;    /* The symbol's demangled name should be something like "vtable for     CLASS", where CLASS is the name of the run-time type of VALUE.     If we didn't like this approach, we could instead look in the     type_info object itself to get the class name.  But this way     should work just as well, and doesn't read target memory.  */  vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);  if (vtable_symbol_name == NULL      || strncmp (vtable_symbol_name, "vtable for ", 11))    {      warning (_("can't find linker symbol for virtual table for `%s' value"),	       TYPE_SAFE_NAME (values_type));      if (vtable_symbol_name)	warning (_("  found `%s' instead"), vtable_symbol_name);      return NULL;    }  class_name = vtable_symbol_name + 11;  /* Strip off @plt and version suffixes.  */  atsign = strchr (class_name, '@');  if (atsign != NULL)    {      char *copy;      copy = alloca (atsign - class_name + 1);      memcpy (copy, class_name, atsign - class_name);      copy[atsign - class_name] = '/0';      class_name = copy;    }  /* Try to look up the class name as a type name.  */  /* FIXME: chastain/2003-11-26: block=NULL is bogus.  See pr gdb/1465.  */  run_time_type = cp_lookup_rtti_type (class_name, NULL);  if (run_time_type == NULL)    return NULL;  /* Get the offset from VALUE to the top of the complete object.     NOTE: this is the reverse of the meaning of *TOP_P.  */  offset_to_top    = value_as_long (value_field (vtable, vtable_field_offset_to_top));  if (full_p)    *full_p = (- offset_to_top == value_embedded_offset (value)               && (TYPE_LENGTH (value_enclosing_type (value))                   >= TYPE_LENGTH (run_time_type)));  if (top_p)    *top_p = - offset_to_top;  return run_time_type;}
开发者ID:nds32,项目名称:binutils,代码行数:88,


示例21: c_get_string

voidc_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer,	      int *length, struct type **char_type,	      const char **charset){  int err, width;  unsigned int fetchlimit;  struct type *type = check_typedef (value_type (value));  struct type *element_type = TYPE_TARGET_TYPE (type);  int req_length = *length;  enum bfd_endian byte_order    = gdbarch_byte_order (get_type_arch (type));  if (element_type == NULL)    goto error;  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)    {      /* If we know the size of the array, we can use it as a limit on	 the number of characters to be fetched.  */      if (TYPE_NFIELDS (type) == 1	  && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE)	{	  LONGEST low_bound, high_bound;	  get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),			       &low_bound, &high_bound);	  fetchlimit = high_bound - low_bound + 1;	}      else	fetchlimit = UINT_MAX;    }  else if (TYPE_CODE (type) == TYPE_CODE_PTR)    fetchlimit = UINT_MAX;  else    /* We work only with arrays and pointers.  */    goto error;  if (! c_textual_element_type (element_type, 0))    goto error;  classify_type (element_type, get_type_arch (element_type), charset);  width = TYPE_LENGTH (element_type);  /* If the string lives in GDB's memory instead of the inferior's,     then we just need to copy it to BUFFER.  Also, since such strings     are arrays with known size, FETCHLIMIT will hold the size of the     array.  */  if ((VALUE_LVAL (value) == not_lval       || VALUE_LVAL (value) == lval_internalvar)      && fetchlimit != UINT_MAX)    {      int i;      const gdb_byte *contents = value_contents (value);      /* If a length is specified, use that.  */      if (*length >= 0)	i  = *length;      else 	/* Otherwise, look for a null character.  */ 	for (i = 0; i < fetchlimit; i++)	  if (extract_unsigned_integer (contents + i * width,					width, byte_order) == 0) 	    break;        /* I is now either a user-defined length, the number of non-null 	 characters, or FETCHLIMIT.  */      *length = i * width;      buffer->reset ((gdb_byte *) xmalloc (*length));      memcpy (buffer->get (), contents, *length);      err = 0;    }  else    {      CORE_ADDR addr = value_as_address (value);      /* Prior to the fix for PR 16196 read_string would ignore fetchlimit	 if length > 0.  The old "broken" behaviour is the behaviour we want:	 The caller may want to fetch 100 bytes from a variable length array	 implemented using the common idiom of having an array of length 1 at	 the end of a struct.  In this case we want to ignore the declared	 size of the array.  However, it's counterintuitive to implement that	 behaviour in read_string: what does fetchlimit otherwise mean if	 length > 0.  Therefore we implement the behaviour we want here:	 If *length > 0, don't specify a fetchlimit.  This preserves the	 previous behaviour.  We could move this check above where we know	 whether the array is declared with a fixed size, but we only want	 to apply this behaviour when calling read_string.  PR 16286.  */      if (*length > 0)	fetchlimit = UINT_MAX;      err = read_string (addr, *length, width, fetchlimit,			 byte_order, buffer, length);      if (err != 0)	memory_error (TARGET_XFER_E_IO, addr);    }  /* If the LENGTH is specified at -1, we want to return the string     length up to the terminating null character.  If an actual length     was specified, we want to return the length of exactly what was     read.  *///.........这里部分代码省略.........
开发者ID:mattstock,项目名称:binutils-bexkat1,代码行数:101,


示例22: java_value_print

//.........这里部分代码省略.........	    }	}      else	{	  struct value *v = allocate_value (el_type);	  struct value *next_v = allocate_value (el_type);	  VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;	  VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);	  while (i < length && things_printed < print_max)	    {	      fputs_filtered (", ", stream);	      wrap_here (n_spaces (2));	      if (i > 0)		{		  struct value *tmp;		  tmp = next_v;		  next_v = v;		  v = tmp;		}	      else		{		  VALUE_LAZY (v) = 1;		  VALUE_OFFSET (v) = 0;		}	      VALUE_OFFSET (next_v) = VALUE_OFFSET (v);	      for (reps = 1; i + reps < length; reps++)		{		  VALUE_LAZY (next_v) = 1;		  VALUE_OFFSET (next_v) += TYPE_LENGTH (el_type);		  if (memcmp (VALUE_CONTENTS (v), VALUE_CONTENTS (next_v),			      TYPE_LENGTH (el_type)) != 0)		    break;		}	      if (reps == 1)		fprintf_filtered (stream, "%d: ", i);	      else		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);	      val_print (VALUE_TYPE (v), VALUE_CONTENTS (v), 0, 0,			 stream, format, 2, 1, pretty);	      things_printed++;	      i += reps;	    }	}      if (i < length)	fprintf_filtered (stream, "...");      fprintf_filtered (stream, "}");      return 0;    }  /* If it's type String, print it */  if (TYPE_CODE (type) == TYPE_CODE_PTR      && TYPE_TARGET_TYPE (type)      && TYPE_NAME (TYPE_TARGET_TYPE (type))      && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "java.lang.String") == 0      && (format == 0 || format == 's')      && address != 0      && value_as_address (val) != 0)    {      struct value *data_val;      CORE_ADDR data;      struct value *boffset_val;      unsigned long boffset;      struct value *count_val;      unsigned long count;      struct value *mark;      mark = value_mark ();	/* Remember start of new values */      data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);      data = value_as_address (data_val);      boffset_val = value_struct_elt (&val, NULL, "boffset", NULL, NULL);      boffset = value_as_address (boffset_val);      count_val = value_struct_elt (&val, NULL, "count", NULL, NULL);      count = value_as_address (count_val);      value_free_to_mark (mark);	/* Release unnecessary values */      val_print_string (data + boffset, count, 2, stream);      return 0;    }  return (val_print (type, VALUE_CONTENTS (val), 0, address,		     stream, format, 1, 0, pretty));}
开发者ID:jichu4n,项目名称:prc-tools-remix,代码行数:101,


示例23: evaluate_subexp_java

static struct value *evaluate_subexp_java (struct type *expect_type, struct expression *exp,		      int *pos, enum noside noside){  int pc = *pos;  int i;  const char *name;  enum exp_opcode op = exp->elts[*pos].opcode;  struct value *arg1;  struct value *arg2;  struct type *type;  switch (op)    {    case UNOP_IND:      if (noside == EVAL_SKIP)	goto standard;      (*pos)++;      arg1 = evaluate_subexp_java (NULL_TYPE, exp, pos, EVAL_NORMAL);      if (is_object_type (value_type (arg1)))	{	  struct type *type;	  type = type_from_class (exp->gdbarch, java_class_from_object (arg1));	  arg1 = value_cast (lookup_pointer_type (type), arg1);	}      return value_ind (arg1);    case BINOP_SUBSCRIPT:      (*pos)++;      arg1 = evaluate_subexp_with_coercion (exp, pos, noside);      arg2 = evaluate_subexp_with_coercion (exp, pos, noside);      if (noside == EVAL_SKIP)	goto nosideret;      /* If the user attempts to subscript something that is not an         array or pointer type (like a plain int variable for example),         then report this as an error.  */      arg1 = coerce_ref (arg1);      type = check_typedef (value_type (arg1));      if (TYPE_CODE (type) == TYPE_CODE_PTR)	type = check_typedef (TYPE_TARGET_TYPE (type));      name = TYPE_NAME (type);      if (name == NULL)	name = TYPE_TAG_NAME (type);      i = name == NULL ? 0 : strlen (name);      if (TYPE_CODE (type) == TYPE_CODE_STRUCT	  && i > 2 && name[i - 1] == ']')	{	  enum bfd_endian byte_order = gdbarch_byte_order (exp->gdbarch);	  CORE_ADDR address;	  long length, index;	  struct type *el_type;	  gdb_byte buf4[4];	  struct value *clas = java_class_from_object (arg1);	  struct value *temp = clas;	  /* Get CLASS_ELEMENT_TYPE of the array type.  */	  temp = value_struct_elt (&temp, NULL, "methods",				   NULL, "structure");	  deprecated_set_value_type (temp, value_type (clas));	  el_type = type_from_class (exp->gdbarch, temp);	  if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)	    el_type = lookup_pointer_type (el_type);	  if (noside == EVAL_AVOID_SIDE_EFFECTS)	    return value_zero (el_type, VALUE_LVAL (arg1));	  address = value_as_address (arg1);	  address += get_java_object_header_size (exp->gdbarch);	  read_memory (address, buf4, 4);	  length = (long) extract_signed_integer (buf4, 4, byte_order);	  index = (long) value_as_long (arg2);	  if (index >= length || index < 0)	    error (_("array index (%ld) out of bounds (length: %ld)"),		   index, length);	  address = (address + 4) + index * TYPE_LENGTH (el_type);	  return value_at (el_type, address);	}      else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)	{	  if (noside == EVAL_AVOID_SIDE_EFFECTS)	    return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));	  else	    return value_subscript (arg1, value_as_long (arg2));	}      if (name)	error (_("cannot subscript something of type `%s'"), name);      else	error (_("cannot subscript requested type"));    case OP_STRING:      (*pos)++;      i = longest_to_int (exp->elts[pc + 1].longconst);      (*pos) += 3 + BYTES_TO_EXP_ELEM (i + 1);      if (noside == EVAL_SKIP)	goto nosideret;      return java_value_string (&exp->elts[pc + 2].string, i);    case STRUCTOP_PTR:      arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);//.........这里部分代码省略.........
开发者ID:NalaGinrut,项目名称:gdb,代码行数:101,


示例24: parse_find_args

static voidparse_find_args (char *args, ULONGEST *max_countp,		 char **pattern_bufp, ULONGEST *pattern_lenp,		 CORE_ADDR *start_addrp, ULONGEST *search_space_lenp,		 bfd_boolean big_p){  /* Default to using the specified type.  */  char size = '/0';  ULONGEST max_count = ~(ULONGEST) 0;  /* Buffer to hold the search pattern.  */  char *pattern_buf;  /* Current size of search pattern buffer.     We realloc space as needed.  */#define INITIAL_PATTERN_BUF_SIZE 100  ULONGEST pattern_buf_size = INITIAL_PATTERN_BUF_SIZE;  /* Pointer to one past the last in-use part of pattern_buf.  */  char *pattern_buf_end;  ULONGEST pattern_len;  CORE_ADDR start_addr;  ULONGEST search_space_len;  char *s = args;  struct cleanup *old_cleanups;  struct value *v;  if (args == NULL)    error (_("Missing search parameters."));  pattern_buf = xmalloc (pattern_buf_size);  pattern_buf_end = pattern_buf;  old_cleanups = make_cleanup (free_current_contents, &pattern_buf);  /* Get search granularity and/or max count if specified.     They may be specified in either order, together or separately.  */  while (*s == '/')    {      ++s;      while (*s != '/0' && *s != '/' && !isspace (*s))	{	  if (isdigit (*s))	    {	      max_count = atoi (s);	      while (isdigit (*s))		++s;	      continue;	    }	  switch (*s)	    {	    case 'b':	    case 'h':	    case 'w':	    case 'g':	      size = *s++;	      break;	    default:	      error (_("Invalid size granularity."));	    }	}      while (isspace (*s))	++s;    }  /* Get the search range.  */  v = parse_to_comma_and_eval (&s);  start_addr = value_as_address (v);  if (*s == ',')    ++s;  while (isspace (*s))    ++s;  if (*s == '+')    {      LONGEST len;      ++s;      v = parse_to_comma_and_eval (&s);      len = value_as_long (v);      if (len == 0)	{	  printf_filtered (_("Empty search range./n"));	  return;	}      if (len < 0)	error (_("Invalid length."));      /* Watch for overflows.  */      if (len > CORE_ADDR_MAX	  || (start_addr + len - 1) < start_addr)	error (_("Search space too large."));      search_space_len = len;    }  else    {      CORE_ADDR end_addr;      v = parse_to_comma_and_eval (&s);      end_addr = value_as_address (v);      if (start_addr > end_addr)//.........这里部分代码省略.........
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:101,


示例25: c_get_string

voidc_get_string (struct value *value, gdb_byte **buffer,	      int *length, struct type **char_type,	      const char **charset){  int err, width;  unsigned int fetchlimit;  struct type *type = check_typedef (value_type (value));  struct type *element_type = TYPE_TARGET_TYPE (type);  int req_length = *length;  enum bfd_endian byte_order    = gdbarch_byte_order (get_type_arch (type));  if (element_type == NULL)    goto error;  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)    {      /* If we know the size of the array, we can use it as a limit on	 the number of characters to be fetched.  */      if (TYPE_NFIELDS (type) == 1	  && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE)	{	  LONGEST low_bound, high_bound;	  get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),			       &low_bound, &high_bound);	  fetchlimit = high_bound - low_bound + 1;	}      else	fetchlimit = UINT_MAX;    }  else if (TYPE_CODE (type) == TYPE_CODE_PTR)    fetchlimit = UINT_MAX;  else    /* We work only with arrays and pointers.  */    goto error;  if (! c_textual_element_type (element_type, 0))    goto error;  classify_type (element_type, get_type_arch (element_type), charset);  width = TYPE_LENGTH (element_type);  /* If the string lives in GDB's memory instead of the inferior's,     then we just need to copy it to BUFFER.  Also, since such strings     are arrays with known size, FETCHLIMIT will hold the size of the     array.  */  if ((VALUE_LVAL (value) == not_lval       || VALUE_LVAL (value) == lval_internalvar)      && fetchlimit != UINT_MAX)    {      int i;      const gdb_byte *contents = value_contents (value);      /* If a length is specified, use that.  */      if (*length >= 0)	i  = *length;      else 	/* Otherwise, look for a null character.  */ 	for (i = 0; i < fetchlimit; i++)	  if (extract_unsigned_integer (contents + i * width,					width, byte_order) == 0) 	    break;        /* I is now either a user-defined length, the number of non-null 	 characters, or FETCHLIMIT.  */      *length = i * width;      *buffer = xmalloc (*length);      memcpy (*buffer, contents, *length);      err = 0;    }  else    {      CORE_ADDR addr = value_as_address (value);      err = read_string (addr, *length, width, fetchlimit,			 byte_order, buffer, length);      if (err)	{	  xfree (*buffer);	  memory_error (err, addr);	}    }  /* If the LENGTH is specified at -1, we want to return the string     length up to the terminating null character.  If an actual length     was specified, we want to return the length of exactly what was     read.  */  if (req_length == -1)    /* If the last character is null, subtract it from LENGTH.  */    if (*length > 0 	&& extract_unsigned_integer (*buffer + *length - width,				     width, byte_order) == 0)      *length -= width;    /* The read_string function will return the number of bytes read.     If length returned from read_string was > 0, return the number of     characters read by dividing the number of bytes by width.  */  if (*length != 0)     *length = *length / width;//.........这里部分代码省略.........
开发者ID:NalaGinrut,项目名称:gdb,代码行数:101,


示例26: gnuv3_rtti_type

static struct type *gnuv3_rtti_type (struct value *value,                 int *full_p, int *top_p, int *using_enc_p){  struct gdbarch *gdbarch;  struct type *vtable_type;  struct type *values_type = check_typedef (value_type (value));  CORE_ADDR vtable_address;  struct value *vtable;  struct minimal_symbol *vtable_symbol;  const char *vtable_symbol_name;  const char *class_name;  struct type *run_time_type;  struct type *base_type;  LONGEST offset_to_top;  struct type *values_type_vptr_basetype;  int values_type_vptr_fieldno;  /* We only have RTTI for class objects.  */  if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)    return NULL;  /* This routine may be called for Java types that do not have     a proper objfile.  Just return NULL for those.  */  if (!TYPE_OBJFILE (values_type)      || !TYPE_OBJFILE (values_type)->obfd)    return NULL;  /* Determine architecture.  */  gdbarch = get_class_arch (values_type);  vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);  /* If we can't find the virtual table pointer for values_type, we     can't find the RTTI.  */  values_type_vptr_fieldno = get_vptr_fieldno (values_type,					       &values_type_vptr_basetype);  if (values_type_vptr_fieldno == -1)    return NULL;  if (using_enc_p)    *using_enc_p = 0;  /* Fetch VALUE's virtual table pointer, and tweak it to point at     an instance of our imaginary gdb_gnu_v3_abi_vtable structure.  */  base_type = check_typedef (values_type_vptr_basetype);  if (values_type != base_type)    {      value = value_cast (base_type, value);      if (using_enc_p)	*using_enc_p = 1;    }  vtable_address    = value_as_address (value_field (value, values_type_vptr_fieldno));  vtable    = value_at_lazy (vtable_type,		     vtable_address - vtable_address_point_offset (gdbarch));    /* Find the linker symbol for this vtable.  */  vtable_symbol    = lookup_minimal_symbol_by_pc (value_address (vtable)                                   + value_embedded_offset (vtable));  if (! vtable_symbol)    return NULL;    /* The symbol's demangled name should be something like "vtable for     CLASS", where CLASS is the name of the run-time type of VALUE.     If we didn't like this approach, we could instead look in the     type_info object itself to get the class name.  But this way     should work just as well, and doesn't read target memory.  */  vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);  if (vtable_symbol_name == NULL      || strncmp (vtable_symbol_name, "vtable for ", 11))    {      warning (_("can't find linker symbol for virtual table for `%s' value"),	       TYPE_NAME (values_type));      if (vtable_symbol_name)	warning (_("  found `%s' instead"), vtable_symbol_name);      return NULL;    }  class_name = vtable_symbol_name + 11;  /* Try to look up the class name as a type name.  */  /* FIXME: chastain/2003-11-26: block=NULL is bogus.  See pr gdb/1465. */  run_time_type = cp_lookup_rtti_type (class_name, NULL);  if (run_time_type == NULL)    return NULL;  /* Get the offset from VALUE to the top of the complete object.     NOTE: this is the reverse of the meaning of *TOP_P.  */  offset_to_top    = value_as_long (value_field (vtable, vtable_field_offset_to_top));  if (full_p)    *full_p = (- offset_to_top == value_embedded_offset (value)               && (TYPE_LENGTH (value_enclosing_type (value))                   >= TYPE_LENGTH (run_time_type)));  if (top_p)    *top_p = - offset_to_top;  return run_time_type;//.........这里部分代码省略.........
开发者ID:OpenInkpot-archive,项目名称:iplinux-gdb,代码行数:101,


示例27: gnuv2_value_rtti_type

static struct type *gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc){  struct type *known_type;  struct type *rtti_type;  CORE_ADDR vtbl;  struct minimal_symbol *minsym;  char *demangled_name;  struct type *btype;  if (full)    *full = 0;  if (top)    *top = -1;  if (using_enc)    *using_enc = 0;  /* Get declared type */  known_type = value_type (v);  CHECK_TYPEDEF (known_type);  /* RTTI works only or class objects */  if (TYPE_CODE (known_type) != TYPE_CODE_CLASS)    return NULL;  /* Plan on this changing in the future as i get around to setting     the vtables properly for G++ compiled stuff.  Also, I'll be using     the type info functions, which are always right.  Deal with it     until then.     JCI - This pretty much useless.  This gets the "true" type      correctly when there is single inheritance - but in all such       cases that I could find gdb already knows that.  In cases      where this points INTO the object (like non-virtual diamond      graphs) the demangled name is something like OUTER::INNER      and this is not a symbol gdb can resolve, so we fail & return      NULL anyway.  Seems like this really isn't going to work till      we actually call the RTTI function & parse it. */  /* If the type has no vptr fieldno, try to get it filled in */  if (TYPE_VPTR_FIELDNO(known_type) < 0)    fill_in_vptr_fieldno(known_type);  /* If we still can't find one, give up */  if (TYPE_VPTR_FIELDNO(known_type) < 0)    return NULL;  /* Make sure our basetype and known type match, otherwise, cast     so we can get at the vtable properly.  */  btype = TYPE_VPTR_BASETYPE (known_type);  CHECK_TYPEDEF (btype);  if (btype != known_type )    {      v = value_cast (btype, v);      if (using_enc)        *using_enc=1;    }  /*    We can't use value_ind here, because it would want to use RTTI, and    we'd waste a bunch of time figuring out we already know the type.    Besides, we don't care about the type, just the actual pointer  */  if (VALUE_ADDRESS (value_field (v, TYPE_VPTR_FIELDNO (known_type))) == 0)    return NULL;  vtbl=value_as_address(value_field(v,TYPE_VPTR_FIELDNO(known_type)));  /* Try to find a symbol that is the vtable */  minsym=lookup_minimal_symbol_by_pc(vtbl);  if (minsym==NULL      || (demangled_name=DEPRECATED_SYMBOL_NAME (minsym))==NULL      || !is_vtable_name (demangled_name))    return NULL;  /* If we just skip the prefix, we get screwed by namespaces */  demangled_name=cplus_demangle(demangled_name,DMGL_PARAMS|DMGL_ANSI);  *(strchr(demangled_name,' '))=0;  /* Lookup the type for the name */  /* FIXME: chastain/2003-11-26: block=NULL is bogus.  See pr gdb/1465. */  rtti_type = cp_lookup_rtti_type (demangled_name, NULL);  if (rtti_type == NULL)    return NULL;  if (TYPE_N_BASECLASSES(rtti_type) > 1 &&  full && (*full) != 1)    {      if (top)        *top=TYPE_BASECLASS_BITPOS(rtti_type,TYPE_VPTR_FIELDNO(rtti_type))/8;      if (top && ((*top) >0))        {          if (TYPE_LENGTH(rtti_type) > TYPE_LENGTH(known_type))            {              if (full)                *full=0;            }          else            {              if (full)                *full=1;            }//.........这里部分代码省略.........
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:101,


示例28: gnuv2_value_rtti_type

static struct type *gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc){  struct type *known_type;  struct type *rtti_type;  CORE_ADDR vtbl;  struct bound_minimal_symbol minsym;  char *demangled_name, *p;  const char *linkage_name;  struct type *btype;  struct type *known_type_vptr_basetype;  int known_type_vptr_fieldno;  if (full)    *full = 0;  if (top)    *top = -1;  if (using_enc)    *using_enc = 0;  /* Get declared type.  */  known_type = value_type (v);  CHECK_TYPEDEF (known_type);  /* RTTI works only or class objects.  */  if (TYPE_CODE (known_type) != TYPE_CODE_STRUCT)    return NULL;  /* Plan on this changing in the future as i get around to setting     the vtables properly for G++ compiled stuff.  Also, I'll be using     the type info functions, which are always right.  Deal with it     until then.  */  /* Try to get the vptr basetype, fieldno.  */  known_type_vptr_fieldno = get_vptr_fieldno (known_type,					      &known_type_vptr_basetype);  /* If we can't find it, give up.  */  if (known_type_vptr_fieldno < 0)    return NULL;  /* Make sure our basetype and known type match, otherwise, cast     so we can get at the vtable properly.  */  btype = known_type_vptr_basetype;  CHECK_TYPEDEF (btype);  if (btype != known_type )    {      v = value_cast (btype, v);      if (using_enc)        *using_enc=1;    }  /* We can't use value_ind here, because it would want to use RTTI, and     we'd waste a bunch of time figuring out we already know the type.     Besides, we don't care about the type, just the actual pointer.  */  if (value_address (value_field (v, known_type_vptr_fieldno)) == 0)    return NULL;  vtbl = value_as_address (value_field (v, known_type_vptr_fieldno));  /* Try to find a symbol that is the vtable.  */  minsym=lookup_minimal_symbol_by_pc(vtbl);  if (minsym.minsym==NULL      || (linkage_name=MSYMBOL_LINKAGE_NAME (minsym.minsym))==NULL      || !is_vtable_name (linkage_name))    return NULL;  /* If we just skip the prefix, we get screwed by namespaces.  */  demangled_name=gdb_demangle(linkage_name,DMGL_PARAMS|DMGL_ANSI);  p = strchr (demangled_name, ' ');  if (p)    *p = '/0';  /* Lookup the type for the name.  */  /* FIXME: chastain/2003-11-26: block=NULL is bogus.  See pr gdb/1465.  */  rtti_type = cp_lookup_rtti_type (demangled_name, NULL);  if (rtti_type == NULL)    return NULL;  if (TYPE_N_BASECLASSES(rtti_type) > 1 &&  full && (*full) != 1)    {      if (top)        *top = TYPE_BASECLASS_BITPOS (rtti_type,				      TYPE_VPTR_FIELDNO(rtti_type)) / 8;      if (top && ((*top) >0))        {          if (TYPE_LENGTH(rtti_type) > TYPE_LENGTH(known_type))            {              if (full)                *full=0;            }          else            {              if (full)                *full=1;            }        }    }  else    {      if (full)        *full=1;//.........这里部分代码省略.........
开发者ID:mbref,项目名称:binutils-gdb-microblaze,代码行数:101,



注:本文中的value_as_address函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ value_cast函数代码示例
C++ valueToString函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。