binutils-gdb/gdb/testsuite/gdb.cp
Pedro Alves 686d4defdf Print nonexisting/optimized out static fields gracefully.
With:

 struct static_struct { static int aaa; };
 struct static_struct sss;
 int main () { return 0; }

We get:

 (gdb) p sss
 $1 = {static aaa = <optimized out>}
 (gdb) p sss.aaa
 field aaa is nonexistent or has been optimized out

Note that the "field aaa ..." message is an error being thrown.

GDB is graceful everywhere else when printing optimized out values.
IOW it usually prints an <optimized out> value and puts that in the
value history.  I see no reason for here to be different, more so that
when the print the whole "containing" object (well, it's a static
field, so it's not really a container), we already print <optimized
out>.

After the patch:

 (gdb) p sss
 $1 = {static aaa = <optimized out>}
 (gdb) p sss.aaa
 $2 = <optimized out>

The value_entirely_optimized_out checks are there to preserve
behavior.  Without those, if the static field is a struct/union, GDB
would go and print its fields one by one (and print <optimized out>
for each).

Tested on x86_64 Fedora 17.

gdb/
2013-10-25  Pedro Alves  <palves@redhat.com>

	* cp-valprint.c (cp_print_value_fields): No longer handle a NULL
	static field value.
	(cp_print_static_field): If the value is entirely optimized out,
	print <optimized out> here.
	* jv-valprint.c (java_print_value_fields): No longer handle a NULL
	static field value.
	* p-valprint.c (pascal_object_print_static_field): If the value is
	entirely optimized out, print <optimized out> here.
	* valops.c (do_search_struct_field)
	(value_struct_elt_for_reference): No longer handle a NULL static
	field value.
	* value.c (value_static_field): Return an optimized out value
	instead of NULL.

gdb/testsuite/
2013-10-25  Pedro Alves  <palves@redhat.com>

	* gdb.cp/m-static.exp: Adjust expected output of printing a
	nonexistent or optimized out static field.  Also test printing the
	the "container" object.
2013-10-25 14:03:01 +00:00
..
abstract-origin.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
abstract-origin.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ambiguous.cc
ambiguous.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
annota2.cc
annota2.exp gdb/testsuite/gdb.cp/annota2.exp: Add missing empty line 2013-06-07 08:51:42 +00:00
annota3.cc
annota3.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
anon-ns.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
anon-ns.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
anon-struct.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
anon-struct.exp gdb/testsuite/gdb.cp: Fix tests for ARM C++ ABI. 2013-06-07 08:47:09 +00:00
anon-union.cc
anon-union.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arg-reference.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
arg-reference.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
baseenum.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
baseenum.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bool.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bool.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
breakpoint.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
breakpoint.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
bs15503.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
bs15503.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
call-c-1.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
call-c.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
call-c.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
casts.cc
casts.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
class2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
class2.exp PR c++/15401: 2013-05-22 20:51:49 +00:00
classes.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
classes.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cmpd-minsyms.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cmpd-minsyms.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
converts.cc * gdb.cp/converts.cc (main): Initialize 'a'. 2013-01-23 20:34:22 +00:00
converts.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cp-relocate.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cp-relocate.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cpcompletion.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cpexprs.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cpexprs.exp PR exp/15109: 2013-03-21 15:19:33 +00:00
cplabel.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
cplabel.exp 2013-04-04 Sandra Loosemore <sandra@codesourcery.com> 2013-04-04 21:01:40 +00:00
cplusfuncs.cc
cplusfuncs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ctti.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
cttiadd.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
cttiadd1.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
cttiadd2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
cttiadd3.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
debug-expr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
demangle.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
derivation.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
derivation.exp * gdb.cp/derivation.exp: Make tests have unique names. 2013-06-06 19:02:27 +00:00
derivation2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
destrprint.cc
destrprint.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
dispcxx.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
dispcxx.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
exception.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
exception.exp PR c++/12824: 2013-04-15 17:27:44 +00:00
exceptprint.cc PR c++/15176: 2013-04-15 18:09:02 +00:00
exceptprint.exp PR c++/13588: 2013-04-15 18:13:01 +00:00
expand-psymtabs-cxx.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
expand-psymtabs-cxx.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
expand-sals.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
expand-sals.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
extern-c.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
extern-c.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
formatted-ref.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
formatted-ref.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
fpointer.cc
fpointer.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb1355.cc
gdb1355.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
gdb2384-base.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
gdb2384-base.h Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
gdb2384.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
gdb2384.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb2495.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
gdb2495.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
hang.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
hang.H
hang1.cc
hang2.cc
hang3.cc
infcall-dlopen-lib.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
infcall-dlopen.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
infcall-dlopen.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
inherit.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
koenig.cc
koenig.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
local.cc
local.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
m-data.cc
m-data.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
m-static.cc PR c++/9197: 2013-03-25 17:26:18 +00:00
m-static.exp Print nonexisting/optimized out static fields gracefully. 2013-10-25 14:03:01 +00:00
m-static.h
m-static1.cc
maint.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
Makefile.in
mb-ctor.cc
mb-ctor.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mb-inline.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
mb-inline.h Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mb-inline1.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mb-inline2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mb-templates.cc
mb-templates.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
member-name.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
member-name.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
member-ptr.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
member-ptr.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
meth-typedefs.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
meth-typedefs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
method.cc
method.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
method2.cc
method2.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
minsym-fallback-main.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
minsym-fallback.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
minsym-fallback.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
minsym-fallback.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
misc.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
misc.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
namespace-enum-main.cc
namespace-enum.cc
namespace-enum.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
namespace-nested-import.cc
namespace-nested-import.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
namespace.cc
namespace.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
namespace1.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
nextoverthrow.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
nextoverthrow.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
no-dmgl-verbose.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
no-dmgl-verbose.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
noparam.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
noparam.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsdecl.cc
nsdecl.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
nsimport.cc
nsimport.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsnested.cc
nsnested.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsnoimports.cc
nsnoimports.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsrecurs.cc
nsrecurs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsstress.cc
nsstress.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
nsusing.cc
nsusing.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
operator.cc
operator.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
oranking.cc
oranking.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
overload-const.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
overload-const.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
overload.cc PR c++/15116: 2013-03-15 17:10:45 +00:00
overload.exp PR c++/15116: 2013-03-15 17:10:45 +00:00
ovldbreak.cc
ovldbreak.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ovsrch.exp 2013-04-02 Sandra Loosemore <sandra@codesourcery.com> 2013-04-03 01:40:19 +00:00
ovsrch.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ovsrch1.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ovsrch2.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ovsrch3.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ovsrch4.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
paren-type.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
paren-type.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
parse-lang.cc gdb/ 2013-01-13 18:57:01 +00:00
parse-lang.exp gdb/ 2013-01-13 18:57:01 +00:00
pass-by-ref.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pass-by-ref.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr-574.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
pr-574.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr-1023.cc
pr-1023.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr-1210.cc
pr-1210.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr9067.cc
pr9067.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr9167.cc
pr9167.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr9594.cc
pr9631.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
pr9631.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr10687.cc
pr10687.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr10728-x.cc
pr10728-x.h
pr10728-y.cc
pr10728.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
pr12028.cc
pr12028.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
printmethod.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
printmethod.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
psmang.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
psmang1.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
psmang2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
psymtab-parameter.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
psymtab-parameter.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype-cv-cp.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype-cv-cp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ptype-flags.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
ptype-flags.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
punctuator.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
re-set-overloaded.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
re-set-overloaded.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
readnow-language.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
readnow-language.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref-params.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
ref-params.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ref-types.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
ref-types.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rtti.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rtti.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rtti1.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
rtti2.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
shadow.cc
shadow.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
smartp.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
smartp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
static-method.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
static-method.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
static-print-quit.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
static-print-quit.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
temargs.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
temargs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
templates.cc
templates.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
try_catch.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
try_catch.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
typedef-operator.cc Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
typedef-operator.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
typeid.cc PR c++/9065: 2013-04-15 17:36:14 +00:00
typeid.exp PR c++/9065: 2013-04-15 17:36:14 +00:00
userdef.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
userdef.exp Fix ptype bug actually exercised in userdef.exp 2013-02-14 12:43:46 +00:00
using-crash.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
using-crash.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
virtbase.cc
virtbase.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
virtfunc.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
virtfunc.exp * gdb.cp/virtfunc.exp (make_one_vtable_result): Handle extra output 2013-06-05 20:38:37 +00:00
virtfunc2.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
virtfunc2.exp Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00