Re: [RFC 06/12] entryval: Display @entry parameters in bt full

Jan Kratochvil
2011-08-03T18:13:16Z

Extended by `set print entry-values default' (which is more backward
compatible) vs. the changed `compact' output as suggested by Jakub.

On Wed, 03 Aug 2011 19:53:29 +0200, Jan Kratochvil wrote:

Extended by `set print entry-values if-needed' as suggested (not its name)
by Jakub.

On Wed, 03 Aug 2011 19:27:25 +0200, Jan Kratochvil wrote:

On Tue, 19 Jul 2011 13:41:48 +0200, Jakub Jelinek wrote:
> There are several possibilities of what info may be available for
> a parameter:

> 1) the entry value as well as current value of the parameter are known
> and known to be equal
="equal"

> 2) both entry value and current value of the parameter are known, but are
> different
="different" variable "i" (or variable "j")

> 3) only entry value is known, current value is optimized out
="validity" parameter "lost"

> 4) only current value is known, entry value isn't provided (the value
> passed to the function in the caller wasn't saved in any call saved
> register or memory slot and wasn't constant, or the compiler didn't
> provide call site info for it)
="validity" parameter "born"

> 5) neither the entry value nor current value are known (both are
> optimized out)
="invalid"

> It might be a good idea to give the user for backtraces the ability
> to say his preference what kind of values he would like to see and what
> information should be printed in all of the above cases,

Such full configurability would have about 5 GDB `set' variables and it would
not be convenient to choose the practical possibilities from all of those.
Most of its combinations would not make sense. If there is an idea for
a useful new behavior GDB can be easily extended for it.

Is there an agreement upon the output below? `set print entry-values both'
shows the real program state. `set print entry-values default' should be the
default option. `set print entry-values preferred' may be possibly the choice
for some backtraces. I would like an approval before I rebuild the testfile
with it again.

The output possibilities are currently limited by the fact that there is no
reliable possibility to distinguish CU (Compilation Unit) which was compiled
without entry-values support (old gcc -g or new gcc -O0 -g; remember only new
gcc -O -g produces entry-values) vs. CU in which there was no valid info to
create at least one DW_TAG_GNU_call_site with. The default settings must
therefore suppress any @entry values output for -O0 -g CUs - it would be very
inconvenient to start printing p=1, p@entry=<optimized out> for all the
parameters in -O0 -g CUs. Whether GDB could differentiate such old CU vs. new
CU with all call sites <optimized out> is a different question, Jakub did not
recommend to differentiate it.

(For MI there proposing a new separate list "args_entry" besides the current
"args" list so there is nothing to talk about, it always acts as "set print
entry-values both", it can be reviewed later in the patch.)

Thanks,
Jan

set print entry-values no
Print only actual parameter values, never print values from function entry
point.

different
#0 d (i=31, j=31.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost=<optimized out>, born=10) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, j=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values only
Print only parameter values from function entry point. The actual parameter
values are never printed.

different
#0 d (i@entry=30, j@entry=30.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost@entry=5, born@entry=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i@entry=<optimized out>, j@entry=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i@entry=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values preferred
Print only parameter values from function entry point. If value from function
entry point is not known while the actual value is known print at least the
actual value for such parameter.

different
#0 d (i@entry=30, j@entry=30.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost@entry=5, born=10) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, j=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i@entry=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values if-needed
Print actual parameter values. If actual parameter value is not known while
value from function entry point is known print at least the entry point value
for such parameter.

different
#0 d (i=31, j=31.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost@entry=5, born=10) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, j=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values both
Always print both the actual parameter value and its value from function entry
point. Still print both even if one of them or both are <optimized out>.

different
#0 d (i=31, i@entry=30, j=31.5, j@entry=30.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost=<optimized out>, lost@entry=5, born=10, born@entry=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, i@entry=<optimized out>, j=<optimized out>, j@entry=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i=100, i@entry=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values compact
Print the actual parameter value if it is know and also its value from
function entry point if it is known. If neither is known print for the actual
value <optimized out>. If both values are known and they are equal print the
shortened param=param@entry=VALUE notation.

different
#0 d (i=31, i@entry=30, j=31.5, j@entry=30.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost@entry=5, born=10) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, j=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i=i@entry=100) at ./gdb.arch/amd64-entry-value.cc:98

set print entry-values default
Always print the actual parameter value. Print also its value from function
entry point but only if it is known. If both values are known and they are
equal print the shortened param=param@entry=VALUE notation.

different
#0 d (i=31, i@entry=30, j=31.5, j@entry=30.5) at ./gdb.arch/amd64-entry-value.cc:34
validity
#0 validity (lost=<optimized out>, lost@entry=5, born=10) at ./gdb.arch/amd64-entry-value.cc:166
invalid
#0 d (i=<optimized out>, j=<optimized out>) at ./gdb.arch/amd64-entry-value.cc:34
equal
#5 0x00000000004006f5 in amb_a (i=i@entry=100) at ./gdb.arch/amd64-entry-value.cc:98