GNU Binutils with patches for OS216
修訂 | 9f6ad286efc0edf7d0cdb8a4126a23d38a267f8d (tree) |
---|---|
時間 | 2019-11-20 05:27:25 |
作者 | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
Fix the "winheight" command
The "winheight" command is broken. I probably broke it in one of my
TUI refactoring patches, though I didn't track down exactly which one.
The bug is that the code does:
*buf_ptr = '\0';
... but then never advances buf_ptr past this point, so no window name
is seen.
This patch refactors the code a bit so that a copy of the argument
string is not needed, also fixing the bug.
A new test case is included.
gdb/ChangeLog
2019-11-19 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c.
Now static. Change type of "name".
(tui_set_win_height_command): Don't copy "arg".
* tui/tui-data.h (tui_partial_win_by_name): Don't declare.
* tui/tui-data.c (tui_partial_win_by_name): Move to tui-win.c.
gdb/testsuite/ChangeLog
2019-11-19 Tom Tromey <tom@tromey.com>
* gdb.tui/winheight.exp: New file.
Change-Id: I0871e93777a70036dbec9c9543f862f42e3a81e5
@@ -1,3 +1,11 @@ | ||
1 | +2019-11-19 Tom Tromey <tom@tromey.com> | |
2 | + | |
3 | + * tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c. | |
4 | + Now static. Change type of "name". | |
5 | + (tui_set_win_height_command): Don't copy "arg". | |
6 | + * tui/tui-data.h (tui_partial_win_by_name): Don't declare. | |
7 | + * tui/tui-data.c (tui_partial_win_by_name): Move to tui-win.c. | |
8 | + | |
1 | 9 | 2019-11-19 Ali Tamur <tamur@google.com> |
2 | 10 | |
3 | 11 | * dwarf2read.c (dw2_get_file_names_reader): Replace "if (attr)" with |
@@ -1,3 +1,7 @@ | ||
1 | +2019-11-19 Tom Tromey <tom@tromey.com> | |
2 | + | |
3 | + * gdb.tui/winheight.exp: New file. | |
4 | + | |
1 | 5 | 2019-11-19 Andrew Burgess <andrew.burgess@embecosm.com> |
2 | 6 | |
3 | 7 | * gdb.base/ctf-whatis.c: Delete. |
@@ -0,0 +1,37 @@ | ||
1 | +# Copyright 2019 Free Software Foundation, Inc. | |
2 | + | |
3 | +# This program is free software; you can redistribute it and/or modify | |
4 | +# it under the terms of the GNU General Public License as published by | |
5 | +# the Free Software Foundation; either version 3 of the License, or | |
6 | +# (at your option) any later version. | |
7 | +# | |
8 | +# This program is distributed in the hope that it will be useful, | |
9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | +# GNU General Public License for more details. | |
12 | +# | |
13 | +# You should have received a copy of the GNU General Public License | |
14 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | + | |
16 | +# Test the "winheight" command. | |
17 | + | |
18 | +load_lib "tuiterm.exp" | |
19 | + | |
20 | +standard_testfile tui-layout.c | |
21 | + | |
22 | +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { | |
23 | + return -1 | |
24 | +} | |
25 | + | |
26 | +Term::clean_restart 24 80 $testfile | |
27 | +if {![Term::enter_tui]} { | |
28 | + unsupported "TUI not supported" | |
29 | +} | |
30 | + | |
31 | +Term::check_box "source box" 0 0 80 15 | |
32 | + | |
33 | +Term::command "winheight cmd +5" | |
34 | +Term::check_box "smaller source box" 0 0 80 10 | |
35 | + | |
36 | +Term::command "winheight cmd -5" | |
37 | +Term::check_box "larger source box" 0 0 80 15 |
@@ -158,25 +158,6 @@ tui_prev_win (struct tui_win_info *cur_win) | ||
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | -/* Answer the window represented by name. */ | |
162 | -struct tui_win_info * | |
163 | -tui_partial_win_by_name (const char *name) | |
164 | -{ | |
165 | - if (name != NULL) | |
166 | - { | |
167 | - for (tui_win_info *item : all_tui_windows ()) | |
168 | - { | |
169 | - const char *cur_name = item->name (); | |
170 | - | |
171 | - if (strlen (name) <= strlen (cur_name) | |
172 | - && startswith (cur_name, name)) | |
173 | - return item; | |
174 | - } | |
175 | - } | |
176 | - | |
177 | - return NULL; | |
178 | -} | |
179 | - | |
180 | 161 | /* See tui-data.h. */ |
181 | 162 | |
182 | 163 | void |
@@ -294,7 +294,6 @@ struct all_tui_windows | ||
294 | 294 | |
295 | 295 | |
296 | 296 | /* Data Manipulation Functions. */ |
297 | -extern struct tui_win_info *tui_partial_win_by_name (const char *); | |
298 | 297 | extern enum tui_layout_type tui_current_layout (void); |
299 | 298 | extern int tui_term_height (void); |
300 | 299 | extern void tui_set_term_height_to (int); |
@@ -51,6 +51,7 @@ | ||
51 | 51 | #include "gdb_curses.h" |
52 | 52 | #include <ctype.h> |
53 | 53 | #include "readline/readline.h" |
54 | +#include "gdbsupport/gdb_string_view.h" | |
54 | 55 | |
55 | 56 | #include <signal.h> |
56 | 57 |
@@ -792,6 +793,24 @@ tui_scroll_right_command (const char *arg, int from_tty) | ||
792 | 793 | } |
793 | 794 | |
794 | 795 | |
796 | +/* Answer the window represented by name. */ | |
797 | +static struct tui_win_info * | |
798 | +tui_partial_win_by_name (gdb::string_view name) | |
799 | +{ | |
800 | + if (name != NULL) | |
801 | + { | |
802 | + for (tui_win_info *item : all_tui_windows ()) | |
803 | + { | |
804 | + const char *cur_name = item->name (); | |
805 | + | |
806 | + if (startswith (cur_name, name)) | |
807 | + return item; | |
808 | + } | |
809 | + } | |
810 | + | |
811 | + return NULL; | |
812 | +} | |
813 | + | |
795 | 814 | /* Set focus to the window named by 'arg'. */ |
796 | 815 | static void |
797 | 816 | tui_set_focus_command (const char *arg, int from_tty) |
@@ -939,20 +958,16 @@ tui_set_win_height_command (const char *arg, int from_tty) | ||
939 | 958 | tui_enable (); |
940 | 959 | if (arg != NULL) |
941 | 960 | { |
942 | - std::string copy = arg; | |
943 | - char *buf = ©[0]; | |
944 | - char *buf_ptr = buf; | |
945 | - char *wname = NULL; | |
961 | + const char *buf = arg; | |
962 | + const char *buf_ptr = buf; | |
946 | 963 | int new_height; |
947 | 964 | struct tui_win_info *win_info; |
948 | 965 | |
949 | - wname = buf_ptr; | |
950 | 966 | buf_ptr = strchr (buf_ptr, ' '); |
951 | 967 | if (buf_ptr != NULL) |
952 | 968 | { |
953 | - *buf_ptr = '\0'; | |
954 | - | |
955 | 969 | /* Validate the window name. */ |
970 | + gdb::string_view wname (buf, buf_ptr - buf); | |
956 | 971 | win_info = tui_partial_win_by_name (wname); |
957 | 972 | |
958 | 973 | if (win_info == NULL) |