From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20624.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::624]) by sourceware.org (Postfix) with ESMTPS id 99ACE386483B for ; Wed, 26 Jan 2022 17:08:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99ACE386483B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhUoLnH396Zisoz5B7AcUNz6sBJbOh73voPP+l6HPjvrI2XWVioV7ZePHhMt6OIVAQqXYvxd5im14UQLCZgGQAWujYKiUqVt62QW5miaeebETKMs4zJ3nNMVm9OXkyBuAzn/mOInaCh0r+f5mmSt3ehhfNV7eIJ2qN3h/Jt3r4H32WWRruyFu8ridtN+oc08DKOJzVQIc+2O4XA15jFTEpAtFC/Yy7NQyQqg8QaXqwY7rxXtbQdO6BN75WZOCMs0k6s2kgtJ0FMmnBKMzavIMd2dkc+StlXVe+kgZoCkwo/bUe48OZbrdxSoAGP7pIN4UFsynY3TD2GktOfrm8zNmA== 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=Df7fBgMlX4QO/114NrHurZ7+sxrq9SLL4eGlohrWyLo=; b=kwXOThHLr4e2ThdyiYNFwiHvEqyTPeITdoYfOgXO8SdIhLYbMJCDn+dm8J5OtuI+xUIWwcoP0NvwdvsxK2M9q5BnSx6YywnIO6SP0C/bIo1JkEtgzRm2cEQ1Sr5xobTUbLun0ibPsmhbngPjPZBihbZy0OYnRdMWfpcKOwKqSuTsz7js016jiNoy4ipiTYK4LilslPTqHHTOcAfycSnxUjWH2CBCsZ1OyOLV9e6+7gZg7bMlnXLUk0pf91cc713f664tfpKx39z3Xot8fXmXT2341yti2SW+VdnOvC3bNPUG/v0vjiWvTd1u67k2qtkHrnpiXhTEoRC9aTqc+VkRGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DM6PR17MB3113.namprd17.prod.outlook.com (2603:10b6:5:6::10) by CY4PR1701MB1702.namprd17.prod.outlook.com (2603:10b6:910:65::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Wed, 26 Jan 2022 17:08:43 +0000 Received: from DM6PR17MB3113.namprd17.prod.outlook.com ([fe80::f544:fbc7:cdfb:3017]) by DM6PR17MB3113.namprd17.prod.outlook.com ([fe80::f544:fbc7:cdfb:3017%6]) with mapi id 15.20.4930.017; Wed, 26 Jan 2022 17:08:43 +0000 Message-ID: <083e4514af3e0707035fa8517e107adc58da051e.camel@labware.com> Subject: Re: [PATCH v2 1/1] gdb/mi: PR20684, preserve user selected thread and frame when invoking MI commands From: Jan Vrany To: Simon Marchi , gdb-patches@sourceware.org Date: Wed, 26 Jan 2022 17:08:38 +0000 In-Reply-To: <74e5b388-9f7a-dd0a-befe-3b069fba54b7@polymtl.ca> References: <20220126132112.3626367-2-jan.vrany@labware.com> <74e5b388-9f7a-dd0a-befe-3b069fba54b7@polymtl.ca> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0029.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::17) To DM6PR17MB3113.namprd17.prod.outlook.com (2603:10b6:5:6::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cda4d3b6-5e39-4f5b-f6b3-08d9e0ee815c X-MS-TrafficTypeDiagnostic: CY4PR1701MB1702:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7CbAvdamqJHO+4JLqgoEBOMrenhpvNl2O0PPUHNwmLxcn0K59LClgZDSTaxO+M7t1yz4s9nenIU+mRuXanlewNx/a9QraHkqLzBLJcMafYiMFNZcATSASX1oeLXyNJlzS7crFPf5en7GO1Yy3+oM7aF/52N0+hf0fp/otYgN6tj8pLNRfwMYziu4wuwDDeIY+1rO7REKDei93ZO22LHqueaGQ1CnWFh//Gj0TZ5qkBiFrJWXZSBXrZmkhfAVyKvUdQaKBVbav2S06FKjc0FO4UB7dacgSNdrKQIj7dfLmlDPKUTr+79YU+dp9ej7XakcKmZL9073k0/tOGdzFICBghIdljQxrADsnhlyZ0p3MUCM54d0zI0zeRIspEdJbuZczM9Vh3uA3FR0UqcuEsmk96plHlTlAj4JXV+WmGk+hGiSjWrK1TylYfuPAV9+Zdic0e2OwxNqFl9xW6bayHF8qGaz6wb7Z+Os5r5zdkHlOGQ3yac22WYy1ftn5WN32lDjYSf+aShfrNK1xLjcQ66MyIF5NQecLGvKRjj3DxSPO0n8MweODxkccfkfn6okkSdPJb3GlLZqeU7ZmpQCa0ofFmMkeRHa37ee5G/YjnCTUBOnMukeiicRdRCUhnnmF/sbU4fBmeQZ0ZWg9lebjkPc0BJvkcixksrsz6ze+/IXpQkEhoA8jRLwHq2mUkSBHE/E6P9cRCiT0WrrBfF0j1bQFUWDUsik3xkqohLfyBp+uGRFc+ynXn6uBptGeO4GM2qoqJT4RVTbM0T4YhUTVR+oaTJcyOLxBqebQbXuPwqy7c4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR17MB3113.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(316002)(66476007)(44832011)(8676002)(8936002)(30864003)(52116002)(53546011)(5660300002)(6512007)(6506007)(83380400001)(66556008)(66946007)(86362001)(186003)(26005)(6666004)(2906002)(36756003)(6486002)(966005)(508600001)(38350700002)(38100700002)(2616005)(2004002)(20210929001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cjRoNldscU8rWnRZTitKNFg3bnFiUTZBMWU0U3pYc01jaUhpeFFyaDl0bjl0?= =?utf-8?B?K1BsdUlMc20xRXRzUVFkQ0pvb2FPQkViTjVxTnBVRGhzM2doVzFTYTkwWTZl?= =?utf-8?B?TnNsVWJZNTZ3cTFpbmF3enhFRCtmMWtFYndHMm4xQnJDTm1uTUNuU2FNbnUr?= =?utf-8?B?bFZqVWpOQnZUaTBrMmp1dVFKTFJiQ3hHVlRUcTBHN2hlNTZ3ekRiMXpaMGd0?= =?utf-8?B?a1dJWXdxWmF5S0gybmVoaEhwWWFTeWhadFFwaFlGSmpFeXZFb25tY0VWc2lB?= =?utf-8?B?eE5jeWY0d2N5ekg2aGxubTdYeE5GbHhLMEJ4WWR5Tk5jektmK2hXZmxITk4v?= =?utf-8?B?VHgvMm5pY2pxWXFRbE9TdlNKNXR4d0RKZkUvcFdTY0ZWV3crWldaZ1hXWUdw?= =?utf-8?B?Wm9rMERpZHIrRURJTmh6eU9MaGt1YkZQLy9tbURndFJUdmxWWUw3Y29YZjlW?= =?utf-8?B?bUJuL20vNmFLYURQNjM3N0dMNklKWFNDelJDOEJRMXNIcTZwSGg4VWFjdGIx?= =?utf-8?B?NkwyV0VJTmordTRDUEVMZzk1eVd4YVZsaGpjRzZJSnh6ZW9EWmM2NG5ib1lP?= =?utf-8?B?d0ZwY2FzQncwOWJKMERZeS9DWmtCQ1E3azNlWm02TGtEekJneDFKSW13K1Ux?= =?utf-8?B?dVJERlIwblpBMnVOUDFUL1FValJkS09FNGZxZVVsK2xCQTVMZzdUMHdNc3JF?= =?utf-8?B?aHNDRUh4QndPNTJ1cjVyZ0lIeFM4KzhBeUkxQzhuelpDdjNlVHVRbDh1ZFA3?= =?utf-8?B?VU04bVQyaTRvTHdFc2xTWktSQ2dIWUM1WTRGMHJWZW1idkhQcHZaQnBHdG9j?= =?utf-8?B?eDlkeHJ2YlVyeXFkUERnYXFDODFsSDI4bmQvdlVpd3lHNDlHRnlpa3VlZEhI?= =?utf-8?B?bXZFeGVBTnVVQlpRdVZMdWlXR09xQ3haSGMzaHNSN2Fpbno3K09RMDVHcldj?= =?utf-8?B?MzMxNFUxWUZiSUo5cHV6WGMrT3dyK0ZRajNiMFlqWXBRQ3lZNUs5Smk0UEJN?= =?utf-8?B?K2RRN3hJU2JITU9pNEo4STNQUHN2ZXNaVXVHSHpYS3ZUU0JGc05mbDlzbWJL?= =?utf-8?B?eTd0dndEV1JKV05LRHQwRW9USlM1NXZhY0p2LytjQ21UMENPSTdxNmZlTElN?= =?utf-8?B?ajkycTlqTDBUTmFGaDduNWovMXUvRTNvWTVpRzlwbUY0eUZpZ2xpUSsrdkZ6?= =?utf-8?B?bnhGUUg1Si9XQ2tHZ2tVK3JIWWlRZ0p3bGxDM05sR0NZOUkyQTJzczdTTXlu?= =?utf-8?B?T1lQbWtQSFMybmRnTHI1cXoyZ004OEJ1d0RsOEc0dFhkUWdSU2ttWXFZdy92?= =?utf-8?B?OUhWK1BlSTJnNkNDTU55T0R4MElIM0t2TlpidG16Q3UwQmVSdnhwU1lkd3hS?= =?utf-8?B?a3ZoVHExMDBnS3EvdlJHYVVsVVJydldkejRON2pLaTJpTSs5aFZFV29reG9J?= =?utf-8?B?L0J0TlRYOFR4dkdNWTZsUkdyYmJKSUFyem5vSGVYVU5OM1k0bWxaaDdsaVQ4?= =?utf-8?B?b0gvZ3YwQTZwVUU3eE4wYzE3Z3B1aVdHQUVwdXBpQ0VWS1BrTC9Xajd1TllD?= =?utf-8?B?Mk9XVlhWbTdjakp4RHFrVHhNY1g1VXN6OFdHOHJjVkVHM0MzTDc4YUdZNnN0?= =?utf-8?B?U3poU1pSRndKd3lqTFpFODdscEx4enJqUlVCeTltd3hQVytFaElZeDJyMm9M?= =?utf-8?B?bFdmak9UcjAwa0ovUkg1YUVXdnE0T1FYWlVBL0d4SExqNFVNaEhYcjBXRU1L?= =?utf-8?B?YVRsdkpBSWRuZlQyNDNDYWw1cjU1M2ZRcWhIdUlBTDFQY0ZNeHpIQnlGMkRD?= =?utf-8?B?MzcydllOZE1jQ1puSjlBMjY5SUpUQUYrbkg0ZWtscW5ySU5BYUJ3cm55cGUw?= =?utf-8?B?RlRlcU1KYTB2S1FTMGhpbHI4R0RMckZHNTBacjJiQWNNVElCOVVvb1dCQzdj?= =?utf-8?B?bytFYkNwYWFXYnVvNnJMUEZ1cVFVWk4xUHR1VXBRRk00N1EzcjdTOGdDSloy?= =?utf-8?B?S2FSVkFaSG1VajBycXJXalU4eXR4MmxNWk5URnp0Mm4vZTA4TU8xanNOVmM2?= =?utf-8?B?dzhnanduVUlmRk1LbDhINVdCOEFCT0RxKzAvUEhNZWlnVzYyL3d5RTNsVTlt?= =?utf-8?B?QkJtWFp0cXI1SitKZEpkbDRWRlJvRzRZZXc4VFlxZUJvL3JqM0ZXWVdKSUlr?= =?utf-8?Q?KlQsua6TwHmGQ+bw7ImII4o=3D?= X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: cda4d3b6-5e39-4f5b-f6b3-08d9e0ee815c X-MS-Exchange-CrossTenant-AuthSource: DM6PR17MB3113.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 17:08:42.9952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gbSPMAbLfobxnHhqOiuS7m85OeY96D8VqtAmoRXsrgS0iSuq9NR4ttYiLflLI7/SXazJyJ7sipCTGCvUUwvxhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1701MB1702 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP 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: Wed, 26 Jan 2022 17:08:49 -0000 Hi, On Wed, 2022-01-26 at 10:01 -0500, Simon Marchi wrote: > Thanks, this is OK. Unfortunately, it is not. I have found a regression when doing final pre-push testing. I think I have a tentative fix, but needs more testing. I'll post v3 of this patch tomorrow. Sorry about that! Jan > > Simon > > On 2022-01-26 08:21, Jan Vrany via Gdb-patches wrote: > > When invoking MI commands with --thread and/or --frame, user selected > > thread and frame was not preserved: > > > >   (gdb) > >   info thread > >   &"info thread\n" > >   ~" Id Target Id Frame \n" > >   ~"* 1 Thread 0x7ffff7c30740 (LWP 19302) \"user-selected-c\" main () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60\n" > >   ~" 2 Thread 0x7ffff7c2f700 (LWP 19306) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" > >   ~" 3 Thread 0x7ffff742e700 (LWP 19307) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" > >   ^done > >   (gdb) > >   info frame > >   &"info frame\n" > >   ~"Stack level 0, frame at 0x7fffffffdf90:\n" > >   ~" rip = 0x555555555207 in main (/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60); saved rip = 0x7ffff7c5709b\n" > >   ~" source language c.\n" > >   ~" Arglist at 0x7fffffffdf80, args: \n" > >   ~" Locals at 0x7fffffffdf80, Previous frame's sp is 0x7fffffffdf90\n" > >   ~" Saved registers:\n " > >   ~" rbp at 0x7fffffffdf80, rip at 0x7fffffffdf88\n" > >   ^done > >   (gdb) > >   -stack-info-depth --thread 3 > >   ^done,depth="4" > >   (gdb) > >   info thread > >   &"info thread\n" > >   ~" Id Target Id Frame \n" > >   ~" 1 Thread 0x7ffff7c30740 (LWP 19302) \"user-selected-c\" main () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:60\n" > >   ~" 2 Thread 0x7ffff7c2f700 (LWP 19306) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" > >   ~"* 3 Thread 0x7ffff742e700 (LWP 19307) \"user-selected-c\" child_sub_function () at /home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30\n" > >   ^done > >   (gdb) > >   info frame > >   &"info frame\n" > >   ~"Stack level 0, frame at 0x7ffff742dee0:\n" > >   ~" rip = 0x555555555169 in child_sub_function (/home/uuu/gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:30); saved rip = 0x555555555188\n" > >   ~" called by frame at 0x7ffff742df00\n" > >   ~" source language c.\n" > >   ~" Arglist at 0x7ffff742ded0, args: \n" > >   ~" Locals at 0x7ffff742ded0, Previous frame's sp is 0x7ffff742dee0\n" > >   ~" Saved registers:\n " > >   ~" rbp at 0x7ffff742ded0, rip at 0x7ffff742ded8\n" > >   ^done > >   (gdb) > > > > This was problematic for frontends that provide access to CLI because UI > > may silently change the context for CLI commands (as demonstrated above). > > > > Bug: https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_bugzilla_show-5Fbug.cgi-3Fid-3D20684&d=DwICaQ&c=sPZ6DeHLiehUHQWKIrsNwWp3t7snrE-az24ztT0w7Jc&r=WpFFGgYa98Yp-c29WHTCwU1wAGFBvszA6a4RzgpMSqc&m=YXXmP3UHATiIQ8jPJrNxkE33ypHZ5NAYKMAvSdtuERM&s=wWlBE5Q8xGagnhvV57p8mRde5PHtg__CrplJVjeVGIU&e= > > --- > >  gdb/mi/mi-cmds.h | 12 ++ > >  gdb/mi/mi-main.c | 13 +- > >  gdb/testsuite/gdb.mi/mi-cmd-user-context.exp | 155 +++++++++++++++++++ > >  3 files changed, 178 insertions(+), 2 deletions(-) > >  create mode 100644 gdb/testsuite/gdb.mi/mi-cmd-user-context.exp > > > > diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h > > index 2a93a9f5476..785652ee1c9 100644 > > --- a/gdb/mi/mi-cmds.h > > +++ b/gdb/mi/mi-cmds.h > > @@ -23,6 +23,7 @@ > >  #define MI_MI_CMDS_H > >   > > > > > > > >  #include "gdbsupport/gdb_optional.h" > > +#include "mi/mi-main.h" > >   > > > > > > > >  enum print_values { > >     PRINT_NO_VALUES, > > @@ -163,6 +164,17 @@ struct mi_command > >       wrong. */ > >    void invoke (struct mi_parse *parse) const; > >   > > > > > > > > + /* Return whether this command preserves user selected context (thread > > + and frame). */ > > + bool preserve_user_selected_context () const > > + { > > + /* Here we exploit the fact that if MI command is supposed to change > > + user context, then it should not emit change notifications. Therefore if > > + command does not suppress user context change notifications, then it should > > + preserve the context. */ > > + return m_suppress_notification != &mi_suppress_notification.user_selected_context; > > + } > > + > >  protected: > >   > > > > > > > >    /* The core of command invocation, this needs to be overridden in each > > diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c > > index 4860da7536a..b25e87a1476 100644 > > --- a/gdb/mi/mi-main.c > > +++ b/gdb/mi/mi-main.c > > @@ -2037,6 +2037,7 @@ mi_cmd_execute (struct mi_parse *parse) > >        set_current_program_space (inf->pspace); > >      } > >   > > > > > > > > + gdb::optional thread_saver; > >    if (parse->thread != -1) > >      { > >        thread_info *tp = find_thread_global_id (parse->thread); > > @@ -2047,9 +2048,13 @@ mi_cmd_execute (struct mi_parse *parse) > >        if (tp->state == THREAD_EXITED) > >   error (_("Thread id: %d has terminated"), parse->thread); > >   > > > > > > > > + if (parse->cmd->preserve_user_selected_context ()) > > + thread_saver.emplace (); > > + > >        switch_to_thread (tp); > >      } > >   > > > > > > > > + gdb::optional frame_saver; > >    if (parse->frame != -1) > >      { > >        struct frame_info *fid; > > @@ -2057,8 +2062,12 @@ mi_cmd_execute (struct mi_parse *parse) > >   > > > > > > > >        fid = find_relative_frame (get_current_frame (), &frame); > >        if (frame == 0) > > - /* find_relative_frame was successful */ > > - select_frame (fid); > > + { > > + if (parse->cmd->preserve_user_selected_context ()) > > + frame_saver.emplace (); > > + > > + select_frame (fid); > > + } > >        else > >   error (_("Invalid frame id: %d"), frame); > >      } > > diff --git a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp > > new file mode 100644 > > index 00000000000..a373dd3a4b0 > > --- /dev/null > > +++ b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp > > @@ -0,0 +1,155 @@ > > +# 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 that GDB/MI commands preserve user selected context when > > +# passed --thread and/or --frame. > > + > > +load_lib mi-support.exp > > + > > +standard_testfile user-selected-context-sync.c > > + > > +if {[build_executable $testfile.exp $testfile ${srcfile} "debug pthreads"] == -1} { > > + untested "failed to compile" > > + return -1 > > +} > > + > > +set main_break_line [gdb_get_line_number "main break line"] > > + > > +set any "\[^\r\n\]*" > > +set nl "\[\r\n\]" > > + > > +mi_clean_restart $binfile > > +mi_create_breakpoint "$srcfile:$main_break_line" "set breakpoint in main" > > +mi_run_cmd > > +mi_expect_stop "breakpoint-hit" "main" "" $srcfile $main_break_line \ > > + { "" "disp=\"keep\"" } "run to breakpoint in main" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 1.*" \ > > + "info thread 1" > > + > > +#========================= > > + > > +mi_gdb_test "-stack-info-depth --thread 3" \ > > + "\\^done,depth=.*" \ > > + "-stack-info-depth --thread 3" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 1.*" \ > > + "info thread 2" > > + > > +#========================= > > + > > +mi_gdb_test "-thread-select 3" \ > > + "\\^done,.*" \ > > + "-thread-select 3" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 3.*" \ > > + "info thread 3" > > + > > +#========================= > > + > > +mi_gdb_test "-thread-select --thread 2 1" \ > > + "\\^done,.*" \ > > + "-thread-select --thread 2 1" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 1.*" \ > > + "info thread 4" > > + > > +#========================= > > + > > +mi_gdb_test "-thread-select --thread 2 2" \ > > + "\\^done,.*" \ > > + "-thread-select --thread 2 2" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 2.*" \ > > + "info thread 5" > > + > > +#========================= > > + > > +mi_gdb_test "frame" \ > > + ".*#0 0x.*" \ > > + "frame 1" > > + > > +mi_gdb_test "-stack-info-frame --thread 2 --frame 1" \ > > + "\\^done,frame=\{level=\"1\".*" \ > > + "-stack-info-frame 1" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 2.*" \ > > + "info thread 6" > > + > > +mi_gdb_test "frame" \ > > + ".*#0 0x.*" \ > > + "frame 2" > > + > > +#========================= > > + > > +mi_gdb_test "-stack-info-frame --thread 3 --frame 1" \ > > + "\\^done,frame=\{level=\"1\".*" \ > > + "-stack-info-frame 2" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 2.*" \ > > + "info thread 7" > > + > > +mi_gdb_test "frame" \ > > + ".*#0 0x.*" \ > > + "frame 3" > > + > > +#========================= > > + > > +mi_gdb_test "-stack-select-frame --thread 2 --frame 0 1" \ > > + "\\^done" \ > > + "--stack-select-frame 1" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 2.*" \ > > + "info thread 8" > > + > > +mi_gdb_test "frame" \ > > + ".*#1 0x.*" \ > > + "frame 4" > > + > > +#========================= > > + > > +mi_gdb_test "-stack-select-frame --thread 2 --frame 2 2" \ > > + "\\^done" \ > > + "--stack-select-frame 2" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 2.*" \ > > + "info thread 9" > > + > > +mi_gdb_test "frame" \ > > + ".*#2 0x.*" \ > > + "frame 5" > > + > > +#========================= > > + > > +mi_gdb_test "-stack-select-frame --thread 1 --frame 0 0" \ > > + "\\^done" \ > > + "--stack-select-frame 3" > > + > > +mi_gdb_test "thread" \ > > + ".*Current thread is 1.*" \ > > + "info thread 10" > > + > > +mi_gdb_test "frame" \ > > + ".*#0 main.*" \ > > + "frame 6"