)]}'
{
  "commit": "a64db49371f040859a9de7c0f4fbfb655d8dda17",
  "tree": "8dc779d920429d4c20b5173f7431bc324e8aebbd",
  "parents": [
    "67a5fc8e12dca723a80bef349d47d4a72ca0482e"
  ],
  "author": {
    "name": "Jason Molenda",
    "email": "jmolenda@apple.com",
    "time": "Fri Jun 27 18:43:41 2025 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Jun 27 18:43:41 2025 -0700"
  },
  "message": "[lldb][Mach-O] Allow \"process metadata\" LC_NOTE to supply registers (#144627)\n\nThe \"process metadata\" LC_NOTE allows for thread IDs to be specified in\na Mach-O corefile. This extends the JSON recognzied in that LC_NOTE to\nallow for additional registers to be supplied on a per-thread basis.\n\nThe registers included in a Mach-O corefile LC_THREAD load command can\nonly be one of the register flavors that the kernel (xnu) defines in\n\u003cmach/arm/thread_status.h\u003e for arm64 -- the general purpose registers,\nfloating point registers, exception registers.\n\nJTAG style corefile producers may have access to many additional\nregisters beyond these that EL0 programs typically use, for instance\nTCR_EL1 on AArch64, and people developing low level code need access to\nthese registers. This patch defines a format for including these\nregisters for any thread.\n\nThe JSON in \"process metadata\" is a dictionary that must have a\n`threads` key. The value is an array of entries, one per LC_THREAD in\nthe Mach-O corefile. The number of entries must match the LC_THREADs so\nthey can be correctly associated.\n\nEach thread\u0027s dictionary must have two keys, `sets`, and `registers`.\n`sets` is an array of register set names. If a register set name matches\none from the LC_THREAD core registers, any registers that are defined\nwill be added to that register set. e.g. metadata can add a register to\nthe \"General Purpose Registers\" set that lldb shows users.\n\n`registers` is an array of dictionaries, one per register. Each register\nmust have the keys `name`, `value`, `bitsize`, and `set`. It may provide\nadditional keys like `alt-name`, that\n`DynamicRegisterInfo::SetRegisterInfo` recognizes.\n\nThis `sets` + `registers` formatting is the same that is used by the\n`target.process.python-os-plugin-path` script interface uses, both are\nparsed by `DynamicRegisterInfo`. The one addition is that in this\nLC_NOTE metadata, each register must also have a `value` field, with the\nvalue provided in big-endian base 10, as usual with JSON.\n\nIn RegisterContextUnifiedCore, I combine the register sets \u0026 registers\nfrom the LC_THREAD for a specific thread, and the metadata sets \u0026\nregisters for that thread from the LC_NOTE. Even if no LC_NOTE is\npresent, this class ingests the LC_THREAD register contexts and\nreformats it to its internal stores before returning itself as the\nRegisterContex, instead of shortcutting and returning the core\u0027s native\nRegisterContext. I could have gone either way with that, but in the end\nI decided if the code is correct, we should live on it always.\n\nI added a test where we process save-core to create a userland corefile,\nthen use a utility \"add-lcnote\" to strip the existing \"process metadata\"\nLC_NOTE that lldb put in it, and adds a new one from a JSON string.\n\nrdar://74358787\n\n---------\n\nCo-authored-by: Jonas Devlieghere \u003cjonas@devlieghere.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "43567592dd44796d453a94834c3baff4657df1e3",
      "old_mode": 33188,
      "old_path": "lldb/include/lldb/Symbol/ObjectFile.h",
      "new_id": "1b9ae1fb31a69e15915a3d0c57270e863f07cee1",
      "new_mode": 33188,
      "new_path": "lldb/include/lldb/Symbol/ObjectFile.h"
    },
    {
      "type": "modify",
      "old_id": "b1741926b74aaaad93979cfaad3964021031a8c3",
      "old_mode": 33188,
      "old_path": "lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp",
      "new_id": "4394caf7f31e9ab6def8d160699d4e2a4eec58da",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp"
    },
    {
      "type": "modify",
      "old_id": "7f67f5e04f1d66083345ac2cabbf42b39a98686e",
      "old_mode": 33188,
      "old_path": "lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h",
      "new_id": "7e3a6754dd0b81f18db1e9210525da3523b26fff",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
    },
    {
      "type": "modify",
      "old_id": "a1ea85ec4c72827a84e8b7d9bd404e4bcf087a0d",
      "old_mode": 33188,
      "old_path": "lldb/source/Plugins/Process/mach-core/CMakeLists.txt",
      "new_id": "926f06d23c64b8ef6a11d04ef2f036649b259a12",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/Process/mach-core/CMakeLists.txt"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "16568f788c2022535fda0e7d0fa334f1a274f1cb",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/Process/mach-core/RegisterContextUnifiedCore.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "971d5cb5684628ba54ee7cad667bded2ece5ef25",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/Process/mach-core/RegisterContextUnifiedCore.h"
    },
    {
      "type": "modify",
      "old_id": "003cdd0fcaa570150ba7c73407881ca15aa7f73f",
      "old_mode": 33188,
      "old_path": "lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp",
      "new_id": "de7de9ee7c5ce7970da4b852cdd6ed50451ceca3",
      "new_mode": 33188,
      "new_path": "lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e232ec5d69675c1cfa638936c254830c6c2c7eff",
      "new_mode": 33188,
      "new_path": "lldb/test/API/macosx/lc-note/additional-registers/Makefile"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "cf9f055bd78fddbe21801648748120eb521fabbc",
      "new_mode": 33188,
      "new_path": "lldb/test/API/macosx/lc-note/additional-registers/TestMetadataRegisters.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "8d9d550a9ad72abbe4b2714d172deb0fa363bfcf",
      "new_mode": 33188,
      "new_path": "lldb/test/API/macosx/lc-note/additional-registers/add-lcnote.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "70679942daf0659214224e88cfc9f125496c9493",
      "new_mode": 33188,
      "new_path": "lldb/test/API/macosx/lc-note/additional-registers/main.c"
    }
  ]
}
