aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1998-10-05 19:42:04 +0000
committerStu Grossman <grossman@cygnus>1998-10-05 19:42:04 +0000
commit242c0d81808102504721ac1289dccec5dce660f9 (patch)
treea0d74af308640017ea9e48e4a98be116f50bac55
parentecd41d25b901d3fdee37e8215c288892b4c8c3d5 (diff)
downloadgdb-242c0d81808102504721ac1289dccec5dce660f9.zip
gdb-242c0d81808102504721ac1289dccec5dce660f9.tar.gz
gdb-242c0d81808102504721ac1289dccec5dce660f9.tar.bz2
* c-lang.c (emit_char c_printchar c_printstr), c-lang.h (c_printstr)
ch-lang.c (chill_printstr chill_printchar) c-valprint.c (c_val_print) ch-valprint.c (chill_val_print) expprint.c (print_subexp) f-lang.c (f_printstr f_printchar emit_char) f-valprint.c (f_val_print) jv-lang.c (java_printchar java_emit_char) jv-valprint.c (java_value_print java_val_print) language.c (unk_lang_printchar unk_lang_printstr unk_lang_emit_char) language.h (struct language_defn LA_PRINT_STRING LA_EMIT_CHAR) m2-lang.c (m2_printstr m2_printchar emit_char) printcmd.c (print_formatted) scm-lang.c (scm_printstr) valprint.c (val_print_string) value.h (val_print_string): Add emit_char routines to language_desc struct to allow finer control over language specific character output issues. Add character width arg to printstr routines to allow handling of wchar_t/Unicode strings. Fix c_printstr to handle wide characters. Supply width argument to LA_PRINT_STRING and val_print_string. * jv-lang.c (java_object_type dynamics_objfile java_link_class_type get_dynamics_objfile get_java_object_type) jv-lang.h (get_java_object_type): Make lots of things static. * expprint.c (dump_prefix_expression dump_subexp): Move opcode name printing to common routine (op_name). * (dump_subexp): Add support for OP_SCOPE.
-rw-r--r--gdb/ChangeLog26
-rw-r--r--gdb/c-lang.c39
-rw-r--r--gdb/c-lang.h4
-rw-r--r--gdb/c-valprint.c6
-rw-r--r--gdb/ch-lang.c6
-rw-r--r--gdb/ch-valprint.c9
-rw-r--r--gdb/f-lang.c18
-rw-r--r--gdb/f-valprint.c4
-rw-r--r--gdb/jv-lang.c29
-rw-r--r--gdb/jv-lang.h2
-rw-r--r--gdb/jv-valprint.c83
-rw-r--r--gdb/language.c22
-rw-r--r--gdb/language.h16
-rw-r--r--gdb/m2-lang.c14
-rw-r--r--gdb/printcmd.c51
-rw-r--r--gdb/scm-lang.c10
16 files changed, 233 insertions, 106 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2ab7934..22313bc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,29 @@
+Fri Oct 2 19:42:31 1998 Stu Grossman <grossman@babylon-5.cygnus.com>
+
+ * c-lang.c (emit_char c_printchar c_printstr), c-lang.h (c_printstr)
+ ch-lang.c (chill_printstr chill_printchar) c-valprint.c (c_val_print)
+ ch-valprint.c (chill_val_print) expprint.c (print_subexp) f-lang.c
+ (f_printstr f_printchar emit_char) f-valprint.c (f_val_print) jv-lang.c
+ (java_printchar java_emit_char) jv-valprint.c (java_value_print
+ java_val_print) language.c (unk_lang_printchar unk_lang_printstr
+ unk_lang_emit_char) language.h (struct language_defn LA_PRINT_STRING
+ LA_EMIT_CHAR) m2-lang.c (m2_printstr m2_printchar emit_char) printcmd.c
+ (print_formatted) scm-lang.c (scm_printstr) valprint.c
+ (val_print_string) value.h (val_print_string): Add emit_char routines
+ to language_desc struct to allow finer control over language specific
+ character output issues. Add character width arg to printstr routines
+ to allow handling of wchar_t/Unicode strings. Fix c_printstr to handle
+ wide characters. Supply width argument to LA_PRINT_STRING and
+ val_print_string.
+
+ * jv-lang.c (java_object_type dynamics_objfile java_link_class_type
+ get_dynamics_objfile get_java_object_type) jv-lang.h
+ (get_java_object_type): Make lots of things static.
+
+ * expprint.c (dump_prefix_expression dump_subexp): Move opcode name
+ printing to common routine (op_name).
+ * (dump_subexp): Add support for OP_SCOPE.
+
Fri Oct 2 16:25:54 1998 Stan Shebs <shebs@andros.cygnus.com>
* configure.host (i[3456]86-*-windows): Remove, no longer used.
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a104e61..251b0b2 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -25,19 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "language.h"
#include "c-lang.h"
-static void emit_char PARAMS ((int, GDB_FILE *, int));
+static void c_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
characters and strings is language specific. */
static void
-emit_char (c, stream, quoter)
+c_emit_char (c, stream, quoter)
register int c;
GDB_FILE *stream;
int quoter;
{
-
c &= 0xFF; /* Avoid sign bit follies */
if (PRINT_LITERAL_FORM (c))
@@ -85,21 +84,23 @@ c_printchar (c, stream)
int c;
GDB_FILE *stream;
{
- fputs_filtered ("'", stream);
- emit_char (c, stream, '\'');
- fputs_filtered ("'", stream);
+ fputc_filtered ('\'', stream);
+ LA_EMIT_CHAR (c, stream, '\'');
+ fputc_filtered ('\'', stream);
}
/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
+ LENGTH is -1 if the string is nul terminated. Each character is WIDTH bytes
+ long. Printing stops early if the number hits print_max; repeat counts are
+ printed as appropriate. Print ellipses at the end if we had to stop before
+ printing LENGTH characters, or if FORCE_ELLIPSES. */
void
-c_printstr (stream, string, length, force_ellipses)
+c_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
register unsigned int i;
@@ -113,7 +114,9 @@ c_printstr (stream, string, length, force_ellipses)
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
style. */
- if ((!force_ellipses) && length > 0 && string[length-1] == '\0')
+ if (!force_ellipses
+ && length > 0
+ && extract_unsigned_integer (string + (length - 1) * width, width) == '\0')
length--;
if (length == 0)
@@ -129,6 +132,7 @@ c_printstr (stream, string, length, force_ellipses)
unsigned int rep1;
/* Number of repetitions we have detected so far. */
unsigned int reps;
+ unsigned long current_char;
QUIT;
@@ -138,9 +142,13 @@ c_printstr (stream, string, length, force_ellipses)
need_comma = 0;
}
+ current_char = extract_unsigned_integer (string + i * width, width);
+
rep1 = i + 1;
reps = 1;
- while (rep1 < length && string[rep1] == string[i])
+ while (rep1 < length
+ && extract_unsigned_integer (string + rep1 * width, width)
+ == current_char)
{
++rep1;
++reps;
@@ -156,7 +164,7 @@ c_printstr (stream, string, length, force_ellipses)
fputs_filtered ("\", ", stream);
in_quotes = 0;
}
- c_printchar (string[i], stream);
+ LA_PRINT_CHAR (current_char, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += repeat_count_threshold;
@@ -172,7 +180,7 @@ c_printstr (stream, string, length, force_ellipses)
fputs_filtered ("\"", stream);
in_quotes = 1;
}
- emit_char (string[i], stream, '"');
+ LA_EMIT_CHAR (current_char, stream, '"');
++things_printed;
}
}
@@ -404,6 +412,7 @@ const struct language_defn c_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
@@ -430,6 +439,7 @@ const struct language_defn cplus_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
@@ -456,6 +466,7 @@ const struct language_defn asm_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index e38df8e..b9536f5 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -41,7 +41,9 @@ c_value_print PARAMS ((struct value *, GDB_FILE *, int, enum val_prettyprint));
extern void c_printchar PARAMS ((int, GDB_FILE*));
-extern void c_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+extern void c_printstr PARAMS ((GDB_FILE *stream, char *string,
+ unsigned int length, int width,
+ int force_ellipses));
extern struct type * c_create_fundamental_type PARAMS ((struct objfile*, int));
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index ee620dc..583b78a 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -95,7 +95,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
len = temp_len;
}
- LA_PRINT_STRING (stream, valaddr, len, 0);
+ LA_PRINT_STRING (stream, valaddr, len, eltlen, 0);
i = len;
}
else
@@ -169,12 +169,14 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
+ /* FIXME: need to handle wchar_t here... */
+
if (TYPE_LENGTH (elttype) == 1
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (format == 0 || format == 's')
&& addr != 0)
{
- i = val_print_string (addr, 0, stream);
+ i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
}
else if (cp_is_vtbl_member(type))
{
diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c
index a91ee17..c54e8bb 100644
--- a/gdb/ch-lang.c
+++ b/gdb/ch-lang.c
@@ -42,7 +42,7 @@ static struct type *
chill_create_fundamental_type PARAMS ((struct objfile *, int));
static void
-chill_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+chill_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
static void
chill_printchar PARAMS ((int, GDB_FILE *));
@@ -111,10 +111,11 @@ chill_printchar (c, stream)
*/
static void
-chill_printstr (stream, string, length, force_ellipses)
+chill_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
register unsigned int i;
@@ -628,6 +629,7 @@ const struct language_defn chill_language_defn = {
evaluate_subexp_chill,
chill_printchar, /* print a character constant */
chill_printstr, /* function to print a string constant */
+ NULL, /* Function to print a single char */
chill_create_fundamental_type,/* Create fundamental type in this language */
chill_print_type, /* Print a type using appropriate syntax */
chill_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index 911c693..9c67d09 100644
--- a/gdb/ch-valprint.c
+++ b/gdb/ch-valprint.c
@@ -329,9 +329,8 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
&& /* If print_max is UINT_MAX, the alloca below will fail.
In that case don't try to print the string. */
print_max < UINT_MAX)
- {
- i = val_print_string (addr, 0, stream);
- }
+ i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+
/* Return number of characters printed, plus one for the
terminating null if we have "reached the end". */
return (i + (print_max && i != print_max));
@@ -339,7 +338,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
case TYPE_CODE_STRING:
i = TYPE_LENGTH (type);
- LA_PRINT_STRING (stream, valaddr, i, 0);
+ LA_PRINT_STRING (stream, valaddr, i, 1, 0);
/* Return number of characters printed, plus one for the terminating
null if we have "reached the end". */
return (i + (print_max && i != print_max));
@@ -432,7 +431,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
segfault. */
return length;
}
- LA_PRINT_STRING (stream, data_addr, length, 0);
+ LA_PRINT_STRING (stream, data_addr, length, 1, 0);
return length;
default:
break;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index a477c40..1590ac8 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -82,9 +82,9 @@ static void patch_common_entries PARAMS ((SAVED_F77_COMMON_PTR, CORE_ADDR, int))
#endif
static struct type *f_create_fundamental_type PARAMS ((struct objfile *, int));
-static void f_printstr PARAMS ((FILE *, char *, unsigned int, int));
-static void f_printchar PARAMS ((int, FILE *));
-static void emit_char PARAMS ((int, FILE *, int));
+static void f_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
+static void f_printchar PARAMS ((int c, GDB_FILE *stream));
+static void f_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
@@ -93,9 +93,9 @@ static void emit_char PARAMS ((int, FILE *, int));
be replaced with a true F77 version. */
static void
-emit_char (c, stream, quoter)
+f_emit_char (c, stream, quoter)
register int c;
- FILE *stream;
+ GDB_FILE *stream;
int quoter;
{
c &= 0xFF; /* Avoid sign bit follies */
@@ -147,7 +147,7 @@ f_printchar (c, stream)
FILE *stream;
{
fputs_filtered ("'", stream);
- emit_char (c, stream, '\'');
+ LA_EMIT_CHAR (c, stream, '\'');
fputs_filtered ("'", stream);
}
@@ -159,10 +159,11 @@ f_printchar (c, stream)
be replaced with a true F77 version. */
static void
-f_printstr (stream, string, length, force_ellipses)
+f_printstr (stream, string, length, width, force_ellipses)
FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
register unsigned int i;
@@ -229,7 +230,7 @@ f_printstr (stream, string, length, force_ellipses)
fputs_filtered ("'", stream);
in_quotes = 1;
}
- emit_char (string[i], stream, '"');
+ LA_EMIT_CHAR (string[i], stream, '"');
++things_printed;
}
}
@@ -470,6 +471,7 @@ const struct language_defn f_language_defn = {
evaluate_subexp_standard,
f_printchar, /* Print character constant */
f_printstr, /* function to print string constant */
+ f_emit_char, /* Function to print a single character */
f_create_fundamental_type, /* Create fundamental type in this language */
f_print_type, /* Print a type using appropriate syntax */
f_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index e730f37..d629d8b 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -392,7 +392,7 @@ f_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
{
case TYPE_CODE_STRING:
f77_get_dynamic_length_of_aggregate (type);
- LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 0);
+ LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
break;
case TYPE_CODE_ARRAY:
@@ -434,7 +434,7 @@ f_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
&& TYPE_CODE (elttype) == TYPE_CODE_INT
&& (format == 0 || format == 's')
&& addr != 0)
- i = val_print_string (addr, 0, stream);
+ i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
/* Return number of characters printed, plus one for the
terminating null if we have "reached the end". */
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 603b225..c852446 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1,5 +1,5 @@
/* Java language support routines for GDB, the GNU debugger.
- Copyright 1997 Free Software Foundation, Inc.
+ Copyright 1997, 1998 Free Software Foundation, Inc.
This file is part of GDB.
@@ -44,16 +44,17 @@ struct type *java_float_type;
struct type *java_double_type;
struct type *java_void_type;
-struct type *java_object_type;
+static void java_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
/* This objfile contains symtabs that have been dynamically created
to record dynamically loaded Java classes and dynamically
compiled java methods. */
-struct objfile *dynamics_objfile = NULL;
-struct type *java_link_class_type PARAMS((struct type*, value_ptr));
+static struct objfile *dynamics_objfile = NULL;
-struct objfile *
+static struct type *java_link_class_type PARAMS ((struct type *, value_ptr));
+
+static struct objfile *
get_dynamics_objfile ()
{
if (dynamics_objfile == NULL)
@@ -560,7 +561,9 @@ java_link_class_type (type, clas)
return type;
}
-struct type*
+static struct type *java_object_type;
+
+struct type *
get_java_object_type ()
{
return java_object_type;
@@ -704,15 +707,16 @@ java_value_string (ptr, len)
error ("not implemented - java_value_string"); /* FIXME */
}
-static void java_printchar PARAMS ((int c, GDB_FILE *stream));
+/* Print the character C on STREAM as part of the contents of a literal
+ string whose delimiter is QUOTER. Note that that format for printing
+ characters and strings is language specific. */
static void
-java_printchar (c, stream)
+java_emit_char (c, stream, quoter)
int c;
GDB_FILE *stream;
+ int quoter;
{
- fputc_filtered ('\'', stream);
-
switch (c)
{
case '\\':
@@ -741,8 +745,6 @@ java_printchar (c, stream)
fprintf_filtered (stream, "\\u%.4x", (unsigned int) c);
break;
}
-
- fputc_filtered ('\'', stream);
}
static value_ptr
@@ -929,8 +931,9 @@ const struct language_defn java_language_defn = {
java_parse,
java_error,
evaluate_subexp_java,
- java_printchar, /* Print a character constant */
+ c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ java_emit_char, /* Function to print a single character */
java_create_fundamental_type, /* Create fundamental type in this language */
java_print_type, /* Print a type using appropriate syntax */
java_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index caaba44..ba8aa4d 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -56,7 +56,7 @@ extern struct type *java_primitive_type PARAMS ((int));
extern struct type *java_array_type PARAMS ((struct type*, int));
-extern struct type *get_java_object_type ();
+extern struct type *get_java_object_type PARAMS ((void));
extern struct type * java_lookup_class PARAMS((char *));
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index d46c4b8..3833984 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -149,6 +149,41 @@ java_value_print (val, stream, format, pretty)
return 0;
}
+ /* If it's type String, print it */
+
+ if (TYPE_CODE (type) == TYPE_CODE_PTR
+ && TYPE_TARGET_TYPE (type)
+ && TYPE_NAME (TYPE_TARGET_TYPE (type))
+ && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "java.lang.String") == 0
+ && (format == 0 || format == 's')
+ && address != 0)
+ {
+ value_ptr data_val;
+ CORE_ADDR data;
+ value_ptr boffset_val;
+ unsigned long boffset;
+ value_ptr count_val;
+ unsigned long count;
+ value_ptr mark;
+
+ mark = value_mark (); /* Remember start of new values */
+
+ data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);
+ data = value_as_pointer (data_val);
+
+ boffset_val = value_struct_elt (&val, NULL, "boffset", NULL, NULL);
+ boffset = value_as_pointer (boffset_val);
+
+ count_val = value_struct_elt (&val, NULL, "count", NULL, NULL);
+ count = value_as_pointer (count_val);
+
+ value_free_to_mark (mark); /* Release unnecessary values */
+
+ val_print_string (data + boffset, count, 2, stream);
+
+ return 0;
+ }
+
return (val_print (type, VALUE_CONTENTS (val), address,
stream, format, 1, 0, pretty));
}
@@ -353,9 +388,22 @@ java_print_value_fields (type, valaddr, address, stream,
fprintf_filtered (stream, "}");
}
+/* Print data of type TYPE located at VALADDR (within GDB), which came from
+ the inferior at address ADDRESS, onto stdio stream STREAM according to
+ FORMAT (a letter or 0 for natural format). The data at VALADDR is in
+ target byte order.
+
+ If the data are a string pointer, returns the number of string characters
+ printed.
+
+ If DEREF_REF is nonzero, then dereference references, otherwise just print
+ them like pointers.
+
+ The PRETTY parameter controls prettyprinting. */
+
int
java_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
- pretty)
+ pretty)
struct type *type;
char *valaddr;
CORE_ADDR address;
@@ -366,7 +414,7 @@ java_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
enum val_prettyprint pretty;
{
register unsigned int i = 0; /* Number of characters printed */
- struct type *elttype;
+ struct type *target_type;
CORE_ADDR addr;
CHECK_TYPEDEF (type);
@@ -395,26 +443,23 @@ java_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
fputs_filtered ("null", stream);
return i;
}
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
- {
- print_unpacked_pointer:
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ target_type = check_typedef (TYPE_TARGET_TYPE (type));
- if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
- {
- /* Try to print what function it points to. */
- print_address_demangle (addr, stream, demangle);
- /* Return value is irrelevant except for string pointers. */
- return (0);
- }
+ if (TYPE_CODE (target_type) == TYPE_CODE_FUNC)
+ {
+ /* Try to print what function it points to. */
+ print_address_demangle (addr, stream, demangle);
+ /* Return value is irrelevant except for string pointers. */
+ return (0);
+ }
- if (addressprint && format != 's')
- {
- fputs_filtered ("@", stream);
- print_longest (stream, 'x', 0, (ULONGEST) addr);
- }
- return i;
+ if (addressprint && format != 's')
+ {
+ fputs_filtered ("@", stream);
+ print_longest (stream, 'x', 0, (ULONGEST) addr);
}
+
+ return i;
case TYPE_CODE_CHAR:
format = format ? format : output_format;
if (format)
diff --git a/gdb/language.c b/gdb/language.c
index 47bf441..1c10026 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -84,10 +84,13 @@ static void
set_type_range PARAMS ((void));
static void
-unk_lang_printchar PARAMS ((int, GDB_FILE *));
+unk_lang_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
static void
-unk_lang_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+unk_lang_printchar PARAMS ((int c, GDB_FILE *stream));
+
+static void
+unk_lang_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
static struct type *
unk_lang_create_fundamental_type PARAMS ((struct objfile *, int));
@@ -1213,6 +1216,15 @@ unk_lang_error (msg)
}
static void
+unk_lang_emit_char (c, stream, quoter)
+ register int c;
+ GDB_FILE *stream;
+ int quoter;
+{
+ error ("internal error - unimplemented function unk_lang_emit_char called.");
+}
+
+static void
unk_lang_printchar (c, stream)
register int c;
GDB_FILE *stream;
@@ -1221,10 +1233,11 @@ unk_lang_printchar (c, stream)
}
static void
-unk_lang_printstr (stream, string, length, force_ellipses)
+unk_lang_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
error ("internal error - unimplemented function unk_lang_printstr called.");
@@ -1290,6 +1303,7 @@ const struct language_defn unknown_language_defn = {
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
+ unk_lang_emit_char,
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
@@ -1317,6 +1331,7 @@ const struct language_defn auto_language_defn = {
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
+ unk_lang_emit_char,
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
@@ -1343,6 +1358,7 @@ const struct language_defn local_language_defn = {
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
+ unk_lang_emit_char,
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/language.h b/gdb/language.h
index 347160d..1699804 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -134,12 +134,16 @@ struct language_defn
void (*la_error) PARAMS ((char *));
/* Evaluate an expression. */
- struct value * (*evaluate_exp) PARAMS ((struct type*, struct expression *,
+ struct value * (*evaluate_exp) PARAMS ((struct type *, struct expression *,
int *, enum noside));
- void (*la_printchar) PARAMS ((int, GDB_FILE *));
+ void (*la_printchar) PARAMS ((int ch, GDB_FILE *stream));
- void (*la_printstr) PARAMS ((GDB_FILE *, char *, unsigned int, int));
+ void (*la_printstr) PARAMS ((GDB_FILE *stream, char *string,
+ unsigned int length, int width,
+ int force_ellipses));
+
+ void (*la_emitchar) PARAMS ((int ch, GDB_FILE *stream, int quoter));
struct type *(*la_fund_type) PARAMS ((struct objfile *, int));
@@ -309,8 +313,10 @@ set_language PARAMS ((enum language));
#define LA_PRINT_CHAR(ch, stream) \
(current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, force_ellipses) \
- (current_language->la_printstr(stream, string, length, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
+ (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_EMIT_CHAR(ch, stream, quoter) \
+ (current_language->la_emitchar(ch, stream, quoter))
/* Test a character to decide whether it can be printed in literal form
or needs to be printed in another representation. For example,
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 7200824..f5f38a9 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -27,9 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "c-lang.h"
static struct type *m2_create_fundamental_type PARAMS ((struct objfile *, int));
-static void m2_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+static void m2_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
static void m2_printchar PARAMS ((int, GDB_FILE *));
-static void emit_char PARAMS ((int, GDB_FILE *, int));
+static void m2_emit_char PARAMS ((int, GDB_FILE *, int));
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
@@ -39,7 +39,7 @@ static void emit_char PARAMS ((int, GDB_FILE *, int));
*/
static void
-emit_char (c, stream, quoter)
+m2_emit_char (c, stream, quoter)
register int c;
GDB_FILE *stream;
int quoter;
@@ -96,7 +96,7 @@ m2_printchar (c, stream)
GDB_FILE *stream;
{
fputs_filtered ("'", stream);
- emit_char (c, stream, '\'');
+ LA_EMIT_CHAR (c, stream, '\'');
fputs_filtered ("'", stream);
}
@@ -108,10 +108,11 @@ m2_printchar (c, stream)
be replaced with a true Modula version. */
static void
-m2_printstr (stream, string, length, force_ellipses)
+m2_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
register unsigned int i;
@@ -178,7 +179,7 @@ m2_printstr (stream, string, length, force_ellipses)
fputs_filtered ("\"", stream);
in_quotes = 1;
}
- emit_char (string[i], stream, '"');
+ LA_EMIT_CHAR (string[i], stream, '"');
++things_printed;
}
}
@@ -424,6 +425,7 @@ const struct language_defn m2_language_defn = {
evaluate_subexp_standard,
m2_printchar, /* Print character constant */
m2_printstr, /* function to print string constant */
+ m2_emit_char, /* Function to print a single character */
m2_create_fundamental_type, /* Create fundamental type in this language */
m2_print_type, /* Print a type using appropriate syntax */
m2_val_print, /* Print a value using appropriate syntax */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ad1ad37..7d0f3a5 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -293,8 +293,9 @@ print_formatted (val, format, size)
switch (format)
{
case 's':
+ /* FIXME: Need to handle wchar_t's here... */
next_address = VALUE_ADDRESS (val)
- + val_print_string (VALUE_ADDRESS (val), 0, gdb_stdout);
+ + val_print_string (VALUE_ADDRESS (val), -1, 1, gdb_stdout);
next_section = VALUE_BFD_SECTION (val);
break;
@@ -688,6 +689,8 @@ print_address_demangle (addr, stream, do_demangle)
/* These are the types that $__ will get after an examine command of one
of these sizes. */
+static struct type *examine_i_type;
+
static struct type *examine_b_type;
static struct type *examine_h_type;
static struct type *examine_w_type;
@@ -720,7 +723,9 @@ do_examine (fmt, addr, sect)
if (format == 's' || format == 'i')
size = 'b';
- if (size == 'b')
+ if (format == 'i')
+ val_type = examine_i_type;
+ else if (size == 'b')
val_type = examine_b_type;
else if (size == 'h')
val_type = examine_h_type;
@@ -753,7 +758,16 @@ do_examine (fmt, addr, sect)
/* Note that print_formatted sets next_address for the next
object. */
last_examine_address = next_address;
- last_examine_value = value_at (val_type, next_address, sect);
+ /* The value to be displayed is not fetched greedily.
+ Instead, to avoid the posibility of a fetched value not
+ being used, its retreval is delayed until the print code
+ uses it. When examining an instruction stream, the
+ disassembler will perform its own memory fetch using just
+ the address stored in LAST_EXAMINE_VALUE. FIXME: Should
+ the disassembler be modified so that LAST_EXAMINE_VALUE
+ is left with the byte sequence from the last complete
+ instruction fetched from memory? */
+ last_examine_value = value_at_lazy (val_type, next_address, sect);
print_formatted (last_examine_value, format, size);
}
printf_filtered ("\n");
@@ -1261,7 +1275,13 @@ x_command (exp, from_tty)
(LONGEST) last_examine_address));
/* Make contents of last address examined available to the user as $__.*/
- set_internalvar (lookup_internalvar ("__"), last_examine_value);
+ /* If the last value has not been fetched from memory then don't
+ fetch it now - instead mark it by voiding the $__ variable. */
+ if (VALUE_LAZY (last_examine_value))
+ set_internalvar (lookup_internalvar ("__"),
+ allocate_value (builtin_type_void));
+ else
+ set_internalvar (lookup_internalvar ("__"), last_examine_value);
}
}
@@ -2190,7 +2210,6 @@ disassemble_command (arg, from_tty)
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error ("No function contains program counter for selected frame.\n");
low += FUNCTION_START_OFFSET;
- high -= 1;
}
else if (!(space_index = (char *) strchr (arg, ' ')))
{
@@ -2199,20 +2218,6 @@ disassemble_command (arg, from_tty)
if (find_pc_partial_function (pc, &name, &low, &high) == 0)
error ("No function contains specified address.\n");
low += FUNCTION_START_OFFSET;
- high -= 1;
- if (overlay_debugging)
- {
- section = find_pc_overlay (pc);
- if (pc_in_unmapped_range (pc, section))
- {
- /* find_pc_partial_function will have returned low and high
- relative to the symbolic (mapped) address range. Need to
- translate them back to the unmapped range where PC is. */
-
- low = overlay_unmapped_address (low, section);
- high = overlay_unmapped_address (high, section);
- }
- }
}
else
{
@@ -2220,7 +2225,6 @@ disassemble_command (arg, from_tty)
*space_index = '\0';
low = parse_and_eval_address (arg);
high = parse_and_eval_address (space_index + 1);
- high -= 1;
}
printf_filtered ("Dump of assembler code ");
@@ -2246,7 +2250,7 @@ disassemble_command (arg, from_tty)
pc_masked = pc;
#endif
- while (pc_masked <= high)
+ while (pc_masked < high)
{
QUIT;
print_address (pc_masked, gdb_stdout);
@@ -2442,6 +2446,11 @@ environment, the value is printed in its own window.");
&setprintlist),
&showprintlist);
+ /* For examine/instruction a single byte quantity is specified as
+ the data. This avoids problems with value_at_lazy() requiring a
+ valid data type (and rejecting VOID). */
+ examine_i_type = init_type (TYPE_CODE_INT, 1, 0, "examine_i_type", NULL);
+
examine_b_type = init_type (TYPE_CODE_INT, 1, 0, "examine_b_type", NULL);
examine_h_type = init_type (TYPE_CODE_INT, 2, 0, "examine_h_type", NULL);
examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 16739a0..82b6a1c 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -34,7 +34,7 @@ static value_ptr evaluate_subexp_scm PARAMS ((struct type *, struct expression *
int *, enum noside));
static value_ptr scm_lookup_name PARAMS ((char *));
static int in_eval_c PARAMS ((void));
-static void scm_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+static void scm_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
extern struct type ** CONST_PTR (c_builtin_types[]);
@@ -49,10 +49,11 @@ scm_printchar (c, stream)
}
static void
-scm_printstr (stream, string, length, force_ellipses)
+scm_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
fprintf_filtered (stream, "\"%s\"", string);
@@ -245,9 +246,10 @@ const struct language_defn scm_language_defn = {
scm_parse,
c_error,
evaluate_subexp_scm,
- scm_printchar, /* Print a character constant */
+ scm_printchar, /* Print a character constant */
scm_printstr, /* Function to print string constant */
- NULL, /* Create fundamental type in this language */
+ NULL, /* Function to print a single character */
+ NULL, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
scm_val_print, /* Print a value using appropriate syntax */
scm_value_print, /* Print a top-level value */