| OLD | NEW |
| 1 /* Language independent support for printing types for GDB, the GNU debugger. | 1 /* Language independent support for printing types for GDB, the GNU debugger. |
| 2 | 2 |
| 3 Copyright (C) 1986, 1988-1989, 1991-1995, 1998-2001, 2003, 2006-2012 | 3 Copyright (C) 1986, 1988-1989, 1991-1995, 1998-2001, 2003, 2006-2012 |
| 4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
| 5 | 5 |
| 6 This file is part of GDB. | 6 This file is part of GDB. |
| 7 | 7 |
| 8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
| 9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
| 10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 /* Print a description of a type TYPE in the form of a declaration of a | 68 /* Print a description of a type TYPE in the form of a declaration of a |
| 69 variable named VARSTRING. (VARSTRING is demangled if necessary.) | 69 variable named VARSTRING. (VARSTRING is demangled if necessary.) |
| 70 Output goes to STREAM (via stdio). | 70 Output goes to STREAM (via stdio). |
| 71 If SHOW is positive, we show the contents of the outermost level | 71 If SHOW is positive, we show the contents of the outermost level |
| 72 of structure even if there is a type name that could be used instead. | 72 of structure even if there is a type name that could be used instead. |
| 73 If SHOW is negative, we never show the details of elements' types. */ | 73 If SHOW is negative, we never show the details of elements' types. */ |
| 74 | 74 |
| 75 void | 75 void |
| 76 type_print (struct type *type, char *varstring, struct ui_file *stream, | 76 type_print (struct type *type, const char *varstring, struct ui_file *stream, |
| 77 int show) | 77 int show) |
| 78 { | 78 { |
| 79 LA_PRINT_TYPE (type, varstring, stream, show, 0); | 79 LA_PRINT_TYPE (type, varstring, stream, show, 0); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /* Print TYPE to a string, returning it. The caller is responsible for | 82 /* Print TYPE to a string, returning it. The caller is responsible for |
| 83 freeing the string. */ | 83 freeing the string. */ |
| 84 | 84 |
| 85 char * | 85 char * |
| 86 type_to_string (struct type *type) | 86 type_to_string (struct type *type) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 val = access_value_history (0); | 132 val = access_value_history (0); |
| 133 | 133 |
| 134 type = value_type (val); | 134 type = value_type (val); |
| 135 | 135 |
| 136 get_user_print_options (&opts); | 136 get_user_print_options (&opts); |
| 137 if (opts.objectprint) | 137 if (opts.objectprint) |
| 138 { | 138 { |
| 139 if (((TYPE_CODE (type) == TYPE_CODE_PTR) | 139 if (((TYPE_CODE (type) == TYPE_CODE_PTR) |
| 140 || (TYPE_CODE (type) == TYPE_CODE_REF)) | 140 || (TYPE_CODE (type) == TYPE_CODE_REF)) |
| 141 && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS)) | 141 && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS)) |
| 142 { | 142 real_type = value_rtti_indirect_type (val, &full, &top, &using_enc); |
| 143 real_type = value_rtti_target_type (val, &full, &top, &using_enc); | |
| 144 if (real_type) | |
| 145 { | |
| 146 if (TYPE_CODE (type) == TYPE_CODE_PTR) | |
| 147 real_type = lookup_pointer_type (real_type); | |
| 148 else | |
| 149 real_type = lookup_reference_type (real_type); | |
| 150 } | |
| 151 } | |
| 152 else if (TYPE_CODE (type) == TYPE_CODE_CLASS) | 143 else if (TYPE_CODE (type) == TYPE_CODE_CLASS) |
| 153 real_type = value_rtti_type (val, &full, &top, &using_enc); | 144 real_type = value_rtti_type (val, &full, &top, &using_enc); |
| 154 } | 145 } |
| 155 | 146 |
| 156 printf_filtered ("type = "); | 147 printf_filtered ("type = "); |
| 157 | 148 |
| 158 if (real_type) | 149 if (real_type) |
| 159 { | 150 { |
| 160 printf_filtered ("/* real type = "); | 151 printf_filtered ("/* real type = "); |
| 161 type_print (real_type, "", gdb_stdout, -1); | 152 type_print (real_type, "", gdb_stdout, -1); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 199 |
| 209 CHECK_TYPEDEF (type); | 200 CHECK_TYPEDEF (type); |
| 210 | 201 |
| 211 switch (TYPE_CODE (type)) | 202 switch (TYPE_CODE (type)) |
| 212 { | 203 { |
| 213 | 204 |
| 214 case TYPE_CODE_ENUM: | 205 case TYPE_CODE_ENUM: |
| 215 len = TYPE_NFIELDS (type); | 206 len = TYPE_NFIELDS (type); |
| 216 for (i = 0; i < len; i++) | 207 for (i = 0; i < len; i++) |
| 217 { | 208 { |
| 218 » if (TYPE_FIELD_BITPOS (type, i) == val) | 209 » if (TYPE_FIELD_ENUMVAL (type, i) == val) |
| 219 { | 210 { |
| 220 break; | 211 break; |
| 221 } | 212 } |
| 222 } | 213 } |
| 223 if (i < len) | 214 if (i < len) |
| 224 { | 215 { |
| 225 fputs_filtered (TYPE_FIELD_NAME (type, i), stream); | 216 fputs_filtered (TYPE_FIELD_NAME (type, i), stream); |
| 226 } | 217 } |
| 227 else | 218 else |
| 228 { | 219 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 Print definition of type TYPE.\n\ | 307 Print definition of type TYPE.\n\ |
| 317 Argument may be a type name defined by typedef, or \"struct STRUCT-TAG\"\n\ | 308 Argument may be a type name defined by typedef, or \"struct STRUCT-TAG\"\n\ |
| 318 or \"class CLASS-NAME\" or \"union UNION-TAG\" or \"enum ENUM-TAG\".\n\ | 309 or \"class CLASS-NAME\" or \"union UNION-TAG\" or \"enum ENUM-TAG\".\n\ |
| 319 The selected stack frame's lexical context is used to look up the name.\n\ | 310 The selected stack frame's lexical context is used to look up the name.\n\ |
| 320 Contrary to \"whatis\", \"ptype\" always unrolls any typedefs.")); | 311 Contrary to \"whatis\", \"ptype\" always unrolls any typedefs.")); |
| 321 | 312 |
| 322 add_com ("whatis", class_vars, whatis_command, | 313 add_com ("whatis", class_vars, whatis_command, |
| 323 _("Print data type of expression EXP.\n\ | 314 _("Print data type of expression EXP.\n\ |
| 324 Only one level of typedefs is unrolled. See also \"ptype\".")); | 315 Only one level of typedefs is unrolled. See also \"ptype\".")); |
| 325 } | 316 } |
| OLD | NEW |