Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1103)

Side by Side Diff: gdb/gnu-v3-abi.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/gnu-v2-abi.c ('k') | gdb/gnulib/Makefile.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Abstraction of GNU v3 abi. 1 /* Abstraction of GNU v3 abi.
2 Contributed by Jim Blandy <jimb@redhat.com> 2 Contributed by Jim Blandy <jimb@redhat.com>
3 3
4 Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc. 4 Copyright (C) 2001-2013 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
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 #include "defs.h" 21 #include "defs.h"
22 #include "value.h" 22 #include "value.h"
23 #include "cp-abi.h" 23 #include "cp-abi.h"
24 #include "cp-support.h" 24 #include "cp-support.h"
25 #include "demangle.h" 25 #include "demangle.h"
26 #include "objfiles.h" 26 #include "objfiles.h"
27 #include "valprint.h" 27 #include "valprint.h"
28 #include "c-lang.h" 28 #include "c-lang.h"
29 #include "exceptions.h" 29 #include "exceptions.h"
30 #include "typeprint.h"
30 31
31 #include "gdb_assert.h" 32 #include "gdb_assert.h"
32 #include "gdb_string.h" 33 #include <string.h>
33 34
34 static struct cp_abi_ops gnu_v3_abi_ops; 35 static struct cp_abi_ops gnu_v3_abi_ops;
35 36
37 /* A gdbarch key for std::type_info, in the event that it can't be
38 found in the debug info. */
39
40 static struct gdbarch_data *std_type_info_gdbarch_data;
41
42
36 static int 43 static int
37 gnuv3_is_vtable_name (const char *name) 44 gnuv3_is_vtable_name (const char *name)
38 { 45 {
39 return strncmp (name, "_ZTV", 4) == 0; 46 return strncmp (name, "_ZTV", 4) == 0;
40 } 47 }
41 48
42 static int 49 static int
43 gnuv3_is_operator_name (const char *name) 50 gnuv3_is_operator_name (const char *name)
44 { 51 {
45 return strncmp (name, "operator", 8) == 0; 52 return strncmp (name, "operator", 8) == 0;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 int *full_p, int *top_p, int *using_enc_p) 282 int *full_p, int *top_p, int *using_enc_p)
276 { 283 {
277 struct gdbarch *gdbarch; 284 struct gdbarch *gdbarch;
278 struct type *values_type = check_typedef (value_type (value)); 285 struct type *values_type = check_typedef (value_type (value));
279 struct value *vtable; 286 struct value *vtable;
280 struct minimal_symbol *vtable_symbol; 287 struct minimal_symbol *vtable_symbol;
281 const char *vtable_symbol_name; 288 const char *vtable_symbol_name;
282 const char *class_name; 289 const char *class_name;
283 struct type *run_time_type; 290 struct type *run_time_type;
284 LONGEST offset_to_top; 291 LONGEST offset_to_top;
292 char *atsign;
285 293
286 /* We only have RTTI for class objects. */ 294 /* We only have RTTI for class objects. */
287 if (TYPE_CODE (values_type) != TYPE_CODE_CLASS) 295 if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
288 return NULL; 296 return NULL;
289 297
290 /* Java doesn't have RTTI following the C++ ABI. */ 298 /* Java doesn't have RTTI following the C++ ABI. */
291 if (TYPE_CPLUS_REALLY_JAVA (values_type)) 299 if (TYPE_CPLUS_REALLY_JAVA (values_type))
292 return NULL; 300 return NULL;
293 301
294 /* Determine architecture. */ 302 /* Determine architecture. */
295 gdbarch = get_type_arch (values_type); 303 gdbarch = get_type_arch (values_type);
296 304
297 if (using_enc_p) 305 if (using_enc_p)
298 *using_enc_p = 0; 306 *using_enc_p = 0;
299 307
300 vtable = gnuv3_get_vtable (gdbarch, value_type (value), 308 vtable = gnuv3_get_vtable (gdbarch, value_type (value),
301 value_as_address (value_addr (value))); 309 value_as_address (value_addr (value)));
302 if (vtable == NULL) 310 if (vtable == NULL)
303 return NULL; 311 return NULL;
304 312
305 /* Find the linker symbol for this vtable. */ 313 /* Find the linker symbol for this vtable. */
306 vtable_symbol 314 vtable_symbol
307 = lookup_minimal_symbol_by_pc (value_address (vtable) 315 = lookup_minimal_symbol_by_pc (value_address (vtable)
308 + value_embedded_offset (vtable)); 316 + value_embedded_offset (vtable)).minsym;
309 if (! vtable_symbol) 317 if (! vtable_symbol)
310 return NULL; 318 return NULL;
311 319
312 /* The symbol's demangled name should be something like "vtable for 320 /* The symbol's demangled name should be something like "vtable for
313 CLASS", where CLASS is the name of the run-time type of VALUE. 321 CLASS", where CLASS is the name of the run-time type of VALUE.
314 If we didn't like this approach, we could instead look in the 322 If we didn't like this approach, we could instead look in the
315 type_info object itself to get the class name. But this way 323 type_info object itself to get the class name. But this way
316 should work just as well, and doesn't read target memory. */ 324 should work just as well, and doesn't read target memory. */
317 vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol); 325 vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);
318 if (vtable_symbol_name == NULL 326 if (vtable_symbol_name == NULL
319 || strncmp (vtable_symbol_name, "vtable for ", 11)) 327 || strncmp (vtable_symbol_name, "vtable for ", 11))
320 { 328 {
321 warning (_("can't find linker symbol for virtual table for `%s' value"), 329 warning (_("can't find linker symbol for virtual table for `%s' value"),
322 TYPE_SAFE_NAME (values_type)); 330 TYPE_SAFE_NAME (values_type));
323 if (vtable_symbol_name) 331 if (vtable_symbol_name)
324 warning (_(" found `%s' instead"), vtable_symbol_name); 332 warning (_(" found `%s' instead"), vtable_symbol_name);
325 return NULL; 333 return NULL;
326 } 334 }
327 class_name = vtable_symbol_name + 11; 335 class_name = vtable_symbol_name + 11;
328 336
337 /* Strip off @plt and version suffixes. */
338 atsign = strchr (class_name, '@');
339 if (atsign != NULL)
340 {
341 char *copy;
342
343 copy = alloca (atsign - class_name + 1);
344 memcpy (copy, class_name, atsign - class_name);
345 copy[atsign - class_name] = '\0';
346 class_name = copy;
347 }
348
329 /* Try to look up the class name as a type name. */ 349 /* Try to look up the class name as a type name. */
330 /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */ 350 /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */
331 run_time_type = cp_lookup_rtti_type (class_name, NULL); 351 run_time_type = cp_lookup_rtti_type (class_name, NULL);
332 if (run_time_type == NULL) 352 if (run_time_type == NULL)
333 return NULL; 353 return NULL;
334 354
335 /* Get the offset from VALUE to the top of the complete object. 355 /* Get the offset from VALUE to the top of the complete object.
336 NOTE: this is the reverse of the meaning of *TOP_P. */ 356 NOTE: this is the reverse of the meaning of *TOP_P. */
337 offset_to_top 357 offset_to_top
338 = value_as_long (value_field (vtable, vtable_field_offset_to_top)); 358 = value_as_long (value_field (vtable, vtable_field_offset_to_top));
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 for a field with the correct vtable offset. First convert it 605 for a field with the correct vtable offset. First convert it
586 to an index, as used in TYPE_FN_FIELD_VOFFSET. */ 606 to an index, as used in TYPE_FN_FIELD_VOFFSET. */
587 voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch)); 607 voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch));
588 608
589 physname = gnuv3_find_method_in (domain, voffset, adjustment); 609 physname = gnuv3_find_method_in (domain, voffset, adjustment);
590 610
591 /* If we found a method, print that. We don't bother to disambiguate 611 /* If we found a method, print that. We don't bother to disambiguate
592 possible paths to the method based on the adjustment. */ 612 possible paths to the method based on the adjustment. */
593 if (physname) 613 if (physname)
594 { 614 {
595 » char *demangled_name = cplus_demangle (physname, 615 » char *demangled_name = gdb_demangle (physname,
596 » » » » » » DMGL_ANSI | DMGL_PARAMS); 616 » » » » » DMGL_ANSI | DMGL_PARAMS);
597 617
598 fprintf_filtered (stream, "&virtual "); 618 fprintf_filtered (stream, "&virtual ");
599 if (demangled_name == NULL) 619 if (demangled_name == NULL)
600 fputs_filtered (physname, stream); 620 fputs_filtered (physname, stream);
601 else 621 else
602 { 622 {
603 fputs_filtered (demangled_name, stream); 623 fputs_filtered (demangled_name, stream);
604 xfree (demangled_name); 624 xfree (demangled_name);
605 } 625 }
606 return; 626 return;
607 } 627 }
608 } 628 }
609 else if (ptr_value != 0) 629 else if (ptr_value != 0)
610 { 630 {
611 /* Found a non-virtual function: print out the type. */ 631 /* Found a non-virtual function: print out the type. */
612 fputs_filtered ("(", stream); 632 fputs_filtered ("(", stream);
613 c_print_type (type, "", stream, -1, 0); 633 c_print_type (type, "", stream, -1, 0, &type_print_raw_options);
614 fputs_filtered (") ", stream); 634 fputs_filtered (") ", stream);
615 } 635 }
616 636
617 /* We didn't find it; print the raw data. */ 637 /* We didn't find it; print the raw data. */
618 if (vbit) 638 if (vbit)
619 { 639 {
620 fprintf_filtered (stream, "&virtual table offset "); 640 fprintf_filtered (stream, "&virtual table offset ");
621 print_longest (stream, 'd', 1, ptr_value); 641 print_longest (stream, 'd', 1, ptr_value);
622 } 642 }
623 else 643 else
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 817
798 static void 818 static void
799 compute_vtable_size (htab_t offset_hash, 819 compute_vtable_size (htab_t offset_hash,
800 VEC (value_and_voffset_p) **offset_vec, 820 VEC (value_and_voffset_p) **offset_vec,
801 struct value *value) 821 struct value *value)
802 { 822 {
803 int i; 823 int i;
804 struct type *type = check_typedef (value_type (value)); 824 struct type *type = check_typedef (value_type (value));
805 void **slot; 825 void **slot;
806 struct value_and_voffset search_vo, *current_vo; 826 struct value_and_voffset search_vo, *current_vo;
807 CORE_ADDR addr = value_address (value) + value_embedded_offset (value);
808 827
809 /* If the object is not dynamic, then we are done; as it cannot have 828 /* If the object is not dynamic, then we are done; as it cannot have
810 dynamic base types either. */ 829 dynamic base types either. */
811 if (!gnuv3_dynamic_class (type)) 830 if (!gnuv3_dynamic_class (type))
812 return; 831 return;
813 832
814 /* Update the hash and the vec, if needed. */ 833 /* Update the hash and the vec, if needed. */
815 search_vo.value = value; 834 search_vo.value = value;
816 slot = htab_find_slot (offset_hash, &search_vo, INSERT); 835 slot = htab_find_slot (offset_hash, &search_vo, INSERT);
817 if (*slot) 836 if (*slot)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 if (count > 0) 983 if (count > 0)
965 printf_filtered ("\n"); 984 printf_filtered ("\n");
966 print_one_vtable (gdbarch, iter->value, iter->max_voffset, &opts); 985 print_one_vtable (gdbarch, iter->value, iter->max_voffset, &opts);
967 ++count; 986 ++count;
968 } 987 }
969 } 988 }
970 989
971 do_cleanups (cleanup); 990 do_cleanups (cleanup);
972 } 991 }
973 992
993 /* Return a GDB type representing `struct std::type_info', laid out
994 appropriately for ARCH.
995
996 We use this function as the gdbarch per-architecture data
997 initialization function. */
998
999 static void *
1000 build_std_type_info_type (struct gdbarch *arch)
1001 {
1002 struct type *t;
1003 struct field *field_list, *field;
1004 int offset;
1005 struct type *void_ptr_type
1006 = builtin_type (arch)->builtin_data_ptr;
1007 struct type *char_type
1008 = builtin_type (arch)->builtin_char;
1009 struct type *char_ptr_type
1010 = make_pointer_type (make_cv_type (1, 0, char_type, NULL), NULL);
1011
1012 field_list = xmalloc (sizeof (struct field [2]));
1013 memset (field_list, 0, sizeof (struct field [2]));
1014 field = &field_list[0];
1015 offset = 0;
1016
1017 /* The vtable. */
1018 FIELD_NAME (*field) = "_vptr.type_info";
1019 FIELD_TYPE (*field) = void_ptr_type;
1020 SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
1021 offset += TYPE_LENGTH (FIELD_TYPE (*field));
1022 field++;
1023
1024 /* The name. */
1025 FIELD_NAME (*field) = "__name";
1026 FIELD_TYPE (*field) = char_ptr_type;
1027 SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
1028 offset += TYPE_LENGTH (FIELD_TYPE (*field));
1029 field++;
1030
1031 gdb_assert (field == (field_list + 2));
1032
1033 t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);
1034 TYPE_NFIELDS (t) = field - field_list;
1035 TYPE_FIELDS (t) = field_list;
1036 TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info";
1037 INIT_CPLUS_SPECIFIC (t);
1038
1039 return t;
1040 }
1041
1042 /* Implement the 'get_typeid_type' method. */
1043
1044 static struct type *
1045 gnuv3_get_typeid_type (struct gdbarch *gdbarch)
1046 {
1047 struct symbol *typeinfo;
1048 struct type *typeinfo_type;
1049
1050 typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN, NULL);
1051 if (typeinfo == NULL)
1052 typeinfo_type = gdbarch_data (gdbarch, std_type_info_gdbarch_data);
1053 else
1054 typeinfo_type = SYMBOL_TYPE (typeinfo);
1055
1056 return typeinfo_type;
1057 }
1058
1059 /* Implement the 'get_typeid' method. */
1060
1061 static struct value *
1062 gnuv3_get_typeid (struct value *value)
1063 {
1064 struct type *typeinfo_type;
1065 struct type *type;
1066 struct gdbarch *gdbarch;
1067 struct cleanup *cleanup;
1068 struct value *result;
1069 char *typename, *canonical;
1070
1071 /* We have to handle values a bit trickily here, to allow this code
1072 to work properly with non_lvalue values that are really just
1073 disguised types. */
1074 if (value_lval_const (value) == lval_memory)
1075 value = coerce_ref (value);
1076
1077 type = check_typedef (value_type (value));
1078
1079 /* In the non_lvalue case, a reference might have slipped through
1080 here. */
1081 if (TYPE_CODE (type) == TYPE_CODE_REF)
1082 type = check_typedef (TYPE_TARGET_TYPE (type));
1083
1084 /* Ignore top-level cv-qualifiers. */
1085 type = make_cv_type (0, 0, type, NULL);
1086 gdbarch = get_type_arch (type);
1087
1088 typename = type_to_string (type);
1089 if (typename == NULL)
1090 error (_("cannot find typeinfo for unnamed type"));
1091 cleanup = make_cleanup (xfree, typename);
1092
1093 /* We need to canonicalize the type name here, because we do lookups
1094 using the demangled name, and so we must match the format it
1095 uses. E.g., GDB tends to use "const char *" as a type name, but
1096 the demangler uses "char const *". */
1097 canonical = cp_canonicalize_string (typename);
1098 if (canonical != NULL)
1099 {
1100 make_cleanup (xfree, canonical);
1101 typename = canonical;
1102 }
1103
1104 typeinfo_type = gnuv3_get_typeid_type (gdbarch);
1105
1106 /* We check for lval_memory because in the "typeid (type-id)" case,
1107 the type is passed via a not_lval value object. */
1108 if (TYPE_CODE (type) == TYPE_CODE_CLASS
1109 && value_lval_const (value) == lval_memory
1110 && gnuv3_dynamic_class (type))
1111 {
1112 struct value *vtable, *typeinfo_value;
1113 CORE_ADDR address = value_address (value) + value_embedded_offset (value);
1114
1115 vtable = gnuv3_get_vtable (gdbarch, type, address);
1116 if (vtable == NULL)
1117 error (_("cannot find typeinfo for object of type '%s'"), typename);
1118 typeinfo_value = value_field (vtable, vtable_field_type_info);
1119 result = value_ind (value_cast (make_pointer_type (typeinfo_type, NULL),
1120 typeinfo_value));
1121 }
1122 else
1123 {
1124 char *sym_name;
1125 struct minimal_symbol *minsym;
1126
1127 sym_name = concat ("typeinfo for ", typename, (char *) NULL);
1128 make_cleanup (xfree, sym_name);
1129 minsym = lookup_minimal_symbol (sym_name, NULL, NULL);
1130
1131 if (minsym == NULL)
1132 error (_("could not find typeinfo symbol for '%s'"), typename);
1133
1134 result = value_at_lazy (typeinfo_type, SYMBOL_VALUE_ADDRESS (minsym));
1135 }
1136
1137 do_cleanups (cleanup);
1138 return result;
1139 }
1140
1141 /* Implement the 'get_typename_from_type_info' method. */
1142
1143 static char *
1144 gnuv3_get_typename_from_type_info (struct value *type_info_ptr)
1145 {
1146 struct gdbarch *gdbarch = get_type_arch (value_type (type_info_ptr));
1147 struct bound_minimal_symbol typeinfo_sym;
1148 CORE_ADDR addr;
1149 const char *symname;
1150 const char *class_name;
1151 const char *atsign;
1152
1153 addr = value_as_address (type_info_ptr);
1154 typeinfo_sym = lookup_minimal_symbol_by_pc (addr);
1155 if (typeinfo_sym.minsym == NULL)
1156 error (_("could not find minimal symbol for typeinfo address %s"),
1157 paddress (gdbarch, addr));
1158
1159 #define TYPEINFO_PREFIX "typeinfo for "
1160 #define TYPEINFO_PREFIX_LEN (sizeof (TYPEINFO_PREFIX) - 1)
1161 symname = SYMBOL_DEMANGLED_NAME (typeinfo_sym.minsym);
1162 if (symname == NULL || strncmp (symname, TYPEINFO_PREFIX,
1163 TYPEINFO_PREFIX_LEN))
1164 error (_("typeinfo symbol '%s' has unexpected name"),
1165 SYMBOL_LINKAGE_NAME (typeinfo_sym.minsym));
1166 class_name = symname + TYPEINFO_PREFIX_LEN;
1167
1168 /* Strip off @plt and version suffixes. */
1169 atsign = strchr (class_name, '@');
1170 if (atsign != NULL)
1171 return savestring (class_name, atsign - class_name);
1172 return xstrdup (class_name);
1173 }
1174
1175 /* Implement the 'get_type_from_type_info' method. */
1176
1177 static struct type *
1178 gnuv3_get_type_from_type_info (struct value *type_info_ptr)
1179 {
1180 char *typename;
1181 struct cleanup *cleanup;
1182 struct value *type_val;
1183 struct expression *expr;
1184 struct type *result;
1185
1186 typename = gnuv3_get_typename_from_type_info (type_info_ptr);
1187 cleanup = make_cleanup (xfree, typename);
1188
1189 /* We have to parse the type name, since in general there is not a
1190 symbol for a type. This is somewhat bogus since there may be a
1191 mis-parse. Another approach might be to re-use the demangler's
1192 internal form to reconstruct the type somehow. */
1193
1194 expr = parse_expression (typename);
1195 make_cleanup (xfree, expr);
1196
1197 type_val = evaluate_type (expr);
1198 result = value_type (type_val);
1199
1200 do_cleanups (cleanup);
1201 return result;
1202 }
1203
974 /* Determine if we are currently in a C++ thunk. If so, get the address 1204 /* Determine if we are currently in a C++ thunk. If so, get the address
975 of the routine we are thunking to and continue to there instead. */ 1205 of the routine we are thunking to and continue to there instead. */
976 1206
977 static CORE_ADDR 1207 static CORE_ADDR
978 gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc) 1208 gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc)
979 { 1209 {
980 CORE_ADDR real_stop_pc, method_stop_pc; 1210 CORE_ADDR real_stop_pc, method_stop_pc, func_addr;
981 struct gdbarch *gdbarch = get_frame_arch (frame); 1211 struct gdbarch *gdbarch = get_frame_arch (frame);
982 struct minimal_symbol *thunk_sym, *fn_sym; 1212 struct minimal_symbol *thunk_sym, *fn_sym;
983 struct obj_section *section; 1213 struct obj_section *section;
984 const char *thunk_name, *fn_name; 1214 const char *thunk_name, *fn_name;
985 1215
986 real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc); 1216 real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc);
987 if (real_stop_pc == 0) 1217 if (real_stop_pc == 0)
988 real_stop_pc = stop_pc; 1218 real_stop_pc = stop_pc;
989 1219
990 /* Find the linker symbol for this potential thunk. */ 1220 /* Find the linker symbol for this potential thunk. */
991 thunk_sym = lookup_minimal_symbol_by_pc (real_stop_pc); 1221 thunk_sym = lookup_minimal_symbol_by_pc (real_stop_pc).minsym;
992 section = find_pc_section (real_stop_pc); 1222 section = find_pc_section (real_stop_pc);
993 if (thunk_sym == NULL || section == NULL) 1223 if (thunk_sym == NULL || section == NULL)
994 return 0; 1224 return 0;
995 1225
996 /* The symbol's demangled name should be something like "virtual 1226 /* The symbol's demangled name should be something like "virtual
997 thunk to FUNCTION", where FUNCTION is the name of the function 1227 thunk to FUNCTION", where FUNCTION is the name of the function
998 being thunked to. */ 1228 being thunked to. */
999 thunk_name = SYMBOL_DEMANGLED_NAME (thunk_sym); 1229 thunk_name = SYMBOL_DEMANGLED_NAME (thunk_sym);
1000 if (thunk_name == NULL || strstr (thunk_name, " thunk to ") == NULL) 1230 if (thunk_name == NULL || strstr (thunk_name, " thunk to ") == NULL)
1001 return 0; 1231 return 0;
1002 1232
1003 fn_name = strstr (thunk_name, " thunk to ") + strlen (" thunk to "); 1233 fn_name = strstr (thunk_name, " thunk to ") + strlen (" thunk to ");
1004 fn_sym = lookup_minimal_symbol (fn_name, NULL, section->objfile); 1234 fn_sym = lookup_minimal_symbol (fn_name, NULL, section->objfile);
1005 if (fn_sym == NULL) 1235 if (fn_sym == NULL)
1006 return 0; 1236 return 0;
1007 1237
1008 method_stop_pc = SYMBOL_VALUE_ADDRESS (fn_sym); 1238 method_stop_pc = SYMBOL_VALUE_ADDRESS (fn_sym);
1239
1240 /* Some targets have minimal symbols pointing to function descriptors
1241 (powerpc 64 for example). Make sure to retrieve the address
1242 of the real function from the function descriptor before passing on
1243 the address to other layers of GDB. */
1244 func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, method_stop_pc,
1245 &current_target);
1246 if (func_addr != 0)
1247 method_stop_pc = func_addr;
1248
1009 real_stop_pc = gdbarch_skip_trampoline_code 1249 real_stop_pc = gdbarch_skip_trampoline_code
1010 (gdbarch, frame, method_stop_pc); 1250 (gdbarch, frame, method_stop_pc);
1011 if (real_stop_pc == 0) 1251 if (real_stop_pc == 0)
1012 real_stop_pc = method_stop_pc; 1252 real_stop_pc = method_stop_pc;
1013 1253
1014 return real_stop_pc; 1254 return real_stop_pc;
1015 } 1255 }
1016 1256
1017 /* Return nonzero if a type should be passed by reference. 1257 /* Return nonzero if a type should be passed by reference.
1018 1258
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 return 1; 1303 return 1;
1064 1304
1065 /* If the mangled name of this method doesn't indicate that it 1305 /* If the mangled name of this method doesn't indicate that it
1066 is a constructor, we're not interested. 1306 is a constructor, we're not interested.
1067 1307
1068 FIXME drow/2007-09-23: We could do this using the name of 1308 FIXME drow/2007-09-23: We could do this using the name of
1069 the method and the name of the class instead of dealing 1309 the method and the name of the class instead of dealing
1070 with the mangled name. We don't have a convenient function 1310 with the mangled name. We don't have a convenient function
1071 to strip off both leading scope qualifiers and trailing 1311 to strip off both leading scope qualifiers and trailing
1072 template arguments yet. */ 1312 template arguments yet. */
1073 » if (!is_constructor_name (TYPE_FN_FIELD_PHYSNAME (fn, fieldelem))) 1313 » if (!is_constructor_name (TYPE_FN_FIELD_PHYSNAME (fn, fieldelem))
1314 » && !TYPE_FN_FIELD_CONSTRUCTOR (fn, fieldelem))
1074 continue; 1315 continue;
1075 1316
1076 /* If this method takes two arguments, and the second argument is 1317 /* If this method takes two arguments, and the second argument is
1077 a reference to this class, then it is a copy constructor. */ 1318 a reference to this class, then it is a copy constructor. */
1078 if (TYPE_NFIELDS (fieldtype) == 2 1319 if (TYPE_NFIELDS (fieldtype) == 2
1079 && TYPE_CODE (TYPE_FIELD_TYPE (fieldtype, 1)) == TYPE_CODE_REF 1320 && TYPE_CODE (TYPE_FIELD_TYPE (fieldtype, 1)) == TYPE_CODE_REF
1080 && check_typedef (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (fieldtype, 1321 && check_typedef (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (fieldtype,
1081 1))) == type) 1322 1))) == type)
1082 return 1; 1323 return 1;
1083 } 1324 }
(...skipping 11 matching lines...) Expand all
1095 return 1; 1336 return 1;
1096 1337
1097 return 0; 1338 return 0;
1098 } 1339 }
1099 1340
1100 static void 1341 static void
1101 init_gnuv3_ops (void) 1342 init_gnuv3_ops (void)
1102 { 1343 {
1103 vtable_type_gdbarch_data 1344 vtable_type_gdbarch_data
1104 = gdbarch_data_register_post_init (build_gdb_vtable_type); 1345 = gdbarch_data_register_post_init (build_gdb_vtable_type);
1346 std_type_info_gdbarch_data
1347 = gdbarch_data_register_post_init (build_std_type_info_type);
1105 1348
1106 gnu_v3_abi_ops.shortname = "gnu-v3"; 1349 gnu_v3_abi_ops.shortname = "gnu-v3";
1107 gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI"; 1350 gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI";
1108 gnu_v3_abi_ops.doc = "G++ Version 3 ABI"; 1351 gnu_v3_abi_ops.doc = "G++ Version 3 ABI";
1109 gnu_v3_abi_ops.is_destructor_name = 1352 gnu_v3_abi_ops.is_destructor_name =
1110 (enum dtor_kinds (*) (const char *))is_gnu_v3_mangled_dtor; 1353 (enum dtor_kinds (*) (const char *))is_gnu_v3_mangled_dtor;
1111 gnu_v3_abi_ops.is_constructor_name = 1354 gnu_v3_abi_ops.is_constructor_name =
1112 (enum ctor_kinds (*) (const char *))is_gnu_v3_mangled_ctor; 1355 (enum ctor_kinds (*) (const char *))is_gnu_v3_mangled_ctor;
1113 gnu_v3_abi_ops.is_vtable_name = gnuv3_is_vtable_name; 1356 gnu_v3_abi_ops.is_vtable_name = gnuv3_is_vtable_name;
1114 gnu_v3_abi_ops.is_operator_name = gnuv3_is_operator_name; 1357 gnu_v3_abi_ops.is_operator_name = gnuv3_is_operator_name;
1115 gnu_v3_abi_ops.rtti_type = gnuv3_rtti_type; 1358 gnu_v3_abi_ops.rtti_type = gnuv3_rtti_type;
1116 gnu_v3_abi_ops.virtual_fn_field = gnuv3_virtual_fn_field; 1359 gnu_v3_abi_ops.virtual_fn_field = gnuv3_virtual_fn_field;
1117 gnu_v3_abi_ops.baseclass_offset = gnuv3_baseclass_offset; 1360 gnu_v3_abi_ops.baseclass_offset = gnuv3_baseclass_offset;
1118 gnu_v3_abi_ops.print_method_ptr = gnuv3_print_method_ptr; 1361 gnu_v3_abi_ops.print_method_ptr = gnuv3_print_method_ptr;
1119 gnu_v3_abi_ops.method_ptr_size = gnuv3_method_ptr_size; 1362 gnu_v3_abi_ops.method_ptr_size = gnuv3_method_ptr_size;
1120 gnu_v3_abi_ops.make_method_ptr = gnuv3_make_method_ptr; 1363 gnu_v3_abi_ops.make_method_ptr = gnuv3_make_method_ptr;
1121 gnu_v3_abi_ops.method_ptr_to_value = gnuv3_method_ptr_to_value; 1364 gnu_v3_abi_ops.method_ptr_to_value = gnuv3_method_ptr_to_value;
1122 gnu_v3_abi_ops.print_vtable = gnuv3_print_vtable; 1365 gnu_v3_abi_ops.print_vtable = gnuv3_print_vtable;
1366 gnu_v3_abi_ops.get_typeid = gnuv3_get_typeid;
1367 gnu_v3_abi_ops.get_typeid_type = gnuv3_get_typeid_type;
1368 gnu_v3_abi_ops.get_type_from_type_info = gnuv3_get_type_from_type_info;
1369 gnu_v3_abi_ops.get_typename_from_type_info
1370 = gnuv3_get_typename_from_type_info;
1123 gnu_v3_abi_ops.skip_trampoline = gnuv3_skip_trampoline; 1371 gnu_v3_abi_ops.skip_trampoline = gnuv3_skip_trampoline;
1124 gnu_v3_abi_ops.pass_by_reference = gnuv3_pass_by_reference; 1372 gnu_v3_abi_ops.pass_by_reference = gnuv3_pass_by_reference;
1125 } 1373 }
1126 1374
1127 extern initialize_file_ftype _initialize_gnu_v3_abi; /* -Wmissing-prototypes */ 1375 extern initialize_file_ftype _initialize_gnu_v3_abi; /* -Wmissing-prototypes */
1128 1376
1129 void 1377 void
1130 _initialize_gnu_v3_abi (void) 1378 _initialize_gnu_v3_abi (void)
1131 { 1379 {
1132 init_gnuv3_ops (); 1380 init_gnuv3_ops ();
1133 1381
1134 register_cp_abi (&gnu_v3_abi_ops); 1382 register_cp_abi (&gnu_v3_abi_ops);
1383 set_cp_abi_as_auto_default (gnu_v3_abi_ops.shortname);
1135 } 1384 }
OLDNEW
« no previous file with comments | « gdb/gnu-v2-abi.c ('k') | gdb/gnulib/Makefile.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698