This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Fix dangling cleanup in linespec_parse_basic
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Fri, 25 Apr 2014 10:46:55 -0700
- Subject: [RFA] Fix dangling cleanup in linespec_parse_basic
- Authentication-results: sourceware.org; auth=none
Hi,
For a linespec such as "filename:$convenience_variable", the local
variable holding the name of the convenience variable ('name' in the
code) is not freed if no parsing error occurred, i.e., the convenience
variable is defined. This leaves a dangling cleanup.
The error case was already properly handling the cleanup. This patch
adds the appropriate cleanup handling when there is no error.
I've also added a test for this to ls-dollar.exp.
Ok?
Keith
ChangeLog
2014-04-25 Keith Seitz <keiths@redhat.com>
* linespec.c (linespec_parse_basic): Run cleanups if a convenience
variable or history value is successfully parsed.
testsuite/ChangeLog
2014-04-25 Keith Seitz <keiths@redhat.com>
* gdb.linespec/ls-dollar.exp: Add test for linespec
file:convenience_variable.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 610809d..cb76b9c 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1665,6 +1665,10 @@ linespec_parse_basic (linespec_parser *parser)
discard_cleanups (cleanup);
return;
}
+
+ /* The convenience variable/history value parsed correctly.
+ NAME is no longer needed. */
+ do_cleanups (cleanup);
}
else
{
diff --git a/gdb/testsuite/gdb.linespec/ls-dollar.exp b/gdb/testsuite/gdb.linespec/ls-dollar.exp
index 2e35804..bccc40a 100644
--- a/gdb/testsuite/gdb.linespec/ls-dollar.exp
+++ b/gdb/testsuite/gdb.linespec/ls-dollar.exp
@@ -30,7 +30,16 @@ if {[prepare_for_testing $testfile $exefile $srcfile \
gdb_test_no_output "set listsize 1"
+set line [gdb_get_line_number {dollar_func}]
+
gdb_test "list \$dollar_var" \
".*static int [string_to_regexp {$dollar_var}] = 0;"
gdb_test "break \$dollar_func" \
- "Breakpoint $decimal at $hex: file .*$srcfile, line [gdb_get_line_number {dollar_func}]\\\."
+ "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\."
+
+gdb_test_no_output "set var \$theline = $line"
+gdb_test "list $srcfile:\$theline" \
+ ".*[string_to_regexp {/* dollar_func */}]"
+
+gdb_test "break $srcfile:\$theline" \
+ "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\."