From patchwork Fri Sep 15 16:04:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 22900 Received: (qmail 91352 invoked by alias); 15 Sep 2017 16:04:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 90651 invoked by uid 89); 15 Sep 2017 16:04:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 16:04:15 +0000 Received: from ESESSHC005.ericsson.se (Unknown_Domain [153.88.183.33]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id EC.36.28997.CF9FBB95; Fri, 15 Sep 2017 18:04:13 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.33) with Microsoft SMTP Server (TLS) id 14.3.352.0; Fri, 15 Sep 2017 18:04:12 +0200 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ki.sw.ericsson.se (192.176.1.82) by DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.5; Fri, 15 Sep 2017 16:04:11 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [pushed 1/2] gdbserver: Remove gdb_id_to_thread_id Date: Fri, 15 Sep 2017 18:04:02 +0200 Message-ID: <1505491443-13658-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: DB6PR0202CA0029.eurprd02.prod.outlook.com (2603:10a6:4:a5::15) To DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) X-MS-Office365-Filtering-Correlation-Id: 7d036911-3d7e-44ba-960b-08d4fc53675c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DBXPR07MB320; X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB320; 3:RF4cRmSyYVmFhtRM9TUBBWewoDsWZunssFz4xWQFydZjTn8QLZCiDq138bw9FgMTHQLSeh0VdBGEVSGBCnzNSvnyFu27JCcpsjYAeGLawv1OPlgUwOhwm6cjFrk9gilT9E+dCIQD4OP3gWhDdVijl0jOnF9oePN+Mr48jSJ/OW5QOn32eqQCj7HKMoGC0Yk5+9R4VE+iKa9ekK+OpP1Ylr/TWN4pQtYyhncNyoESfMDyY5bkb5aKjA/hxbVQ8nxs; 25:XA4QsPG+KWbXsB0skSyNh8H6ytxsGCJN1FLdVm6nXQNhNyw41x68VNLZg8eA/mEHQ6YSc0xB3blMgtH0BWJCbUiLs/YDXsdVRRVqoesOmTU2GAby2SLwoJ1OSeDXJVTUicxuhOhJEoldWJpMZNJxoLiQjVcE2NT5o/EtLIpktfmFfkeAioBQp5lzhF31KRmypmnCb5jArQeH/JMztYAN5E1VCVvAu7eHVK764d8hYKDvaGguJLsMHGsqjv7F0JbTH3MTPzB8AsZTXMtUYuBeXNFhNFc3MvEi0Lmi1cJ/6EwFIdK7sBpWqTD3IYERwDpYE13YpwSSxK6zrgqaalCVCw==; 31:srpXRlSFd4ReCYOT3J8jQ72vVwU5TvOi57AC3qpH8//cLzvTaWrnCdJtdXd29mApapmvyW9RcxLsvcbG3VJKL1NlwRxTz9fxr0KuoD3qa/vOhD9IydBsWqulJ4EN62Po4hA070/kEeBk5hWsv/eP2PIRLC7yvNjEGN2Adf2cDUYzSLRGRbfP3zBpXjvOIn1pWRdC12e66eJcBcUoBJz8DRCkmiD4g6WTzBGJz8MsijQ= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBXPR07MB320: X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB320; 20:23Zl4WoiFrGDtmTLj/9m58oFQXapptWPHehlZTkXGpgKItuAwhdVGrQQXJzRkLmJlTbE1ljyslK+573oKM0SubFOB5gLB5eB/PXTPSv/K60R/HN2vt1NqwRna88d14eeKSYuOU5VoWuVz9bdjPKAexprqwjfhY5q4m6ISppPfYgikweV/m8p4UW+igxQ0kOoZulTc6iv5egMRE/Cd5wSg6aQW52iYVKgCSDb9Lj/4DEWkA64HfuZ9r7uABQ4HZ7RZ85VdbMqTpDqxR8SNx9NY2bxIDUEi/zRB8SAPaIV6kMwc/rFQDRSKHU+J7TKWCmingPfP+HxZ7+xlNHYeK27hEklaGxfMNg5WUJ5jNfA0btSWLI/dDIjotBMcrq+UQGvnMRLX5+wGLeSP/V9BU/FBQVhMcUEpmL0+YCJFj51UIbf9fg88n59g5azenipF0bJH+nCWqICGuG3BPjpBVdI/i0VaqLDhNuKTxHvuV0trKg156sncTizdcwWcj0Hw9Wo; 4:nAjnLXqbH94Sks/XoR/dUAakXZWg44+9+5y6zWb+f0Jg9cth+mkBzszgB7Jkchz1lwgUlU5I980WvFmJnluk36D/97fEl9dAw5zgy9sKUO6ZcQK+KZZO8Vew4vJoLyx0uXc5ZRU9hJSeF6SlVytn55QDQzuneN58xO34dGE0RXiXma6/skg9I0qQ02Ag2nS0gZJaOH+Rf0ws0Y4ylPefIYat2B9PI6rxIyBwBcpwlcmyh4il9gpYhyQmn822VoFaFmPwIzrze0LnCjEhZ7UFrzxBEDmpGXE70eT2mOqzxWA= X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123555025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DBXPR07MB320; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DBXPR07MB320; X-Forefront-PRVS: 0431F981D8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(54534003)(199003)(377424004)(189002)(101416001)(3846002)(478600001)(2361001)(106356001)(6116002)(6512007)(2351001)(105586002)(305945005)(36756003)(7736002)(5890100001)(2906002)(33646002)(66066001)(5003940100001)(47776003)(6486002)(6506006)(6916009)(25786009)(50226002)(8936002)(68736007)(6666003)(81166006)(81156014)(5660300001)(8676002)(189998001)(86362001)(48376002)(107886003)(97736004)(16526017)(50986999)(53936002)(16586007)(50466002)(110136004)(4326008)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR07MB320; H:elxacz23q12.ki.sw.ericsson.se; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DBXPR07MB320; 23:AaYJuKgiSmOToxo6889OvQLp/Twm2iM6bCePibjUnP?= =?us-ascii?Q?J4vi3vK1Er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yYWx3tA7dwoNQ0jfk5VvNw5o3yP5VeftTLPmrYWY9onp456Z2MpWzitvkR0DBscUe+bnqrox18IRz9cRgga5Ra23aQEI1Q7VujuSlSVm3xqxqmW0BJHNjs3cHx3FaAUnT0xZS0HPnI2Ffm0VXPIaC0sZg5K9EOQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 16:04:11.0188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR07MB320 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes From what I understand, this function is not doing anything useful as of today. Here's the result of my archeological research: - The field thread_info::gdb_id was added in a06660f7 Use LWP IDs for thread IDs in gdbserver There was problem when using a 32-bits gdb with a 64-bits gdbserver. For some reason that I don't fully understand, the thread ids exchanged between gdb and gdbserver could overflow a 32 bits data type. My guess is that they were the thread address (e.g. the 0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today). This patch changed that so gdb/gdbserver would talk in terms of the OS assigned numerical id (as shown in ps). It therefore added a way to convert between this gdb_id (the numerical id) and the thread id (the address). - 95954743cb Implement the multiprocess extensions, and add linux multiprocess supportNon-stop mode support. This patch made gdbserver deal with threads using their numerical ids and not the address-like id. Starting from there, the gdb_id <-> thread id conversion was not needed anymore, since the remote protocol and gdbserver were using the same kind of ids again. The gdb_id field in the thread_info structure was also unused starting there. - d50171e4 Teach linux gdbserver to step-over-breakpoints. This patch moved the thread_info structure around, and got rid of the gdb_id field (which was unused). Looking at the implementation of gdb_id_to_thread_id, it is not doing anything useful. It is looking up a thread by ptid using find_thread_ptid, which basically loops over all threads looking at their entry.id field. If a thread with that ptid is found, it returns its entry.id field. So it will always return the same thing as it input (with the exception of if no thread exist with that ptid, then it will return null_ptid). gdb/gdbserver/ChangeLog: * inferiors.h (gdb_id_to_thread_id): Remove. * inferiors.c (gdb_id_to_thread_id): Remove. * server.c (process_serial_event): Adjust to gdb_id_to_thread_id removal. Move pid declaration closer to where it's used. --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/inferiors.c | 8 -------- gdb/gdbserver/inferiors.h | 1 - gdb/gdbserver/server.c | 28 +++++++++------------------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 144e09a..eaf8e6e 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,12 @@ 2017-09-15 Simon Marchi + * inferiors.h (gdb_id_to_thread_id): Remove. + * inferiors.c (gdb_id_to_thread_id): Remove. + * server.c (process_serial_event): Adjust to gdb_id_to_thread_id + removal. Move pid declaration closer to where it's used. + +2017-09-15 Simon Marchi + * server.c (handle_detach): New function. (process_serial_event): Move code out, call handle_detach. diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 2212850..933dd76 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -173,14 +173,6 @@ find_any_thread_of_pid (int pid) return (struct thread_info *) entry; } -ptid_t -gdb_id_to_thread_id (ptid_t gdb_id) -{ - struct thread_info *thread = find_thread_ptid (gdb_id); - - return thread ? thread->entry.id : null_ptid; -} - static void free_one_thread (struct inferior_list_entry *inf) { diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h index f229e67..6316fe5 100644 --- a/gdb/gdbserver/inferiors.h +++ b/gdb/gdbserver/inferiors.h @@ -144,7 +144,6 @@ int have_started_inferiors_p (void); int have_attached_inferiors_p (void); ptid_t thread_to_gdb_id (struct thread_info *); -ptid_t gdb_id_to_thread_id (ptid_t); void clear_inferiors (void); struct inferior_list_entry *find_inferior diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 3de7f16..32c9bab 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -4139,23 +4139,16 @@ process_serial_event (void) case 'H': if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's') { - ptid_t gdb_id, thread_id; - int pid; - require_running_or_break (own_buf); - gdb_id = read_ptid (&own_buf[2], NULL); - - pid = ptid_get_pid (gdb_id); + ptid_t thread_id = read_ptid (&own_buf[2], NULL); - if (ptid_equal (gdb_id, null_ptid) - || ptid_equal (gdb_id, minus_one_ptid)) + if (thread_id == null_ptid || thread_id == minus_one_ptid) thread_id = null_ptid; - else if (pid != 0 - && ptid_equal (pid_to_ptid (pid), - gdb_id)) + else if (thread_id.is_pid ()) { - thread_info *thread = find_any_thread_of_pid (pid); + /* The ptid represents a pid. */ + thread_info *thread = find_any_thread_of_pid (thread_id.pid ()); if (thread == NULL) { @@ -4167,8 +4160,8 @@ process_serial_event (void) } else { - thread_id = gdb_id_to_thread_id (gdb_id); - if (ptid_equal (thread_id, null_ptid)) + /* The ptid represents a lwp/tid. */ + if (find_thread_ptid (thread_id) == NULL) { write_enn (own_buf); break; @@ -4373,13 +4366,10 @@ process_serial_event (void) case 'T': { - ptid_t gdb_id, thread_id; - require_running_or_break (own_buf); - gdb_id = read_ptid (&own_buf[1], NULL); - thread_id = gdb_id_to_thread_id (gdb_id); - if (ptid_equal (thread_id, null_ptid)) + ptid_t thread_id = read_ptid (&own_buf[1], NULL); + if (find_thread_ptid (thread_id) == NULL) { write_enn (own_buf); break;