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]

RE: [RFA] testsuite: Avoid buffer overrun in gdb.base/default.exp



> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Jan Kratochvil
> Envoyé?: Friday, August 06, 2010 5:08 PM
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [RFA] testsuite: Avoid buffer overrun in
> gdb.base/default.exp
> 
> On Fri, 06 Aug 2010 17:00:18 +0200, Pierre Muller wrote:
> 
> When using attachments please use:
> 	Content-Disposition: inline
> and not
> 	Content-Disposition: attachment

  Sorry, but I am bound to "Microsoft Outlook" and 
don't know where I can set this option :(
  I usually directly insert the patch inside the email itself,
but when there are very long line like in this case,
this can lead to troubles...
 
> +gdb_test_multiple "info set" "info set" {
> +    -re "confirm:  Whether to confirm potentially dangerous operations
> is o\[a-z\]*.(\[^\r\n\]*\[\r\n\])+history filename:  The filename in
> which to record the command history is (\[^\r\n\]*\[\r\n\])+listsize:
> Number of source lines gdb will list by default is 10.*" {
> +	verbose "Confirm dislayed"
> +	set set_confirm_seen 1
> +	exp_continue
> +    }
> +    -re "Gdb's prompt is \"$gdb_prompt \"" {
> +	verbose "GDB prompt displayed"
> +	set set_prompt_seen 1
> +	exp_continue
> +    }
> +    -re "Writing into executable.*$gdb_prompt $" {
> +	verbose "write displayed"
> +	if { $set_prompt_seen && $set_confirm_seen } {
> +	    pass "info set"
> +	} else {
> +	    verbose "prompt $set_prompt_seen confirm $set_confirm_seen"
> +	    fail "info set (incomplete output)"
> +	}
> +    }
> +}
> 
> The first pattern can eat up the text expected to be matched by the
> third
> pattern.  This way the loop will never finish.  Or do I miss something?

  You might be right, I should remove the final ".*" from the first pattern,
this is an oversight.

> The first pattern can match at once something like:
> confirm:  Whether to confirm potentially dangerous operations is o
> history filename:  The filename in which to record the command history
> is listsize:  Number of source lines gdb will list by default is 10
> Writing into executable (gdb)

  Thanks for that valuable contribution.

Below is a modified patch that removes the ".*" at the end of the two first
patterns.
The results on the test machine I used are unchanged.

Pierre

Direct inclusion try:


2010-08-06  Pierre Muller  <muller@ics.u-strasbg.fr>

	* gdb.base/default.exp (info set): Avoid full buffer error and force
	reading up to final gdb prompt.
	(show): Likewise.

Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/default.exp,v
retrieving revision 1.43
diff -u -p -r1.43 default.exp
--- src/gdb/testsuite/gdb.base/default.exp	7 Jul 2010 18:49:51 -0000
1.43
+++ src/gdb/testsuite/gdb.base/default.exp	6 Aug 2010 13:41:24 -0000
@@ -316,10 +316,37 @@ gdb_test "info s" "No stack." "info stac
 #test info stack
 gdb_test "info stack" "No stack." "info stack"
 #test info set
-# FIXME -- needs to match the entire output
-# FIXME -- on native solaris 2.8, this test fails due to this line:
+# Test improved to check three parts:
+# 1) confirm
+# 2) prompt
+# 3) write
+# And only succeed if all three are matched.
+# This should fix an old problem on native solaris 2.8,
+# where this test fails due to this line:
 #  prompt:  Gdb's prompt is "(gdb) ".^M
-gdb_test "info set" "confirm:  Whether to confirm potentially dangerous
operations is o\[a-z\]*.(\[^\r\n\]*\[\r\n\])+history filename:  The filename
in which to record the command history is (\[^\r\n\]*\[\r\n\])+listsize:
Number of source lines gdb will list by default is 10.*" "info set"
+set set_confirm_seen 0
+set set_prompt_seen 0
+gdb_test_multiple "info set" "info set" {
+    -re "confirm:  Whether to confirm potentially dangerous operations is
o\[a-z\]*.(\[^\r\n\]*\[\r\n\])+history filename:  The filename in which to
record the command history is (\[^\r\n\]*\[\r\n\])+listsize:  Number of
source lines gdb will list by default is 10" {
+	verbose "Confirm dislayed"
+	set set_confirm_seen 1
+	exp_continue
+    }
+    -re "Gdb's prompt is \"$gdb_prompt \"" {
+	verbose "GDB prompt displayed"
+	set set_prompt_seen 1
+	exp_continue
+    }
+    -re "Writing into executable.*$gdb_prompt $" {
+	verbose "write displayed"
+	if { $set_prompt_seen && $set_confirm_seen } {
+	    pass "info set"
+	} else {
+	    verbose "prompt $set_prompt_seen confirm $set_confirm_seen"
+	    fail "info set (incomplete output)"
+	}
+    }
+}
 gdb_test "info symbol" "Argument required .address.."
 #test info source
 gdb_test  "info source" "No current source file..*" "info source"
@@ -651,7 +678,29 @@ gdb_test "show width" "Number of charact
 # This is only supported on targets which use exec.o.
 gdb_test "show write" "Writing into executable and core files is o.*" "show
write"
 #test show
-gdb_test "show" "confirm:  *Whether to confirm potentially dangerous
operations is on.(\[^\r\n\]*\[\r\n\])+history filename:  *The filename in
which to record the command history is (\[^\r\n\]*\[\r\n\])+history save:
*Saving of the history record on exit is on.(\[^\r\n\]*\[\r\n\])+history
size:  *The size of the command history is(\[^\r\n\]*\[\r\n\])+listsize:
*Number of source lines gdb will list by default is
10(\[^\r\n]*\[\r\n\])+print elements:  *Limit on string chars or array
elements to print is 200..*" "show"
+set show_confirm_seen 0
+set show_prompt_seen 0
+gdb_test_multiple "show" "show" {
+    -re "confirm:  *Whether to confirm potentially dangerous operations is
on.(\[^\r\n\]*\[\r\n\])+history filename:  *The filename in which to record
the command history is (\[^\r\n\]*\[\r\n\])+history save:  *Saving of the
history record on exit is on.(\[^\r\n\]*\[\r\n\])+history size:  *The size
of the command history is(\[^\r\n\]*\[\r\n\])+listsize:  *Number of source
lines gdb will list by default is 10(\[^\r\n]*\[\r\n\])+print elements:
*Limit on string chars or array elements to print is 200." {
+	verbose "Confirm dislayed"
+	set show_confirm_seen 1
+	exp_continue
+    }
+    -re "Gdb's prompt is \"$gdb_prompt \"" {
+	verbose "GDB prompt displayed"
+	set show_prompt_seen 1
+	exp_continue
+    }
+    -re "Writing into executable.*$gdb_prompt $" {
+	verbose "write displayed"
+	if { $show_prompt_seen && $show_confirm_seen } {
+	    pass "show"
+	} else {
+	    verbose "prompt $show_prompt_seen confirm $show_confirm_seen"
+	    fail "show (incomplete output)"
+	}
+    }
+}
 #test stepi "si" abbreviation
 gdb_test  "si" "The program is not being run." "stepi \"si\" abbreviation"
 #test stepi


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