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

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

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

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

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

示例1: value_args_as_decimal

/* Obtain decimal value of arguments for binary operation, converting from   other types if one of them is not decimal floating point.  */static voidvalue_args_as_decimal (struct value *arg1, struct value *arg2,		       gdb_byte *x, int *len_x, enum bfd_endian *byte_order_x,		       gdb_byte *y, int *len_y, enum bfd_endian *byte_order_y){  struct type *type1, *type2;  type1 = check_typedef (value_type (arg1));  type2 = check_typedef (value_type (arg2));  /* At least one of the arguments must be of decimal float type.  */  gdb_assert (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT	      || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT);  if (TYPE_CODE (type1) == TYPE_CODE_FLT      || TYPE_CODE (type2) == TYPE_CODE_FLT)    /* The DFP extension to the C language does not allow mixing of     * decimal float types with other float types in expressions     * (see WDTR 24732, page 12).  */    error (_("Mixing decimal floating types with "	     "other floating types is not allowed."));  /* Obtain decimal value of arg1, converting from other types     if necessary.  */  if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)    {      *byte_order_x = gdbarch_byte_order (get_type_arch (type1));      *len_x = TYPE_LENGTH (type1);      memcpy (x, value_contents (arg1), *len_x);    }  else if (is_integral_type (type1))    {      *byte_order_x = gdbarch_byte_order (get_type_arch (type2));      *len_x = TYPE_LENGTH (type2);      decimal_from_integral (arg1, x, *len_x, *byte_order_x);    }  else    error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),	     TYPE_NAME (type2));  /* Obtain decimal value of arg2, converting from other types     if necessary.  */  if (TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)    {      *byte_order_y = gdbarch_byte_order (get_type_arch (type2));      *len_y = TYPE_LENGTH (type2);      memcpy (y, value_contents (arg2), *len_y);    }  else if (is_integral_type (type2))    {      *byte_order_y = gdbarch_byte_order (get_type_arch (type1));      *len_y = TYPE_LENGTH (type1);      decimal_from_integral (arg2, y, *len_y, *byte_order_y);    }  else    error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),	     TYPE_NAME (type2));}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:62,


示例2: value_args_as_target_float

/* Obtain argument values for binary operation, converting from   other types if one of them is not floating point.  */static voidvalue_args_as_target_float (struct value *arg1, struct value *arg2,			    gdb_byte *x, struct type **eff_type_x,			    gdb_byte *y, struct type **eff_type_y){  struct type *type1, *type2;  type1 = check_typedef (value_type (arg1));  type2 = check_typedef (value_type (arg2));  /* At least one of the arguments must be of floating-point type.  */  gdb_assert (is_floating_type (type1) || is_floating_type (type2));  if (is_floating_type (type1) && is_floating_type (type2)      && TYPE_CODE (type1) != TYPE_CODE (type2))    /* The DFP extension to the C language does not allow mixing of     * decimal float types with other float types in expressions     * (see WDTR 24732, page 12).  */    error (_("Mixing decimal floating types with "	     "other floating types is not allowed."));  /* Obtain value of arg1, converting from other types if necessary.  */  if (is_floating_type (type1))    {      *eff_type_x = type1;      memcpy (x, value_contents (arg1), TYPE_LENGTH (type1));    }  else if (is_integral_type (type1))    {      *eff_type_x = type2;      if (TYPE_UNSIGNED (type1))	target_float_from_ulongest (x, *eff_type_x, value_as_long (arg1));      else	target_float_from_longest (x, *eff_type_x, value_as_long (arg1));    }  else    error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),	     TYPE_NAME (type2));  /* Obtain value of arg2, converting from other types if necessary.  */  if (is_floating_type (type2))    {      *eff_type_y = type2;      memcpy (y, value_contents (arg2), TYPE_LENGTH (type2));    }  else if (is_integral_type (type2))    {      *eff_type_y = type1;      if (TYPE_UNSIGNED (type2))	target_float_from_ulongest (y, *eff_type_y, value_as_long (arg2));      else	target_float_from_longest (y, *eff_type_y, value_as_long (arg2));    }  else    error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),	     TYPE_NAME (type2));}
开发者ID:bminor,项目名称:binutils-gdb,代码行数:61,


示例3: ada_value_print

intada_value_print (struct value *val0, struct ui_file *stream, int format,		 enum val_prettyprint pretty){  const gdb_byte *valaddr = value_contents (val0);  CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);  struct type *type =    ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);  struct value *val =    value_from_contents_and_address (type, valaddr, address);  /* If it is a pointer, indicate what it points to.  */  if (TYPE_CODE (type) == TYPE_CODE_PTR)    {      /* Hack:  don't print (char *) for char strings.  Their         type is indicated by the quoted string anyway.  */      if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) != sizeof (char)	  || TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_INT 	  || TYPE_UNSIGNED (TYPE_TARGET_TYPE (type)))	{	  fprintf_filtered (stream, "(");	  type_print (type, "", stream, -1);	  fprintf_filtered (stream, ") ");	}    }  else if (ada_is_array_descriptor_type (type))    {      fprintf_filtered (stream, "(");      type_print (type, "", stream, -1);      fprintf_filtered (stream, ") ");    }  else if (ada_is_bogus_array_descriptor (type))    {      fprintf_filtered (stream, "(");      type_print (type, "", stream, -1);      fprintf_filtered (stream, ") (...?)");      return 0;    }  if (TYPE_CODE (type) == TYPE_CODE_ARRAY      && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == 0      && TYPE_CODE (TYPE_INDEX_TYPE (type)) == TYPE_CODE_RANGE)    {      /* This is an array of zero-length elements, that is an array         of null records.  This array needs to be printed by hand,         as the standard routine to print arrays relies on the size of         the array elements to be nonzero.  This is because it computes         the number of elements in the array by dividing the array size         by the array element size.  */      fprintf_filtered (stream, "(%d .. %d => ())",                        TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),                        TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type)));      return 0;    }    return (val_print (type, value_contents (val), 0, address,		     stream, format, 1, 0, pretty));}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:58,


示例4: m2_print_unbounded_array

static voidm2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,			  int embedded_offset, CORE_ADDR address,			  struct ui_file *stream, int recurse,			  const struct value_print_options *options){  struct type *content_type;  CORE_ADDR addr;  LONGEST len;  struct value *val;  CHECK_TYPEDEF (type);  content_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0));  addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),			 (TYPE_FIELD_BITPOS (type, 0) / 8) +			 valaddr + embedded_offset);  val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),		       addr);  len = unpack_field_as_long (type, valaddr + embedded_offset, 1);  fprintf_filtered (stream, "{");    m2_print_array_contents (value_type (val), value_contents(val),			   value_embedded_offset (val), addr, stream,			   recurse, options, len);  fprintf_filtered (stream, ", HIGH = %d}", (int) len);}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:28,


示例5: mi_cmd_data_evaluate_expression

/* Evaluate the value of the argument. The argument is an   expression. If the expression contains spaces it needs to be   included in double quotes. */enum mi_cmd_resultmi_cmd_data_evaluate_expression (char *command, char **argv, int argc){  struct expression *expr;  struct cleanup *old_chain = NULL;  struct value *val;  struct ui_stream *stb = NULL;  stb = ui_out_stream_new (uiout);  if (argc != 1)    {      mi_error_message = xstrprintf ("mi_cmd_data_evaluate_expression: Usage: -data-evaluate-expression expression");      return MI_CMD_ERROR;    }  expr = parse_expression (argv[0]);  old_chain = make_cleanup (free_current_contents, &expr);  val = evaluate_expression (expr);  /* Print the result of the expression evaluation. */  val_print (value_type (val), value_contents (val),	     value_embedded_offset (val), VALUE_ADDRESS (val),	     stb->stream, 0, 0, 0, 0);  ui_out_field_stream (uiout, "value", stb);  ui_out_stream_delete (stb);  do_cleanups (old_chain);  return MI_CMD_DONE;}
开发者ID:debrouxl,项目名称:tiemu,代码行数:37,


示例6: amd64_windows_adjust_args_passed_by_pointer

static CORE_ADDRamd64_windows_adjust_args_passed_by_pointer (struct value **args,					     int nargs, CORE_ADDR sp){  int i;  for (i = 0; i < nargs; i++)    if (amd64_windows_passed_by_pointer (value_type (args[i])))      {	struct type *type = value_type (args[i]);	const gdb_byte *valbuf = value_contents (args[i]);	const int len = TYPE_LENGTH (type);	/* Store a copy of that argument on the stack, aligned to	   a 16 bytes boundary, and then use the copy's address as	   the argument.  */	sp -= len;	sp &= ~0xf;	write_memory (sp, valbuf, len);	args[i]	  = value_addr (value_from_contents_and_address (type, valbuf, sp));      }  return sp;}
开发者ID:CromFr,项目名称:gdb,代码行数:27,


示例7: dump_value_to_file

/* FIXME: needs comment: */static voiddump_value_to_file(const char *cmd, const char *mode, const char *file_format){  struct cleanup *old_cleanups = make_cleanup(null_cleanup, NULL);  struct value *val;  char *filename;  /* Open the file.  */  filename = scan_filename_with_cleanup(&cmd, NULL);  /* Find the value: */  if ((cmd == NULL) || (*cmd == '/0'))    error(_("No value to %s."), ((*mode == 'a') ? "append" : "dump"));  val = parse_and_eval(cmd);  if (val == NULL)    error(_("Invalid expression."));  /* Have everything.  Open/write the data: */  if ((file_format == NULL) || (strcmp(file_format, "binary") == 0))    {      dump_binary_file(filename, mode, value_contents(val),                       TYPE_LENGTH(value_type(val)));    }  else    {      CORE_ADDR vaddr;      if (VALUE_LVAL(val))	{	  vaddr = VALUE_ADDRESS(val);	}      else	{	  vaddr = 0;	  warning(_("value is not an lval: address assumed to be zero"));	}      dump_bfd_file(filename, mode, file_format, vaddr,		    value_contents(val),		    TYPE_LENGTH(value_type(val)));    }  do_cleanups(old_cleanups);}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:45,


示例8: gnuv3_method_ptr_to_value

static struct value *gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr){  struct gdbarch *gdbarch;  const gdb_byte *contents = value_contents (method_ptr);  CORE_ADDR ptr_value;  struct type *domain_type, *final_type, *method_type;  LONGEST adjustment;  struct value *adjval;  int vbit;  domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));  final_type = lookup_pointer_type (domain_type);  method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));  /* Extract the pointer to member.  */  gdbarch = get_class_arch (domain_type);  vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment);  /* First convert THIS to match the containing type of the pointer to     member.  This cast may adjust the value of THIS.  */  *this_p = value_cast (final_type, *this_p);  /* Then apply whatever adjustment is necessary.  This creates a somewhat     strange pointer: it claims to have type FINAL_TYPE, but in fact it     might not be a valid FINAL_TYPE.  For instance, it might be a     base class of FINAL_TYPE.  And if it's not the primary base class,     then printing it out as a FINAL_TYPE object would produce some pretty     garbage.     But we don't really know the type of the first argument in     METHOD_TYPE either, which is why this happens.  We can't     dereference this later as a FINAL_TYPE, but once we arrive in the     called method we'll have debugging information for the type of     "this" - and that'll match the value we produce here.     You can provoke this case by casting a Base::* to a Derived::*, for     instance.  */  *this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);  adjval = value_from_longest (builtin_type (gdbarch)->builtin_long,			       adjustment);  *this_p = value_ptradd (*this_p, adjval);  *this_p = value_cast (final_type, *this_p);  if (vbit)    {      LONGEST voffset;      voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch));      return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p),				   method_type, voffset);    }  else    return value_from_pointer (lookup_pointer_type (method_type), ptr_value);}
开发者ID:OpenInkpot-archive,项目名称:iplinux-gdb,代码行数:55,


示例9: amd64_windows_store_arg_in_reg

static voidamd64_windows_store_arg_in_reg (struct regcache *regcache,				struct value *arg, int regno){  struct type *type = value_type (arg);  const gdb_byte *valbuf = value_contents (arg);  gdb_byte buf[8];  gdb_assert (TYPE_LENGTH (type) <= 8);  memset (buf, 0, sizeof buf);  memcpy (buf, valbuf, min (TYPE_LENGTH (type), 8));  regcache_cooked_write (regcache, regno, buf);}
开发者ID:CromFr,项目名称:gdb,代码行数:13,


示例10: store_regs

static voidstore_regs (struct type *regs_type, CORE_ADDR regs_base){  struct gdbarch *gdbarch = target_gdbarch ();  struct regcache *regcache = get_thread_regcache (inferior_ptid);  int fieldno;  for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)    {      const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);      ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);      ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);      ULONGEST reg_offset;      struct type *reg_type = check_typedef (TYPE_FIELD_TYPE (regs_type,							      fieldno));      ULONGEST reg_size = TYPE_LENGTH (reg_type);      int regnum;      struct value *regval;      CORE_ADDR inferior_addr;      if (strcmp (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY) == 0)	continue;      if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)	error (_("Invalid register /"%s/" position %s bits or size %s bits"),	       reg_name, pulongest (reg_bitpos), pulongest (reg_bitsize));      reg_offset = reg_bitpos / 8;      if (TYPE_CODE (reg_type) != TYPE_CODE_INT	  && TYPE_CODE (reg_type) != TYPE_CODE_PTR)	error (_("Invalid register /"%s/" type code %d"), reg_name,	       TYPE_CODE (reg_type));      regnum = compile_register_name_demangle (gdbarch, reg_name);      regval = value_from_register (reg_type, regnum, get_current_frame ());      if (value_optimized_out (regval))	error (_("Register /"%s/" is optimized out."), reg_name);      if (!value_entirely_available (regval))	error (_("Register /"%s/" is not available."), reg_name);      inferior_addr = regs_base + reg_offset;      if (0 != target_write_memory (inferior_addr, value_contents (regval),				    reg_size))	error (_("Cannot write register /"%s/" to inferior memory at %s."),	       reg_name, paddress (gdbarch, inferior_addr));    }}
开发者ID:dcolascione,项目名称:binutils,代码行数:48,


示例11: pascal_object_print_static_field

static voidpascal_object_print_static_field (struct value *val,				  struct ui_file *stream,				  int recurse,				  const struct value_print_options *options){  struct type *type = value_type (val);  struct value_print_options opts;  if (TYPE_CODE (type) == TYPE_CODE_STRUCT)    {      CORE_ADDR *first_dont_print, addr;      int i;      first_dont_print	= (CORE_ADDR *) obstack_base (&dont_print_statmem_obstack);      i = (CORE_ADDR *) obstack_next_free (&dont_print_statmem_obstack)	- first_dont_print;      while (--i >= 0)	{	  if (value_address (val) == first_dont_print[i])	    {	      fputs_filtered ("<same as static member of an already seen type>",			      stream);	      return;	    }	}      addr = value_address (val);      obstack_grow (&dont_print_statmem_obstack, (char *) &addr,		    sizeof (CORE_ADDR));      CHECK_TYPEDEF (type);      pascal_object_print_value_fields (type, value_contents (val), addr,					stream, recurse, NULL, options,					NULL, 1);      return;    }  opts = *options;  opts.deref_ref = 0;  common_val_print (val, stream, recurse, &opts, current_language);}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:44,


示例12: pascal_object_print_static_field

static voidpascal_object_print_static_field (struct value *val,				  struct ui_file *stream, int format,				  int recurse, enum val_prettyprint pretty){  struct type *type = value_type (val);  if (TYPE_CODE (type) == TYPE_CODE_STRUCT)    {      CORE_ADDR *first_dont_print;      int i;      first_dont_print	= (CORE_ADDR *) obstack_base (&dont_print_statmem_obstack);      i = (CORE_ADDR *) obstack_next_free (&dont_print_statmem_obstack)	- first_dont_print;      while (--i >= 0)	{	  if (VALUE_ADDRESS (val) == first_dont_print[i])	    {	      fputs_filtered ("<same as static member of an already seen type>",			      stream);	      return;	    }	}      obstack_grow (&dont_print_statmem_obstack, (char *) &VALUE_ADDRESS (val),		    sizeof (CORE_ADDR));      CHECK_TYPEDEF (type);      pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),				  stream, format, recurse, pretty, NULL, 1);      return;    }  common_val_print (val, stream, format, 0, recurse, pretty);}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:37,


示例13: value_bitstring_subscript

struct value *value_bitstring_subscript (struct type *type,			   struct value *bitstring, LONGEST index){  struct type *bitstring_type, *range_type;  struct value *v;  int offset, byte, bit_index;  LONGEST lowerbound, upperbound;  bitstring_type = check_typedef (value_type (bitstring));  gdb_assert (TYPE_CODE (bitstring_type) == TYPE_CODE_BITSTRING);  range_type = TYPE_INDEX_TYPE (bitstring_type);  get_discrete_bounds (range_type, &lowerbound, &upperbound);  if (index < lowerbound || index > upperbound)    error (_("bitstring index out of range"));  index -= lowerbound;  offset = index / TARGET_CHAR_BIT;  byte = *((char *) value_contents (bitstring) + offset);  bit_index = index % TARGET_CHAR_BIT;  byte >>= (gdbarch_bits_big_endian (get_type_arch (bitstring_type)) ?	    TARGET_CHAR_BIT - 1 - bit_index : bit_index);  v = value_from_longest (type, byte & 1);  set_value_bitpos (v, bit_index);  set_value_bitsize (v, 1);  set_value_component_location (v, bitstring);  VALUE_FRAME_ID (v) = VALUE_FRAME_ID (bitstring);  set_value_offset (v, offset + value_offset (bitstring));  return v;}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:37,


示例14: scm_lreadr

static voidscm_lreadr (int skipping){  int c, j;  struct stoken str;  LONGEST svalue = 0;tryagain:  c = *lexptr++;  switch (c)    {    case '/0':      lexptr--;      return;    case '[':    case '(':      scm_lreadparen (skipping);      return;    case ']':    case ')':      error ("unexpected #//%c", c);      goto tryagain;    case '/'':    case '`':      str.ptr = lexptr - 1;      scm_lreadr (skipping);      if (!skipping)	{	  struct value *val = scm_evaluate_string (str.ptr, lexptr - str.ptr);	  if (!is_scmvalue_type (value_type (val)))	    error ("quoted scm form yields non-SCM value");	  svalue = extract_signed_integer (value_contents (val),					   TYPE_LENGTH (value_type (val)));	  goto handle_immediate;	}      return;    case ',':      c = *lexptr++;      if ('@' != c)	lexptr--;      scm_lreadr (skipping);      return;    case '#':      c = *lexptr++;      switch (c)	{	case '[':	case '(':	  scm_lreadparen (skipping);	  return;	case 't':	case 'T':	  svalue = SCM_BOOL_T;	  goto handle_immediate;	case 'f':	case 'F':	  svalue = SCM_BOOL_F;	  goto handle_immediate;	case 'b':	case 'B':	case 'o':	case 'O':	case 'd':	case 'D':	case 'x':	case 'X':	case 'i':	case 'I':	case 'e':	case 'E':	  lexptr--;	  c = '#';	  goto num;	case '*':		/* bitvector */	  scm_read_token (c, 0);	  return;	case '{':	  scm_read_token (c, 1);	  return;	case '//':		/* character */	  c = *lexptr++;	  scm_read_token (c, 0);	  return;	case '|':	  j = 1;		/* here j is the comment nesting depth */	lp:	  c = *lexptr++;	lpc:	  switch (c)	    {	    case '/0':	      error ("unbalanced comment");	    default:	      goto lp;	    case '|':	      if ('#' != (c = *lexptr++))		goto lpc;	      if (--j)		goto lp;	      break;	    case '#'://.........这里部分代码省略.........
开发者ID:davearrama,项目名称:gdb,代码行数:101,


示例15: java_value_print

intjava_value_print (struct value *val, struct ui_file *stream, 		  const struct value_print_options *options){  struct gdbarch *gdbarch = get_type_arch (value_type (val));  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  struct type *type;  CORE_ADDR address;  int i;  char *name;  struct value_print_options opts;  type = value_type (val);  address = value_address (val);  if (is_object_type (type))    {      CORE_ADDR obj_addr;      /* Get the run-time type, and cast the object into that */      obj_addr = unpack_pointer (type, value_contents (val));      if (obj_addr != 0)	{	  type = type_from_class (gdbarch, java_class_from_object (val));	  type = lookup_pointer_type (type);	  val = value_at (type, address);	}    }  if (TYPE_CODE (type) == TYPE_CODE_PTR && !value_logical_not (val))    type_print (TYPE_TARGET_TYPE (type), "", stream, -1);  name = TYPE_TAG_NAME (type);  if (TYPE_CODE (type) == TYPE_CODE_STRUCT && name != NULL      && (i = strlen (name), name[i - 1] == ']'))    {      gdb_byte buf4[4];      long length;      unsigned int things_printed = 0;      int reps;      struct type *el_type	= java_primitive_type_from_name (gdbarch, name, i - 2);      i = 0;      read_memory (address + get_java_object_header_size (gdbarch), buf4, 4);      length = (long) extract_signed_integer (buf4, 4, byte_order);      fprintf_filtered (stream, "{length: %ld", length);      if (el_type == NULL)	{	  CORE_ADDR element;	  CORE_ADDR next_element = -1; /* dummy initial value */	  /* Skip object header and length. */	  address += get_java_object_header_size (gdbarch) + 4;	  while (i < length && things_printed < options->print_max)	    {	      gdb_byte *buf;	      buf = alloca (gdbarch_ptr_bit (gdbarch) / HOST_CHAR_BIT);	      fputs_filtered (", ", stream);	      wrap_here (n_spaces (2));	      if (i > 0)		element = next_element;	      else		{		  read_memory (address, buf, sizeof (buf));		  address += gdbarch_ptr_bit (gdbarch) / HOST_CHAR_BIT;		  /* FIXME: cagney/2003-05-24: Bogus or what.  It                     pulls a host sized pointer out of the target and                     then extracts that as an address (while assuming                     that the address is unsigned)!  */		  element = extract_unsigned_integer (buf, sizeof (buf),						      byte_order);		}	      for (reps = 1; i + reps < length; reps++)		{		  read_memory (address, buf, sizeof (buf));		  address += gdbarch_ptr_bit (gdbarch) / HOST_CHAR_BIT;		  /* FIXME: cagney/2003-05-24: Bogus or what.  It                     pulls a host sized pointer out of the target and                     then extracts that as an address (while assuming                     that the address is unsigned)!  */		  next_element = extract_unsigned_integer (buf, sizeof (buf),							   byte_order);		  if (next_element != element)		    break;		}	      if (reps == 1)		fprintf_filtered (stream, "%d: ", i);	      else		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);//.........这里部分代码省略.........
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:101,


示例16: mn10300_push_dummy_call

static CORE_ADDRmn10300_push_dummy_call (struct gdbarch *gdbarch, 			 struct value *target_func,			 struct regcache *regcache,			 CORE_ADDR bp_addr, 			 int nargs, struct value **args,			 CORE_ADDR sp, 			 int struct_return,			 CORE_ADDR struct_addr){  const int push_size = register_size (gdbarch, E_PC_REGNUM);  int regs_used;  int len, arg_len;   int stack_offset = 0;  int argnum;  char *val, valbuf[MAX_REGISTER_SIZE];  /* This should be a nop, but align the stack just in case something     went wrong.  Stacks are four byte aligned on the mn10300.  */  sp &= ~3;  /* Now make space on the stack for the args.     XXX This doesn't appear to handle pass-by-invisible reference     arguments.  */  regs_used = struct_return ? 1 : 0;  for (len = 0, argnum = 0; argnum < nargs; argnum++)    {      arg_len = (TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3;      while (regs_used < 2 && arg_len > 0)	{	  regs_used++;	  arg_len -= push_size;	}      len += arg_len;    }  /* Allocate stack space.  */  sp -= len;  if (struct_return)    {      regs_used = 1;      write_register (E_D0_REGNUM, struct_addr);    }  else    regs_used = 0;  /* Push all arguments onto the stack. */  for (argnum = 0; argnum < nargs; argnum++)    {      /* FIXME what about structs?  Unions?  */      if (TYPE_CODE (value_type (*args)) == TYPE_CODE_STRUCT	  && TYPE_LENGTH (value_type (*args)) > 8)	{	  /* Change to pointer-to-type.  */	  arg_len = push_size;	  store_unsigned_integer (valbuf, push_size, 				  VALUE_ADDRESS (*args));	  val = &valbuf[0];	}      else	{	  arg_len = TYPE_LENGTH (value_type (*args));	  val = (char *) value_contents (*args);	}      while (regs_used < 2 && arg_len > 0)	{	  write_register (regs_used, 			  extract_unsigned_integer (val, push_size));	  val += push_size;	  arg_len -= push_size;	  regs_used++;	}      while (arg_len > 0)	{	  write_memory (sp + stack_offset, val, push_size);	  arg_len -= push_size;	  val += push_size;	  stack_offset += push_size;	}      args++;    }  /* Make space for the flushback area.  */  sp -= 8;  /* Push the return address that contains the magic breakpoint.  */  sp -= 4;  write_memory_unsigned_integer (sp, push_size, bp_addr);  /* Update $sp.  */  regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);  return sp;}
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:97,


示例17: ppc64_sysv_abi_push_dummy_call

CORE_ADDRppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,				struct regcache *regcache, CORE_ADDR bp_addr,				int nargs, struct value **args, CORE_ADDR sp,				int struct_return, CORE_ADDR struct_addr){  CORE_ADDR func_addr = find_function_addr (function, NULL);  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);  /* By this stage in the proceedings, SP has been decremented by "red     zone size" + "struct return size".  Fetch the stack-pointer from     before this and use that as the BACK_CHAIN.  */  const CORE_ADDR back_chain = read_sp ();  /* See for-loop comment below.  */  int write_pass;  /* Size of the Altivec's vector parameter region, the final value is     computed in the for-loop below.  */  LONGEST vparam_size = 0;  /* Size of the general parameter region, the final value is computed     in the for-loop below.  */  LONGEST gparam_size = 0;  /* Kevin writes ... I don't mind seeing tdep->wordsize used in the     calls to align_up(), align_down(), etc.  because this makes it     easier to reuse this code (in a copy/paste sense) in the future,     but it is a 64-bit ABI and asserting that the wordsize is 8 bytes     at some point makes it easier to verify that this function is     correct without having to do a non-local analysis to figure out     the possible values of tdep->wordsize.  */  gdb_assert (tdep->wordsize == 8);  /* Go through the argument list twice.     Pass 1: Compute the function call's stack space and register     requirements.     Pass 2: Replay the same computation but this time also write the     values out to the target.  */  for (write_pass = 0; write_pass < 2; write_pass++)    {      int argno;      /* Next available floating point register for float and double         arguments.  */      int freg = 1;      /* Next available general register for non-vector (but possibly         float) arguments.  */      int greg = 3;      /* Next available vector register for vector arguments.  */      int vreg = 2;      /* The address, at which the next general purpose parameter         (integer, struct, float, ...) should be saved.  */      CORE_ADDR gparam;      /* Address, at which the next Altivec vector parameter should be         saved.  */      CORE_ADDR vparam;      if (!write_pass)	{	  /* During the first pass, GPARAM and VPARAM are more like	     offsets (start address zero) than addresses.  That way	     the accumulate the total stack space each region	     requires.  */	  gparam = 0;	  vparam = 0;	}      else	{	  /* Decrement the stack pointer making space for the Altivec	     and general on-stack parameters.  Set vparam and gparam	     to their corresponding regions.  */	  vparam = align_down (sp - vparam_size, 16);	  gparam = align_down (vparam - gparam_size, 16);	  /* Add in space for the TOC, link editor double word,	     compiler double word, LR save area, CR save area.  */	  sp = align_down (gparam - 48, 16);	}      /* If the function is returning a `struct', then there is an         extra hidden parameter (which will be passed in r3)         containing the address of that struct..  In that case we         should advance one word and start from r4 register to copy         parameters.  This also consumes one on-stack parameter slot.  */      if (struct_return)	{	  if (write_pass)	    regcache_cooked_write_signed (regcache,					  tdep->ppc_gp0_regnum + greg,					  struct_addr);	  greg++;	  gparam = align_up (gparam + tdep->wordsize, tdep->wordsize);	}      for (argno = 0; argno < nargs; argno++)	{	  struct value *arg = args[argno];	  struct type *type = check_typedef (value_type (arg));	  const bfd_byte *val = value_contents (arg);	  if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) <= 8)	    {	      /* Floats and Doubles go in f1 .. f13.  They also	         consume a left aligned GREG,, and can end up in//.........这里部分代码省略.........
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:101,


示例18: ppc_push_argument

static voidppc_push_argument (struct ppc_stack_abi *abi, 		   struct ppc_stack_context *c, struct value *arg,		   int argno, int do_copy, int floatonly){  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);  struct type *type = check_typedef (value_type (arg));  int len = TYPE_LENGTH (type);  gdb_byte buf[16];  c->argoffset = ROUND_UP (c->argoffset, 4);  switch (TYPE_CODE (type)) {        case TYPE_CODE_FLT:    {      if (c->freg <= abi->last_freg)	{	  struct value *rval;	  struct type *rtype;	  int rlen;	  /* APPLE LOCAL: If the thing is already a long double type,	     don't cast it to a builtin type double, since there are two	     long double types, and we will pass an 16 byte long double	     wrong if we assume it is an 8 byte double.  */	  if (strcmp (TYPE_NAME (type), "long double") != 0)	    {	      rval  = value_cast (builtin_type_double, arg);	      rtype = check_typedef (value_type (rval));	      rlen = TYPE_LENGTH (rtype);	    }	  else	    {	      rval = arg;	      rtype = type;	      rlen = len;	    }	  /* APPLE LOCAL: GCC 4.0 has 16 byte long doubles */	  if ((len != 4) && (len != 8) && (len != 16))	    error ("floating point parameter had unexpected size");	  if (rlen != 8 && rlen != 16)	    error ("floating point parameter had unexpected size");	  if (do_copy)	    regcache_raw_write (current_regcache, FP0_REGNUM + c->freg, 				value_contents (rval));	  if (do_copy && ! floatonly && abi->fregs_shadow_gregs)	    ppc_copy_into_greg (current_regcache, c->greg, tdep->wordsize, len, value_contents (arg));	  if (do_copy && ! floatonly && abi->regs_shadow_stack)	    write_memory (c->sp + c->argoffset, value_contents (arg), len);	  c->freg++;	  /* APPLE LOCAL: We took up two registers...  */	  if (rlen == 16)	    c->freg++;	  if (! floatonly && (abi->fregs_shadow_gregs) && (c->greg <= abi->last_greg))	    c->greg += len / 4;	  if (! floatonly && abi->regs_shadow_stack)	    c->argoffset += len;	}      else if (! floatonly)	{	  if ((len != 4) && (len != 8) && (len != 16))	    error ("floating point parameter had unexpected size");	  c->argoffset = ROUND_UP (c->argoffset, len);	  if (do_copy)	    write_memory (c->sp + c->argoffset, value_contents (arg), len);	  c->argoffset += len;	}      break;    }  case TYPE_CODE_INT:  case TYPE_CODE_ENUM:  case TYPE_CODE_PTR:  case TYPE_CODE_REF:    {      int nregs;      gdb_byte *val_contents;      if (floatonly)	break;      /* APPLE LOCAL: Huge Hack...  The problem is that if we are a 32	 bit app on Mac OS X, the registers are really 64 bits, but we	 don't want to pass all 64 bits.  So if we get passed a value	 that came from a register, and it's length is > the wordsize,	 cast it to the wordsize first before passing it in.  */      if (VALUE_REGNUM (arg) != -1 && len == 8 && tdep->wordsize == 4)	{	  len = 4;	  val_contents = value_contents (arg) + 4;	}      else//.........这里部分代码省略.........
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:101,


示例19: 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,


示例20: lm32_push_dummy_call

static CORE_ADDRlm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,		      struct regcache *regcache, CORE_ADDR bp_addr,		      int nargs, struct value **args, CORE_ADDR sp,		      int struct_return, CORE_ADDR struct_addr){  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  int first_arg_reg = SIM_LM32_R1_REGNUM;  int num_arg_regs = 8;  int i;  /* Set the return address.  */  regcache_cooked_write_signed (regcache, SIM_LM32_RA_REGNUM, bp_addr);  /* If we're returning a large struct, a pointer to the address to     store it at is passed as a first hidden parameter.  */  if (struct_return)    {      regcache_cooked_write_unsigned (regcache, first_arg_reg, struct_addr);      first_arg_reg++;      num_arg_regs--;      sp -= 4;    }  /* Setup parameters.  */  for (i = 0; i < nargs; i++)    {      struct value *arg = args[i];      struct type *arg_type = check_typedef (value_type (arg));      gdb_byte *contents;      int len;      int j;      int reg;      ULONGEST val;      /* Promote small integer types to int.  */      switch (TYPE_CODE (arg_type))	{	case TYPE_CODE_INT:	case TYPE_CODE_BOOL:	case TYPE_CODE_CHAR:	case TYPE_CODE_RANGE:	case TYPE_CODE_ENUM:	  if (TYPE_LENGTH (arg_type) < 4)	    {	      arg_type = builtin_type (gdbarch)->builtin_int32;	      arg = value_cast (arg_type, arg);	    }	  break;	}      /* FIXME: Handle structures.  */      contents = (gdb_byte *) value_contents (arg);      len = TYPE_LENGTH (arg_type);      val = extract_unsigned_integer (contents, len, byte_order);      /* First num_arg_regs parameters are passed by registers,          and the rest are passed on the stack.  */      if (i < num_arg_regs)	regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val);      else	{	  write_memory (sp, (void *) &val, len);	  sp -= 4;	}    }  /* Update stack pointer.  */  regcache_cooked_write_signed (regcache, SIM_LM32_SP_REGNUM, sp);  /* Return adjusted stack pointer.  */  return sp;}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:74,


示例21: 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,


示例22: m88k_store_arguments

static CORE_ADDRm88k_store_arguments (struct regcache *regcache, int nargs,		      struct value **args, CORE_ADDR sp){  struct gdbarch *gdbarch = get_regcache_arch (regcache);  int num_register_words = 0;  int num_stack_words = 0;  int i;  for (i = 0; i < nargs; i++)    {      struct type *type = value_type (args[i]);      int len = TYPE_LENGTH (type);      if (m88k_integral_or_pointer_p (type) && len < 4)	{	  args[i] = value_cast (builtin_type (gdbarch)->builtin_int32,				args[i]);	  type = value_type (args[i]);	  len = TYPE_LENGTH (type);	}      if (m88k_in_register_p (type))	{	  int num_words = 0;	  if (num_register_words % 2 == 1 && m88k_8_byte_align_p (type))	    num_words++;	  num_words += ((len + 3) / 4);	  if (num_register_words + num_words <= 8)	    {	      num_register_words += num_words;	      continue;	    }	  /* We've run out of available registers.  Pass the argument             on the stack.  */	}      if (num_stack_words % 2 == 1 && m88k_8_byte_align_p (type))	num_stack_words++;      num_stack_words += ((len + 3) / 4);    }  /* Allocate stack space.  */  sp = align_down (sp - 32 - num_stack_words * 4, 16);  num_stack_words = num_register_words = 0;  for (i = 0; i < nargs; i++)    {      const bfd_byte *valbuf = value_contents (args[i]);      struct type *type = value_type (args[i]);      int len = TYPE_LENGTH (type);      int stack_word = num_stack_words;      if (m88k_in_register_p (type))	{	  int register_word = num_register_words;	  if (register_word % 2 == 1 && m88k_8_byte_align_p (type))	    register_word++;	  gdb_assert (len == 4 || len == 8);	  if (register_word + len / 8 < 8)	    {	      int regnum = M88K_R2_REGNUM + register_word;	      regcache_raw_write (regcache, regnum, valbuf);	      if (len > 4)		regcache_raw_write (regcache, regnum + 1, valbuf + 4);	      num_register_words = (register_word + len / 4);	      continue;	    }	}      if (stack_word % 2 == -1 && m88k_8_byte_align_p (type))	stack_word++;      write_memory (sp + stack_word * 4, valbuf, len);      num_stack_words = (stack_word + (len + 3) / 4);    }  return sp;}
开发者ID:5kg,项目名称:gdb,代码行数:88,


示例23: ppc_sysv_abi_push_dummy_call

CORE_ADDRppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,			      struct regcache *regcache, CORE_ADDR bp_addr,			      int nargs, struct value **args, CORE_ADDR sp,			      int struct_return, CORE_ADDR struct_addr){  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  ULONGEST saved_sp;  int argspace = 0;		/* 0 is an initial wrong guess.  */  int write_pass;  gdb_assert (tdep->wordsize == 4);  regcache_cooked_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch),				 &saved_sp);  /* Go through the argument list twice.     Pass 1: Figure out how much new stack space is required for     arguments and pushed values.  Unlike the PowerOpen ABI, the SysV     ABI doesn't reserve any extra space for parameters which are put     in registers, but does always push structures and then pass their     address.     Pass 2: Replay the same computation but this time also write the     values out to the target.  */  for (write_pass = 0; write_pass < 2; write_pass++)    {      int argno;      /* Next available floating point register for float and double         arguments.  */      int freg = 1;      /* Next available general register for non-float, non-vector         arguments.  */      int greg = 3;      /* Next available vector register for vector arguments.  */      int vreg = 2;      /* Arguments start above the "LR save word" and "Back chain".  */      int argoffset = 2 * tdep->wordsize;      /* Structures start after the arguments.  */      int structoffset = argoffset + argspace;      /* If the function is returning a `struct', then the first word         (which will be passed in r3) is used for struct return         address.  In that case we should advance one word and start         from r4 register to copy parameters.  */      if (struct_return)	{	  if (write_pass)	    regcache_cooked_write_signed (regcache,					  tdep->ppc_gp0_regnum + greg,					  struct_addr);	  greg++;	}      for (argno = 0; argno < nargs; argno++)	{	  struct value *arg = args[argno];	  struct type *type = check_typedef (value_type (arg));	  int len = TYPE_LENGTH (type);	  const bfd_byte *val = value_contents (arg);	  if (TYPE_CODE (type) == TYPE_CODE_FLT && len <= 8	      && !tdep->soft_float)	    {	      /* Floating point value converted to "double" then	         passed in an FP register, when the registers run out,	         8 byte aligned stack is used.  */	      if (freg <= 8)		{		  if (write_pass)		    {		      /* Always store the floating point value using		         the register's floating-point format.  */		      gdb_byte regval[MAX_REGISTER_SIZE];		      struct type *regtype			= register_type (gdbarch, tdep->ppc_fp0_regnum + freg);		      convert_typed_floating (val, type, regval, regtype);		      regcache_cooked_write (regcache,                                             tdep->ppc_fp0_regnum + freg,					     regval);		    }		  freg++;		}	      else		{		  /* The SysV ABI tells us to convert floats to		     doubles before writing them to an 8 byte aligned		     stack location.  Unfortunately GCC does not do		     that, and stores floats into 4 byte aligned		     locations without converting them to doubles.		     Since there is no know compiler that actually		     follows the ABI here, we implement the GCC		     convention.  */		  /* Align to 4 bytes or 8 bytes depending on the type of		     the argument (float or double).  */		  argoffset = align_up (argoffset, len);//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:101,


示例24: amd64_push_arguments

static CORE_ADDRamd64_push_arguments(struct regcache *regcache, int nargs,		     struct value **args, CORE_ADDR sp, int struct_return){  static int integer_regnum[] =  {    AMD64_RDI_REGNUM,		/* %rdi */    AMD64_RSI_REGNUM,		/* %rsi */    AMD64_RDX_REGNUM,		/* %rdx */    AMD64_RCX_REGNUM,		/* %rcx */    8,				/* %r8 */    9				/* %r9 */  };  static int sse_regnum[] =  {    /* %xmm0 ... %xmm7 */    AMD64_XMM0_REGNUM + 0, AMD64_XMM1_REGNUM,    AMD64_XMM0_REGNUM + 2, AMD64_XMM0_REGNUM + 3,    AMD64_XMM0_REGNUM + 4, AMD64_XMM0_REGNUM + 5,    AMD64_XMM0_REGNUM + 6, AMD64_XMM0_REGNUM + 7,  };  struct value **stack_args = alloca(nargs * sizeof(struct value *));  int num_stack_args = 0;  int num_elements = 0;  int element = 0;  int integer_reg = 0;  int sse_reg = 0;  int i;  /* Reserve a register for the "hidden" argument: */  if (struct_return)    integer_reg++;  for (i = 0; i < nargs; i++)    {      struct type *type = value_type(args[i]);      int len = TYPE_LENGTH(type);      enum amd64_reg_class reg_class[2];      int needed_integer_regs = 0;      int needed_sse_regs = 0;      int j;      /* Classify argument: */      amd64_classify(type, reg_class);      /* Calculate the number of integer and SSE registers needed for         this argument.  */      for (j = 0; j < 2; j++)	{	  if (reg_class[j] == AMD64_INTEGER)	    needed_integer_regs++;	  else if (reg_class[j] == AMD64_SSE)	    needed_sse_regs++;	}      /* Check whether enough registers are available, and if the         argument should be passed in registers at all.  */      if (((size_t)(integer_reg + needed_integer_regs) > ARRAY_SIZE(integer_regnum))	  || ((size_t)(sse_reg + needed_sse_regs) > ARRAY_SIZE(sse_regnum))	  || ((needed_integer_regs == 0) && (needed_sse_regs == 0)))	{	  /* The argument will be passed on the stack: */	  num_elements += ((len + 7) / 8);	  stack_args[num_stack_args++] = args[i];	}      else	{	  /* The argument will be passed in registers: */	  const gdb_byte *valbuf = value_contents(args[i]);	  gdb_byte buf[8];	  gdb_assert(len <= 16);	  for (j = 0; len > 0; j++, len -= 8)	    {	      int regnum = -1;	      int offset = 0;	      switch (reg_class[j])		{		case AMD64_INTEGER:		  regnum = integer_regnum[integer_reg++];		  break;		case AMD64_SSE:		  regnum = sse_regnum[sse_reg++];		  break;		case AMD64_SSEUP:		  gdb_assert(sse_reg > 0);		  regnum = sse_regnum[sse_reg - 1];		  offset = 8;		  break;		default:		  gdb_assert(!"Unexpected register class.");		}	      gdb_assert(regnum != -1);	      memset(buf, 0, sizeof(buf));//.........这里部分代码省略.........
开发者ID:dougmencken,项目名称:apple-gdb-1824,代码行数:101,


示例25: c_val_print

//.........这里部分代码省略.........	{	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);	}      else	{	  val_print_type_code_int (type, valaddr + embedded_offset, stream);	  /* C and C++ has no single byte int type, char is used instead.	     Since we don't know whether the value is really intended to	     be used as an integer or a character, print the character	     equivalent as well. */	  if (TYPE_LENGTH (type) == 1)	    {	      fputs_filtered (" ", stream);	      LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),			     stream);	    }	}      break;    case TYPE_CODE_CHAR:      format = format ? format : output_format;      if (format)	{	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);	}      else	{	  val = unpack_long (type, valaddr + embedded_offset);	  if (TYPE_UNSIGNED (type))	    fprintf_filtered (stream, "%u", (unsigned int) val);	  else	    fprintf_filtered (stream, "%d", (int) val);	  fputs_filtered (" ", stream);	  LA_PRINT_CHAR ((unsigned char) val, stream);	}      break;    case TYPE_CODE_FLT:      if (format)	{	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);	}      else	{	  print_floating (valaddr + embedded_offset, type, stream);	}      break;    case TYPE_CODE_METHOD:      {	struct value *v = value_at (type, address);	cp_print_class_method (value_contents (value_addr (v)),			       lookup_pointer_type (type), stream);	break;      }    case TYPE_CODE_VOID:      fprintf_filtered (stream, "void");      break;    case TYPE_CODE_ERROR:      /* APPLE LOCAL display error as unknown type */      fprintf_filtered (stream, _("<unknown type>"));      break;    case TYPE_CODE_UNDEF:      /* This happens (without TYPE_FLAG_STUB set) on systems which don't use         dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"         and no complete type for struct foo in that file.  */      fprintf_filtered (stream, _("<incomplete type>"));      break;    case TYPE_CODE_COMPLEX:      if (format)	print_scalar_formatted (valaddr + embedded_offset,				TYPE_TARGET_TYPE (type),				format, 0, stream);      else	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),			stream);      fprintf_filtered (stream, " + ");      if (format)	print_scalar_formatted (valaddr + embedded_offset				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),				TYPE_TARGET_TYPE (type),				format, 0, stream);      else	print_floating (valaddr + embedded_offset			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),			TYPE_TARGET_TYPE (type),			stream);      fprintf_filtered (stream, " * I");      break;    default:      error (_("Invalid C/C++ type code %d in symbol table."), TYPE_CODE (type));    }  gdb_flush (stream);  return (0);}
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:101,


示例26: xstormy16_push_dummy_call

static CORE_ADDRxstormy16_push_dummy_call (struct gdbarch *gdbarch,			   struct value *function,			   struct regcache *regcache,			   CORE_ADDR bp_addr, int nargs,			   struct value **args,			   CORE_ADDR sp, int struct_return,			   CORE_ADDR struct_addr){  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  CORE_ADDR stack_dest = sp;  int argreg = E_1ST_ARG_REGNUM;  int i, j;  int typelen, slacklen;  const gdb_byte *val;  gdb_byte buf[xstormy16_pc_size];  /* If struct_return is true, then the struct return address will     consume one argument-passing register.  */  if (struct_return)    {      regcache_cooked_write_unsigned (regcache, E_PTR_RET_REGNUM, struct_addr);      argreg++;    }  /* Arguments are passed in R2-R7 as they fit.  If an argument doesn't     fit in the remaining registers we're switching over to the stack.     No argument is put on stack partially and as soon as we switched     over to stack no further argument is put in a register even if it     would fit in the remaining unused registers.  */  for (i = 0; i < nargs && argreg <= E_LST_ARG_REGNUM; i++)    {      typelen = TYPE_LENGTH (value_enclosing_type (args[i]));      if (typelen > E_MAX_RETTYPE_SIZE (argreg))	break;      /* Put argument into registers wordwise.  */      val = value_contents (args[i]);      for (j = 0; j < typelen; j += xstormy16_reg_size)	{	  ULONGEST regval;	  int size = (typelen - j == 1) ? 1 : xstormy16_reg_size;	  regval = extract_unsigned_integer (val + j, size, byte_order);	  regcache_cooked_write_unsigned (regcache, argreg++, regval);	}    }  /* Align SP */  stack_dest = xstormy16_frame_align (gdbarch, stack_dest);  /* Loop backwards through remaining arguments and push them on the stack,     wordaligned.  */  for (j = nargs - 1; j >= i; j--)    {      gdb_byte *val;      struct cleanup *back_to;      const gdb_byte *bytes = value_contents (args[j]);      typelen = TYPE_LENGTH (value_enclosing_type (args[j]));      slacklen = typelen & 1;      val = xmalloc (typelen + slacklen);      back_to = make_cleanup (xfree, val);      memcpy (val, bytes, typelen);      memset (val + typelen, 0, slacklen);      /* Now write this data to the stack.  The stack grows upwards.  */      write_memory (stack_dest, val, typelen + slacklen);      stack_dest += typelen + slacklen;      do_cleanups (back_to);    }  store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);  write_memory (stack_dest, buf, xstormy16_pc_size);  stack_dest += xstormy16_pc_size;  /* Update stack pointer.  */  regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, stack_dest);  /* Return the new stack pointer minus the return address slot since     that's what DWARF2/GCC uses as the frame's CFA.  */  return stack_dest - xstormy16_pc_size;}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:83,


示例27: rs6000_lynx178_push_dummy_call

static CORE_ADDRrs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch,				struct value *function,				struct regcache *regcache, CORE_ADDR bp_addr,				int nargs, struct value **args, CORE_ADDR sp,				int struct_return, CORE_ADDR struct_addr){  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  int ii;  int len = 0;  int argno;			/* current argument number */  int argbytes;			/* current argument byte */  gdb_byte tmp_buffer[50];  int f_argno = 0;		/* current floating point argno */  int wordsize = gdbarch_tdep (gdbarch)->wordsize;  CORE_ADDR func_addr = find_function_addr (function, NULL);  struct value *arg = 0;  struct type *type;  ULONGEST saved_sp;  /* The calling convention this function implements assumes the     processor has floating-point registers.  We shouldn't be using it     on PPC variants that lack them.  */  gdb_assert (ppc_floating_point_unit_p (gdbarch));  /* The first eight words of ther arguments are passed in registers.     Copy them appropriately.  */  ii = 0;  /* If the function is returning a `struct', then the first word     (which will be passed in r3) is used for struct return address.     In that case we should advance one word and start from r4     register to copy parameters.  */  if (struct_return)    {      regcache_raw_write_unsigned (regcache, tdep->ppc_gp0_regnum + 3,				   struct_addr);      ii++;    }  /* Effectively indirect call... gcc does...     return_val example( float, int);     eabi:     float in fp0, int in r3     offset of stack on overflow 8/16     for varargs, must go by type.     power open:     float in r3&r4, int in r5     offset of stack on overflow different     both:     return in r3 or f0.  If no float, must study how gcc emulates floats;     pay attention to arg promotion.     User may have to cast/args to handle promotion correctly     since gdb won't know if prototype supplied or not.  */  for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii)    {      int reg_size = register_size (gdbarch, ii + 3);      arg = args[argno];      type = check_typedef (value_type (arg));      len = TYPE_LENGTH (type);      if (TYPE_CODE (type) == TYPE_CODE_FLT)	{	  /* Floating point arguments are passed in fpr's, as well as gpr's.	     There are 13 fpr's reserved for passing parameters.  At this point	     there is no way we would run out of them.	     Always store the floating point value using the register's	     floating-point format.  */	  const int fp_regnum = tdep->ppc_fp0_regnum + 1 + f_argno;	  gdb_byte reg_val[MAX_REGISTER_SIZE];	  struct type *reg_type = register_type (gdbarch, fp_regnum);	  gdb_assert (len <= 8);	  convert_typed_floating (value_contents (arg), type,				  reg_val, reg_type);	  regcache_cooked_write (regcache, fp_regnum, reg_val);	  ++f_argno;	}      if (len > reg_size)	{	  /* Argument takes more than one register.  */	  while (argbytes < len)	    {	      gdb_byte word[MAX_REGISTER_SIZE];	      memset (word, 0, reg_size);	      memcpy (word,		      ((char *) value_contents (arg)) + argbytes,		      (len - argbytes) > reg_size//.........这里部分代码省略.........
开发者ID:5kg,项目名称:gdb,代码行数:101,


示例28: tilegx_push_dummy_call

static CORE_ADDRtilegx_push_dummy_call (struct gdbarch *gdbarch,			struct value *function,			struct regcache *regcache,			CORE_ADDR bp_addr, int nargs,			struct value **args,			CORE_ADDR sp, int struct_return,			CORE_ADDR struct_addr){  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);  CORE_ADDR stack_dest = sp;  int argreg = TILEGX_R0_REGNUM;  int i, j;  int typelen, slacklen;  static const gdb_byte four_zero_words[16] = { 0 };  /* If struct_return is 1, then the struct return address will     consume one argument-passing register.  */  if (struct_return)    regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);  /* Arguments are passed in R0 - R9, and as soon as an argument     will not fit completely in the remaining registers, then it,     and all remaining arguments, are put on the stack.  */  for (i = 0; i < nargs && argreg <= TILEGX_R9_REGNUM; i++)    {      const gdb_byte *val;      typelen = TYPE_LENGTH (value_enclosing_type (args[i]));      if (typelen > (TILEGX_R9_REGNUM - argreg + 1) * tilegx_reg_size)	break;      /* Put argument into registers wordwise.	*/      val = value_contents (args[i]);      for (j = 0; j < typelen; j += tilegx_reg_size)	{	  /* ISSUE: Why special handling for "typelen = 4x + 1"?	     I don't ever see "typelen" values except 4 and 8.	*/	  int n = (typelen - j == 1) ? 1 : tilegx_reg_size;	  ULONGEST w = extract_unsigned_integer (val + j, n, byte_order);	  regcache_cooked_write_unsigned (regcache, argreg++, w);	}    }  /* Align SP.  */  stack_dest = tilegx_frame_align (gdbarch, stack_dest);  /* Loop backwards through remaining arguments and push them on     the stack, word aligned.  */  for (j = nargs - 1; j >= i; j--)    {      gdb_byte *val;      struct cleanup *back_to;      const gdb_byte *contents = value_contents (args[j]);      typelen = TYPE_LENGTH (value_enclosing_type (args[j]));      slacklen = align_up (typelen, 8) - typelen;      val = (gdb_byte *) xmalloc (typelen + slacklen);      back_to = make_cleanup (xfree, val);      memcpy (val, contents, typelen);      memset (val + typelen, 0, slacklen);      /* Now write data to the stack.  The stack grows downwards.  */      stack_dest -= typelen + slacklen;      write_memory (stack_dest, val, typelen + slacklen);      do_cleanups (back_to);    }  /* Add 16 bytes for linkage space to the stack.  */  stack_dest = stack_dest - 16;  write_memory (stack_dest, four_zero_words, 16);  /* Update stack pointer.  */  regcache_cooked_write_unsigned (regcache, TILEGX_SP_REGNUM, stack_dest);  /* Set the return address register to point to the entry point of     the program, where a breakpoint lies in wait.  */  regcache_cooked_write_unsigned (regcache, TILEGX_LR_REGNUM, bp_addr);  return stack_dest;}
开发者ID:Cookfeces,项目名称:binutils-gdb,代码行数:82,


示例29: sparc32_store_arguments

static CORE_ADDRsparc32_store_arguments (struct regcache *regcache, int nargs,			 struct value **args, CORE_ADDR sp,			 int struct_return, CORE_ADDR struct_addr){  /* Number of words in the "parameter array".  */  int num_elements = 0;  int element = 0;  int i;  for (i = 0; i < nargs; i++)    {      struct type *type = value_type (args[i]);      int len = TYPE_LENGTH (type);      if (sparc_structure_or_union_p (type)	  || (sparc_floating_p (type) && len == 16))	{	  /* Structure, Union and Quad-Precision Arguments.  */	  sp -= len;	  /* Use doubleword alignment for these values.  That's always             correct, and wasting a few bytes shouldn't be a problem.  */	  sp &= ~0x7;	  write_memory (sp, value_contents (args[i]), len);	  args[i] = value_from_pointer (lookup_pointer_type (type), sp);	  num_elements++;	}      else if (sparc_floating_p (type))	{	  /* Floating arguments.  */	  gdb_assert (len == 4 || len == 8);	  num_elements += (len / 4);	}      else	{	  /* Integral and pointer arguments.  */	  gdb_assert (sparc_integral_or_pointer_p (type));	  if (len < 4)	    args[i] = value_cast (builtin_type_int32, args[i]);	  num_elements += ((len + 3) / 4);	}    }  /* Always allocate at least six words.  */  sp -= max (6, num_elements) * 4;  /* The psABI says that "Software convention requires space for the     struct/union return value pointer, even if the word is unused."  */  sp -= 4;  /* The psABI says that "Although software convention and the     operating system require every stack frame to be doubleword     aligned."  */  sp &= ~0x7;  for (i = 0; i < nargs; i++)    {      const bfd_byte *valbuf = value_contents (args[i]);      struct type *type = value_type (args[i]);      int len = TYPE_LENGTH (type);      gdb_assert (len == 4 || len == 8);      if (element < 6)	{	  int regnum = SPARC_O0_REGNUM + element;	  regcache_cooked_write (regcache, regnum, valbuf);	  if (len > 4 && element < 5)	    regcache_cooked_write (regcache, regnum + 1, valbuf + 4);	}      /* Always store the argument in memory.  */      write_memory (sp + 4 + element * 4, valbuf, len);      element += len / 4;    }  gdb_assert (element == num_elements);  if (struct_return)    {      gdb_byte buf[4];      store_unsigned_integer (buf, 4, struct_addr);      write_memory (sp, buf, 4);    }  return sp;}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:92,


示例30: ppc64_sysv_abi_push_dummy_call

//.........这里部分代码省略.........	  vparam = 0;	}      else	{	  /* Decrement the stack pointer making space for the Altivec	     and general on-stack parameters.  Set vparam and gparam	     to their corresponding regions.  */	  vparam = align_down (sp - vparam_size, 16);	  gparam = align_down (vparam - gparam_size, 16);	  /* Add in space for the TOC, link editor double word,	     compiler double word, LR save area, CR save area.  */	  sp = align_down (gparam - 48, 16);	}      /* If the function is returning a `struct', then there is an         extra hidden parameter (which will be passed in r3)         containing the address of that struct..  In that case we         should advance one word and start from r4 register to copy         parameters.  This also consumes one on-stack parameter slot.  */      if (struct_return)	{	  if (write_pass)	    regcache_cooked_write_signed (regcache,					  tdep->ppc_gp0_regnum + greg,					  struct_addr);	  greg++;	  gparam = align_up (gparam + tdep->wordsize, tdep->wordsize);	}      for (argno = 0; argno < nargs; argno++)	{	  struct value *arg = args[argno];	  struct type *type = check_typedef (value_type (arg));	  const bfd_byte *val = value_contents (arg);	  if (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) <= 8)	    {	      /* Floats and Doubles go in f1 .. f13.  They also	         consume a left aligned GREG,, and can end up in	         memory.  */	      if (write_pass)		{		  gdb_byte regval[MAX_REGISTER_SIZE];		  const gdb_byte *p;		  /* Version 1.7 of the 64-bit PowerPC ELF ABI says:		     "Single precision floating point values are mapped to		     the first word in a single doubleword."		     And version 1.9 says:		     "Single precision floating point values are mapped to		     the second word in a single doubleword."		     GDB then writes single precision floating point values		     at both words in a doubleword, to support both ABIs.  */		  if (TYPE_LENGTH (type) == 4)		    {		      memcpy (regval, val, 4);		      memcpy (regval + 4, val, 4);		      p = regval;		    }		  else		    p = val;
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:66,



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


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