X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fp-typeprint.c;h=e35e0fbd80bee4e49376c19a3bf67bf9317ca94f;hb=58ed5c38f52511e73c9748b86c319320177fb0ca;hp=9a2a0d832809d29a9c5737fe3699fd7c540f82e7;hpb=79d43c6168cdc6f263988e7c2fad9d4c82b5cd42;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 9a2a0d8328..e35e0fbd80 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -1,5 +1,5 @@ /* Support for printing Pascal types for GDB, the GNU debugger. - Copyright (C) 2000-2002, 2006-2012 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of GDB. @@ -31,8 +31,6 @@ #include "p-lang.h" #include "typeprint.h" #include "gdb-demangle.h" -#include "gdb_string.h" -#include #include static void pascal_type_print_varspec_suffix (struct type *, struct ui_file *, @@ -57,7 +55,7 @@ pascal_print_type (struct type *type, const char *varstring, code = TYPE_CODE (type); if (show > 0) - CHECK_TYPEDEF (type); + type = check_typedef (type); if ((code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)) @@ -98,7 +96,7 @@ void pascal_print_typedef (struct type *type, struct symbol *new_symbol, struct ui_file *stream) { - CHECK_TYPEDEF (type); + type = check_typedef (type); fprintf_filtered (stream, "type "); fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new_symbol)); type_print (type, "", stream, 0); @@ -156,8 +154,8 @@ void pascal_type_print_method_args (const char *physname, const char *methodname, struct ui_file *stream) { - int is_constructor = (strncmp (physname, "__ct__", 6) == 0); - int is_destructor = (strncmp (physname, "__dt__", 6) == 0); + int is_constructor = (startswith (physname, "__ct__")); + int is_destructor = (startswith (physname, "__dt__")); if (is_constructor || is_destructor) { @@ -229,7 +227,8 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream, case TYPE_CODE_METHOD: if (passed_a_ptr) fprintf_filtered (stream, "("); - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) + if (TYPE_TARGET_TYPE (type) != NULL + && TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) { fprintf_filtered (stream, "function "); } @@ -241,7 +240,7 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream, if (passed_a_ptr) { fprintf_filtered (stream, " "); - pascal_type_print_base (TYPE_DOMAIN_TYPE (type), + pascal_type_print_base (TYPE_SELF_TYPE (type), stream, 0, passed_a_ptr, flags); fprintf_filtered (stream, "::"); } @@ -257,7 +256,8 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream, if (passed_a_ptr) fprintf_filtered (stream, "("); - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) + if (TYPE_TARGET_TYPE (type) != NULL + && TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) { fprintf_filtered (stream, "function "); } @@ -336,6 +336,33 @@ pascal_print_func_args (struct type *type, struct ui_file *stream, } } +/* Helper for pascal_type_print_varspec_suffix to print the suffix of + a function or method. */ + +static void +pascal_type_print_func_varspec_suffix (struct type *type, struct ui_file *stream, + int show, int passed_a_ptr, + int demangled_args, + const struct type_print_options *flags) +{ + if (TYPE_TARGET_TYPE (type) == NULL + || TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) + { + fprintf_filtered (stream, " : "); + pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), + stream, 0, 0, flags); + + if (TYPE_TARGET_TYPE (type) == NULL) + type_print_unknown_return_type (stream); + else + pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0, + flags); + + pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, + passed_a_ptr, 0, flags); + } +} + /* Print any array sizes, function arguments or close parentheses needed after the variable name (to describe its type). Args work like pascal_type_print_varspec_prefix. */ @@ -367,16 +394,8 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream, pascal_type_print_method_args ("", "", stream); - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) - { - fprintf_filtered (stream, " : "); - pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), - stream, 0, 0, flags); - pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0, - flags); - pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - passed_a_ptr, 0, flags); - } + pascal_type_print_func_varspec_suffix (type, stream, show, + passed_a_ptr, 0, flags); break; case TYPE_CODE_PTR: @@ -390,16 +409,8 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ")"); if (!demangled_args) pascal_print_func_args (type, stream, flags); - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) - { - fprintf_filtered (stream, " : "); - pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), - stream, 0, 0, flags); - pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0, - flags); - pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - passed_a_ptr, 0, flags); - } + pascal_type_print_func_varspec_suffix (type, stream, show, + passed_a_ptr, 0, flags); break; case TYPE_CODE_UNDEF: @@ -481,7 +492,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, return; } - CHECK_TYPEDEF (type); + type = check_typedef (type); switch (TYPE_CODE (type)) { @@ -569,7 +580,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { QUIT; /* Don't print out virtual function table. */ - if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0) + if ((startswith (TYPE_FIELD_NAME (type, i), "_vptr")) && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5])) continue; @@ -645,8 +656,8 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); - int is_constructor = (strncmp (physname, "__ct__", 6) == 0); - int is_destructor = (strncmp (physname, "__dt__", 6) == 0); + int is_constructor = (startswith (physname, "__ct__")); + int is_destructor = (startswith (physname, "__dt__")); QUIT; if (TYPE_FN_FIELD_PROTECTED (f, j))