From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2079.outbound.protection.outlook.com [40.92.98.79]) by sourceware.org (Postfix) with ESMTPS id DAE073858402 for ; Thu, 24 Feb 2022 17:26:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DAE073858402 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H0FCu7kygQOD6BYnOYedN3dmAD+IawkSi9W4Nxa2K++rVvccAkcx1ltiOD0TmtyJqDsoKE+ky6/nIRiAHPwurLACqqK4s1qSQxRH/BH4l3ohlbiDumHVEbc35h18JctwoyE0BJMaK7B2X84m5utkEjQnF8qLZFXT5WViY7Bel57x1aalSYDifxYUzvWIK4BA+2cn9m1Tj6S/tz0PQh4TDEFIzUhecoTgQW5x9zqkEm6DwjiK2c/If0+OmTxGu9dUsvqz1h6Tthyw/R7P5YQRM83mrtrwlG59SQW+p7s5KIVoXGARjfpO1CR9BZwkiBQX6PPF87vb7BjaD8ZiyCtAlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9ZycbSJ9ozN9R2O8cOCCLqOsLqNq1KD27tAqzd3SLkw=; b=isdeS/y2xpm3dqPmWlCT2zcgCMzB6pZZf6v84vNPb/m2yFa24c5MnkngJkJwbfo+3xCZWKi+77cfg4uMr7PSzWDrQqg2wlbRQgH6QqUHunEgcR/zNUkyUow1ymwTsD2T0oyFWlISi3ZaD+5ztDapEFo4uWXUpztL9RGdGwXF8sVTOgase/vVuS+aQLHO4GlN43OQVs83T6Cyg7YcckkDjKOL4bt2x9mG2lU1oktJvhn0o7zm2J4pusJHd08fWZnCahHRJBOcn+RwM4Njo32/dOV6mtqn9iYhTMfHA6O0Gtp+D6KLdaX3K0+kL26sh9vn2GUEmxe7vwdEpPyxyOkE5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from OS3PR01MB6291.jpnprd01.prod.outlook.com (2603:1096:604:e2::9) by TYYPR01MB8198.jpnprd01.prod.outlook.com (2603:1096:400:fe::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.23; Thu, 24 Feb 2022 17:26:07 +0000 Received: from OS3PR01MB6291.jpnprd01.prod.outlook.com ([fe80::adf3:eada:74f8:f8a1]) by OS3PR01MB6291.jpnprd01.prod.outlook.com ([fe80::adf3:eada:74f8:f8a1%8]) with mapi id 15.20.5017.025; Thu, 24 Feb 2022 17:26:07 +0000 Message-ID: Date: Thu, 24 Feb 2022 22:25:51 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Content-Language: en-US From: Muhammad Umair Sair To: "gdb-patches@sourceware.org" Subject: [PATCH] Fixing regression in mi -add-inferior command Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TMN: [AfdYMsPPpiK7Bep1uiz0MQgwMstG9SWZ] X-ClientProxiedBy: DB6PR0802CA0046.eurprd08.prod.outlook.com (2603:10a6:4:a3::32) To OS3PR01MB6291.jpnprd01.prod.outlook.com (2603:1096:604:e2::9) X-Microsoft-Original-Message-ID: <75b6ba73-d3df-b97c-7c86-792dfd8623a2@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be2d2516-1d85-4d54-e894-08d9f7babc6a X-MS-TrafficTypeDiagnostic: TYYPR01MB8198:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lrgnjZJ5OI2ZW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8?B?UWlINDRIVDNNVjFRd2l2eTd0UWs3dTBpYWM2bERpT2k0Tkx6QnBPaXBqSFhH?= =?utf-8?B?WTJqNjJ2RnpVN0FBUkEyRnhlZTJWbk00VzdkVUsrNXNmZDRxQT09?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-9cf38.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: be2d2516-1d85-4d54-e894-08d9f7babc6a X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB6291.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2022 17:26:07.2045 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYYPR01MB8198 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_MUA_MOZILLA, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 17:26:14 -0000 From 6b0edd1364f5ea63416838c3d08631adeed55474 Mon Sep 17 00:00:00 2001 From: Umair Sair Date: Tue, 22 Feb 2022 01:40:06 +0500 Subject: [PATCH] Fixing regression in mi -add-inferior command This commit fixes the regression (backward compatibility issue) in -add-inferior mi command after the addition of multi-target debugging support. Previously adding a new inferior via mi or cli uses same connection as other inferiors are using. Now after the addition of multi-target support, add-inferior command without arguments in cli adds a new inferior and sets the connection of previously selected inferior as the connection of new inferior as well which keeps the backward compatibility intact. But the same command for machine interpreter is not setting the connection for new inferior and causing backward compatibility issue. This commit fixes the backward compatibility issue and makes the console and machine interpreter behavior consistent for add-inferior command with no arguments. --- gdb/inferior.c | 2 +- gdb/inferior.h | 3 ++ gdb/mi/mi-main.c | 2 + gdb/testsuite/gdb.mi/mi-add-inferior.exp | 49 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.mi/mi-add-inferior.exp diff --git a/gdb/inferior.c b/gdb/inferior.c index bebddb44173..82fd39c142d 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -761,7 +761,7 @@ add_inferior_with_spaces (void) NO_CONNECTION is true, push the process_stratum_target of ORG_INF to NEW_INF. */ -static void +void switch_to_inferior_and_push_target (inferior *new_inf, bool no_connection, inferior *org_inf) { diff --git a/gdb/inferior.h b/gdb/inferior.h index 45de3c2d9c8..00978bec404 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -740,4 +740,7 @@ extern struct inferior *add_inferior_with_spaces (void); /* Print the current selected inferior. */ extern void print_selected_inferior (struct ui_out *uiout); +extern void switch_to_inferior_and_push_target (inferior *new_inf, + bool no_connection, inferior *org_inf); + #endif /* !defined (INFERIOR_H) */ diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 4860da7536a..3a477bf3d05 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1710,6 +1710,8 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) inf = add_inferior_with_spaces (); + switch_to_inferior_and_push_target (inf, false, current_inferior ()); + current_uiout->field_fmt ("inferior", "i%d", inf->num); } diff --git a/gdb/testsuite/gdb.mi/mi-add-inferior.exp b/gdb/testsuite/gdb.mi/mi-add-inferior.exp new file mode 100644 index 00000000000..6f10e9cc2d6 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-add-inferior.exp @@ -0,0 +1,49 @@ +# Copyright 2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test MI -add-inferior + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +standard_testfile basics.c + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "failed to compile" + return -1 +} + +mi_gdb_load ${binfile} + +# Start execution to establish a connection +mi_runto_main + +# Adding new inferior should use the connection of previous inferior +# Match following +# -add-inferior +# =thread-group-added,id="i2" +# ~"[New inferior 2]\n" +# ~"Added inferior 2 on connection 1.*" +# ^done,inferior="i2" +mi_gdb_test "-add-inferior" "=thread-group-added,id=\"i2\"\r\n~\"\\\[New inferior 2\\\]\\\\n\"\r\n\~\"Added inferior 2 on connection .*\"\r\n\\^done,inferior=\"i2\"" \ + "mi add inferior" + +mi_gdb_exit +return 0 -- 2.31.1