[v2,2/3] Remove hard-coded line number from templates.exp

Message ID 20200420215708.42314-3-keiths@redhat.com
State New
Headers show
Series
  • Completer C++ template support
Related show

Commit Message

Rogerio Alves via Gdb-patches April 20, 2020, 9:57 p.m.
templates.exp has a hard-coded line number in it:

  gdb_test "b 770" \
      "Breakpoint .* at .*, line 770."

The problems with this are well-known, and this patch simply removes it.
I've also added the missing FSF copyright header to templates.cc.

This patch was previously approved:
https://sourceware.org/pipermail/gdb-patches/2018-February/146820.html

testsuite/ChangeLog:

	* gdb.cp/templates.cc (main): Add breakpoint marker comment.
	* gdb.cp/templates.exp: Remove hard-coded line number.
---
 gdb/testsuite/gdb.cp/templates.cc  | 19 ++++++++++++++++++-
 gdb/testsuite/gdb.cp/templates.exp |  8 ++------
 2 files changed, 20 insertions(+), 7 deletions(-)

-- 
2.25.2

Comments

Tom Tromey April 24, 2020, 7:58 p.m. | #1
>>>>> "Keith" == Keith Seitz via Gdb-patches <gdb-patches@sourceware.org> writes:


Keith> templates.exp has a hard-coded line number in it:
Keith>   gdb_test "b 770" \
Keith>       "Breakpoint .* at .*, line 770."

Keith> The problems with this are well-known, and this patch simply removes it.
Keith> I've also added the missing FSF copyright header to templates.cc.

Keith> This patch was previously approved:
Keith> https://sourceware.org/pipermail/gdb-patches/2018-February/146820.html

Keith> testsuite/ChangeLog:

Keith> 	* gdb.cp/templates.cc (main): Add breakpoint marker comment.
Keith> 	* gdb.cp/templates.exp: Remove hard-coded line number.

Ok.

Tom

Patch

diff --git a/gdb/testsuite/gdb.cp/templates.cc b/gdb/testsuite/gdb.cp/templates.cc
index 49cf6b66ef..e28e63623c 100644
--- a/gdb/testsuite/gdb.cp/templates.cc
+++ b/gdb/testsuite/gdb.cp/templates.cc
@@ -1,3 +1,20 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 1992-2020 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
 /* This test code is from Wendell Baker (wbaker@comet.berkeley.edu) */
 
 #include <stddef.h>
@@ -801,5 +818,5 @@  int main()
 
   arg.method(empty);
 
-  return 0;
+  return 0;			// break here
 }
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index e4f50a3958..bfa50bcaa6 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -283,12 +283,8 @@  do_tests
 # weren't breakpointing past a point where the below expressions were
 # initialized in the actual source. - djb
 
-gdb_test "b 770" \
-    "Breakpoint .* at .*, line 770."
-
-gdb_test "c" \
-    "Continuing.*Breakpoint .*" \
-    "continue to line 770"
+gdb_breakpoint [gdb_get_line_number "break here"]
+gdb_continue_to_breakpoint "continue to test marker"
 
 gdb_test "print fint" \
    "\\$\[0-9\]* = \\{x = 0, t = 0\\}"