This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Fix print of value type in a corner case of finish


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2f41223f62de5d893bd6a4bd832293c2c3e80d91

commit 2f41223f62de5d893bd6a4bd832293c2c3e80d91
Author: Antoine Tremblay <antoine.tremblay@ericsson.com>
Date:   Wed Feb 25 11:00:01 2015 -0500

    Fix print of value type in a corner case of finish
    
    When doing finish in a function, if gdb fails to return a value, gdb
    also fails at printing the value type if this type is a struct.
    
    For example :
    
    (gdb) fin
    ....
    Value returned has type: . Cannot determine contents
    
    This patch fixes this by calling type_to_string to print the type
    so that we can support these types.
    
    This patch returns the following example output :
    
    (gdb) fin
    ....
    Value returned has type: struct test. Cannot determine contents
    
    Also, this patch modifies structs.exp to check that we return the
    correct type.
    
    gdb/ChangeLog:
    	* gdb/infcmd.c (print_return_value): use type_to_string to print type.
    
    gdb/testsuite/ChangeLog:
    	* gdb.base/structs.exp: Check for correct struct on finish.

Diff:
---
 gdb/ChangeLog                      | 4 ++++
 gdb/infcmd.c                       | 8 +++++++-
 gdb/testsuite/ChangeLog            | 4 ++++
 gdb/testsuite/gdb.base/structs.exp | 2 +-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2a2dadd..5c4138e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-26  Antoine Tremblay  <antoine.tremblay@ericsson.com>
+
+	* gdb/infcmd.c (print_return_value): use type_to_string to print type.
+
 2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* elfread.c (elf_read_minimal_symbols): Use bfd_alloc for
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 9a1fb8d..3737b8f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1607,10 +1607,16 @@ print_return_value (struct value *function, struct type *value_type)
     }
   else
     {
+      struct cleanup *oldchain;
+      char *type_name;
+
+      type_name = type_to_string (value_type);
+      oldchain = make_cleanup (xfree, type_name);
       ui_out_text (uiout, "Value returned has type: ");
-      ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
+      ui_out_field_string (uiout, "return-type", type_name);
       ui_out_text (uiout, ".");
       ui_out_text (uiout, " Cannot determine contents\n");
+      do_cleanups (oldchain);
     }
 }
 
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d06b5e5..b578053 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-26  Antoine Tremblay  <antoine.tremblay@ericsson.com>
+
+	* gdb.base/structs.exp: Check for correct struct on finish.
+
 2015-02-26  Yao Qi  <yao.qi@linaro.org>
 
 	* lib/dwarf.exp (function_range): Adjust pattern when $func_length
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 927e3b8..5d94a41 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -428,7 +428,7 @@ proc test_struct_returns { n } {
 	-re "Value returned is .*${gdb_prompt} $" {
 	    pass "${test}"
 	}
-	-re "Cannot determine contents.*${gdb_prompt} $" {
+	-re "Value returned has type: struct struct$n. Cannot determine contents.*${gdb_prompt} $" {
 	    # Expected bad value.  For the moment this is ok.
 	    set finish_value_known 0
 	    pass "${test}"


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