summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-02-27 00:01:14 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-02-27 00:01:14 +0000
commitb0d41ce2d23b171c7030f8e671ae69f210a34624 (patch)
tree74e769dc5709151e2f82db302606b7a6ab492f63
parent730902294267ef579c8a181af97ccf9379115ed8 (diff)
downloadgdb-b0d41ce2d23b171c7030f8e671ae69f210a34624.tar.gz
2004-02-26 Jeff Johnston <jjohnstn@redhat.com>
* valprint.h (print_hex_chars, print_char_chars): New prototypes. * valprint.c (print_hex_chars): Change from static to external. (print_char_chars): New function. * printcmd.c (print_scalar_formatted): For integer and enum types that are longer than LONGEST, perform processing via appropriate print_*_chars routines.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/printcmd.c27
-rw-r--r--gdb/valprint.c39
-rw-r--r--gdb/valprint.h6
4 files changed, 77 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d9df03c7435..9c4a0ae46c7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2004-02-26 Jeff Johnston <jjohnstn@redhat.com>
+
+ * valprint.h (print_hex_chars, print_char_chars): New prototypes.
+ * valprint.c (print_hex_chars): Change from static to external.
+ (print_char_chars): New function.
+ * printcmd.c (print_scalar_formatted): For integer and enum types
+ that are longer than LONGEST, perform processing via appropriate
+ print_*_chars routines.
+
2004-02-26 Andrew Cagney <cagney@redhat.com>
* Makefile.in: Update dependencies.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index a93ddbf8dd8..9734ec12ed6 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -350,6 +350,33 @@ print_scalar_formatted (void *valaddr, struct type *type, int format, int size,
LONGEST val_long = 0;
unsigned int len = TYPE_LENGTH (type);
+ if (len > sizeof(LONGEST) &&
+ (TYPE_CODE (type) == TYPE_CODE_INT
+ || TYPE_CODE (type) == TYPE_CODE_ENUM))
+ {
+ switch (format)
+ {
+ case 'o':
+ print_octal_chars (stream, valaddr, len);
+ return;
+ case 'u':
+ case 'd':
+ print_decimal_chars (stream, valaddr, len);
+ return;
+ case 't':
+ print_binary_chars (stream, valaddr, len);
+ return;
+ case 'x':
+ print_hex_chars (stream, valaddr, len);
+ return;
+ case 'c':
+ print_char_chars (stream, valaddr, len);
+ return;
+ default:
+ break;
+ };
+ }
+
if (format != 'f')
val_long = unpack_long (type, valaddr);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0aaf8f5dafb..294e09f58ab 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -42,9 +42,6 @@
static int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
int len, int *errnoptr);
-static void print_hex_chars (struct ui_file *, unsigned char *,
- unsigned int);
-
static void show_print (char *, int);
static void set_print (char *, int);
@@ -846,7 +843,7 @@ print_decimal_chars (struct ui_file *stream, unsigned char *valaddr,
/* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */
-static void
+void
print_hex_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
{
unsigned char *p;
@@ -875,6 +872,40 @@ print_hex_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
fputs_filtered (local_hex_format_suffix (), stream);
}
+/* VALADDR points to a char integer of LEN bytes. Print it out in appropriate language form on stream.
+ Omit any leading zero chars. */
+
+void
+print_char_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
+{
+ unsigned char *p;
+
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+ {
+ p = valaddr;
+ while (p < valaddr + len - 1 && *p == 0)
+ ++p;
+
+ while (p < valaddr + len)
+ {
+ LA_EMIT_CHAR (*p, stream, '\'');
+ ++p;
+ }
+ }
+ else
+ {
+ p = valaddr + len - 1;
+ while (p > valaddr && *p == 0)
+ --p;
+
+ while (p >= valaddr)
+ {
+ LA_EMIT_CHAR (*p, stream, '\'');
+ --p;
+ }
+ }
+}
+
/* Called by various <lang>_val_print routines to print elements of an
array in the form "<elem1>, <elem2>, <elem3>, ...".
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4e2d1661ad2..647b4bdc37d 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -63,4 +63,10 @@ extern void print_octal_chars (struct ui_file *, unsigned char *,
extern void print_decimal_chars (struct ui_file *, unsigned char *,
unsigned int);
+
+extern void print_hex_chars (struct ui_file *, unsigned char *,
+ unsigned int);
+
+extern void print_char_chars (struct ui_file *, unsigned char *,
+ unsigned int);
#endif