#include "cli/cli-option.h"
#include "gdbarch.h"
#include "cli/cli-style.h"
+#include "count-one-bits.h"
/* Maximum number of wchars returned from wchar_iterate. */
#define MAX_WCHARS 4
{
int first = 1;
- /* We have a "flag" enum, so we try to decompose it into
- pieces as appropriate. A flag enum has disjoint
- constants by definition. */
+ /* We have a "flag" enum, so we try to decompose it into pieces as
+ appropriate. The enum may have multiple enumerators representing
+ the same bit, in which case we choose to only print the first one
+ we find. */
fputs_filtered ("(", stream);
for (i = 0; i < len; ++i)
{
QUIT;
- if ((val & TYPE_FIELD_ENUMVAL (type, i)) != 0)
+ ULONGEST enumval = TYPE_FIELD_ENUMVAL (type, i);
+ int nbits = count_one_bits_ll (enumval);
+
+ gdb_assert (nbits == 0 || nbits == 1);
+
+ if ((val & enumval) != 0)
{
if (!first)
fputs_filtered (" | ", stream);