)]}'
{
  "commit": "b45d18f19ec9507d7561c4d503a5a189214f3f77",
  "tree": "c78a555149a7007f2fc2f48381a6e87bd1902ce6",
  "parents": [
    "14e61dbbbbb50e2b48834ba489942931514e7ff5"
  ],
  "author": {
    "name": "Hannes Domani",
    "email": "ssbssa@yahoo.de",
    "time": "Sat Dec 16 11:24:16 2023 +0100"
  },
  "committer": {
    "name": "Hannes Domani",
    "email": "ssbssa@yahoo.de",
    "time": "Sat Dec 16 11:27:25 2023 +0100"
  },
  "message": "Use function entry point record only for entry values\n\nPR28987 notes that optimized code sometimes shows the wrong\nvalue of variables at the entry point of a function, if some\ncode was optimized away and the variable has multiple values\nstored in the debug info for this location.\n\nIn this example:\n```\nvoid foo()\n{\n   int l_3 \u003d 5, i \u003d 0;\n   for (; i \u003c 8; i++)\n       ;\n   test(l_3, i);\n}\n```\nWhen compiled with optimization, the entry point of foo is at\nthe test() function call, since everything else is optimized\naway.\nThe debug info of i looks like this:\n```\n(gdb) info address i\nSymbol \"i\" is multi-location:\n  Base address 0x140001600  Range 0x13fd41600-0x13fd41600: the constant 0\n  Range 0x13fd41600-0x13fd41600: the constant 1\n  Range 0x13fd41600-0x13fd41600: the constant 2\n  Range 0x13fd41600-0x13fd41600: the constant 3\n  Range 0x13fd41600-0x13fd41600: the constant 4\n  Range 0x13fd41600-0x13fd41600: the constant 5\n  Range 0x13fd41600-0x13fd41600: the constant 6\n  Range 0x13fd41600-0x13fd41600: the constant 7\n  Range 0x13fd41600-0x13fd4160f: the constant 8\n(gdb) p i\n$1 \u003d 0\n```\n\nCurrently, when at the entry point of a function, it will\nalways show the initial value (here 0), while the user would\nexpect the last value (here 8).\nThis logic was introduced for showing the entry-values of\nfunction arguments if they are available, but for some\nreason this was added for non-entry-values as well.\n\nOne of the tests of amd64-entry-value.exp shows the same\nproblem for function arguments, if you \"break stacktest\"\nin the following example, you stop at this line:\n```\n124     static void __attribute__((noinline, noclone))\n125     stacktest (int r1, int r2, int r3, int r4, int r5, int r6, int s1, int s2,\n126                double d1, double d2, double d3, double d4, double d5, double d6,\n127                double d7, double d8, double d9, double da)\n128     {\n129       s1 \u003d 3;\n130       s2 \u003d 4;\n131       d9 \u003d 3.5;\n132       da \u003d 4.5;\n133 -\u003e    e (v, v);\n134     asm (\"breakhere_stacktest:\");\n135       e (v, v);\n136     }\n```\nBut `bt` still shows the entry values:\n```\ns1\u003ds1@entry\u003d11, s2\u003ds2@entry\u003d12, ..., d9\u003dd9@entry\u003d11.5, da\u003dda@entry\u003d12.5\n```\n\nI\u0027ve fixed this by only using the initial values when\nexplicitely looking for entry values.\n\nNow the local variable of the first example is as expected:\n```\n(gdb) p i\n$1 \u003d 8\n```\n\nAnd the test of amd64-entry-value.exp shows the expected\ncurrent and entry values of the function arguments:\n```\ns1\u003d3, s1@entry\u003d11, s2\u003d4, s2@entry\u003d12, ..., d9\u003d3.5, d9@entry\u003d11.5, da\u003d4.5, da@entry\u003d12.5\n```\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d28987\nTested-By: Guinevere Larsen \u003cblarsen@redhat.com\u003e\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "5b2d58ab44e42677d2e92d9ef7da39b48711ca4b",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/loc.c",
      "new_id": "c15221eb7a288010fb4e85d7ee8e4638f7941e89",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/loc.c"
    },
    {
      "type": "modify",
      "old_id": "5cf824d3ae24241e8855fd772ab668376f568bf7",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/loc.h",
      "new_id": "94e1fbe517eb8f5e668a868d48ce62bde60379ed",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/loc.h"
    },
    {
      "type": "modify",
      "old_id": "3c666acc1170fe32bb4b4e464c1d0a4d775bf3e2",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.arch/amd64-entry-value.exp",
      "new_id": "c7fea226df72d1ae17d6cdf493dc73ce6bec2044",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.arch/amd64-entry-value.exp"
    }
  ]
}
