This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pushed] Add test for "List actual code around more than one location" change (Re: [PATCH v1 1/1] list actual code around more than one locations)


On 08/22/2017 05:00 PM, Pedro Alves wrote:

> Thanks for the patch!  I pushed it in with a couple minor
> tweaks.  See below.

FYI, I pushed in this testsuite patch to cover the new functionality.

>From 5277199aeb328247d5d37ad6f34e4cf200fe42fa Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 22 Aug 2017 14:51:18 +0100
Subject: [PATCH] Add test for "List actual code around more than one location"
 change

This adds a test for the "list" command change done in 0d999a6ef0f9
("List actual code around more than one location").

gdb/ChangeLog:
2017-08-22  Pedro Alves  <palves@redhat.com>

	* gdb.cp/overload.exp (line_range_pattern): New procedure.
	(top level): Add "list all overloads" tests.
---
 gdb/testsuite/ChangeLog           |  5 +++++
 gdb/testsuite/gdb.cp/overload.exp | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2be26a7..d2ccd84 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-22  Pedro Alves  <palves@redhat.com>
+
+	* gdb.cp/overload.exp (line_range_pattern): New procedure.
+	(top level): Add "list all overloads" tests.
+
 2017-08-22  Tom Tromey  <tom@tromey.com>
 
 	* gdb.gdb/xfullpath.exp: Remove.
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index 77a2505..8cb9311 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -263,10 +263,24 @@ gdb_test "print bar(d)" "= 22"
 
 # List overloaded functions.
 
+gdb_test_no_output "set listsize 1" ""
+
+# Build source listing pattern based on an inclusive line range.
+
+proc line_range_pattern { range_start range_end } {
+    global line_re
+
+    for {set i $range_start} {$i <= $range_end} {incr i} {
+	append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
+    }
+
+    verbose -log "pattern $pattern"
+    return $pattern
+}
+
 # The void case is tricky because some compilers say "(void)"
 # and some compilers say "()".
 
-gdb_test_no_output "set listsize 1" ""
 gdb_test_multiple "info func overloadfnarg" "list overloaded function with no args" {
     -re ".*overloadfnarg\\(void\\).*$gdb_prompt $" {
 	# gcc 2
@@ -324,6 +338,24 @@ gdb_test "print N::nsoverload ()" " = 1"
 gdb_test "print N::nsoverload (2)" " = 2"
 gdb_test "print N::nsoverload (2, 3)" " = 5"
 
+# Test "list function" when there are multiple "function" overloads.
+
+with_test_prefix "list all overloads" {
+    # Bump up listsize again, to make sure the number of lines to
+    # display before/after each location is computed correctly.
+    gdb_test_no_output "set listsize 10"
+
+    set line_bar_A [gdb_get_line_number "int bar (A)"]
+    set line_bar_B [gdb_get_line_number "int bar (B)"]
+    set lines1 [line_range_pattern [expr $line_bar_A - 5] [expr $line_bar_A + 4]]
+    set lines2 [line_range_pattern [expr $line_bar_B - 5] [expr $line_bar_B + 4]]
+
+    set any "\[^\r\n\]*"
+    set h1_re "file: \"${any}overload.cc\", line number: $line_bar_A"
+    set h2_re "file: \"${any}overload.cc\", line number: $line_bar_B"
+    gdb_test "list bar" "${h1_re}${lines1}\r\n${h2_re}${lines2}"
+}
+
 if ![runto 'XXX::marker2'] then {
     perror "couldn't run to XXX::marker2"
     continue
-- 
2.5.5



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]