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]

<value optimized out>, <optimized out>


Some places print "<value optimized out>", others print "<optimized out>".

Factor this out into a function that does the actual printing.
This ends up with only "<optimized out>" (drops the "value"
everywhere) just because I preferred the shorter string (errr, fits
more on the screen).  I don't think we lose anything by not
actually spelling out saying "value".  

Any objections?

The actual initial reason that made want to factor this out,
was to be able to easily set a breakpoint at the place
we are about to print an optimized out value...  The second
initial reason, is that I'll be adding a val_print_unavailable
function that similarly, just prints "<unavailable>".

No regressions on x86_64-linux.

-- 
Pedro Alves

2011-01-24  Pedro Alves  <pedro@codesourcery.com>

	Centralized printing "<optimized out>".

	gdb/
	* valprint.h (val_print_optimized_out): Declare.
	* cp-valprint.c (cp_print_value_fields): Use
	val_print_optimized_out.
	* jv-valprint.c (java_print_value_fields): Ditto.
	* p-valprint.c (pascal_object_print_value_fields): Ditto.
	* printcmd.c (print_formatted): Ditto.
	* valprint.c (valprint_check_validity): Ditto.
	(value_check_printable): Ditto.
	(val_print_optimized_out): New.

	gdb/doc/
	* gdb.texinfo: s/value optimized out/optimized out/g

	gdb/testsuite/
	* gdb.base/frame-args.exp: Adjust.
	* gdb.dwarf2/dw2-noloc.exp: Adjust.
	* gdb.dwarf2/dw2-inline-param.exp: Adjust.
	* gdb.dwarf2/pieces.exp: Adjust.
	* gdb.opt/clobbered-registers-O2.exp: Adjust.
	* gdb.opt/inline-locals.exp: Adjust.
	* gdb.threads/fork-child-threads.exp: Adjust.

---
 gdb/cp-valprint.c                                |    4 +--
 gdb/doc/gdb.texinfo                              |    8 +++----
 gdb/jv-valprint.c                                |    4 +--
 gdb/p-valprint.c                                 |    4 +--
 gdb/testsuite/gdb.base/frame-args.exp            |    2 -
 gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp    |    2 -
 gdb/testsuite/gdb.dwarf2/dw2-noloc.exp           |   26 +++++++++++------------
 gdb/testsuite/gdb.dwarf2/pieces.exp              |    2 -
 gdb/testsuite/gdb.opt/clobbered-registers-O2.exp |    4 +--
 gdb/testsuite/gdb.opt/inline-locals.exp          |    4 +--
 gdb/testsuite/gdb.threads/fork-child-threads.exp |    2 -
 gdb/valprint.c                                   |   10 +++++++-
 gdb/valprint.h                                   |    2 +
 13 files changed, 41 insertions(+), 33 deletions(-)

Index: src/gdb/cp-valprint.c
===================================================================
--- src.orig/gdb/cp-valprint.c	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/cp-valprint.c	2011-01-24 22:06:58.517639997 +0000
@@ -316,7 +316,7 @@ cp_print_value_fields (struct type *type
 					  TYPE_FIELD_BITPOS (type, i),
 					  TYPE_FIELD_BITSIZE (type, i)))
 		{
-		  fputs_filtered (_("<value optimized out>"), stream);
+		  val_print_optimized_out (stream);
 		}
 	      else
 		{
@@ -343,7 +343,7 @@ cp_print_value_fields (struct type *type
 		  struct value *v = value_static_field (type, i);
 
 		  if (v == NULL)
-		    fputs_filtered ("<optimized out>", stream);
+		    val_print_optimized_out (stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i),
 					   v, stream, recurse + 1,
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/doc/gdb.texinfo	2011-01-24 22:06:58.527639998 +0000
@@ -5951,7 +5951,7 @@ only if it is a scalar (integer, pointer
 @kbd{set print frame-arguments} in @ref{Print Settings} for more details
 on how to configure the way function parameter values are printed.
 
-@cindex value optimized out, in backtrace
+@cindex optimized out, in backtrace
 @cindex function call arguments, optimized out
 If your program was compiled with optimizations, some compilers will
 optimize away arguments passed to functions if those arguments are
@@ -5965,8 +5965,8 @@ such a backtrace might look like:
 @group
 #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
     at builtin.c:993
-#1  0x6e38 in expand_macro (sym=<value optimized out>) at macro.c:242
-#2  0x6840 in expand_token (obs=0x0, t=<value optimized out>, td=0xf7fffb08)
+#1  0x6e38 in expand_macro (sym=<optimized out>) at macro.c:242
+#2  0x6840 in expand_token (obs=0x0, t=<optimized out>, td=0xf7fffb08)
     at macro.c:71
 (More stack frames follow...)
 @end group
@@ -5974,7 +5974,7 @@ such a backtrace might look like:
 
 @noindent
 The values of arguments that were not saved in their stack frames are
-shown as @samp{<value optimized out>}.
+shown as @samp{<optimized out>}.
 
 If you need to display the values of such optimized-out arguments,
 either deduce that from other variables whose values depend on the one
Index: src/gdb/jv-valprint.c
===================================================================
--- src.orig/gdb/jv-valprint.c	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/jv-valprint.c	2011-01-24 22:06:58.537640002 +0000
@@ -407,7 +407,7 @@ java_print_value_fields (struct type *ty
 	      else if (!value_bits_valid (val, TYPE_FIELD_BITPOS (type, i),
 					  TYPE_FIELD_BITSIZE (type, i)))
 		{
-		  fputs_filtered (_("<value optimized out>"), stream);
+		  val_print_optimized_out (stream);
 		}
 	      else
 		{
@@ -434,7 +434,7 @@ java_print_value_fields (struct type *ty
 		  struct value *v = value_static_field (type, i);
 
 		  if (v == NULL)
-		    fputs_filtered ("<optimized out>", stream);
+		    val_print_optimized_out (stream);
 		  else
 		    {
 		      struct value_print_options opts;
Index: src/gdb/p-valprint.c
===================================================================
--- src.orig/gdb/p-valprint.c	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/p-valprint.c	2011-01-24 22:06:58.537640002 +0000
@@ -810,7 +810,7 @@ pascal_object_print_value_fields (struct
 	      else if (!value_bits_valid (val, TYPE_FIELD_BITPOS (type, i),
 					  TYPE_FIELD_BITSIZE (type, i)))
 		{
-		  fputs_filtered (_("<value optimized out>"), stream);
+		  val_print_optimized_out (stream);
 		}
 	      else
 		{
@@ -842,7 +842,7 @@ pascal_object_print_value_fields (struct
 		     unpack_field_as_long (type, valaddr + offset, i));
 
 		  if (v == NULL)
-		    fputs_filtered ("<optimized out>", stream);
+		    val_print_optimized_out (stream);
 		  else
 		    pascal_object_print_static_field (v, stream, recurse + 1,
 						      options);
Index: src/gdb/testsuite/gdb.base/frame-args.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/frame-args.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.base/frame-args.exp	2011-01-24 22:06:58.537640002 +0000
@@ -40,7 +40,7 @@ if ![runto break_me] then {
 gdb_test_no_output "set print frame-arguments all" \
          "set print frame-arguments all"
 gdb_test "frame 1" \
-         ".*in call_me \\(i=3, f=5, s=({a = 3, b = 5}|<value optimized out>), ss=0x\[0-9a-f\]\+, u=({.*}|<value optimized out>), e=green\\) at .*frame-args\\.c:.*" \
+         ".*in call_me \\(i=3, f=5, s=({a = 3, b = 5}|<optimized out>), ss=0x\[0-9a-f\]\+, u=({.*}|<optimized out>), e=green\\) at .*frame-args\\.c:.*" \
          "frame 1 with print frame-arguments set to all"
 
 # Test with "print frame-arguments" set to "scalars"
Index: src/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	2011-01-24 22:06:58.537640002 +0000
@@ -46,16 +46,16 @@ proc file_symbols {type} {
     gdb_test "print file_locaddr_unresolvable" "= 1234567890"
     gdb_test "ptype file_locaddr_unresolvable" "type = int"
 
-    gdb_test "print file_locempty_resolvable" "= <value optimized out>"
+    gdb_test "print file_locempty_resolvable" "= <optimized out>"
     gdb_test "ptype file_locempty_resolvable" "type = int"
 
-    gdb_test "print file_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "print file_locempty_unresolvable" "= <optimized out>"
     gdb_test "ptype file_locempty_unresolvable" "type = int"
 
-    gdb_test "print file_locno_resolvable" "= <value optimized out>"
+    gdb_test "print file_locno_resolvable" "= <optimized out>"
     gdb_test "ptype file_locno_resolvable" "type = int"
 
-    gdb_test "print file_locno_unresolvable" "= <value optimized out>"
+    gdb_test "print file_locno_unresolvable" "= <optimized out>"
     gdb_test "ptype file_locno_unresolvable" "type = int"
 
     gdb_test "print file_extern_locaddr_resolvable" "= 1234567890"
@@ -64,10 +64,10 @@ proc file_symbols {type} {
     gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890"
     gdb_test "ptype file_extern_locaddr_unresolvable" "type = int"
 
-    gdb_test "print file_extern_locempty_resolvable" "= <value optimized out>"
+    gdb_test "print file_extern_locempty_resolvable" "= <optimized out>"
     gdb_test "ptype file_extern_locempty_resolvable" "type = int"
 
-    gdb_test "print file_extern_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "print file_extern_locempty_unresolvable" "= <optimized out>"
     gdb_test "ptype file_extern_locempty_unresolvable" "type = int"
 
     gdb_test "print file_extern_locno_resolvable" "= 1234567890"
@@ -76,7 +76,7 @@ proc file_symbols {type} {
     # `print file_extern_locno_unresolvable' currently prints
     # Address of symbol "file_extern_locno_unresolvable" is unknown.
     # As DW_AT_declaration is not present in this DIE
-    # it should print <value optimized out>.  As usefulness of such DIE is not
+    # it should print <optimized out>.  As usefulness of such DIE is not
     # clear its resolution is not being tested.
 
     set pf_prefix $old_prefix
@@ -97,16 +97,16 @@ gdb_test "ptype main_local_locaddr_resol
 gdb_test "print main_local_locaddr_unresolvable" "= 1234567890"
 gdb_test "ptype main_local_locaddr_unresolvable" "type = int"
 
-gdb_test "print main_local_locempty_resolvable" "= <value optimized out>"
+gdb_test "print main_local_locempty_resolvable" "= <optimized out>"
 gdb_test "ptype main_local_locempty_resolvable" "type = int"
 
-gdb_test "print main_local_locempty_unresolvable" "= <value optimized out>"
+gdb_test "print main_local_locempty_unresolvable" "= <optimized out>"
 gdb_test "ptype main_local_locempty_unresolvable" "type = int"
 
-gdb_test "print main_local_locno_resolvable" "= <value optimized out>"
+gdb_test "print main_local_locno_resolvable" "= <optimized out>"
 gdb_test "ptype main_local_locno_resolvable" "type = int"
 
-gdb_test "print main_local_locno_unresolvable" "= <value optimized out>"
+gdb_test "print main_local_locno_unresolvable" "= <optimized out>"
 gdb_test "ptype main_local_locno_unresolvable" "type = int"
 
 gdb_test "print main_extern_locaddr_resolvable" "= 1234567890"
@@ -115,10 +115,10 @@ gdb_test "ptype main_extern_locaddr_reso
 gdb_test "print main_extern_locaddr_unresolvable" "= 1234567890"
 gdb_test "ptype main_extern_locaddr_unresolvable" "type = int"
 
-gdb_test "print main_extern_locempty_resolvable" "= <value optimized out>"
+gdb_test "print main_extern_locempty_resolvable" "= <optimized out>"
 gdb_test "ptype main_extern_locempty_resolvable" "type = int"
 
-gdb_test "print main_extern_locempty_unresolvable" "= <value optimized out>"
+gdb_test "print main_extern_locempty_unresolvable" "= <optimized out>"
 gdb_test "ptype main_extern_locempty_unresolvable" "type = int"
 
 gdb_test "print main_extern_locno_resolvable" "= 1234567890"
Index: src/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp	2011-01-24 22:06:58.537640002 +0000
@@ -53,12 +53,12 @@ if { ![runto start_sequence] } then {
 gdb_test "frame 1" "#1.*in gen_movsd.*" "Backtracing"
 
 gdb_test_multiple "print operand0" "print operand0" {
-    -re "\\\$$decimal = <value optimized out>\r\n$gdb_prompt $" { pass "print operand0"}
+    -re "\\\$$decimal = <optimized out>\r\n$gdb_prompt $" { pass "print operand0"}
     -re "$hex\r\n$gdb_prompt $" { gdb_test "print *operand0" "13" "print operand0" }
 }
 
 gdb_test_multiple "print operand1" "print operand1" {
-    -re "\\\$$decimal = <value optimized out>\r\n$gdb_prompt $" { pass "print operand1"}
+    -re "\\\$$decimal = <optimized out>\r\n$gdb_prompt $" { pass "print operand1"}
     -re "$hex\r\n$gdb_prompt $" { gdb_test "print *operand1" "14" "print operand1" }
 }
 
Index: src/gdb/testsuite/gdb.opt/inline-locals.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.opt/inline-locals.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.opt/inline-locals.exp	2011-01-24 22:06:58.537640002 +0000
@@ -62,7 +62,7 @@ if { ! $no_frames } {
 	-re "arg1 = $decimal\r\n$gdb_prompt $" {
 	    pass $msg
 	}
-	-re "arg1 = <value optimized out>\r\n$gdb_prompt $" {
+	-re "arg1 = <optimized out>\r\n$gdb_prompt $" {
 	    # GCC 4.3 and later lose location information for arg1.  GCC 4.2 is OK.
 	    if { [test_compiler_info "gcc-4-3-*"]  || [test_compiler_info "gcc-4-4-*"]} {
 		setup_xfail *-*-*
@@ -101,7 +101,7 @@ if { ! $no_frames } {
 	-re "arg1 = $decimal\r\n$gdb_prompt $" {
 	    pass $msg
 	}
-	-re "arg1 = <value optimized out>\r\n$gdb_prompt $" {
+	-re "arg1 = <optimized out>\r\n$gdb_prompt $" {
 	    # GCC 4.3 and later lose location information for arg1.  GCC 4.2 is OK.
 	    if { [test_compiler_info "gcc-4-3-*"]  || [test_compiler_info "gcc-4-4-*"]} {
 		setup_xfail *-*-*
Index: src/gdb/testsuite/gdb.threads/fork-child-threads.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.threads/fork-child-threads.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.threads/fork-child-threads.exp	2011-01-24 22:06:58.547639998 +0000
@@ -52,6 +52,6 @@ gdb_test "continue" "Breakpoint 2, start
 # * 2 LWP 4466  start (arg=0x0) at fork-child-threads.c:28
 # Correct:
 # * 3 Thread 0x40a00950 (LWP 5553)  start (arg=0x0) at ../.././gdb/testsuite/gdb.threads/fork-child-threads.c:28
-#   2 Thread 0x2aaaaaac3000 (LWP 5552)  0x00000031674076dd in pthread_join (threadid=<value optimized out>, thread_return=<value optimized out>) at pthread_join.c:89
+#   2 Thread 0x2aaaaaac3000 (LWP 5552)  0x00000031674076dd in pthread_join (threadid=<optimized out>, thread_return=<optimized out>) at pthread_join.c:89
 
 gdb_test "info threads" " Thread .* Thread .*" "two threads found"
Index: src/gdb/valprint.c
===================================================================
--- src.orig/gdb/valprint.c	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/valprint.c	2011-01-24 22:06:58.547639998 +0000
@@ -272,7 +272,7 @@ valprint_check_validity (struct ui_file
       if (! value_bits_valid (val, TARGET_CHAR_BIT * offset,
 			      TARGET_CHAR_BIT * TYPE_LENGTH (type)))
 	{
-	  fprintf_filtered (stream, _("<value optimized out>"));
+	  val_print_optimized_out (stream);
 	  return 0;
 	}
 
@@ -287,6 +287,12 @@ valprint_check_validity (struct ui_file
   return 1;
 }
 
+void
+val_print_optimized_out (struct ui_file *stream)
+{
+  fprintf_filtered (stream, _("<optimized out>"));
+}
+
 /* Print using the given LANGUAGE the data of type TYPE located at VALADDR
    (within GDB), which came from the inferior at address ADDRESS, onto
    stdio stream STREAM according to OPTIONS.
@@ -378,7 +384,7 @@ value_check_printable (struct value *val
 
   if (value_entirely_optimized_out (val))
     {
-      fprintf_filtered (stream, _("<value optimized out>"));
+      val_print_optimized_out (stream);
       return 0;
     }
 
Index: src/gdb/valprint.h
===================================================================
--- src.orig/gdb/valprint.h	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/valprint.h	2011-01-24 22:44:11.777640008 +0000
@@ -145,4 +145,6 @@ int read_string (CORE_ADDR addr, int len
 		 enum bfd_endian byte_order, gdb_byte **buffer,
 		 int *bytes_read);
 
+extern void val_print_optimized_out (struct ui_file *stream);
+
 #endif
Index: src/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp	2011-01-24 22:06:31.000000000 +0000
+++ src/gdb/testsuite/gdb.dwarf2/dw2-inline-param.exp	2011-01-24 22:06:58.547639998 +0000
@@ -57,4 +57,4 @@ if ![runto "*${break_at}"] {
     return -1
 }
 
-gdb_test "bt" "#0  (0x\[0-9a-f\]+ in )?func \\(funcparam=<value optimized out>\\)\r\n#1  main \\(mainparam=<value optimized out>\\)\[^\r\n\]*"
+gdb_test "bt" "#0  (0x\[0-9a-f\]+ in )?func \\(funcparam=<optimized out>\\)\r\n#1  main \\(mainparam=<optimized out>\\)\[^\r\n\]*"
Index: src/gdb/testsuite/gdb.dwarf2/pieces.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.dwarf2/pieces.exp	2011-01-20 16:21:11.000000000 +0000
+++ src/gdb/testsuite/gdb.dwarf2/pieces.exp	2011-01-24 22:42:21.807639994 +0000
@@ -82,7 +82,7 @@ proc pieces_test_f6 {} {
        "set f6 breakpoint for pieces"
     gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
     gdb_test "print a" \
-	" = {i = 7, j = 8, q = .value optimized out.}" \
+	" = {i = 7, j = 8, q = .optimized out.}" \
 	"print a with optimized out piece"
     # Note: no warning for this case.
     gdb_test_multiple "print a.i" \


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