• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂9f6ad286efc0edf7d0cdb8a4126a23d38a267f8d (tree)
時間2019-11-20 05:27:25
作者Tom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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

Change Summary

差異

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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+
19 2019-11-19 Ali Tamur <tamur@google.com>
210
311 * dwarf2read.c (dw2_get_file_names_reader): Replace "if (attr)" with
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
1+2019-11-19 Tom Tromey <tom@tromey.com>
2+
3+ * gdb.tui/winheight.exp: New file.
4+
15 2019-11-19 Andrew Burgess <andrew.burgess@embecosm.com>
26
37 * gdb.base/ctf-whatis.c: Delete.
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/winheight.exp
@@ -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
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -158,25 +158,6 @@ tui_prev_win (struct tui_win_info *cur_win)
158158 }
159159
160160
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-
180161 /* See tui-data.h. */
181162
182163 void
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -294,7 +294,6 @@ struct all_tui_windows
294294
295295
296296 /* Data Manipulation Functions. */
297-extern struct tui_win_info *tui_partial_win_by_name (const char *);
298297 extern enum tui_layout_type tui_current_layout (void);
299298 extern int tui_term_height (void);
300299 extern void tui_set_term_height_to (int);
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -51,6 +51,7 @@
5151 #include "gdb_curses.h"
5252 #include <ctype.h>
5353 #include "readline/readline.h"
54+#include "gdbsupport/gdb_string_view.h"
5455
5556 #include <signal.h>
5657
@@ -792,6 +793,24 @@ tui_scroll_right_command (const char *arg, int from_tty)
792793 }
793794
794795
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+
795814 /* Set focus to the window named by 'arg'. */
796815 static void
797816 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)
939958 tui_enable ();
940959 if (arg != NULL)
941960 {
942- std::string copy = arg;
943- char *buf = &copy[0];
944- char *buf_ptr = buf;
945- char *wname = NULL;
961+ const char *buf = arg;
962+ const char *buf_ptr = buf;
946963 int new_height;
947964 struct tui_win_info *win_info;
948965
949- wname = buf_ptr;
950966 buf_ptr = strchr (buf_ptr, ' ');
951967 if (buf_ptr != NULL)
952968 {
953- *buf_ptr = '\0';
954-
955969 /* Validate the window name. */
970+ gdb::string_view wname (buf, buf_ptr - buf);
956971 win_info = tui_partial_win_by_name (wname);
957972
958973 if (win_info == NULL)