From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CB9C33858C2C for ; Wed, 25 Jan 2023 11:33:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB9C33858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674646396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2EwkMrs14B5YI9yM+cqrWYbgxAq0gL/xNfAHi6rjLu0=; b=DZ7LQGlqC7UIPli8e+MDQASG0f9qjCESUAxWW+Bc/xLutemyu4vrbJk8syyYPxhFqAbT2A pO8zdMVQFRYqMEhyGC7Su9nhFLT6hJMIcd+F1Lkd3cxISq4CBTA1tL3NkZH9oxWJF/nv98 eudYKjmikNfHque4Cga/BTKwQKhT1T0= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-209-hFZN_r72PCWOaN8QGX5Fgg-1; Wed, 25 Jan 2023 06:33:15 -0500 X-MC-Unique: hFZN_r72PCWOaN8QGX5Fgg-1 Received: by mail-qk1-f199.google.com with SMTP id x12-20020a05620a258c00b007051ae500a2so12717270qko.15 for ; Wed, 25 Jan 2023 03:33:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2EwkMrs14B5YI9yM+cqrWYbgxAq0gL/xNfAHi6rjLu0=; b=7aG5TDon9ytEHF4Hatb30FiQkMharse0F8SMHqoXmouxQTVt4h5iKoO1dveIsgGKqs AoWTGDjFANOPYXaJLxbZVBse76Rdyd13Qfci7fkp2qoWCws6tmu8CNgr0c9I0/txWWUI m8BPfglAwvfBSApWNFIMMDqACtuMMrsDE8VY3gvxbMbRsQD0mV3lPvROtPfyF6j7bRzG /d6SuMvcogR6gSlQjNhuvKFWxU/uo+BnlDreqSjhFOrvjzvd39XUgdgbJkSnkLjPGzlM nYthmp0V95A3mCge/qUuAXE7+YT8KFJSdlTzp4apdbge8Gmolf1xsXofWqwHxBpJdJQq tbCw== X-Gm-Message-State: AFqh2kpDINxXUiwhLB2RT4A9kxyLrbGpieDzGUFFrtkUx0I4E6+AHRJ4 WHQLGG0v0Yn4XiMJrrkZOt0u6eI/wV3d3NcA6P/4VhmcMxcRf16ybQlbDRDhT5SuaDMw8kP0prH xYPW1ZmTfZHfo04hUC5HD9DjxpdsAgZ02J9DGAbJWUAyufCy7PvVxQ6ZVy1z/V0D0kc04NPJGeA == X-Received: by 2002:a05:6214:d05:b0:535:276:9244 with SMTP id 5-20020a0562140d0500b0053502769244mr60119328qvh.29.1674646394578; Wed, 25 Jan 2023 03:33:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXsIHMS6B/7WgBRvyGshNNwIqMULrETv8jJFqKfQdkSHeImUNPXBvz5cPn8pm/H6nElIIR/ZmQ== X-Received: by 2002:a05:6214:d05:b0:535:276:9244 with SMTP id 5-20020a0562140d0500b0053502769244mr60119295qvh.29.1674646394274; Wed, 25 Jan 2023 03:33:14 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id 71-20020a370c4a000000b006fc5a1d9cd4sm3304128qkm.34.2023.01.25.03.33.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 03:33:13 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH 05/15] gdb/tui: convert if/error to an assert In-Reply-To: <41ae74a51377abd813ad2bdb29cedfbfbdc54e3c.1673000632.git.aburgess@redhat.com> References: <41ae74a51377abd813ad2bdb29cedfbfbdc54e3c.1673000632.git.aburgess@redhat.com> Date: Wed, 25 Jan 2023 11:33:12 +0000 Message-ID: <87edrix30n.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Andrew Burgess writes: > While working on the previous commit, I realised that there was an > error in tui_set_focus_command that could never be triggered. > > Since the big tui rewrite (adding dynamic layouts) it is no longer > true that there is a tui_win_info object for every window at all > times. We now only create a tui_win_info object for a particular > window, when the window is part of the current layout. As a result, > if we have a tui_win_info pointer, then the window must be visible > inside tui_set_focus_command (this function calls tui_enable as its > first action, which makes the current layout visible). > > The gdb.tui/tui-focus.exp test script exercises this area of code, and > doesn't trigger the assert, nor do any of our other existing tui > tests. I've gone ahead and pushed this patch. The final version is included below. Thanks, Andrew --- commit 6789344ab22f7fbce94a31297b994f85685b90c6 Author: Andrew Burgess Date: Thu Dec 22 12:43:38 2022 +0000 gdb/tui: convert if/error to an assert While working on the previous commit, I realised that there was an error in tui_set_focus_command that could never be triggered. Since the big tui rewrite (adding dynamic layouts) it is no longer true that there is a tui_win_info object for every window at all times. We now only create a tui_win_info object for a particular window, when the window is part of the current layout. As a result, if we have a tui_win_info pointer, then the window must be visible inside tui_set_focus_command (this function calls tui_enable as its first action, which makes the current layout visible). The gdb.tui/tui-focus.exp test script exercises this area of code, and doesn't trigger the assert, nor do any of our other existing tui tests. diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 9c088899817..4fc8e7a4503 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -720,8 +720,11 @@ tui_set_focus_command (const char *arg, int from_tty) if (win_info == NULL) error (_("Unrecognized window name \"%s\""), arg); - if (!win_info->is_visible ()) - error (_("Window \"%s\" is not visible"), arg); + + /* If a window is part of the current layout then it will have a + tui_win_info associated with it and be visible, otherwise, there will + be no tui_win_info and the above error will have been raised. */ + gdb_assert (win_info->is_visible ()); if (!win_info->can_focus ()) error (_("Window \"%s\" cannot be focused"), arg);