From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 38EE73857835; Wed, 25 Jan 2023 11:27:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38EE73857835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674646047; bh=umsGNgJGY14GExsQTkX1HNHhVfiACX18TGBP14hhDbs=; h=From:To:Subject:Date:From; b=OZKUP9PnVY5+/CtrUCo4tlz7QkV+ohaBiOBmVv9dyltfDO+4YnDUQZjY24rS2SEFF ebhZARfEdmJ50uonnojzuu7iEQ/ViFY0x2Qcd5YUkw6HJsEWzlNe3ulwvNeDG3rExd Vhp3lBqwuSuk6Zi6EuSeXmukvzdq+yfHMQcdYujI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/tui: convert if/error to an assert X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 24f3aded1d42f515527e2de7e8e9e26f0b77c932 X-Git-Newrev: 6789344ab22f7fbce94a31297b994f85685b90c6 Message-Id: <20230125112727.38EE73857835@sourceware.org> Date: Wed, 25 Jan 2023 11:27:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6789344ab22f= 7fbce94a31297b994f85685b90c6 commit 6789344ab22f7fbce94a31297b994f85685b90c6 Author: Andrew Burgess Date: Thu Dec 22 12:43:38 2022 +0000 gdb/tui: convert if/error to an assert =20 While working on the previous commit, I realised that there was an error in tui_set_focus_command that could never be triggered. =20 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). =20 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: --- gdb/tui/tui-win.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) =20 if (win_info =3D=3D 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 ()); =20 if (!win_info->can_focus ()) error (_("Window \"%s\" cannot be focused"), arg);