old-cross-binutils/gdb/testsuite/gdb.mi
Pedro Alves 901461f8eb Print registers not saved in the frame as "<not saved>" instead of "<optimized out>".
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers.  An <optimized out> register is a confusing
concept.  What this really means is that the register is
call-clobbered, or IOW, not saved by the callee.  This patch makes GDB
say that instead.

Before patch:

 (gdb) p/x $rax $1 = <optimized out>
 (gdb) info registers rax
 rax            <optimized out>

After patch:

 (gdb) p/x $rax
 $1 = <not saved>
 (gdb) info registers rax
 rax            <not saved>

However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable.  IOW, <not saved> is reserved for
inspecting registers at the machine level.  The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.

** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did.  Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.

frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.

value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits.  It isn't used for
anything else.  This function makes sure to return lval_register
values.  The patch makes "info registers" and the MI equivalent use it
too.  I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.

We're likely to need a different encoding at some point, if/when we
support partially saved registers.  Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.

value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.

Tested on x86_64 Fedora 17

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

	* cp-valprint.c (cp_print_value_fields): Adjust calls to
	val_print_optimized_out.
	* jv-valprint.c (java_print_value_fields): Likewise.
	* p-valprint.c (pascal_object_print_value_fields): Likewise.
	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
	<DWARF_VALUE_REGISTER>: If the register was not saved, return a
	new optimized out value.
	* findvar.c (address_from_register): Likewise.
	* frame.c (put_frame_register): Tweak error string to say the
	register was not saved, rather than optimized out.
	* infcmd.c (default_print_one_register_info): Adjust call to
	val_print_optimized_out.  Use value_of_register instead of
	get_frame_register_value.
	* mi/mi-main.c (output_register): Use value_of_register instead of
	get_frame_register_value.
	* valprint.c (valprint_check_validity): Likewise.
	(val_print_optimized_out): New value parameter.  If the value is
	lval_register, print <not saved> instead.
	(value_check_printable, val_print_scalar_formatted): Adjust calls
	to val_print_optimized_out.
	* valprint.h (val_print_optimized_out): New value parameter.
	* value.c (struct value) <optimized_out>: Extend comment.
	(error_value_optimized_out): New function.
	(require_not_optimized_out): Use it.  Use a different string for
	lval_register values.
	* value.h (error_value_optimized_out): New declaration.
	* NEWS: Mention <not saved>.

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

	* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
	pattern_rax_rbx_rcx_info>: Set to "<not saved>".
	* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
	(not_saved_pattern): New.
	Replace use of the former with the latter.

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

	* gdb.texinfo (Registers): Expand description of saved registers
	in frames.  Explain <not saved>.
2013-10-02 16:15:46 +00:00
..
array.f Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
basics.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
ChangeLog-1999-2003
dw2-ref-missing-frame-func.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
dw2-ref-missing-frame-main.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
dw2-ref-missing-frame.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
dw2-ref-missing-frame.S Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb669.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb680.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb701.c
gdb701.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb792.cc
gdb792.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb2549.exp * gdb.mi/gdb2549.exp (register_tests): Expect any decimal for 2013-07-06 02:32:31 +00:00
Makefile.in 2013-05-21 Hui Zhu <hui@codesourcery.com> 2013-05-21 04:18:55 +00:00
mi-async.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-basics.exp gdb/testsuite/ 2013-07-24 09:17:15 +00:00
mi-break.exp create_breapoint / explicit mode: Error out if there's garbage after the breakpoint location. 2013-04-08 14:09:30 +00:00
mi-breakpoint-changed.exp 2013-06-25 Yao Qi <yao@codesourcery.com> 2013-06-25 11:37:48 +00:00
mi-catch-load-so.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-catch-load.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-catch-load.exp 2013-01-21 Marc Khouzam <marc.khouzam@ericsson.com> 2013-01-21 23:58:00 +00:00
mi-cli.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-cmd-param-changed.exp gdb/ 2013-05-30 00:25:16 +00:00
mi-console.c
mi-console.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-disassemble.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-dprintf.c 2013-05-21 Hui Zhu <hui@codesourcery.com> 2013-05-21 04:18:55 +00:00
mi-dprintf.exp 2013-07-19 Hui Zhu <hui@codesourcery.com> 2013-07-19 07:26:46 +00:00
mi-eval.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-file-transfer.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-file.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-fill-memory.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-fullname-deleted.exp gdb/ 2013-02-03 16:00:36 +00:00
mi-hack-cli.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-info-os.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-inheritance-syntax-error.cc gdb/testsuite/ 2011-08-26 21:11:08 +00:00
mi-inheritance-syntax-error.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
mi-logging.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
mi-memory-changed.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-nonstop-exit.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-nonstop.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-ns-stale-regcache.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-nsintrall.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-nsmoribund.exp 2013-01-21 Marc Khouzam <marc.khouzam@ericsson.com> 2013-01-21 23:58:00 +00:00
mi-nsthrexec.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-pending.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-pending.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-pendshr.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-pthreads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-read-memory.c
mi-read-memory.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-record-changed.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-reg-undefined.c Resue 'z' formatter from mi register display code. 2013-07-25 10:39:39 +00:00
mi-reg-undefined.exp Print registers not saved in the frame as "<not saved>" instead of "<optimized out>". 2013-10-02 16:15:46 +00:00
mi-reg-undefined.S Resue 'z' formatter from mi register display code. 2013-07-25 10:39:39 +00:00
mi-regs.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-return.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-reverse.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
mi-simplerun.exp 2013-01-21 Marc Khouzam <marc.khouzam@ericsson.com> 2013-01-21 23:58:00 +00:00
mi-solib.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-stack.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-stack.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-stepi.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-stepn.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mi-stepn.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-syn-frame.c gdb/testsuite/ 2011-08-14 15:58:40 +00:00
mi-syn-frame.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-until.exp Tweak intro comments to some MI test files. 2013-02-12 16:36:07 +00:00
mi-var-block.exp 2013-01-24 Hafiz Abid Qadeer <abidh@codesourcery.com> 2013-01-24 10:29:09 +00:00
mi-var-child-f.exp * gdb.mi/mi-var-child-f.exp: Pass f90 to gdb_compile instead 2013-07-26 18:15:07 +00:00
mi-var-child.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-var-child.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-var-cmd.exp gdb/testsuite/ 2013-07-24 09:17:15 +00:00
mi-var-cp.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mi-var-cp.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
mi-var-create-rtti.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-var-create-rtti.exp * gdb.mi/mi-var-create-rtti.exp: Create a variable of 2013-04-18 10:08:08 +00:00
mi-var-display.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-var-invalidate.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-var-rtti.cc Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
mi-var-rtti.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
mi-watch-nonstop.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi-watch.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
mi2-amd64-entry-value.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi2-amd64-entry-value.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi2-amd64-entry-value.s Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi2-prompt.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
mi2-var-child.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-stop-exit.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-stop.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
ns-stale-regcache.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
nsintrall.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
nsmoribund.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
nsthrexec.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pending.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pendshr1.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pendshr2.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pr11022.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
pr11022.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
pthreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
solib-lib.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
solib-main.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
testcmds
until.c
var-cmd.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watch-nonstop.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00