This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/22600] New: GDB doesn't handle bitfield offsets on big-endian architectures


https://sourceware.org/bugzilla/show_bug.cgi?id=22600

            Bug ID: 22600
           Summary: GDB doesn't handle bitfield offsets on big-endian
                    architectures
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: sergiodj at redhat dot com
  Target Milestone: ---

This bug was discovered while doing the "ptype /o" work, because it uses the
same algorithm for calculating offsets on bitfields.  The code in question can
be found at value.c:value_primitive_field.

It seems like the algorithm for calculating bitfield offsets is not working
correctly on BE machines.  This is not only for "ptype /o", but also for
regular print commands.  For example, consider this test:

  struct tyu
  {
    int a1 : 1;
    int a2 : 3;
    int a3 : 23;
    char a4 : 2;
    int64_t a5;
    int a6 : 5;
    int64_t a7 : 3;
  };

  int
  main (int argc, char *argv[])
  {
    struct tyu e;

    e.a1 = e.a2 = e.a3 = e.a4 = e.a6 = e.a7 = -1;

    return 0;
  }

After stopping GDB at the "return 0;" line, here's what we see when we print
"e" on x86_64:

  (gdb) p e
  $1 = {a1 = -1, a2 = -1, a3 = -1, a4 = -1 '\377', a5 = 140737488344880, a6 =
-1, a7 = -1}

While on PPC64BE:

  (gdb) p e
  $1 = {a1 = -1, a2 = 3, a3 = 3, a4 = 3 '\003', a5 = 70367536153528, a6 = -1,
a7 = -1}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]