)]}'
{
  "commit": "a8f4696286aa48c8c5df6569c10036eaa980c0b2",
  "tree": "ef461c639ebd08941b84f33311ad3058dfafbd55",
  "parents": [
    "7b91a240d6e0c1a2766276ecfbfabde4a68420a5"
  ],
  "author": {
    "name": "Piotr Rudnicki",
    "email": "piotr.rudnicki@intel.com",
    "time": "Fri May 30 15:21:49 2025 +0200"
  },
  "committer": {
    "name": "Piotr Rudnicki",
    "email": "piotr.rudnicki@intel.com",
    "time": "Tue Jun 03 09:50:03 2025 +0200"
  },
  "message": "gdb: handle struct and union types in evaluate_subexp_for_address_base\n\nSuppose a function returns a struct and a method of that struct is\ncalled.  E.g.:\n\n  struct S\n  {\n    int a;\n    int get () { return a; }\n  };\n\n  S f ()\n  {\n    S s;\n    s.a \u003d 42;\n    return s;\n  }\n\n  ...\n  int z \u003d f().get();\n  ...\n\nGDB is able to evaluate the expression:\n\n  (gdb) print f().get()\n  $1 \u003d 42\n\nHowever, type-checking the expression fails:\n\n  (gdb) ptype f().get()\n  Attempt to take address of value not located in memory.\n\nThis happens because the `get` function takes an implicit `this`\npointer, which in this case is the value returned by `f()`, and GDB\nwants to get an address for that value, as if passing the implicit\nthis pointer.  However, during type-checking, the struct value\nreturned by `f()` is a `not_lval`.\n\nA similar issue exists for union types, where methods called on\ntemporary union objects would fail type-checking in the same way.\n\nAddress the problems by handling `TYPE_CODE_STRUCT` and\n`TYPE_CODE_UNION` in `evaluate_subexp_for_address_base`.\n\nWith this change, for struct\u0027s method call, we get\n\n  (gdb) ptype f().get()\n  type \u003d int\n\nAdd new test cases to file gdb.cp/chained-calls.exp to test this change.\n\nRegression-tested in X86-64 Linux.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "7601c3b0dddb94f9326cc85ce998c13caeacc871",
      "old_mode": 33188,
      "old_path": "gdb/eval.c",
      "new_id": "539b700ad8ff08206efde54e6365fe5296aa7b05",
      "new_mode": 33188,
      "new_path": "gdb/eval.c"
    },
    {
      "type": "modify",
      "old_id": "9d12c988b4d2f515a2b7226f6fb4fc5793139312",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.cp/chained-calls.cc",
      "new_id": "9358c716b4433cd6353fffa8471474ee1bc2629e",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/chained-calls.cc"
    },
    {
      "type": "modify",
      "old_id": "4f0597a0005e127e62e1ce5445ebff877c92a9ed",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.cp/chained-calls.exp",
      "new_id": "d34162c355b136c313a1d48fcc58816351f834a6",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/chained-calls.exp"
    }
  ]
}
