+2006-01-18 Mark Kettenis <kettenis@gnu.org>
+
+ Based on a previous patch form Michal Ludvig:
+ * gdbtypes.c (append_flags_type_flag, init_flags_type): New
+ functions.
+ (is_integral_type, rank_one_type, recursive_dump_type): Add
+ support for TYPE_CODE_FLAGS.
+ * gdbtypes.h (enum type_code): Add TYPE_CODE_FLAGS.
+ (append_flags_type_field, init_flags_type): New prototypes.
+ * ada-valprint.c (ada_val_print_1): Add support for
+ TYPE_CODE_FLAGS.
+ * c-valprint.c (c_val_print): Likewise.
+ * f-valprint.c (f_val_print): Likewise.
+ * p-valprint.c (pascal_val_print): Likewise.
+ * valprint.c (val_print_type_code_flags): New function.
+ * valprint.h (val_print_type_code_flags): New prototype.
+ * value.c (unpack_long, value_from_longest): Add support for
+ TYPE_CODE_FLAGS.
+
2006-01-17 Christopher Faylor <cgf@timesys.com>
* MAINTAINERS: Very belatedly remove myself from from the list of
/* Support for printing Ada values for GDB, the GNU debugger.
Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001,
- 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GDB.
}
break;
+ case TYPE_CODE_FLAGS:
+ if (format)
+ print_scalar_formatted (valaddr, type, format, 0, stream);
+ else
+ val_print_type_code_flags (type, valaddr, stream);
+ break;
+
case TYPE_CODE_FLT:
if (format)
return c_val_print (type, valaddr0, embedded_offset, address, stream,
/* Support for printing C values for GDB, the GNU debugger.
Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation,
- Inc.
+ 1997, 1998, 1999, 2000, 2001, 2003, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GDB.
}
break;
+ case TYPE_CODE_FLAGS:
+ if (format)
+ print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ else
+ val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ break;
+
case TYPE_CODE_FUNC:
if (format)
{
/* Support for printing Fortran values for GDB, the GNU debugger.
- Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2005 Free
- Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2005, 2006
+ Free Software Foundation, Inc.
Contributed by Motorola. Adapted from the C definitions by Farooq Butt
(fmbutt@engage.sps.mot.com), additionally worked over by Stan Shebs.
}
break;
+ case TYPE_CODE_FLAGS:
+ if (format)
+ print_scalar_formatted (valaddr, type, format, 0, stream);
+ else
+ val_print_type_code_flags (type, valaddr, stream);
+ break;
+
case TYPE_CODE_FLT:
if (format)
print_scalar_formatted (valaddr, type, format, 0, stream);
/* Support routines for manipulating internal types for GDB.
- Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004 Free Software Foundation, Inc.
+
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
+ 2003, 2004, 2006 Free Software Foundation, Inc.
+
Contributed by Cygnus Support, using pieces from other GDB modules.
This file is part of GDB.
return (result_type);
}
+void
+append_flags_type_flag (struct type *type, int bitpos, char *name)
+{
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLAGS);
+ gdb_assert (bitpos < TYPE_NFIELDS (type));
+ gdb_assert (bitpos >= 0);
+
+ if (name)
+ {
+ TYPE_FIELD_NAME (type, bitpos) = xstrdup (name);
+ TYPE_FIELD_BITPOS (type, bitpos) = bitpos;
+ }
+ else
+ {
+ /* Don't show this field to the user. */
+ TYPE_FIELD_BITPOS (type, bitpos) = -1;
+ }
+}
+
+struct type *
+init_flags_type (char *name, int length)
+{
+ int nfields = length * TARGET_CHAR_BIT;
+ struct type *type;
+
+ type = init_type (TYPE_CODE_FLAGS, length, TYPE_FLAG_UNSIGNED, name, NULL);
+ TYPE_NFIELDS (type) = nfields;
+ TYPE_FIELDS (type) = TYPE_ALLOC (type, nfields * sizeof (struct field));
+ memset (TYPE_FIELDS (type), 0, sizeof (struct field));
+
+ return type;
+}
+
/* Construct and return a type of the form:
struct NAME { ELT_TYPE ELT_NAME[N]; }
We use these types for SIMD registers. For example, the type of
((t != NULL)
&& ((TYPE_CODE (t) == TYPE_CODE_INT)
|| (TYPE_CODE (t) == TYPE_CODE_ENUM)
+ || (TYPE_CODE (t) == TYPE_CODE_FLAGS)
|| (TYPE_CODE (t) == TYPE_CODE_CHAR)
|| (TYPE_CODE (t) == TYPE_CODE_RANGE)
|| (TYPE_CODE (t) == TYPE_CODE_BOOL)));
return rank_one_type (TYPE_TARGET_TYPE (parm), arg);
case TYPE_CODE_INT:
case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_CHAR:
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
else
return INTEGER_CONVERSION_BADNESS;
case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_CHAR:
case TYPE_CODE_RANGE:
case TYPE_CODE_BOOL:
case TYPE_CODE_ENUM:
printf_filtered ("(TYPE_CODE_ENUM)");
break;
+ case TYPE_CODE_FLAGS:
+ printf_filtered ("(TYPE_CODE_FLAGS)");
+ break;
case TYPE_CODE_FUNC:
printf_filtered ("(TYPE_CODE_FUNC)");
break;
/* Internal type definitions for GDB.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
TYPE_CODE_STRUCT, /* C struct or Pascal record */
TYPE_CODE_UNION, /* C union or Pascal variant part */
TYPE_CODE_ENUM, /* Enumeration type */
+ TYPE_CODE_FLAGS, /* Bit flags type */
TYPE_CODE_FUNC, /* Function type */
TYPE_CODE_INT, /* Integer type */
extern void append_composite_type_field (struct type *t, char *name,
struct type *field);
+/* Helper functions to construct a bit flags type. An initially empty
+ type is created using init_flag_type(). Flags are then added using
+ append_flag_type_flag(). */
+extern struct type *init_flags_type (char *name, int length);
+extern void append_flags_type_flag (struct type *type, int bitpos, char *name);
+
extern struct type *lookup_reference_type (struct type *);
extern struct type *make_reference_type (struct type *, struct type **);
/* Support for printing Pascal values for GDB, the GNU debugger.
- Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2003, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GDB.
}
break;
+ case TYPE_CODE_FLAGS:
+ if (format)
+ print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ else
+ val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ break;
+
case TYPE_CODE_FUNC:
if (format)
{
}
}
+void
+val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
+ struct ui_file *stream)
+{
+ LONGEST val = unpack_long (type, valaddr);
+ int bitpos, nfields = TYPE_NFIELDS (type);
+
+ fputs_filtered ("[ ", stream);
+ for (bitpos = 0; bitpos < nfields; bitpos++)
+ {
+ if (TYPE_FIELD_BITPOS (type, bitpos) != -1 && (val & (1 << bitpos)))
+ {
+ if (TYPE_FIELD_NAME (type, bitpos))
+ fprintf_filtered (stream, "%s ", TYPE_FIELD_NAME (type, bitpos));
+ else
+ fprintf_filtered (stream, "#%d ", bitpos);
+ }
+ }
+ fputs_filtered ("]", stream);
+}
+
/* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
The raison d'etre of this function is to consolidate printing of
LONG_LONG's into this one function. The format chars b,h,w,g are
extern void val_print_type_code_int (struct type *, const gdb_byte *,
struct ui_file *);
+extern void val_print_type_code_flags (struct type *type,
+ const gdb_byte *valaddr,
+ struct ui_file *stream);
+
extern void print_binary_chars (struct ui_file *, const gdb_byte *,
unsigned int);
/* Low level packing and unpacking of values for GDB, the GNU Debugger.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005 Free
- Software Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GDB.
case TYPE_CODE_TYPEDEF:
return unpack_long (check_typedef (type), valaddr);
case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_BOOL:
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_BOOL:
case TYPE_CODE_RANGE:
store_signed_integer (value_contents_raw (val), len, num);