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: small test suite cleanup


 I am just surprised by the regular expression used for
the matching of the result...
 
 This only accepts digits, but
if you use "/x" for the format,
you would get an hexadecimal printout,
shouldn't that be also accepted?

 Given the very general name of the proc: "get_valueof"
I would have expected it to support any format and
accept any output, even complicated ones.
  But then we could run into problems
of the correct regexp to delimit the return value
(especially because the final newline before 
gdb_prompt needs to be rejected, and this one is
quite system dependent...)

  Another option would be to rename you proc to
get_numeric_valueof and accepted only number
in binary, octal, decimal and hexadecimal forms...

  But I don't like the idea of having a
procedure that would issue FAIL
if used for instance as
  [get_valueof "/s" "*args.argv" "0"]
in gdb main function.

  By the way, the third argument should probably
be optional with a default "0", no?

Pierre Muller
Pascal language support maintainer for GDB




 

> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé?: Friday, February 13, 2009 5:13 PM
> À?: gdb-patches@sourceware.org
> Objet?: FYI: small test suite cleanup
> 
> I needed get_sizeof for the charset patch, and while looking I found
> multiple copies of this in the testsuite.
> 
> This patch consolidates most of them -- I left a get_valueofx in
> pc-fp.exp.
> 
> Built and regtested on x86-64 (compile farm).
> 
> Tom
> 
> 2009-02-13  Tom Tromey  <tromey@redhat.com>
> 
> 	* gdb.base/remote.exp (get_sizeof): Remove.
> 	* gdb.base/long_long.exp (get_valueof, get_sizeof): Remove.
> 	* gdb.base/dfp-test.exp (get_valueof, get_sizeof): Remove.
> 	* gdb.base/sizeof.exp (get_valueof, get_sizeof): Remove.
> 	* lib/gdb.exp (get_valueof): Move from long_long.exp.
> 	(get_sizeof): Likewise.
> 
> diff --git a/gdb/testsuite/gdb.base/dfp-test.exp
> b/gdb/testsuite/gdb.base/dfp-test.exp
> index 32f36a9..94fcb41 100644
> --- a/gdb/testsuite/gdb.base/dfp-test.exp
> +++ b/gdb/testsuite/gdb.base/dfp-test.exp
> @@ -43,26 +43,6 @@ if ![runto_main] then {
>      continue
>  }
> 
> -# Detect the size of the target's basic types (from
> gdb.base/long_long.exp).
> -
> -proc get_valueof { fmt exp default } {
> -    global gdb_prompt
> -    send_gdb "print${fmt} ${exp}\n"
> -    gdb_expect {
> -	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
> -	    set val $expect_out(1,string)
> -	}
> -	timeout {
> -	    set val ${default}
> -	}
> -    }
> -    return ${val}
> -}
> -
> -proc get_sizeof { type default } {
> -    return [get_valueof "/d" "sizeof (${type})" $default]
> -}
> -
>  set sizeof_long [get_sizeof "long" 4]
> 
>  proc d32_set_tests {} {
> diff --git a/gdb/testsuite/gdb.base/long_long.exp
> b/gdb/testsuite/gdb.base/long_long.exp
> index e585396..d0ad5ba 100644
> --- a/gdb/testsuite/gdb.base/long_long.exp
> +++ b/gdb/testsuite/gdb.base/long_long.exp
> @@ -74,26 +74,6 @@ gdb_expect {
> 
>  # Detect the size of the target's basic types.
> 
> -proc get_valueof { fmt exp default } {
> -    global gdb_prompt
> -    send_gdb "print${fmt} ${exp}\n"
> -    gdb_expect {
> -	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
> -	    set val $expect_out(1,string)
> -	    pass "get value of ${exp} ($val)"
> -	}
> -	timeout {
> -	    set size ${default}
> -	    fail "get value of ${exp} (timeout)"
> -	}
> -    }
> -    return ${val}
> -}
> -
> -proc get_sizeof { type default } {
> -    return [get_valueof "/d" "sizeof (${type})" $default]
> -}
> -
>  set sizeof_char [get_sizeof "char" 1]
>  set sizeof_short [get_sizeof "short" 2]
>  set sizeof_int [get_sizeof "int" 4]
> diff --git a/gdb/testsuite/gdb.base/remote.exp
> b/gdb/testsuite/gdb.base/remote.exp
> index 0dee13a..113c56b 100644
> --- a/gdb/testsuite/gdb.base/remote.exp
> +++ b/gdb/testsuite/gdb.base/remote.exp
> @@ -125,22 +125,6 @@ gdb_load_timed $binfile "limit" 0
>  # Query GDB for the size of various types
>  #
> 
> -proc get_sizeof { type default } {
> -    global gdb_prompt
> -    send_gdb "print/d sizeof (${type})\n"
> -    gdb_expect {
> -	-re "\\$\[0-9\]* = (\[0-9\]*).*$gdb_prompt $" {
> -	    set size $expect_out(1,string)
> -	    pass "get sizeof ${type} ($size)"
> -	}
> -	timeout {
> -	    set size ${default}
> -	    fail "get sizeof ${type} (timeout)"
> -	}
> -    }
> -    return ${size}
> -}
> -
>  # Get the size of random_data table (defaults to 48K).
>  set sizeof_random_data [get_sizeof "random_data" 48*1024]
> 
> diff --git a/gdb/testsuite/gdb.base/sizeof.exp
> b/gdb/testsuite/gdb.base/sizeof.exp
> index 61a6be3..82f0da2 100644
> --- a/gdb/testsuite/gdb.base/sizeof.exp
> +++ b/gdb/testsuite/gdb.base/sizeof.exp
> @@ -61,24 +61,6 @@ if ![runto_main] then {
>  # Query GDB for the size of various types
>  #
> 
> -proc get_valueof { fmt exp default } {
> -    global gdb_prompt
> -
> -    set test "get valueof \"${exp}\""
> -    set val ${default}
> -    gdb_test_multiple "print${fmt} ${exp}" "$test" {
> -	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
> -	    set val $expect_out(1,string)
> -	    pass "$test ($val)"
> -	}
> -    }
> -    return ${val}
> -}
> -
> -proc get_sizeof { type default } {
> -    return [get_valueof "/d" "sizeof (${type})" $default]
> -}
> -
>  gdb_test "next"
> 
>  set sizeof_char [get_sizeof "char" 1]
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index b0059b7..e329b96 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -2878,3 +2878,26 @@ proc prepare_for_testing { testname executable
> {sources ""} {options {debug}}} {
> 
>      return 0
>  }
> +
> +proc get_valueof { fmt exp default } {
> +    global gdb_prompt
> +
> +    set test "get valueof \"${exp}\""
> +    set val ${default}
> +    gdb_test_multiple "print${fmt} ${exp}" "$test" {
> +	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
> +	    set val $expect_out(1,string)
> +	    pass "$test ($val)"
> +	}
> +	timeout {
> +	    set size ${default}
> +	    fail "get value of ${exp} (timeout)"
> +	}
> +    }
> +    return ${val}
> +}
> +
> +proc get_sizeof { type default } {
> +    return [get_valueof "/d" "sizeof (${type})" $default]
> +}
> +


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