From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 5/8] Add array start and end strings to generic_val_print_decorations
Date: Wed, 27 Apr 2016 02:50:00 -0000 [thread overview]
Message-ID: <1461725371-17620-6-git-send-email-tom@tromey.com> (raw)
In-Reply-To: <1461725371-17620-1-git-send-email-tom@tromey.com>
For Rust value-printing, I wanted to use generic_val_print_array, but
I also wanted to control the starting and ending strings.
This patch adds new strings to generic_val_print_decorations, updates
generic_val_print_array to use them, and updates all the existing
instances of generic_val_print_decorations.
2016-04-26 Tom Tromey <tom@tromey.com>
* valprint.h (struct generic_val_print_array) <array_start,
array_end>: New fields.
* valprint.c (generic_val_print_array): Add "decorations"
parameter. Use "array_start", "array_end".
(generic_val_print) <TYPE_CODE_ARRAY>: Update.
* p-valprint.c (p_decorations): Update.
* m2-valprint.c (m2_decorations): Update.
* f-valprint.c (f_decorations): Update.
* c-valprint.c (c_decorations): Update.
---
gdb/ChangeLog | 12 ++++++++++++
gdb/c-valprint.c | 4 +++-
gdb/f-valprint.c | 2 ++
gdb/m2-valprint.c | 4 +++-
gdb/p-valprint.c | 4 +++-
gdb/valprint.c | 16 +++++++++-------
gdb/valprint.h | 4 ++++
7 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ab137ca..7fc99f7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
2016-04-26 Tom Tromey <tom@tromey.com>
+ * valprint.h (struct generic_val_print_array) <array_start,
+ array_end>: New fields.
+ * valprint.c (generic_val_print_array): Add "decorations"
+ parameter. Use "array_start", "array_end".
+ (generic_val_print) <TYPE_CODE_ARRAY>: Update.
+ * p-valprint.c (p_decorations): Update.
+ * m2-valprint.c (m2_decorations): Update.
+ * f-valprint.c (f_decorations): Update.
+ * c-valprint.c (c_decorations): Update.
+
+2016-04-26 Tom Tromey <tom@tromey.com>
+
* selftest.h: New file.
* selftest.c: New file.
* maint.c: Include selftest.h.
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 62552ec..75dae19 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -124,7 +124,9 @@ static const struct generic_val_print_decorations c_decorations =
" * I",
"true",
"false",
- "void"
+ "void",
+ "{",
+ "}"
};
/* Print a pointer based on the type of its target.
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 71bd2c3..1264737 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -203,6 +203,8 @@ static const struct generic_val_print_decorations f_decorations =
".TRUE.",
".FALSE.",
"VOID",
+ "{",
+ "}"
};
/* See val_print for a description of the various parameters of this
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 73fbdfe..2d3a32f 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -301,7 +301,9 @@ static const struct generic_val_print_decorations m2_decorations =
" * I",
"TRUE",
"FALSE",
- "void"
+ "void",
+ "{",
+ "}"
};
/* See val_print for a description of the various parameters of this
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 72dc6fd..3e840d8 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -49,7 +49,9 @@ static const struct generic_val_print_decorations p_decorations =
" * I",
"true",
"false",
- "void"
+ "void",
+ "{",
+ "}"
};
/* See val_print for a description of the various parameters of this
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 720942b..cea69f3 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -407,10 +407,12 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
static void
generic_val_print_array (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int recurse,
- const struct value *original_value,
- const struct value_print_options *options)
+ int embedded_offset, CORE_ADDR address,
+ struct ui_file *stream, int recurse,
+ const struct value *original_value,
+ const struct value_print_options *options,
+ const struct
+ generic_val_print_decorations *decorations)
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
struct type *elttype = check_typedef (unresolved_elttype);
@@ -427,11 +429,11 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr,
print_spaces_filtered (2 + 2 * recurse, stream);
}
- fprintf_filtered (stream, "{");
+ fputs_filtered (decorations->array_start, stream);
val_print_array_elements (type, valaddr, embedded_offset,
address, stream,
recurse, original_value, options, 0);
- fprintf_filtered (stream, "}");
+ fputs_filtered (decorations->array_end, stream);
}
else
{
@@ -851,7 +853,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
{
case TYPE_CODE_ARRAY:
generic_val_print_array (type, valaddr, embedded_offset, address, stream,
- recurse, original_value, options);
+ recurse, original_value, options, decorations);
break;
case TYPE_CODE_MEMBERPTR:
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 1a83cb5..451b5fe 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -186,6 +186,10 @@ struct generic_val_print_decorations
/* What to print when we see TYPE_CODE_VOID. */
const char *void_name;
+
+ /* Array start and end strings. */
+ const char *array_start;
+ const char *array_end;
};
--
2.5.5
next prev parent reply other threads:[~2016-04-27 2:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 2:50 [PATCH 0/8] Add Rust language support Tom Tromey
2016-04-27 2:50 ` [PATCH 2/8] Fix latent yacc-related bug in gdb/Makefile.in init.c rule Tom Tromey
2016-04-27 11:38 ` Pedro Alves
2016-04-27 2:50 ` [PATCH 6/8] Add support for the Rust language Tom Tromey
2016-04-27 11:43 ` Pedro Alves
2016-04-27 11:49 ` Pedro Alves
2016-04-27 18:27 ` Tom Tromey
2016-04-27 18:36 ` Pedro Alves
2016-04-27 19:52 ` Tom Tromey
2016-04-27 2:50 ` [PATCH 8/8] Add Rust documentation Tom Tromey
2016-04-27 7:10 ` Eli Zaretskii
2016-04-27 2:50 ` [PATCH 3/8] Make gdb expression debugging handle OP_F90_RANGE Tom Tromey
2016-04-27 11:38 ` Pedro Alves
2016-04-27 2:50 ` Tom Tromey [this message]
2016-04-27 11:40 ` [PATCH 5/8] Add array start and end strings to generic_val_print_decorations Pedro Alves
2016-04-27 2:50 ` [PATCH 7/8] Update gdb test suite for Rust Tom Tromey
2016-04-27 11:44 ` Pedro Alves
2016-04-27 2:50 ` [PATCH 4/8] Add self-test framework to gdb Tom Tromey
2016-04-27 11:40 ` Pedro Alves
2016-04-27 17:58 ` Tom Tromey
2016-04-27 2:50 ` [PATCH 1/8] Add DW_LANG_Rust and DW_LANG_Rust_old Tom Tromey
2016-04-27 11:44 ` Pedro Alves
2016-04-27 11:47 ` [PATCH 0/8] Add Rust language support Pedro Alves
2016-04-27 16:22 ` Tom Tromey
2016-04-27 18:23 ` Pedro Alves
2016-04-27 21:56 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461725371-17620-6-git-send-email-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox