)]}'
{
  "commit": "ad6dde5aaae846176fcc984e438ee7c187f27044",
  "tree": "70c8ae10b575073c33b745fa20a1e69b4ffe6530",
  "parents": [
    "9044044c27c3619a18f58c8c235250264cd95a7e"
  ],
  "author": {
    "name": "Simon Marchi",
    "email": "simon.marchi@polymtl.ca",
    "time": "Sun Feb 09 00:51:01 2025 -0500"
  },
  "committer": {
    "name": "Simon Marchi",
    "email": "simon.marchi@efficios.com",
    "time": "Mon Feb 10 11:26:44 2025 -0500"
  },
  "message": "gdb/dwarf: write offset to parent entry for DW_IDX_parent\n\nNew in v2:\n\n - add doc\n - fix computation of offset in entry pool\n\nDue to a mistake in the DWARF 5 spec, the way that GDB interprets\nDW_IDX_parent when generating and reading .debug_names is not correct.\n\nIn Section 6.1.1.2, the parent index entry attribute is described as:\n\n  Parent debugging information entry, a reference to the index entry for\n  the parent. This is represented as the offset of the entry relative to\n  the start of the entry pool.\n\nBut in Table 6.1, DW_IDX_parent is described as:\n\n  Index of name table entry for parent\n\nThese two contradict each other.  The former is the correct one and the\nlatter is an unfortunate leftover from an earlier version of the\nproposal, according to [1].  It does make sense, because pointing to a\nname table entry is ambiguous, while poiting to an index entry directly\nis not.  Unfortunately, GDB implemented pointing to a name table entry.\n\nChanges on the writer side:\n\n - For each written pool entry, remember the offset within the pool.\n\n - Change the DW_IDX_parent form to DW_FORM_data4.\n\n   Using DW_FORM_udata isn\u0027t an option, because we don\u0027t know the actual\n   value when doing the first pass of writing the pool (see next point),\n   so we wouldn\u0027t know how many bytes to reserve, if we used a\n   variable-size encoding.\n\n   Using a fixed 4 bytes encoding would be an issue if the entry pool\n   was larger than 4 GiB, but that seems unlikely.\n\n   Note that clang uses DW_FORM_ref4 for this, but I\u0027m not sure it is\n   appropriate, since forms of the reference class are specified as\n   referring \"to one of the debugging information entries that describe\n   the program\".  Since we\u0027re not referring to a DIE, I decided to stay\n   with a form of the \"constant\" class.  I think that readers will be\n   able to understand either way.\n\n - Write a dummy 4 byte number when writing the pool, then patch those\n   values later.  This is needed because parents can appear before their\n   children in the pool (there\u0027s no way to ensure that parents always\n   appear before their children), so we might now know at first what\n   value to put in.\n\n - Add a `write_uint` method to `class data_buf` to support that use\n   case of patching a value in the middle of the data buffer.\n\n - Simplify the type of `m_name_to_value_set`, we no longer need to\n   track the index at which a name will be written at.\n\n - Produce a new augmentation string, \"GDB3\", to be able to distinguish\n   \"old\" and \"new\" indexes.  It would be possible for a reader to\n   distinguish the two semantics of DW_IDX_parent using the form.\n   However, current versions of GDB don\u0027t do that, so they would be\n   confused trying to read a new index.  I think it is preferable to use\n   a new augmentation string so that they will reject a new index\n   instead.\n\nChanges on the reader side:\n\n - Track the GDB augmentation version, in addition to whether the\n   augmentation string indicates the index was produced by GDB.\n\n - When reading index entries, maintain a \"pool offset\" -\u003e \"cooked index\n   entry\" mapping, to be able to find parents by pool offset.\n\n - When resolving parents, keep the existing behavior of finding parents\n   by name table index if the augmentation string is \"GDB2.  Otherwise,\n   look up parents by pool offset.  This assumes that .debug_names from\n   other producers (if/when we add support for reading them) use pool\n   offsets for DW_IDX_parent.  This at least what clang does.\n\n - Simplify augmentation string comparison a bit by using array views.\n\nUpdate the \"Extensions to ‘.debug_names’\" section of the documentation\nto reflect the new augmentation string version.\n\nTested by:\n\n - manually producing executables with \"GDB2\" and \"GDB3\" .debug_names\n   sections and reading them.\n - running the testsuite with the cc-with-debug-names board\n\n[1] https://lists.dwarfstd.org/pipermail/dwarf-discuss/2025-January/002618.html\n\nChange-Id: I265fa38070b86ef320e0a972c300d1d755735d8d\nReviewed-By: Eli Zaretskii \u003celiz@gnu.org\u003e\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "507598c63ee50cee2a6a3b6e1f9be09872d4846c",
      "old_mode": 33188,
      "old_path": "gdb/doc/gdb.texinfo",
      "new_id": "88b6c68967e8d04da2b3501e35abc03017229f5a",
      "new_mode": 33188,
      "new_path": "gdb/doc/gdb.texinfo"
    },
    {
      "type": "modify",
      "old_id": "e82d38ab1dc9a036d2696c947404df6d1c6c7b87",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/index-write.c",
      "new_id": "9087adde4f2c70d352a2bf1b12ff18c81ef5e0ec",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/index-write.c"
    },
    {
      "type": "modify",
      "old_id": "3d73bcde9a506648275a8642b65344e61177ebaf",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read-debug-names.c",
      "new_id": "aeddab66b51938395b8ffd40e4a487d9b038d369",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read-debug-names.c"
    },
    {
      "type": "modify",
      "old_id": "729fe898ea8a10adc7ba336d6bc70e183b2e0139",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read-debug-names.h",
      "new_id": "ef91a70d7338586e44caf51d6623d148a2118974",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read-debug-names.h"
    }
  ]
}
