From c7da3ed3cd1cf1168a969567f4b0741718fe61f3 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Thu, 14 Jan 1993 05:10:12 +0000 Subject: * c-valprint.c (cp_print_class_member): Add extern decl. * c-valprint.c (c_val_print): Extract code for printing methods and move it to cp_print_class_method in cp-valprint.c. * c-valprint.c (c_val_print): Extract code to print strings and move it to val_print_string in valprint.c. * cp-valprint.c (cp_print_class_method): New function using code extracted from c_val_print. * valprint.c (val_print_string): New function using code extracted from c_val_print. * value.h (val_print_string): Add prototype. **** start-sanitize-chill **** * ch-exp.y (CHARACTER_STRING_LITERAL): Set correct token type. * ch-exp.y (literal): Add action for CHARACTER_STRING_LITERAL. * ch-exp.y (tempbuf, tempbufsize, tempbufindex, GROWBY_MIN_SIZE, CHECKBUF, growbuf_by_size): New variables, macros, and support functions for implementing a dynamically expandable temp buffer. * ch-exp.y (match_string_literal): New lexer function. * ch-exp.y (match_bitstring_literal): Dynamic buffer code removed and replaced with new CHECKBUF macro. * ch-exp.y (yylex): Call match_string_literal when appropriate. * ch-valprint.c (ch_val_print): Add code for TYPE_CODE_PTR. **** end-sanitize-chill **** --- gdb/ch-valprint.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'gdb/ch-valprint.c') diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 8c80bc4..b53326a 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -52,6 +52,10 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, enum val_prettyprint pretty; { LONGEST val; + unsigned int i; + struct type *elttype; + unsigned eltlen; + CORE_ADDR addr; switch (TYPE_CODE (type)) { @@ -130,6 +134,44 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, break; case TYPE_CODE_PTR: + if (format && format != 's') + { + print_scalar_formatted (valaddr, type, format, 0, stream); + break; + } + addr = unpack_pointer (type, valaddr); + elttype = 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 (addressprint && format != 's') + { + fprintf_filtered (stream, "0x%x", addr); + } + + /* For a pointer to char or unsigned char, also print the string + pointed to, unless pointer is null. */ + i = 0; /* Number of characters printed. */ + if (TYPE_LENGTH (elttype) == 1 + && TYPE_CODE (elttype) == TYPE_CODE_CHAR + && (format == 0 || format == 's') + && addr != 0 + && /* 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, 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)); + break; + case TYPE_CODE_MEMBER: case TYPE_CODE_REF: case TYPE_CODE_UNION: -- cgit v1.1