public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb.base/memattr.exp regexp improvements
@ 2014-04-11 17:36 Andrew Burgess
  2014-04-16 15:46 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2014-04-11 17:36 UTC (permalink / raw)
  To: gdb-patches

I hit an issue in the test gdb.base/memattr.exp, on my target the
memory regions created were not listed in the order 1, 2, 3, 4, 5,
instead, region 1 is placed after region 5.

This is just because region 1 is initialised data, and 2->5 are
uninitialised, and it just happens that our linker places things
in that order.

It's possible to see the same errors on x86-64 if the memory
regions in the file gdb.base/memattr.c (the test source) are
reordered, so, for example, move region 2 to the end of the list.

The patch below just improves the regexps used in the test such
that the order of the memory regions is no longer important.  I
don't believe that the order is actually important to the test[1].

OK to apply?

Thanks,
Andrew

[1] We're probably NOT currently testing that the memory regions
are in ascending order, but we weren't really testing this before
either.



gdb/testsuite/ChangeLog:

	* gdb.base/memattr.exp: Improve regexps to handle memory regions
	appearing in any order.


diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp
index af7de1f..1e23dae 100644
--- a/gdb/testsuite/gdb.base/memattr.exp
+++ b/gdb/testsuite/gdb.base/memattr.exp
@@ -110,24 +110,31 @@ set see3 0
 set see4 0
 set see5 0
 
+set info_mem_header_pattern \
+    "info mem.*Num\[ \t\]+Enb\[ \t\]+Low\[ \t\]+Addr\[ \t\]+High\[ \t\]+Addr\[ \t\]+Attrs\[^\n\r]*.."
+
 gdb_test_multiple "info mem" "info mem(1)" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -181,23 +188,27 @@ set see4 0
 set see5 0
 
 gdb_test_multiple "info mem" "mem 2 and 4 were disabled" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   n  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   n  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -219,23 +230,27 @@ set see4 0
 set see5 0
 
 gdb_test_multiple "info mem" "mem 2-4 were enabled" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -257,23 +272,27 @@ set see4 0
 set see5 0
 
 gdb_test_multiple "info mem" "mem 1 to 5 were disabled" {
-    -re "1   n  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   n  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   n  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   n  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   n  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   n  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -295,23 +314,27 @@ set see4 0
 set see5 0
 
 gdb_test_multiple "info mem" "mem 1 to 5 were enabled" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -340,23 +363,27 @@ set see5 0
 
 gdb_test_no_output "delete mem 1" "delete mem 1"
 gdb_test_multiple "info mem" "mem 1 was deleted" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -377,23 +404,27 @@ set see5 0
 
 gdb_test_no_output "delete mem 2 4" "delete mem 2 4"
 gdb_test_multiple "info mem" "mem 2 and 4 were deleted" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }
@@ -416,23 +447,27 @@ gdb_test "delete mem 2-4" \
     "No memory region number 2.*No memory region number 4." \
     "delete mem 2-4"
 gdb_test_multiple "info mem" "mem 2-4 were deleted" {
-    -re "1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*" {
+    -re ${info_mem_header_pattern} {
+	# Discard the header.
+	exp_continue
+    }
+    -re "^1   y  \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
 	set see1 1
 	exp_continue
     }
-    -re "2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*" {
+    -re "^2   y  \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
 	set see2 1
 	exp_continue
     }
-    -re "3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^3   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see3 1
 	exp_continue
     }
-    -re "4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*" {
+    -re "^4   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see4 1
 	exp_continue
     }
-    -re "5   y  \[ \t\]+$hex $hex rw nocache .\[^\r\n\]*" {
+    -re "^5   y  \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
 	set see5 1
 	exp_continue
     }


 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb.base/memattr.exp regexp improvements
  2014-04-11 17:36 [PATCH] gdb.base/memattr.exp regexp improvements Andrew Burgess
@ 2014-04-16 15:46 ` Joel Brobecker
  2014-04-16 16:47   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2014-04-16 15:46 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

> gdb/testsuite/ChangeLog:
> 
> 	* gdb.base/memattr.exp: Improve regexps to handle memory regions
> 	appearing in any order.

OK!

Thanks,
-- 
Joel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb.base/memattr.exp regexp improvements
  2014-04-16 15:46 ` Joel Brobecker
@ 2014-04-16 16:47   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2014-04-16 16:47 UTC (permalink / raw)
  To: gdb-patches

On 16/04/2014 4:46 PM, Joel Brobecker wrote:
>> gdb/testsuite/ChangeLog:
>>
>> 	* gdb.base/memattr.exp: Improve regexps to handle memory regions
>> 	appearing in any order.
> 
> OK!
> 

Committed.

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-16 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 17:36 [PATCH] gdb.base/memattr.exp regexp improvements Andrew Burgess
2014-04-16 15:46 ` Joel Brobecker
2014-04-16 16:47   ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).