)]}'
{
  "commit": "fc829affa73453a466af5a301e22fae3dd76b971",
  "tree": "73b39b02bf9ad75a74b20195078829609e0a2f7a",
  "parents": [
    "8bf4b69718d406abc99dd9cdc4c9cef79d7344cf"
  ],
  "author": {
    "name": "Rohr, Stephan",
    "email": "stephan.rohr@intel.com",
    "time": "Thu Jun 25 14:58:50 2026 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Tue Jul 07 17:00:55 2026 +0100"
  },
  "message": "gdb: set frame_info_ptr::m_cached_id in the destructor\n\nCurrently frame_info_ptr caches the frame_id at construction time, see\nframe_info_ptr::frame_info_ptr in frame.c.  The problem with this is\nthat a frame\u0027s frame-id might not be known at this point.\n\nConsider get_prev_frame_maybe_check_cycle, this calls\nget_prev_frame_raw to create the previous frame, placing the result\ninto a frame_info_ptr PREV_FRAME.  Then (for frames other than frame\n0) compute_frame_id is called, however, this only computes the\nframe_id for the frame_info object pointed to by the frame_info_ptr,\nthe cached frame_id within the frame_info_ptr itself is not updated.\n\nWhat this means is that in get_prev_frame_maybe_check_cycle, the\nPREV_FRAME local has no cached frame-id.\n\nIf we consider the call stack:\n\n  get_selected_frame\n    lookup_selected_frame\n      frame_find_by_id\n        get_prev_frame\n\t  get_prev_frame_always\n\t    get_prev_frame_always_1\n\t      get_prev_frame_maybe_check_cycle\n\nThen what we see is that the frame_info_ptr created in\nget_prev_frame_maybe_check_cycle, which lacks a cached frame_id, can\nbe passed all the way back to lookup_selected_frame, where it will be\nstored in the SELECTED_FRAME global by a call to select_frame.  The\nouter get_selected_frame call (in the above backtrace) will then\nreturn the SELECTED_FRAME global, which lacks a cached frame-id.\n\nIf GDB ever tries to reinflate the SELECTED_FRAME frame_info_ptr (or a\ncopy of it), then we will trigger the assert:\n`gdb_assert (frame_id_p (m_cached_id));` which can be found in\n`frame_info_ptr::reinflate` in frame.c.\n\nAn example of how this can be triggered is included in the updated\ntest case, frame #1 is selected and the frame is printed.  The pretty\nprinter performs an inferior call which invalidates the frame cache,\nthe assertion then triggers when trying to reinflate the selected\nframe frame_info_ptr.\n\nThe problem is that frame\u0027s don\u0027t always know their frame-id when they\nare placed into a frame_info_ptr, but they always do (for frame other\nthan #0) after get_prev_frame_maybe_check_cycle has finished.  We\ncould try to have get_prev_frame_maybe_check_cycle or compute_frame_id\npush the computed frame-id into the frame_info_ptr, or we can just\ndefer caching the frame-id until we know we might need it, i.e. when\nthe frame cache is being flushed.\n\nThis second approach is actually nice in that it defers the work until\nwe know we need it, and frame_info_ptr objects that are created and\ndestroyed without the frame cache ever being flushed no longer need to\ncache the frame-id.  This isn\u0027t going to give any noticable\nperformance improvement, but still, it feels nice.\n\nThe changes in this commit then are:\n\n  1. In reinit_frame_cache we call frame_info_ptr::invalidate before\n     deleting all the frame_info objects (by clearing the obstacks),\n     this allows us to copy the frame_id from these objects.\n\n  2. In frame_info_ptr::frame_info_ptr we still need to record every\n     frame_info_ptr in the global list, and for now at least, we still\n     cache the frame level, this is needed for\n     frame_info_ptr::is_null, which checks the cached level.\n\n  3. In frame_info::invalidate, we can assert that the cached level\n     matches the stored frame\u0027s level, this should never change, and\n     it is here that we now cache the frame-id.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cefdde5ed1ef9b5428e1e6dad3688989a653c35b",
      "old_mode": 33188,
      "old_path": "gdb/frame.c",
      "new_id": "e7974060cb8e20ffe66892fd86a6124d45311b94",
      "new_mode": 33188,
      "new_path": "gdb/frame.c"
    },
    {
      "type": "modify",
      "old_id": "f6553fb7b6dd57819e17d48ef6b05a2ee49e0c1e",
      "old_mode": 33188,
      "old_path": "gdb/frame.h",
      "new_id": "b386303d89523c5df17b982039112c7af76fa09b",
      "new_mode": 33188,
      "new_path": "gdb/frame.h"
    },
    {
      "type": "modify",
      "old_id": "52162fc995220cc831f977cd158b3e7e9a120a34",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp",
      "new_id": "a2a29c4d0f87c715e457b29c4b1af02b1178453f",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp"
    }
  ]
}
