From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114059 invoked by alias); 3 Mar 2017 18:31:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113064 invoked by uid 89); 3 Mar 2017 18:31:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,SPF_PASS autolearn=ham version=3.3.2 spammy=focuses, lk-thread, untangle, thread_info X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Mar 2017 18:31:41 +0000 Received: from ESESSHC016.ericsson.se (Unknown_Domain [153.88.183.66]) by (Symantec Mail Security) with SMTP id F2.11.14655.A86B9B85; Fri, 3 Mar 2017 19:31:39 +0100 (CET) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.66) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 3 Mar 2017 19:31:38 +0100 Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=ericsson.com; Received: from [142.133.50.177] (192.75.88.130) by AM4PR07MB1716.eurprd07.prod.outlook.com (10.166.133.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.2; Fri, 3 Mar 2017 18:31:36 +0000 Subject: Re: [PATCH RFC] Decouple user selection from internal selection To: Philipp Rudo References: <20170223222850.5511-1-simon.marchi@ericsson.com> <20170303182421.4ba0d248@ThinkPad> CC: From: Simon Marchi Message-ID: <5e0a88c0-b541-c261-97a0-37e8753ccb6a@ericsson.com> Date: Fri, 03 Mar 2017 18:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170303182421.4ba0d248@ThinkPad> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BN6PR17CA0019.namprd17.prod.outlook.com (10.173.147.29) To AM4PR07MB1716.eurprd07.prod.outlook.com (10.166.133.24) X-MS-Office365-Filtering-Correlation-Id: a93e33ce-7c6c-4b3b-6baa-08d4626386ea X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM4PR07MB1716; X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1716;3:rGWOxw4efQ1S++UUH1wgmjuOGczAlXmtf1zMNaMJNsrfOpWLZRO61OAXlsEYIzd+dOCqk7T/fhOsPfdSgWjhfOLAG2YqpakCXOFzxWfR1PvuaNUcYCHFxP/is6darUdmg3gkQxhdM/U7gEXtvkEf0Vdwck1/KOgZ6OZEGL52NhX0CK0b/8WyHd/+/Vpiu9AU4Lua82fc+q5uK7nq7+VLNi+wCZiOMCiHd/LeOC3tKSdqXEl3im/HEULIY4xf0NuZ6D//WWJZgKiHhiiFh1tl0Q==;25:bS9DmFJOH4KbkBJcGMly1Y1olL5VIDxe3nr33V2A2xLnNUgPyTk2QuL/lGpH5T9xlyI0TTH/4eIwWaaf2Zogg/pk5CrvtAKCYNsjutXaVb1+QlMiR79SCxHwdsElcpQ3jG0AxPVevS2ew32ynZzWMj9DwNtupMKxOUhakGs0BzIWliQnYIPtv8tupFEur5X8319OLVXb06ocV7DW3BmyXhV5fSvE/3YUpwgNIKt9UPzeodUrI7QsTIqYvoJUz4PjMVesCq4qxiL12NQ5TmL7QxPwrm3gAvpOFyYWNXNj0fzkp50O/5U+vmttTA3WdkdE/p+1Ej6SX/+74QoFYXx8O3tfwVvnx2T52oPj1zs8b8MVSkfGrpzeJhydmx1Ttk40WSdch+2MEWpIqnBlFLWmEiFUp8A4J+5jNlgMtZQeZEDmtYpPVkuVKU7yyFBTFDE7gw+/67o47KDXjXtEyH9wTA== X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1716;31:1uxLBixhUHgubzsJ280UrXItTF3/XKM9QCz/DluBQUJs8pRiTFq8SN+lflk5u8MegyhPn9EjyG7Aq9fh6caf9NzJL82YxsoCflA/0LWVUF9xMZ5fhvAcFWGsp5X5b+bOFLGJvxHZ/YkE4P+2IIlAij+Q/8hAh49/6siuIe1L+mNfbRUJnEBoJnqgyVs/4WZf8RsYkLf9PY/JeVz1BM8d+8NCmJFA7luMQ+QiebGIWqNE7nuqLrf1UNblnprU0PG1pFK3Sftb1M3lQl9H2kuTjh094zgHcHFeesoK1IdPS3M=;20:MYuoe6hnWZEc00hpT36fOkVYyVOWgH2IC5ZMd3Ch15cV9c0M8hgrYT7iwhhUeYn8t1n0yddxkpW0C9wu11LmfIxwt9J/fu263yS8Kkn8zbvfVfJOptvv/6r5XhtrBYMpmfY3yUAmVRr6fYcTiltrBTcCqpBkVVsfw2GxQfsAt8Uiiil3HFVi37DT9dxGR/Ryw6Jo2MADj0HuRalpp8TA9j7TNCjZkyrakC7m+Vb3pMDB1GvxDWxw+MLRWjIADOLn1XswOaRT1sRa5Fae5mqa1qhHDOs9g3Uv6fIGdxpbCkepLLhDLrJKFJbzugNFYMdD5QmKsbmmFRWj9EUd6RnSeT2224T+ZiolL+HRlxDUWP+wAXcrd11Dxe0juK1rjRsFh+nrISAyFEm+/oGk+oXfBu7XIo1789d4KmcYA7s9AwwPQPjedcRrdbomJsH9LyaR8iVfPmEKs2KZAfLOmuKZNLPXndQ+fZb+HXPULWWLsFj1db4guEeVs1AbeHI87U5v X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(20161123558025)(6072148);SRVR:AM4PR07MB1716;BCL:0;PCL:0;RULEID:;SRVR:AM4PR07MB1716; X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1716;4:GI/ZQ+HLqe06RNHGeKqpo8MrcrfljSLYEGyHBFaO+48lGrmjzdXghD4uwOCNf9CScCivDHMkC8XMo55ixxBErJg/p8wYhC/kaHLcuFMR1l5XzxrKQL1KCldKtFl852a/w4zsGOGqheOvf9GNPtHTKZVAIxl85+bhGVomlAn3gBssbrnDNVOacFuyncPrOAtAuhC6ru5fTBJ9gqHehetgpaNeTBpjbL6LRNXR20TzULFIVVppDD5pMsaWeFvvmWjeFh6Qg2/7PFgftjasKsUK9v81lhJBFjGuTDIxotQX2U3hwqZ5Y/yrnwtyV21VusczKZ2ViAb695XOHqD7BZGFHkHhoVI50BxgDEhT5v7AM4J0fYW9AlfkmQBG3izmICo93lTrPARGkEDev51wzvGoyZ8aY6vJYAlElFFV517o2O64lqBn7HPv9szWiY5grjGVNJRtHVzaoPFmr4+sJ2S/Hv2utrbBJ6K20rG3Sdv+Kh2Vf2K1B6BAPLLLkzss2yKQZIi43pj/E64uDXQ2/jav2It5vEIsw12V8eAfHX0tZtj9dukeFZE0HdYkH5dKrsodomsW17kRSp3kXo/l0QzrGQ2OCAHGcdwAa//tVR4AND0= X-Forefront-PRVS: 0235CBE7D0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(39450400003)(377454003)(51444003)(377424004)(24454002)(53546006)(6116002)(64126003)(6916009)(92566002)(76176999)(3846002)(6246003)(65956001)(38730400002)(110136004)(31686004)(36756003)(65826007)(50986999)(23676002)(2906002)(42186005)(53936002)(6666003)(47776003)(50466002)(83506001)(66066001)(230700001)(5660300001)(4326008)(229853002)(189998001)(54356999)(2950100002)(8676002)(33646002)(31696002)(7736002)(4001350100001)(86362001)(6486002)(81166006)(305945005)(25786008);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR07MB1716;H:[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tg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 18:31:36.6345 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR07MB1716 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00027.txt.bz2 Hi Philipp, On 17-03-03 12:24 PM, Philipp Rudo wrote: > Hi Simon > > I have mixed feelings for this patch. On the one hand I think its good > you try to untangle the different uses of the global variables. On the > other hand your approach is just an other workaround for the main > problem, using global variables. > > For me the long-term goal should be to get rid of the global > variables. This would require to define a "debug_context" which can be > a user selected as well as a GDB internal context. This > "debug_context" (or parts of it) can then be passed down the stack. So > every function gets the information it needs from its caller. This not > only gives you flexibility, as you can have different contexts, but > also prevents bugs where the global variables are not properly > set/restored, like you have with MI. I agree. I think a good way of stating the direction to take is to reduce the usage of the inferior_ptid global variable. As I mentioned in the patch message, it currently has two functions: 1. User/front-end selected thread 2. Internally selected thread This patch tries to separate those two concerns. #1 doesn't really have the choice to be global at the moment, because we have a single globally shared user selection. If we decide to have a selection per UI, it would change that. #2 is where we can reduce the usage of the global right now. inferior_ptid is in many ways used to indirectly pass information to called functions (on which thread to operate), whereas this information should be passed down the callstack, as you say. Whether we can use the same debug_context objects for storing the user selection and the debug contexts passed down the stack, I don't know. Whoever implements this will discover the answer. So I think that my patch, even though it doesn't address the problem of the globals directly, is in line with the long-term direction you are proposing. > Those different "debug_contexts" will also be needed for the > multi-target idea Andreas and I have. With this feature we want to > allow the user to take a look at a given problem from the point of view > of different targets. For example consider the potential target stack > (from [1]): > > - goroutine (Goroutine) > - multi-thread (multi-threaded child process.) <-- linux-thread-db > - lk-user (User-space task) <-- focuses on one user-space process > - lk-thread (Linux kernel threads) <-- uses the kernel's task list > - core (Local core dump file) <-- "threads" are actually CPUs > - exec (Local exec file) > - None (None) > > In this scenario there are five different views on threads (from > hardware threads to goroutines). The user might be interested in all > of them and wants to choose a target and get its perspective on the > problem. But switching between different targets, with different views > on threads/inferiors, using global variables would be a pain and error > prone. That's why we prefer the approach described above. It would be very interesting indeed, to be able to choose the level of abstraction at which to look at the system. > Of course getting rid of the global variables would be a huge job. > Here your approach could be an intermediate solution (I understand your > "user_selection" to be a "debug_context"). It allows us to update GDB > over time by passing it down the stack one after one and apply the > context to the global variables for the parts which where not updated, > yet. > > Independent to what I said before you should split up this patch into a > series to make review easier. For example the introduction of > thread_info::put/get in gdbthread.h or scoped_restore_suppress_output > in ui-out.c are independent of the user-selection and should go in > separate patches. Indeed, I will do that. Thanks a lot for the comments. Simon