)]}'
{
  "commit": "21b25b168dc6ed25a14c88fa43ae8128487cb557",
  "tree": "f194a07a5e866863c72fa593b52e5e5bcdafc36a",
  "parents": [
    "831b11eab51e63fb635f03001398d73dc4d888aa"
  ],
  "author": {
    "name": "Tom Tromey",
    "email": "tromey@adacore.com",
    "time": "Tue May 27 12:18:30 2025 -0600"
  },
  "committer": {
    "name": "Tom Tromey",
    "email": "tromey@adacore.com",
    "time": "Fri Jun 06 10:13:23 2025 -0600"
  },
  "message": "Fix regression with DW_AT_bit_offset handling\n\nInternal AdaCore testing using -gdwarf-4 found a spot where GCC will\nemit a negative DW_AT_bit_offset.  However, my recent signed/unsigned\nchanges assumed that this value had to be positive.\n\nI feel this bug somewhat invalidates my previous thinking about how\nDWARF attributes should be handled.\n\nIn particular, both GCC and LLVM at understand that a negative bit\noffset can be generated -- but for positive offsets they might use a\nsmaller \"data\" form, which is expected not to be sign-extended.  LLVM\nhas similar code but GCC does:\n\n  if (bit_offset \u003c 0)\n    add_AT_int (die, DW_AT_bit_offset, bit_offset);\n  else\n    add_AT_unsigned (die, DW_AT_bit_offset, (unsigned HOST_WIDE_INT) bit_offset);\n\nWhat this means is that this attribute is \"signed but default\nunsigned\".\n\nTo fix this, I\u0027ve added a new attribute::confused_constant method.\nThis should be used when a constant value might be signed, but where\nnarrow forms (e.g., DW_FORM_data1) should *not* cause sign extension.\n\nI examined the GCC and LLVM DWARF writers to come up with the list of\nattributes where this applies, namely DW_AT_bit_offset,\nDW_AT_const_value and DW_AT_data_member_location (GCC only, but LLVM\nalways emits it as unsigned, so we\u0027re safe here).\n\nThis patch corrects the bug and imports the relevant test case.\n\nRegression tested on x86-64 Fedora 41.\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d32680\nBug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id\u003d118837\nApproved-By: Simon Marchi \u003csimon.marchi@efficios.com\u003e\n\n\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8ff03531613898e02d375e87c252a5982d79a02a",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/attribute.c",
      "new_id": "d2b536466171576681c4aa7a8c4fd4ba04094ee3",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/attribute.c"
    },
    {
      "type": "modify",
      "old_id": "31ff018a80ccdb9af4332c089b7b257f96f6c149",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/attribute.h",
      "new_id": "234de4e109fea78547257df5546007cf4461beaf",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/attribute.h"
    },
    {
      "type": "modify",
      "old_id": "22345657d361b164e6d9a2251146ca287b49aa3b",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read.c",
      "new_id": "583b6dbaab0fbb0d3d602a9fa7f4c10133f36a9c",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "c5fcae1272229a72e41573c63833f97811100749",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.ada/negative-bit-offset.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e3c177584808d7a6470859b01ed4ffc4ded9bfc1",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.ada/negative-bit-offset/prog.adb"
    }
  ]
}
