)]}'
{
  "commit": "44c04ee9bf959b40819de6327500557fbb5d8c4a",
  "tree": "f2fae0b73585f6b67cfbb0f7c29d65f9d70ebc77",
  "parents": [
    "a567769b813b2538bebc97d689fc0739f172028e"
  ],
  "author": {
    "name": "Simon Marchi",
    "email": "simon.marchi@ericsson.com",
    "time": "Thu Dec 08 13:06:14 2016 -0500"
  },
  "committer": {
    "name": "Simon Marchi",
    "email": "simon.marchi@ericsson.com",
    "time": "Thu Feb 23 17:25:30 2017 -0500"
  },
  "message": "Decouple user selection from internal selection\n\nI am sending this as an RFC because it\u0027s far from complete and\ndefinitive, but I\u0027d like to gather some comments and opinions before\ngoing further in this direction.\n\nThe goal of this patch is to decouple the notion of the user-selected\ninferior/thread/frame from GDB\u0027s internally selected\ninferior/thread/frame.\n\nCurrently, for example, the inferior_ptid variable has two jobs:\n\n - it\u0027s the user-selected thread: it\u0027s changed by the \"thread\" command.\n   Other commands (continue, backtrace, etc) apply to this thread.\n - it\u0027s the internally-selected thread: it defines the thread GDB is\n   currently \"working\" on.  For example, implementations of\n   to_xfer_partial will refer to it to know from which thread to\n   read/write memory.\n\nBecause of this dual usage, if we want to do some operations on a thread\nother than the currently selected one, we have to save the current\ninferior/thread/frame and restore them when we\u0027re done.  Failing to do\nso would result in an unexpected selection switch for the user.\n\nTo improve this, Pedro suggested in [1] to decouple the two concepts.  This\nis essentially what this patch is trying to do.\n\nA new \"user_selection\" object is introduced, which contains the selected\ninferior/thread/frame from the point of view of the user.  Before every\ncommand, we \"apply\" this selection to the core of GDB to make sure the\ninternal selection matches the user selection.\n\nThere is a single user selection for the whole GDB (named \"global\nuser-selection\"), but as was mentioned in the linked thread, it opens\nthe door to having different selections for different UIs.  This means\nthat each UI would have its own user-selection object, which would be\napplied to the core prior to executing commands from this UI.\n\nThe global user-selection object only gets modified when we really\nintend to change it.  It can be because of the thread / -thread-select /\nup / down / frame / inferior commands, a breakpoint hit in all-stop, an\ninferior exit, etc.\n\nThe problem that initially prompted this effort is that the \"--thread\"\nflag of MI commands changes the user-selected thread under the user\u0027s\nfeet.  My initial attempt to fix it was to restore the selection after\nthe MI command execution.  However, some cases are hard to get right.\nFor example:\n\n  (thread 1 is currently selected)\n  -interpreter-exec --thread 2 console \"thread 3\"\n\nRestoring the selected thread to thread 1 after the MI command execution\nwrongfully cancels the switch to thread 3.  So it\u0027s hard to determine\nwhen we should or shouldn\u0027t restore.   With the current patch, it works\nnaturally: the --thread flag doesn\u0027t touch the user-selected thread,\nonly the internal one.  The \"thread 3\" command updates the user\nselection.\n\nAnother difficulty is to send the right notifications to MI when the\nuser selection changes.  That means to not miss any, but not send too\nmany either.  Getting it somewhat right lead to ugly hacks (see the\ncommand_notifies_uscc_observer function) and even then it\u0027s not perfect\n(see the kfails in user-selected-context-sync.exp test).  With the\nproposed method, it\u0027s easy to know when the user-selection changes and\nsend notifications.\n\nWith this patch, there are probably a few usage of\nmake_cleanup_restore_current_thread that are not needed anymore, if they\nare only used to restore the user selection.  I kept removing them for a\nlater time though.\n\nIn the current state, there are a few minor regressions in the testsuite\n(especially some follow-fork stuff I\u0027m not sure how to handle), but the\nvast majority of the previously passing tests still pass.\n\nComments are welcome!\n\nThanks,\n\nSimon\n\n[1] https://sourceware.org/ml/gdb-patches/2016-08/msg00031.html\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "268c2c6ead30d77ec3bf073d478a3a650522a206",
      "old_mode": 33188,
      "old_path": "gdb/Makefile.in",
      "new_id": "85706a590941ec505c309acb7d8000b90fea4a3f",
      "new_mode": 33188,
      "new_path": "gdb/Makefile.in"
    },
    {
      "type": "modify",
      "old_id": "1b6a1ade81211e054131194acdfebdc9865a19e4",
      "old_mode": 33188,
      "old_path": "gdb/cli-out.h",
      "new_id": "5a775e9881f1f9cb3d30828d70fb229c58f04aeb",
      "new_mode": 33188,
      "new_path": "gdb/cli-out.h"
    },
    {
      "type": "modify",
      "old_id": "8712c75f3962b3d480e1230c841b353a4c56c11d",
      "old_mode": 33188,
      "old_path": "gdb/cli/cli-interp.c",
      "new_id": "d460a68771bb9a548ae89b512ab0617f4936fd46",
      "new_mode": 33188,
      "new_path": "gdb/cli/cli-interp.c"
    },
    {
      "type": "modify",
      "old_id": "606ddfe53687f82d7d8d7a4df8ac116f228c51ab",
      "old_mode": 33188,
      "old_path": "gdb/doc/observer.texi",
      "new_id": "f786b1e2b7d30a172526325a4fa5f22a07041154",
      "new_mode": 33188,
      "new_path": "gdb/doc/observer.texi"
    },
    {
      "type": "modify",
      "old_id": "5d8d077a9a44a1209d37ed26092d8f3617857241",
      "old_mode": 33188,
      "old_path": "gdb/event-top.c",
      "new_id": "9056b46c60ad69a6220be9698a4787e6c9b622e7",
      "new_mode": 33188,
      "new_path": "gdb/event-top.c"
    },
    {
      "type": "modify",
      "old_id": "d98003dee7c34a63bd25356e6674721664a4b2f3",
      "old_mode": 33188,
      "old_path": "gdb/frame.c",
      "new_id": "93f658534d1b3f465e348e52fc6c2452148e2d4f",
      "new_mode": 33188,
      "new_path": "gdb/frame.c"
    },
    {
      "type": "modify",
      "old_id": "1d0644f12de59b86130882db5ae02a01d18c103f",
      "old_mode": 33188,
      "old_path": "gdb/frame.h",
      "new_id": "5c68febde67f81d3f6bb0e2b4e173d00170919d8",
      "new_mode": 33188,
      "new_path": "gdb/frame.h"
    },
    {
      "type": "modify",
      "old_id": "ac1e683314d0aae1fe39d2c0faacaea3a9253a6a",
      "old_mode": 33188,
      "old_path": "gdb/gdb.h",
      "new_id": "c224d419be6e9ec7010ff62bc89d0b979d784cee",
      "new_mode": 33188,
      "new_path": "gdb/gdb.h"
    },
    {
      "type": "modify",
      "old_id": "06ed78f56819be733eaf6bf8a9b929903574ab27",
      "old_mode": 33188,
      "old_path": "gdb/gdbthread.h",
      "new_id": "47cf1258a1282bcdd17b94c3e2776e53b6368e89",
      "new_mode": 33188,
      "new_path": "gdb/gdbthread.h"
    },
    {
      "type": "modify",
      "old_id": "f55acb5c27e27a1a625c1114ee86b499a34de0b9",
      "old_mode": 33188,
      "old_path": "gdb/infcall.c",
      "new_id": "fc3e4e7e75f3b43482f28aa116ad73a8bedb1c88",
      "new_mode": 33188,
      "new_path": "gdb/infcall.c"
    },
    {
      "type": "modify",
      "old_id": "c4ab6d7d7f6130d4a9b8c39fc8d5be337aac941c",
      "old_mode": 33188,
      "old_path": "gdb/inferior.c",
      "new_id": "d9d026a936c221a3b93f2a52bf621f945c9b7f90",
      "new_mode": 33188,
      "new_path": "gdb/inferior.c"
    },
    {
      "type": "modify",
      "old_id": "7c0ddf37f1e0bdea33833916fd2718ce3eb3076b",
      "old_mode": 33188,
      "old_path": "gdb/inferior.h",
      "new_id": "b06866f49006e5f2b2129da82710665d10c96699",
      "new_mode": 33188,
      "new_path": "gdb/inferior.h"
    },
    {
      "type": "modify",
      "old_id": "1e5e9f14a64593a4bef574cbf79621ff599c83f4",
      "old_mode": 33188,
      "old_path": "gdb/infrun.c",
      "new_id": "a55acdf6dd40d7ac1b36a952b960ad8123f559d0",
      "new_mode": 33188,
      "new_path": "gdb/infrun.c"
    },
    {
      "type": "modify",
      "old_id": "158d6d821545f19fbad05b9e6838980a6231dbb5",
      "old_mode": 33188,
      "old_path": "gdb/jit.c",
      "new_id": "d58457da020c5e859ac3b23c96c5ca26f3147c2a",
      "new_mode": 33188,
      "new_path": "gdb/jit.c"
    },
    {
      "type": "modify",
      "old_id": "acb44a28ee51cd0ec79835f7a96989c0fcd75cd9",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-cmd-stack.c",
      "new_id": "fadfdaa4352978e4ca173fe9fd9cd553eed8bba9",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-cmd-stack.c"
    },
    {
      "type": "modify",
      "old_id": "86340e4a0815df8c2692e7e1e664feae42cfd88d",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-interp.c",
      "new_id": "958f154130c2c74bd5a260161bf064eaa910d7da",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-interp.c"
    },
    {
      "type": "modify",
      "old_id": "cf4e45ad4137e91abcd6141bfb0d82a4ab17b7c3",
      "old_mode": 33188,
      "old_path": "gdb/mi/mi-main.c",
      "new_id": "63458d9113953085e5e63ad3f5c2b7b8e6ef9fd8",
      "new_mode": 33188,
      "new_path": "gdb/mi/mi-main.c"
    },
    {
      "type": "modify",
      "old_id": "49db6b8cef400c146a92019dd2c050eeb26eccea",
      "old_mode": 33261,
      "old_path": "gdb/observer.sh",
      "new_id": "02a3e7be22144ab0c902b684947ccf9e6b63e122",
      "new_mode": 33261,
      "new_path": "gdb/observer.sh"
    },
    {
      "type": "modify",
      "old_id": "aa3a80e9a82605cca205e2e44730589c41e22824",
      "old_mode": 33188,
      "old_path": "gdb/stack.c",
      "new_id": "26fb40dbec7468e2ab69df5e9e0f8ec56322076e",
      "new_mode": 33188,
      "new_path": "gdb/stack.c"
    },
    {
      "type": "modify",
      "old_id": "1583200cb2930339c9f1b65e3b7554cf74059161",
      "old_mode": 33188,
      "old_path": "gdb/stack.h",
      "new_id": "75fa4d6692000ad5815746474958938e1194e1a2",
      "new_mode": 33188,
      "new_path": "gdb/stack.h"
    },
    {
      "type": "modify",
      "old_id": "1b569d7e64efdb34b1d087091d5cff52ab23232a",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.mi/mi-pthreads.exp",
      "new_id": "07e02ab446b149844ec083c419aa6787a7ff14d8",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.mi/mi-pthreads.exp"
    },
    {
      "type": "modify",
      "old_id": "91f414610747921b05e72946e5b5c667c0f44f6c",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.mi/mi-return.exp",
      "new_id": "6b099bf001fd9b7f5047c95df5f2e73c00013a8f",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.mi/mi-return.exp"
    },
    {
      "type": "modify",
      "old_id": "77734aec05c3641d48803d8cd7f1a7eea3af1fe7",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.mi/user-selected-context-sync.exp",
      "new_id": "f7697f5b126428194a7c9f6b85eb9fde64be44c8",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.mi/user-selected-context-sync.exp"
    },
    {
      "type": "modify",
      "old_id": "99fe42471780c0b74224e19c82eb37f68a6f642a",
      "old_mode": 33188,
      "old_path": "gdb/thread.c",
      "new_id": "b40d8cd36ae4c30337c6efcbad740991e9fb8cf6",
      "new_mode": 33188,
      "new_path": "gdb/thread.c"
    },
    {
      "type": "modify",
      "old_id": "6bf9d8c02165ee70a002cef37f8c61f4769b2107",
      "old_mode": 33188,
      "old_path": "gdb/top.c",
      "new_id": "3a8b9616dffa471b8b094e04871dc24c37929492",
      "new_mode": 33188,
      "new_path": "gdb/top.c"
    },
    {
      "type": "modify",
      "old_id": "dbcd65d5dfac71424dfc690caf22d05e0eaf1522",
      "old_mode": 33188,
      "old_path": "gdb/tracefile-tfile.c",
      "new_id": "91f97cfa9fd3f532322efdeee5f7659df8a4f934",
      "new_mode": 33188,
      "new_path": "gdb/tracefile-tfile.c"
    },
    {
      "type": "modify",
      "old_id": "702c34269c0c0f84664260d38015609be47f35ae",
      "old_mode": 33188,
      "old_path": "gdb/tui/tui-interp.c",
      "new_id": "66423efee4e0af600c6da71c7dde4920bd8e7dbc",
      "new_mode": 33188,
      "new_path": "gdb/tui/tui-interp.c"
    },
    {
      "type": "modify",
      "old_id": "9278cabdaab41e3f6a7d16132158569bddbf4ebe",
      "old_mode": 33188,
      "old_path": "gdb/ui-out.h",
      "new_id": "17933d12f3c726ef34b0654e02f0b2b8191b88da",
      "new_mode": 33188,
      "new_path": "gdb/ui-out.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "098f9154a80e22976b289a0cb99996544993648f",
      "new_mode": 33188,
      "new_path": "gdb/user-selection.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a6f9af30c917d920054d060e572923c0f49873ce",
      "new_mode": 33188,
      "new_path": "gdb/user-selection.h"
    }
  ]
}
