* valprint.c (val_print_string): Don't print leading space.

* p-valprint.c (pascal_val_print) <TYPE_CODE_PTR>: Optionally
	print space before string or vtbl.
	* m2-valprint.c (print_unpacked_pointer): Optionally print space
	before string.
	* jv-valprint.c (java_value_print): Print space before string.
	* go-valprint.c (print_go_string): Print space before string.
	* f-valprint.c (f_val_print) <TYPE_CODE_PTR>: Optionally print
	space before string.
	* c-valprint.c (c_val_print) <TYPE_CODE_PTR>: Optionally print
	space before string or vtbl.
	* auxv.c (fprint_target_auxv): Print space after address.
This commit is contained in:
Tom Tromey 2012-05-18 15:29:13 +00:00
parent 1d51a733d5
commit b012acddd8
11 changed files with 83 additions and 18 deletions

View File

@ -1,3 +1,18 @@
2012-05-18 Tom Tromey <tromey@redhat.com>
* valprint.c (val_print_string): Don't print leading space.
* p-valprint.c (pascal_val_print) <TYPE_CODE_PTR>: Optionally
print space before string or vtbl.
* m2-valprint.c (print_unpacked_pointer): Optionally print space
before string.
* jv-valprint.c (java_value_print): Print space before string.
* go-valprint.c (print_go_string): Print space before string.
* f-valprint.c (f_val_print) <TYPE_CODE_PTR>: Optionally print
space before string.
* c-valprint.c (c_val_print) <TYPE_CODE_PTR>: Optionally print
space before string or vtbl.
* auxv.c (fprint_target_auxv): Print space after address.
2012-05-18 Tom Tromey <tromey@redhat.com>
* printcmd.c (print_address_demangle): Remove special case for 0.

View File

@ -483,7 +483,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
get_user_print_options (&opts);
if (opts.addressprint)
fprintf_filtered (file, "%s", paddress (target_gdbarch, val));
fprintf_filtered (file, "%s ", paddress (target_gdbarch, val));
val_print_string (builtin_type (target_gdbarch)->builtin_char,
NULL, val, -1, file, &opts);
fprintf_filtered (file, "\n");

View File

@ -254,9 +254,13 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
unresolved_elttype = TYPE_TARGET_TYPE (type);
elttype = check_typedef (unresolved_elttype);
{
int want_space;
addr = unpack_pointer (type, valaddr + embedded_offset);
print_unpacked_pointer:
want_space = 0;
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
/* Try to print what function it points to. */
@ -265,7 +269,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
}
if (options->addressprint)
fputs_filtered (paddress (gdbarch, addr), stream);
{
fputs_filtered (paddress (gdbarch, addr), stream);
want_space = 1;
}
/* For a pointer to a textual type, also print the string
pointed to, unless pointer is null. */
@ -274,6 +281,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
options->format)
&& addr != 0)
{
if (want_space)
fputs_filtered (" ", stream);
i = val_print_string (unresolved_elttype, NULL,
addr, -1,
stream, options);
@ -284,16 +293,20 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
CORE_ADDR vt_address = unpack_pointer (type,
valaddr
+ embedded_offset);
struct minimal_symbol *msymbol =
lookup_minimal_symbol_by_pc (vt_address);
if ((msymbol != NULL)
&& (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
{
if (want_space)
fputs_filtered (" ", stream);
fputs_filtered (" <", stream);
fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
fputs_filtered (">", stream);
want_space = 1;
}
if (vt_address && options->vtblprint)
{
struct value *vt_val;
@ -302,6 +315,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
struct block *block = (struct block *) NULL;
int is_this_fld;
if (want_space)
fputs_filtered (" ", stream);
if (msymbol != NULL)
wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol),
block, VAR_DOMAIN,

View File

@ -310,6 +310,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
else
{
int want_space = 0;
addr = unpack_pointer (type, valaddr + embedded_offset);
elttype = check_typedef (TYPE_TARGET_TYPE (type));
@ -321,7 +323,10 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
if (options->addressprint && options->format != 's')
fputs_filtered (paddress (gdbarch, addr), stream);
{
fputs_filtered (paddress (gdbarch, addr), stream);
want_space = 1;
}
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
@ -329,8 +334,12 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (options->format == 0 || options->format == 's')
&& addr != 0)
i = val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
stream, options);
{
if (want_space)
fputs_filtered (" ", stream);
i = val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
stream, options);
}
return;
}
break;

View File

@ -64,7 +64,10 @@ print_go_string (struct type *type, const gdb_byte *valaddr,
/* TODO(dje): Print address of struct or actual string? */
if (options->addressprint)
fputs_filtered (paddress (gdbarch, addr), stream);
{
fputs_filtered (paddress (gdbarch, addr), stream);
fputs_filtered (" ", stream);
}
if (length < 0)
{

View File

@ -231,6 +231,8 @@ java_value_print (struct value *val, struct ui_file *stream,
unsigned long count;
struct value *mark;
fputs_filtered (" ", stream);
mark = value_mark (); /* Remember start of new values. */
data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);

View File

@ -195,6 +195,7 @@ print_unpacked_pointer (struct type *type,
{
struct gdbarch *gdbarch = get_type_arch (type);
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
int want_space = 0;
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
@ -205,7 +206,10 @@ print_unpacked_pointer (struct type *type,
}
if (options->addressprint && options->format != 's')
fputs_filtered (paddress (gdbarch, address), stream);
{
fputs_filtered (paddress (gdbarch, address), stream);
want_space = 1;
}
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
@ -214,8 +218,12 @@ print_unpacked_pointer (struct type *type,
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (options->format == 0 || options->format == 's')
&& addr != 0)
return val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
stream, options);
{
if (want_space)
fputs_filtered (" ", stream);
return val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
stream, options);
}
return 0;
}

View File

@ -74,6 +74,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct type *char_type;
LONGEST val;
CORE_ADDR addr;
int want_space = 0;
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
@ -176,6 +177,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
if (options->addressprint && options->format != 's')
{
fputs_filtered (paddress (gdbarch, addr), stream);
want_space = 1;
}
/* For a pointer to char or unsigned char, also print the string
@ -188,6 +190,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
&& (options->format == 0 || options->format == 's')
&& addr != 0)
{
if (want_space)
fputs_filtered (" ", stream);
/* No wide string yet. */
i = val_print_string (elttype, NULL, addr, -1, stream, options);
}
@ -203,6 +207,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
ULONGEST string_length;
void *buffer;
if (want_space)
fputs_filtered (" ", stream);
buffer = xmalloc (length_size);
read_memory (addr + length_pos, buffer, length_size);
string_length = extract_unsigned_integer (buffer, length_size,
@ -223,9 +229,12 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
if ((msymbol != NULL)
&& (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
{
fputs_filtered (" <", stream);
if (want_space)
fputs_filtered (" ", stream);
fputs_filtered ("<", stream);
fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
fputs_filtered (">", stream);
want_space = 1;
}
if (vt_address && options->vtblprint)
{
@ -235,6 +244,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct block *block = (struct block *) NULL;
int is_this_fld;
if (want_space)
fputs_filtered (" ", stream);
if (msymbol != NULL)
wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol), block,
VAR_DOMAIN, &is_this_fld);

View File

@ -1,3 +1,7 @@
2012-05-18 Tom Tromey <tromey@redhat.com>
* gdb.base/charset.exp (string_display): Update.
2012-05-18 Tom Tromey <tromey@redhat.com>
* gdb.mi/mi2-var-display.exp: Update.

View File

@ -604,7 +604,7 @@ gdb_test "print 'a' == 'a' || 'b' == 'b'" \
proc string_display { var_name set_prefix x_size x_type} {
gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "Assign ${var_name} with prefix ${set_prefix}"
gdb_test "x /2${x_size}s ${var_name}" ".* ${x_type}\"Test String\"\[\r\n\]+.* ${x_type}\"with zeroes\"" "Display String ${var_name} with x/${x_size}s"
gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" "Display String ${var_name} with x/${x_size}s"
}
if {$ucs2_ok} {

View File

@ -2351,10 +2351,6 @@ val_print_string (struct type *elttype, const char *encoding,
and then the error message. */
if (errcode == 0 || bytes_read > 0)
{
if (options->addressprint)
{
fputs_filtered (" ", stream);
}
LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width,
encoding, force_ellipsis, options);
}
@ -2363,13 +2359,13 @@ val_print_string (struct type *elttype, const char *encoding,
{
if (errcode == EIO)
{
fprintf_filtered (stream, " <Address ");
fprintf_filtered (stream, "<Address ");
fputs_filtered (paddress (gdbarch, addr), stream);
fprintf_filtered (stream, " out of bounds>");
}
else
{
fprintf_filtered (stream, " <Error reading address ");
fprintf_filtered (stream, "<Error reading address ");
fputs_filtered (paddress (gdbarch, addr), stream);
fprintf_filtered (stream, ": %s>", safe_strerror (errcode));
}