diff mbox

[2/3] Testsuite: Rename "end()" to avoid libinproctrace C++ symbol clash

Message ID 1521043903-18837-3-git-send-email-arnez@linux.vnet.ibm.com
State New
Headers show

Commit Message

Andreas Arnez March 14, 2018, 4:11 p.m. UTC
Some of GDB's trace test cases define a function end() and place a
breakpoint there with "break end".  However, when libinproctrace is linked
to the binary, there are multiple methods named "end", such as
std::string::end() from the C++ library or format_pieces::end() from
common/format.h.  GDB then creates multiple breakpoints instead of just a
single one, and some FAILs result, such as these:

  FAIL: gdb.trace/trace-mt.exp: ftrace on: break end
  FAIL: gdb.trace/trace-mt.exp: ftrace off: break end

This is fixed by renaming end() to my_end().  For consistency, where end()
was paired with a previous begin(), the latter is renamed to my_begin() as
well.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-break.c (end): Rename to...
	(my_end): ...this.
	(main): Adjust call.
	* gdb.trace/trace-mt.c (end): Rename to...
	(my_end): ...this.
	(main): Adjust call.
	* gdb.trace/unavailable.cc (begin): Rename to...
	(my_begin): ...this.
	(end): Rename to...
	(my_end): ...this.
	(main): Adjust calls.
	* gdb.trace/trace-break.exp: Reflect function name change.
	* gdb.trace/trace-mt.exp: Likewise.
	* gdb.trace/unavailable.exp: Likewise.
---
 gdb/testsuite/gdb.trace/trace-break.c   |  4 ++--
 gdb/testsuite/gdb.trace/trace-break.exp | 12 ++++++------
 gdb/testsuite/gdb.trace/trace-mt.c      |  4 ++--
 gdb/testsuite/gdb.trace/trace-mt.exp    |  2 +-
 gdb/testsuite/gdb.trace/unavailable.cc  |  8 ++++----
 gdb/testsuite/gdb.trace/unavailable.exp | 20 ++++++++++----------
 6 files changed, 25 insertions(+), 25 deletions(-)

Comments

Simon Marchi March 15, 2018, 9:57 p.m. UTC | #1
On 2018-03-14 12:11 PM, Andreas Arnez wrote:
> Some of GDB's trace test cases define a function end() and place a
> breakpoint there with "break end".  However, when libinproctrace is linked
> to the binary, there are multiple methods named "end", such as
> std::string::end() from the C++ library or format_pieces::end() from
> common/format.h.  GDB then creates multiple breakpoints instead of just a
> single one, and some FAILs result, such as these:
> 
>   FAIL: gdb.trace/trace-mt.exp: ftrace on: break end
>   FAIL: gdb.trace/trace-mt.exp: ftrace off: break end
> 
> This is fixed by renaming end() to my_end().  For consistency, where end()
> was paired with a previous begin(), the latter is renamed to my_begin() as
> well.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/trace-break.c (end): Rename to...
> 	(my_end): ...this.
> 	(main): Adjust call.
> 	* gdb.trace/trace-mt.c (end): Rename to...
> 	(my_end): ...this.
> 	(main): Adjust call.
> 	* gdb.trace/unavailable.cc (begin): Rename to...
> 	(my_begin): ...this.
> 	(end): Rename to...
> 	(my_end): ...this.
> 	(main): Adjust calls.
> 	* gdb.trace/trace-break.exp: Reflect function name change.
> 	* gdb.trace/trace-mt.exp: Likewise.
> 	* gdb.trace/unavailable.exp: Likewise.

Hi Andreas,

Another way would have been to pass "-qualified" to the break command,
or use gdb_breakpoint and pass the "qualified" arg.  There are also
other instances of the same "problem" in tests that don't check the
output of the break command at all...

  gdb_test "break end" ".*" ""

In any case, this patch LGTM.

Thanks,

Simon
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.trace/trace-break.c b/gdb/testsuite/gdb.trace/trace-break.c
index 6aa9d09214..3349066dcc 100644
--- a/gdb/testsuite/gdb.trace/trace-break.c
+++ b/gdb/testsuite/gdb.trace/trace-break.c
@@ -31,13 +31,13 @@  marker (void)
 }
 
 static void
-end (void)
+my_end (void)
 {}
 
 int
 main ()
 {
   marker ();
-  end ();
+  my_end ();
   return 0;
 }
diff --git a/gdb/testsuite/gdb.trace/trace-break.exp b/gdb/testsuite/gdb.trace/trace-break.exp
index 539fcb5218..602b2e23ec 100644
--- a/gdb/testsuite/gdb.trace/trace-break.exp
+++ b/gdb/testsuite/gdb.trace/trace-break.exp
@@ -53,7 +53,7 @@  proc break_trace_same_addr_1 { trace_type option } \
 
     gdb_test_no_output "set breakpoint always-inserted ${option}"
 
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
     gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
@@ -88,7 +88,7 @@  proc break_trace_same_addr_2 { trace_type1 trace_type2 option } \
 
     gdb_test_no_output "set breakpoint always-inserted ${option}"
 
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "${trace_type1} set_point" \
 	"\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
@@ -127,7 +127,7 @@  proc break_trace_same_addr_3 { trace_type option } \
 
     gdb_test_no_output "set breakpoint always-inserted ${option}"
     gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
     gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
@@ -165,7 +165,7 @@  proc break_trace_same_addr_4 { trace_type option } \
 
     gdb_test_no_output "set breakpoint always-inserted ${option}"
     gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
     gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
@@ -208,7 +208,7 @@  proc break_trace_same_addr_5 { trace1 trace2 trace3 trace3_at_first_loc } \
     }
 
     gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "${trace1} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
 	"${trace1} set_point 1"
@@ -282,7 +282,7 @@  proc break_trace_same_addr_6 { trace1 enable1 trace2 enable2 } \
     }
 
     gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
 	"continue to marker"
diff --git a/gdb/testsuite/gdb.trace/trace-mt.c b/gdb/testsuite/gdb.trace/trace-mt.c
index 6f04ba7775..37d1ee0ea5 100644
--- a/gdb/testsuite/gdb.trace/trace-mt.c
+++ b/gdb/testsuite/gdb.trace/trace-mt.c
@@ -25,7 +25,7 @@  thread_function(void *arg)
 }
 
 static void
-end (void)
+my_end (void)
 {}
 
 int
@@ -40,7 +40,7 @@  main (int argc, char *argv[], char *envp[])
   for (i = 0; i < 2; i++)
     pthread_join (threads[i], NULL);
 
-  end ();
+  my_end ();
 
   return 0;
 }
diff --git a/gdb/testsuite/gdb.trace/trace-mt.exp b/gdb/testsuite/gdb.trace/trace-mt.exp
index f327406a13..bd89c9bec2 100644
--- a/gdb/testsuite/gdb.trace/trace-mt.exp
+++ b/gdb/testsuite/gdb.trace/trace-mt.exp
@@ -81,7 +81,7 @@  proc break_trace_same_addr { trace_type option } \
 
     gdb_test_no_output "set breakpoint always-inserted ${option}"
 
-    gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
+    gdb_test "break my_end" "Breakpoint \[0-9\] at $hex: file.*"
 
     gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
     gdb_test "${trace_type} set_point1" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
diff --git a/gdb/testsuite/gdb.trace/unavailable.cc b/gdb/testsuite/gdb.trace/unavailable.cc
index 56e5541259..aa4aeef65f 100644
--- a/gdb/testsuite/gdb.trace/unavailable.cc
+++ b/gdb/testsuite/gdb.trace/unavailable.cc
@@ -174,12 +174,12 @@  Virtual *virtualp = &virtual_partial;
 /* Test functions.  */
 
 static void
-begin ()	/* called before anything else */
+my_begin ()	/* called before anything else */
 {
 }
 
 static void
-end ()		/* called after everything else */
+my_end ()		/* called after everything else */
 {
 }
 
@@ -325,7 +325,7 @@  main (int argc, char **argv, char **envp)
   test_struct mystruct;
   int         myarray[4];
 
-  begin ();
+  my_begin ();
   /* Assign collectable values to global variables.  */
   globalc = 71;
   globali = 72;
@@ -395,6 +395,6 @@  main (int argc, char **argv, char **envp)
   g_structref.clear ();
   g_structref_p = NULL;
 
-  end ();
+  my_end ();
   return 0;
 }
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 79aa8ef1b0..7e8fc8b303 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -61,21 +61,21 @@  proc prepare_for_trace_test {} {
 
     runto_main
 
-    gdb_test "break begin" ".*" ""
-    gdb_test "break end" ".*" ""
+    gdb_test "break my_begin" ".*" ""
+    gdb_test "break my_end" ".*" ""
 }
 
 proc run_trace_experiment { test_func } {
     global gdb_prompt
 
     gdb_test "continue" \
-	".*Breakpoint \[0-9\]+, begin .*" \
-	"advance to begin"
+	".*Breakpoint \[0-9\]+, my_begin .*" \
+	"advance to my_begin"
 
     gdb_test_no_output "tstart" "start trace experiment"
 
     gdb_test "continue" \
-	    "Continuing.*Breakpoint \[0-9\]+, end.*" \
+	    "Continuing.*Breakpoint \[0-9\]+, my_end.*" \
 	    "run trace experiment"
     gdb_test "tstop" \
 	    "\[\r\n\]+" \
@@ -189,7 +189,7 @@  proc gdb_collect_args_test {} {
 	gdb_collect_args_test_1
 
 	gdb_test "tfind none" \
-	    "#0  end .*" \
+	    "#0  my_end .*" \
 	    "cease trace debugging"
 
 	set tracefile [standard_output_file ${testfile}]
@@ -273,7 +273,7 @@  proc gdb_collect_locals_test { func msg } {
 	gdb_collect_locals_test_1 $func
 
 	gdb_test "tfind none" \
-	    "#0  end .*" \
+	    "#0  my_end .*" \
 	    "cease trace debugging"
 
 	set tracefile [standard_output_file ${testfile}]
@@ -357,7 +357,7 @@  proc gdb_unavailable_registers_test { } {
 
 	gdb_unavailable_registers_test_1
 
-	gdb_test "tfind none" "#0  end .*" "cease trace debugging"
+	gdb_test "tfind none" "#0  my_end .*" "cease trace debugging"
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.registers.tfile" \
@@ -421,7 +421,7 @@  proc gdb_unavailable_floats { } {
 
 	gdb_unavailable_floats_1
 
-	gdb_test "tfind none" "#0  end .*" "cease trace debugging"
+	gdb_test "tfind none" "#0  my_end .*" "cease trace debugging"
 
 	set tracefile [standard_output_file ${testfile}]
 	gdb_test "tsave ${tracefile}.floats.tfile" \
@@ -688,7 +688,7 @@  proc gdb_collect_globals_test { } {
 	gdb_collect_globals_test_1
 
 	gdb_test "tfind none" \
-	    "#0  end .*" \
+	    "#0  my_end .*" \
 	    "cease trace debugging"
 
 	set tracefile [standard_output_file ${testfile}]