public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add test name argument to get_valueof, get_integer_valueof and get_sizeof
@ 2017-03-10 15:49 Anton Kolesov
  2017-03-13 19:23 ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Kolesov @ 2017-03-10 15:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Anton Kolesov, Francois Bedard

An optional parameter TEST has been added to get_hexadecimal_valueof in commit:

  https://sourceware.org/ml/gdb-patches/2016-06/msg00469.html

This patch adds a similar optional parameter to other related methods that
retrieve expression values: get_valueof, get_integer_valueof and get_sizeof.
Thus tests that evaluate same expression multiple times can provide custom
test names, ensuring that test names will be unique.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* lib/gdb.exp (get_valueof, get_integer_valueof, get_sizeof):
	  Add optional 'test' parameter.
---
 gdb/testsuite/lib/gdb.exp | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 188484f..63d816e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5523,10 +5523,18 @@ proc prepare_for_testing { testname executable {sources ""} {options {debug}}} {
     return 0
 }
 
-proc get_valueof { fmt exp default } {
+# Retrieve the value of EXP in the inferior, represented in format
+# specified in FMT (using "printFMT").  DEFAULT is used as fallback if
+# print fails.  TEST is the test message to use.  It can be omitted,
+# in which case a test message is built from EXP.
+
+proc get_valueof { fmt exp default {test ""} } {
     global gdb_prompt
 
-    set test "get valueof \"${exp}\""
+    if {$test == "" } {
+	set test "get valueof \"${exp}\""
+    }
+
     set val ${default}
     gdb_test_multiple "print${fmt} ${exp}" "$test" {
 	-re "\\$\[0-9\]* = (.*)\[\r\n\]*$gdb_prompt $" {
@@ -5540,10 +5548,18 @@ proc get_valueof { fmt exp default } {
     return ${val}
 }
 
-proc get_integer_valueof { exp default } {
+# Retrieve the value of EXP in the inferior, as a signed decimal value
+# (using "print /d").  DEFAULT is used as fallback if print fails.
+# TEST is the test message to use.  It can be omitted, in which case
+# a test message is built from EXP.
+
+proc get_integer_valueof { exp default {test ""} } {
     global gdb_prompt
 
-    set test "get integer valueof \"${exp}\""
+    if {$test == ""} {
+	set test "get integer valueof \"${exp}\""
+    }
+
     set val ${default}
     gdb_test_multiple "print /d ${exp}" "$test" {
 	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
@@ -5559,7 +5575,7 @@ proc get_integer_valueof { exp default } {
 
 # Retrieve the value of EXP in the inferior, as an hexadecimal value
 # (using "print /x").  DEFAULT is used as fallback if print fails.
-# TEST is the test message to use.  If can be ommitted, in which case
+# TEST is the test message to use.  It can be omitted, in which case
 # a test message is built from EXP.
 
 proc get_hexadecimal_valueof { exp default {test ""} } {
@@ -5579,8 +5595,12 @@ proc get_hexadecimal_valueof { exp default {test ""} } {
     return ${val}
 }
 
-proc get_sizeof { type default } {
-    return [get_integer_valueof "sizeof (${type})" $default]
+# Retrieve the size of TYPE in the inferior, as a decimal value.  DEFAULT
+# is used as fallback if print fails.  TEST is the test message to use.
+# It can be omitted, in which case a test message is 'sizeof (TYPE)'.
+
+proc get_sizeof { type default {test ""} } {
+    return [get_integer_valueof "sizeof (${type})" $default $test]
 }
 
 proc get_target_charset { } {
-- 
2.8.3

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

* Re: [PATCH] Add test name argument to get_valueof, get_integer_valueof and get_sizeof
  2017-03-10 15:49 [PATCH] Add test name argument to get_valueof, get_integer_valueof and get_sizeof Anton Kolesov
@ 2017-03-13 19:23 ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2017-03-13 19:23 UTC (permalink / raw)
  To: Anton Kolesov, gdb-patches; +Cc: Francois Bedard

On 03/10/2017 03:48 PM, Anton Kolesov wrote:
> An optional parameter TEST has been added to get_hexadecimal_valueof in commit:
> 
>   https://sourceware.org/ml/gdb-patches/2016-06/msg00469.html
> 
> This patch adds a similar optional parameter to other related methods that
> retrieve expression values: get_valueof, get_integer_valueof and get_sizeof.
> Thus tests that evaluate same expression multiple times can provide custom
> test names, ensuring that test names will be unique.
> 
> gdb/testsuite/ChangeLog:
> yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>
> 
> 	* lib/gdb.exp (get_valueof, get_integer_valueof, get_sizeof):
> 	  Add optional 'test' parameter.

OK.

Thanks,
Pedro Alves

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

end of thread, other threads:[~2017-03-13 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 15:49 [PATCH] Add test name argument to get_valueof, get_integer_valueof and get_sizeof Anton Kolesov
2017-03-13 19:23 ` Pedro Alves

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).