* Changed commands
+print
+ Printing of floating-point values with base-modifying formats like
+ /x has been changed to display the underlying bytes of the value in
+ the desired base. This was GDB's documented behavior, but was never
+ implemented correctly.
+
maint packet
This command can now print a reply, if the reply includes
non-printable characters. Any non-printable characters are printed
@table @code
@item x
-Regard the bits of the value as an integer, and print the integer in
-hexadecimal.
+Print the binary representation of the value in hexadecimal.
@item d
-Print as integer in signed decimal.
+Print the binary representation of the value in decimal.
@item u
-Print as integer in unsigned decimal.
+Print the binary representation of the value as an decimal, as if it
+were unsigned.
@item o
-Print as integer in octal.
+Print the binary representation of the value in octal.
@item t
-Print as integer in binary. The letter @samp{t} stands for ``two''.
-@footnote{@samp{b} cannot be used because these format letters are also
-used with the @code{x} command, where @samp{b} stands for ``byte'';
-see @ref{Memory,,Examining Memory}.}
+Print the binary representation of the value in binary. The letter
+@samp{t} stands for ``two''. @footnote{@samp{b} cannot be used
+because these format letters are also used with the @code{x} command,
+where @samp{b} stands for ``byte''; see @ref{Memory,,Examining
+Memory}.}
@item a
@cindex unknown address, locating
@xref{Symbols, info symbol}.
@item c
-Regard as an integer and print it as a character constant. This
-prints both the numerical value and its character representation. The
-character representation is replaced with the octal escape @samp{\nnn}
-for characters outside the 7-bit @sc{ascii} range.
+Cast the value to an integer (unlike other formats, this does not just
+reinterpret the underlying bits) and print it as a character constant.
+This prints both the numerical value and its character representation.
+The character representation is replaced with the octal escape
+@samp{\nnn} for characters outside the 7-bit @sc{ascii} range.
Without this format, @value{GDBN} displays @code{char},
@w{@code{unsigned char}}, and @w{@code{signed char}} data as character
len = newlen;
}
- /* Historically gdb has printed floats by first casting them to a
- long, and then printing the long. PR cli/16242 suggests changing
- this to using C-style hex float format.
-
- Biased range types and sub-word scalar types must also be handled
+ /* Biased range types and sub-word scalar types must be handled
here; the value is correctly computed by unpack_long. */
gdb::byte_vector converted_bytes;
/* Some cases below will unpack the value again. In the biased
range case, we want to avoid this, so we store the unpacked value
here for possible use later. */
gdb::optional<LONGEST> val_long;
- if (((type->code () == TYPE_CODE_FLT
- || is_fixed_point_type (type))
+ if ((is_fixed_point_type (type)
&& (options->format == 'o'
|| options->format == 'x'
|| options->format == 't'
/* -- */
+float f_var = 65.0f;
+
int main ()
{
void *p = malloc (1);
# Regression test for PR gdb/21675
proc test_radices {} {
gdb_test "print/o 16777211" " = 077777773"
- gdb_test "print/d 1.5" " = 1"
- gdb_test "print/u 1.5" " = 1"
+
+ # This is written in a somewhat funny way to avoid assuming a
+ # particular float format.
+ set s_int [get_sizeof int -1]
+ set s_float [get_sizeof float -1]
+ if {$s_int == $s_float && $s_int != -1} {
+ foreach fmt {d u x t o} {
+ set ival [get_valueof "/$fmt" "*(int *) &f_var" "FAIL" \
+ "get_valueof int/$fmt"]
+ set fval [get_valueof "/$fmt" f_var "FAIL" \
+ "get_valueof float/$fmt"]
+ # See PR gdb/16242 for this.
+ if {[string compare $ival $fval] == 0 && $ival != "FAIL"} {
+ pass "print/$fmt f_var"
+ } else {
+ fail "print/$fmt f_var"
+ }
+ }
+ }
+
+ gdb_test "print/c f_var" " = 65 'A'"
gdb_test "print/u (char) -1" " = 255"
gdb_test "print/d (unsigned char) -1" " = -1"
"advance to marker"
# And if it returned the full width of the result.
- gdb_test "print /d t" " = -1" "full width of the returned result"
+ if {$type == "float" || $type == "double"} {
+ set flag ""
+ } else {
+ set flag "/d"
+ }
+ gdb_test "print $flag t" " = -1" "full width of the returned result"
}
}
}