aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-01-28 13:21:35 -0700
committerTom Tromey <tom@tromey.com>2019-02-17 10:39:45 -0700
commit0c820d679358aa1ec7cd9e33c4bc23a7db964ea1 (patch)
treef490407b3ae557274e87a0cf61c8e3628610ab3b /gdb
parenta008792038c2510800db466897c4bb6305d20042 (diff)
downloadgdb-0c820d679358aa1ec7cd9e33c4bc23a7db964ea1.zip
gdb-0c820d679358aa1ec7cd9e33c4bc23a7db964ea1.tar.gz
gdb-0c820d679358aa1ec7cd9e33c4bc23a7db964ea1.tar.bz2
Fix some valgrind errors in the TUI
The styling series introduced some new errors in the TUI -- the series changed how source lines are allocated, without updating tui_set_source_content_nil. There are several failures but a typical one looks like: ==6274== Use of uninitialised value of size 8 ==6274== at 0x4E4A095: wclrtoeol (in /usr/lib64/libncursesw.so.6.1) ==6274== by 0x4E47617: waddch (in /usr/lib64/libncursesw.so.6.1) ==6274== by 0x8325CB: tui_puts_internal(_win_st*, char const*, int*) (tui-io.c:393) ==6274== by 0x82E89D: tui_file::puts(char const*) (tui-file.c:39) ==6274== by 0x84BF5F: vfprintf_unfiltered(ui_file*, char const*, __va_list_tag*) (utils.c:2026) This patch rewrites tui_set_source_content_nil, fixing the bug. This was also reported as PR tui/24197. Verified by running valgrind before and after on x86-64 Fedora 29. gdb/ChangeLog 2019-02-17 Tom Tromey <tom@tromey.com> PR tui/24197: * tui/tui-source.c (tui_set_source_content_nil): Rewrite.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/tui/tui-source.c21
2 files changed, 10 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eb3bc0b..b9af73f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2019-02-17 Tom Tromey <tom@tromey.com>
+ PR tui/24197:
+ * tui/tui-source.c (tui_set_source_content_nil): Rewrite.
+
+2019-02-17 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (user_select_syms): Use filtered printing.
* utils.c (wrap_style): New global.
(desired_style): Remove.
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index a7e801e..7cc3c00 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -253,33 +253,22 @@ tui_set_source_content_nil (struct tui_win_info *win_info,
if (curr_line == (n_lines / 2 + 1))
{
- int i;
int xpos;
int warning_length = strlen (warning_string);
char *src_line;
- src_line = element->which_element.source.line;
-
if (warning_length >= ((line_width - 1) / 2))
xpos = 1;
else
xpos = (line_width - 1) / 2 - warning_length;
- for (i = 0; i < xpos; i++)
- src_line[i] = ' ';
-
- sprintf (src_line + i, "%s", warning_string);
-
- for (i = xpos + warning_length; i < line_width; i++)
- src_line[i] = ' ';
-
- src_line[i] = '\n';
-
- } /* end if */
+ src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string);
+ xfree (element->which_element.source.line);
+ element->which_element.source.line = src_line;
+ }
curr_line++;
-
- } /* end while */
+ }
}