+\f
+int
+c_value_print (struct value *val, struct ui_file *stream, int format,
+ enum val_prettyprint pretty)
+{
+ struct type *type, *real_type;
+ int full, top, using_enc;
+
+ /* 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. */
+
+ type = check_typedef (value_type (val));
+
+ 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. */
+ if (TYPE_CODE (type) == TYPE_CODE_PTR
+ && TYPE_NAME (type) == NULL
+ && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
+ && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
+ {
+ /* Print nothing */
+ }
+ else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+ {
+
+ if (TYPE_CODE(type) == TYPE_CODE_REF)
+ {
+ /* Copy value, change to pointer, so we don't get an
+ * error about a non-pointer type in value_rtti_target_type
+ */
+ struct value *temparg;
+ temparg=value_copy(val);
+ deprecated_set_value_type (temparg, lookup_pointer_type (TYPE_TARGET_TYPE(type)));
+ val=temparg;
+ }
+ /* Pointer to class, check real type of object */
+ fprintf_filtered (stream, "(");
+ real_type = value_rtti_target_type (val, &full, &top, &using_enc);
+ if (real_type)
+ {
+ /* RTTI entry found */
+ if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ {
+ /* create a pointer type pointing to the real type */
+ type = lookup_pointer_type (real_type);
+ }
+ else
+ {
+ /* create a reference type referencing the real type */
+ type = lookup_reference_type (real_type);
+ }
+ /* JYG: Need to adjust pointer value. */
+ /* NOTE: cagney/2005-01-02: THIS IS BOGUS. */
+ value_contents_writeable (val)[0] -= top;
+
+ /* 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, ") ");
+ }
+ 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 (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) ",
+ TYPE_NAME (real_type),
+ full ? "" : _(" [incomplete object]"));
+ /* Print out object: enclosing type is same as real_type if full */
+ return val_print (value_enclosing_type (val),
+ value_contents_all (val), 0,
+ VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
+ /* Note: When we look up RTTI entries, we don't get any information on
+ const or volatile attributes */
+ }
+ else if (type != check_typedef (value_enclosing_type (val)))
+ {
+ /* No RTTI information, so let's do our best */
+ fprintf_filtered (stream, "(%s ?) ",
+ TYPE_NAME (value_enclosing_type (val)));
+ return val_print (value_enclosing_type (val),
+ value_contents_all (val), 0,
+ VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
+ }
+ /* Otherwise, we end up at the return outside this "if" */
+ }
+
+ return val_print (type, value_contents_all (val),
+ value_embedded_offset (val),
+ VALUE_ADDRESS (val) + value_offset (val),
+ stream, format, 1, 0, pretty);
+}