From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by sourceware.org (Postfix) with ESMTPS id 9C0723854833 for ; Tue, 2 Mar 2021 17:40:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C0723854833 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kichwacoders.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jonah@kichwacoders.com Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 5B4B611D242 for ; Tue, 2 Mar 2021 12:40:16 -0500 (EST) (envelope-from jonah@kichwacoders.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=sasl; bh=YjdRjMPj9PDp0jjer2OG6Rk0SBI=; b=Br8QKR j+E9Mi0eN6Ry6NA9UiWcUZUygiRl9qeCI5rWFJ0J/Ktlv4XhzoHWiuV6WP5CTp7a jfqvqiy1lbZ59Mxm16qn2uV7ITZanpnMnJoSzpTW8od6qumzV9WeI/z4unfpeFug CVGZrW5zG/AO/dljzq8SFbHt3LfRZp03L9jS0= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 536B311D241 for ; Tue, 2 Mar 2021 12:40:16 -0500 (EST) (envelope-from jonah@kichwacoders.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kichwacoders.com; h=mime-version:references:in-reply-to:from:date:message-id:subject:to:cc:content-type; s=mesmtp; bh=GjBDGzGJCIw0YGAw1rJZ34eVnfCQerhZcUNEDPc6jM4=; b=PxwtiRpfnn5kj034AKYQQk+IwfhkKILo5IKpJF7qMgWF4gYmRLrND8m8KitmSNEYDseOFU5rcacVgO15ro+L+BB9fG1bSQ8yy9nZH3eiGLlhe5Q/txMO49N6YUErRv0Nonawm48HkbtdiN6hBIcfZHFttal1/fd5CG/uNqA2t6c= Received: from mail-il1-f176.google.com (unknown [209.85.166.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id D2ACC11D23F for ; Tue, 2 Mar 2021 12:40:12 -0500 (EST) (envelope-from jonah@kichwacoders.com) Received: by mail-il1-f176.google.com with SMTP id p10so6633935ils.9 for ; Tue, 02 Mar 2021 09:40:12 -0800 (PST) X-Gm-Message-State: AOAM5321XaUHVpPe/Vi+KkAXYwURzE8RVlQDqHeTsvA+BQS6tFj8tTaL 7RFNl9Py6ATc5uEBsOBjCR7gyy+KlhAlYOxKaMA= X-Google-Smtp-Source: ABdhPJyDSOqukVEmDqRS77DeZzn/7dR65XeMU2Y193OXDpzvItTa85YQByUcgLtJBBhrP0/FqOODAtooyAc55jMjGhU= X-Received: by 2002:a05:6e02:b29:: with SMTP id e9mr1529489ilu.119.1614706811652; Tue, 02 Mar 2021 09:40:11 -0800 (PST) MIME-Version: 1.0 References: <20210209100813.710754-1-jan.vrany@labware.com> <71093a268d80ba44ededb868b850dde4873987b3.camel@labware.com> In-Reply-To: From: Jonah Graham Date: Tue, 2 Mar 2021 12:39:35 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PING] Re: [PATCH] MI: PR20684, preserve user selected thread and frame when invoking MI commands To: Jan Vrany Cc: gdb-patches@sourceware.org X-Pobox-Relay-ID: 577C3F24-7B7E-11EB-9BE3-E43E2BB96649-18936988!pb-smtp20.pobox.com X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Tue, 02 Mar 2021 17:40:21 -0000 Hi Jan, I am not a GDB maintainer, so not sure how much I can help here (I was cc'ed in the original patch email). How does this change interact with -thread-select? Eclipse CDT expects -thread-select issued on the MI channel to affect the thread in the CLI channel. In fact this use was added in CDT when the new-ui was introduced, while the referenced bug 20684 is actually concerning "old ui" use case. Jonah On Tue, 2 Mar 2021 at 05:36, Jan Vrany via Gdb-patches < gdb-patches@sourceware.org> wrote: > Polite ping. > > On Tue, 2021-02-23 at 11:20 +0000, Jan Vrany wrote: > > Polite ping. > > > > On Tue, 2021-02-09 at 10:08 +0000, Jan Vrany 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). > > > > > > gdb/Changelog > > > > > > PR 20684 > > > * gdb/mi/mi-main.c (mi_cmd_execute): Preserve user selected > > > thread > > > and frame when invoking MI commands. > > > --- > > > gdb/ChangeLog | 6 ++++++ > > > gdb/mi/mi-main.c | 36 +++++++++++++++--------------------- > > > 2 files changed, 21 insertions(+), 21 deletions(-) > > > > > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > > > index e67668d315c..ea232ff1b3f 100644 > > > --- a/gdb/ChangeLog > > > +++ b/gdb/ChangeLog > > > @@ -1,3 +1,9 @@ > > > +2021-02-09 Jan Vrany > > > + > > > + PR 20684 > > > + * gdb/mi/mi-main.c (mi_cmd_execute): Preserve user selected > > > thread > > > + and frame when invoking MI commands. > > > + > > > 2021-02-08 Shahab Vahedi > > > > > > PR tdep/27369 > > > diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c > > > index 9a14d78e1e2..c5103800314 100644 > > > --- a/gdb/mi/mi-main.c > > > +++ b/gdb/mi/mi-main.c > > > @@ -1971,25 +1971,13 @@ mi_execute_command (const char *cmd, int > > > from_tty) > > > again. */ > > > && !command_notifies_uscc_observer (command.get ())) > > > { > > > - int report_change = 0; > > > - > > > - if (command->thread == -1) > > > - { > > > - report_change = (previous_ptid != null_ptid > > > - && inferior_ptid != previous_ptid > > > - && inferior_ptid != null_ptid); > > > - } > > > - else if (inferior_ptid != null_ptid) > > > - { > > > - struct thread_info *ti = inferior_thread (); > > > - > > > - report_change = (ti->global_num != command->thread); > > > - } > > > - > > > - if (report_change) > > > - { > > > - gdb::observers::user_selected_context_changed.notify > > > - (USER_SELECTED_THREAD | USER_SELECTED_FRAME); > > > + if (command->thread == -1 > > > + && previous_ptid != null_ptid > > > + && inferior_ptid != previous_ptid > > > + && inferior_ptid != null_ptid) > > > + { > > > + gdb::observers::user_selected_context_changed.notify > > > + (USER_SELECTED_THREAD | > > > USER_SELECTED_FRAME); > > > } > > > } > > > } > > > @@ -2035,6 +2023,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); > > > @@ -2045,9 +2034,11 @@ mi_cmd_execute (struct mi_parse *parse) > > > if (tp->state == THREAD_EXITED) > > > error (_("Thread id: %d has terminated"), parse->thread); > > > > > > + thread_saver.emplace (); > > > switch_to_thread (tp); > > > } > > > > > > + gdb::optional frame_saver; > > > if (parse->frame != -1) > > > { > > > struct frame_info *fid; > > > @@ -2055,8 +2046,11 @@ 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); > > > + { > > > + /* find_relative_frame was successful */ > > > + frame_saver.emplace (); > > > + select_frame (fid); > > > + } > > > else > > > error (_("Invalid frame id: %d"), frame); > > > } > > > > >