1 /* Abstraction of GNU v3 abi.
2 Contributed by Jim Blandy <jimb@redhat.com>
4 Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
27 #include "cp-support.h"
32 #include "gdb_assert.h"
33 #include "gdb_string.h"
35 static struct cp_abi_ops gnu_v3_abi_ops
;
38 gnuv3_is_vtable_name (const char *name
)
40 return strncmp (name
, "_ZTV", 4) == 0;
44 gnuv3_is_operator_name (const char *name
)
46 return strncmp (name
, "operator", 8) == 0;
50 /* To help us find the components of a vtable, we build ourselves a
51 GDB type object representing the vtable structure. Following the
52 V3 ABI, it goes something like this:
54 struct gdb_gnu_v3_abi_vtable {
56 / * An array of virtual call and virtual base offsets. The real
57 length of this array depends on the class hierarchy; we use
58 negative subscripts to access the elements. Yucky, but
59 better than the alternatives. * /
60 ptrdiff_t vcall_and_vbase_offsets[0];
62 / * The offset from a virtual pointer referring to this table
63 to the top of the complete object. * /
64 ptrdiff_t offset_to_top;
66 / * The type_info pointer for this class. This is really a
67 std::type_info *, but GDB doesn't really look at the
68 type_info object itself, so we don't bother to get the type
72 / * Virtual table pointers in objects point here. * /
74 / * Virtual function pointers. Like the vcall/vbase array, the
75 real length of this table depends on the class hierarchy. * /
76 void (*virtual_functions[0]) ();
80 The catch, of course, is that the exact layout of this table
81 depends on the ABI --- word size, endianness, alignment, etc. So
82 the GDB type object is actually a per-architecture kind of thing.
84 vtable_type_gdbarch_data is a gdbarch per-architecture data pointer
85 which refers to the struct type * for this structure, laid out
86 appropriately for the architecture. */
87 static struct gdbarch_data
*vtable_type_gdbarch_data
;
90 /* Human-readable names for the numbers of the fields above. */
92 vtable_field_vcall_and_vbase_offsets
,
93 vtable_field_offset_to_top
,
94 vtable_field_type_info
,
95 vtable_field_virtual_functions
99 /* Return a GDB type representing `struct gdb_gnu_v3_abi_vtable',
100 described above, laid out appropriately for ARCH.
102 We use this function as the gdbarch per-architecture data
103 initialization function. We assume that the gdbarch framework
104 calls the per-architecture data initialization functions after it
105 sets current_gdbarch to the new architecture. */
107 build_gdb_vtable_type (struct gdbarch
*arch
)
110 struct field
*field_list
, *field
;
113 struct type
*void_ptr_type
114 = lookup_pointer_type (builtin_type_void
);
115 struct type
*ptr_to_void_fn_type
116 = lookup_pointer_type (lookup_function_type (builtin_type_void
));
118 /* ARCH can't give us the true ptrdiff_t type, so we guess. */
119 struct type
*ptrdiff_type
120 = init_type (TYPE_CODE_INT
,
121 gdbarch_ptr_bit (current_gdbarch
) / TARGET_CHAR_BIT
, 0,
124 /* We assume no padding is necessary, since GDB doesn't know
125 anything about alignment at the moment. If this assumption bites
126 us, we should add a gdbarch method which, given a type, returns
127 the alignment that type requires, and then use that here. */
129 /* Build the field list. */
130 field_list
= xmalloc (sizeof (struct field
[4]));
131 memset (field_list
, 0, sizeof (struct field
[4]));
132 field
= &field_list
[0];
135 /* ptrdiff_t vcall_and_vbase_offsets[0]; */
136 FIELD_NAME (*field
) = "vcall_and_vbase_offsets";
138 = create_array_type (0, ptrdiff_type
,
139 create_range_type (0, builtin_type_int
, 0, -1));
140 FIELD_BITPOS (*field
) = offset
* TARGET_CHAR_BIT
;
141 offset
+= TYPE_LENGTH (FIELD_TYPE (*field
));
144 /* ptrdiff_t offset_to_top; */
145 FIELD_NAME (*field
) = "offset_to_top";
146 FIELD_TYPE (*field
) = ptrdiff_type
;
147 FIELD_BITPOS (*field
) = offset
* TARGET_CHAR_BIT
;
148 offset
+= TYPE_LENGTH (FIELD_TYPE (*field
));
151 /* void *type_info; */
152 FIELD_NAME (*field
) = "type_info";
153 FIELD_TYPE (*field
) = void_ptr_type
;
154 FIELD_BITPOS (*field
) = offset
* TARGET_CHAR_BIT
;
155 offset
+= TYPE_LENGTH (FIELD_TYPE (*field
));
158 /* void (*virtual_functions[0]) (); */
159 FIELD_NAME (*field
) = "virtual_functions";
161 = create_array_type (0, ptr_to_void_fn_type
,
162 create_range_type (0, builtin_type_int
, 0, -1));
163 FIELD_BITPOS (*field
) = offset
* TARGET_CHAR_BIT
;
164 offset
+= TYPE_LENGTH (FIELD_TYPE (*field
));
167 /* We assumed in the allocation above that there were four fields. */
168 gdb_assert (field
== (field_list
+ 4));
170 t
= init_type (TYPE_CODE_STRUCT
, offset
, 0, 0, 0);
171 TYPE_NFIELDS (t
) = field
- field_list
;
172 TYPE_FIELDS (t
) = field_list
;
173 TYPE_TAG_NAME (t
) = "gdb_gnu_v3_abi_vtable";
179 /* Return the offset from the start of the imaginary `struct
180 gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
181 (i.e., where objects' virtual table pointers point). */
183 vtable_address_point_offset (void)
185 struct type
*vtable_type
= gdbarch_data (current_gdbarch
,
186 vtable_type_gdbarch_data
);
188 return (TYPE_FIELD_BITPOS (vtable_type
, vtable_field_virtual_functions
)
194 gnuv3_rtti_type (struct value
*value
,
195 int *full_p
, int *top_p
, int *using_enc_p
)
197 struct type
*vtable_type
= gdbarch_data (current_gdbarch
,
198 vtable_type_gdbarch_data
);
199 struct type
*values_type
= check_typedef (value_type (value
));
200 CORE_ADDR vtable_address
;
201 struct value
*vtable
;
202 struct minimal_symbol
*vtable_symbol
;
203 const char *vtable_symbol_name
;
204 const char *class_name
;
205 struct type
*run_time_type
;
206 struct type
*base_type
;
207 LONGEST offset_to_top
;
209 /* We only have RTTI for class objects. */
210 if (TYPE_CODE (values_type
) != TYPE_CODE_CLASS
)
213 /* If we can't find the virtual table pointer for values_type, we
214 can't find the RTTI. */
215 fill_in_vptr_fieldno (values_type
);
216 if (TYPE_VPTR_FIELDNO (values_type
) == -1)
222 /* Fetch VALUE's virtual table pointer, and tweak it to point at
223 an instance of our imaginary gdb_gnu_v3_abi_vtable structure. */
224 base_type
= check_typedef (TYPE_VPTR_BASETYPE (values_type
));
225 if (values_type
!= base_type
)
227 value
= value_cast (base_type
, value
);
232 = value_as_address (value_field (value
, TYPE_VPTR_FIELDNO (values_type
)));
233 vtable
= value_at_lazy (vtable_type
,
234 vtable_address
- vtable_address_point_offset ());
236 /* Find the linker symbol for this vtable. */
238 = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtable
)
239 + value_offset (vtable
)
240 + value_embedded_offset (vtable
));
244 /* The symbol's demangled name should be something like "vtable for
245 CLASS", where CLASS is the name of the run-time type of VALUE.
246 If we didn't like this approach, we could instead look in the
247 type_info object itself to get the class name. But this way
248 should work just as well, and doesn't read target memory. */
249 vtable_symbol_name
= SYMBOL_DEMANGLED_NAME (vtable_symbol
);
250 if (vtable_symbol_name
== NULL
251 || strncmp (vtable_symbol_name
, "vtable for ", 11))
253 warning (_("can't find linker symbol for virtual table for `%s' value"),
254 TYPE_NAME (values_type
));
255 if (vtable_symbol_name
)
256 warning (_(" found `%s' instead"), vtable_symbol_name
);
259 class_name
= vtable_symbol_name
+ 11;
261 /* Try to look up the class name as a type name. */
262 /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */
263 run_time_type
= cp_lookup_rtti_type (class_name
, NULL
);
264 if (run_time_type
== NULL
)
267 /* Get the offset from VALUE to the top of the complete object.
268 NOTE: this is the reverse of the meaning of *TOP_P. */
270 = value_as_long (value_field (vtable
, vtable_field_offset_to_top
));
273 *full_p
= (- offset_to_top
== value_embedded_offset (value
)
274 && (TYPE_LENGTH (value_enclosing_type (value
))
275 >= TYPE_LENGTH (run_time_type
)));
277 *top_p
= - offset_to_top
;
279 return run_time_type
;
282 /* Find the vtable for CONTAINER and return a value of the correct
283 vtable type for this architecture. */
285 static struct value
*
286 gnuv3_get_vtable (struct value
*container
)
288 struct type
*vtable_type
= gdbarch_data (current_gdbarch
,
289 vtable_type_gdbarch_data
);
290 struct type
*vtable_pointer_type
;
291 struct value
*vtable_pointer
;
292 CORE_ADDR vtable_pointer_address
, vtable_address
;
294 /* We do not consult the debug information to find the virtual table.
295 The ABI specifies that it is always at offset zero in any class,
296 and debug information may not represent it. We won't issue an
297 error if there's a class with virtual functions but no virtual table
298 pointer, but something's already gone seriously wrong if that
301 We avoid using value_contents on principle, because the object might
304 /* Find the type "pointer to virtual table". */
305 vtable_pointer_type
= lookup_pointer_type (vtable_type
);
307 /* Load it from the start of the class. */
308 vtable_pointer_address
= value_as_address (value_addr (container
));
309 vtable_pointer
= value_at (vtable_pointer_type
, vtable_pointer_address
);
310 vtable_address
= value_as_address (vtable_pointer
);
312 /* Correct it to point at the start of the virtual table, rather
313 than the address point. */
314 return value_at_lazy (vtable_type
,
315 vtable_address
- vtable_address_point_offset ());
318 /* Return a function pointer for CONTAINER's VTABLE_INDEX'th virtual
319 function, of type FNTYPE. */
321 static struct value
*
322 gnuv3_get_virtual_fn (struct value
*container
, struct type
*fntype
,
325 struct value
*vtable
= gnuv3_get_vtable (container
);
328 /* Fetch the appropriate function pointer from the vtable. */
329 vfn
= value_subscript (value_field (vtable
, vtable_field_virtual_functions
),
330 value_from_longest (builtin_type_int
, vtable_index
));
332 /* If this architecture uses function descriptors directly in the vtable,
333 then the address of the vtable entry is actually a "function pointer"
334 (i.e. points to the descriptor). We don't need to scale the index
335 by the size of a function descriptor; GCC does that before outputing
336 debug information. */
337 if (gdbarch_vtable_function_descriptors (current_gdbarch
))
338 vfn
= value_addr (vfn
);
340 /* Cast the function pointer to the appropriate type. */
341 vfn
= value_cast (lookup_pointer_type (fntype
), vfn
);
346 /* GNU v3 implementation of value_virtual_fn_field. See cp-abi.h
347 for a description of the arguments. */
349 static struct value
*
350 gnuv3_virtual_fn_field (struct value
**value_p
,
351 struct fn_field
*f
, int j
,
352 struct type
*vfn_base
, int offset
)
354 struct type
*values_type
= check_typedef (value_type (*value_p
));
356 /* Some simple sanity checks. */
357 if (TYPE_CODE (values_type
) != TYPE_CODE_CLASS
)
358 error (_("Only classes can have virtual functions."));
360 /* Cast our value to the base class which defines this virtual
361 function. This takes care of any necessary `this'
363 if (vfn_base
!= values_type
)
364 *value_p
= value_cast (vfn_base
, *value_p
);
366 return gnuv3_get_virtual_fn (*value_p
, TYPE_FN_FIELD_TYPE (f
, j
),
367 TYPE_FN_FIELD_VOFFSET (f
, j
));
370 /* Compute the offset of the baseclass which is
371 the INDEXth baseclass of class TYPE,
372 for value at VALADDR (in host) at ADDRESS (in target).
373 The result is the offset of the baseclass value relative
374 to (the address of)(ARG) + OFFSET.
376 -1 is returned on error. */
378 gnuv3_baseclass_offset (struct type
*type
, int index
, const bfd_byte
*valaddr
,
381 struct type
*vtable_type
= gdbarch_data (current_gdbarch
,
382 vtable_type_gdbarch_data
);
383 struct value
*vtable
;
384 struct type
*vbasetype
;
385 struct value
*offset_val
, *vbase_array
;
386 CORE_ADDR vtable_address
;
387 long int cur_base_offset
, base_offset
;
389 /* If it isn't a virtual base, this is easy. The offset is in the
391 if (!BASETYPE_VIA_VIRTUAL (type
, index
))
392 return TYPE_BASECLASS_BITPOS (type
, index
) / 8;
394 /* To access a virtual base, we need to use the vbase offset stored in
395 our vtable. Recent GCC versions provide this information. If it isn't
396 available, we could get what we needed from RTTI, or from drawing the
397 complete inheritance graph based on the debug info. Neither is
399 cur_base_offset
= TYPE_BASECLASS_BITPOS (type
, index
) / 8;
400 if (cur_base_offset
>= - vtable_address_point_offset ())
401 error (_("Expected a negative vbase offset (old compiler?)"));
403 cur_base_offset
= cur_base_offset
+ vtable_address_point_offset ();
404 if ((- cur_base_offset
) % TYPE_LENGTH (builtin_type_void_data_ptr
) != 0)
405 error (_("Misaligned vbase offset."));
406 cur_base_offset
= cur_base_offset
407 / ((int) TYPE_LENGTH (builtin_type_void_data_ptr
));
409 /* We're now looking for the cur_base_offset'th entry (negative index)
410 in the vcall_and_vbase_offsets array. We used to cast the object to
411 its TYPE_VPTR_BASETYPE, and reference the vtable as TYPE_VPTR_FIELDNO;
412 however, that cast can not be done without calling baseclass_offset again
413 if the TYPE_VPTR_BASETYPE is a virtual base class, as described in the
414 v3 C++ ABI Section 2.4.I.2.b. Fortunately the ABI guarantees that the
415 vtable pointer will be located at the beginning of the object, so we can
416 bypass the casting. Verify that the TYPE_VPTR_FIELDNO is in fact at the
417 start of whichever baseclass it resides in, as a sanity measure - iff
418 we have debugging information for that baseclass. */
420 vbasetype
= TYPE_VPTR_BASETYPE (type
);
421 if (TYPE_VPTR_FIELDNO (vbasetype
) < 0)
422 fill_in_vptr_fieldno (vbasetype
);
424 if (TYPE_VPTR_FIELDNO (vbasetype
) >= 0
425 && TYPE_FIELD_BITPOS (vbasetype
, TYPE_VPTR_FIELDNO (vbasetype
)) != 0)
426 error (_("Illegal vptr offset in class %s"),
427 TYPE_NAME (vbasetype
) ? TYPE_NAME (vbasetype
) : "<unknown>");
429 vtable_address
= value_as_address (value_at_lazy (builtin_type_void_data_ptr
,
431 vtable
= value_at_lazy (vtable_type
,
432 vtable_address
- vtable_address_point_offset ());
433 offset_val
= value_from_longest(builtin_type_int
, cur_base_offset
);
434 vbase_array
= value_field (vtable
, vtable_field_vcall_and_vbase_offsets
);
435 base_offset
= value_as_long (value_subscript (vbase_array
, offset_val
));
439 /* Locate a virtual method in DOMAIN or its non-virtual base classes
440 which has virtual table index VOFFSET. The method has an associated
441 "this" adjustment of ADJUSTMENT bytes. */
444 gnuv3_find_method_in (struct type
*domain
, CORE_ADDR voffset
,
448 const char *physname
;
450 /* Search this class first. */
456 len
= TYPE_NFN_FIELDS (domain
);
457 for (i
= 0; i
< len
; i
++)
462 f
= TYPE_FN_FIELDLIST1 (domain
, i
);
463 len2
= TYPE_FN_FIELDLIST_LENGTH (domain
, i
);
465 check_stub_method_group (domain
, i
);
466 for (j
= 0; j
< len2
; j
++)
467 if (TYPE_FN_FIELD_VOFFSET (f
, j
) == voffset
)
468 return TYPE_FN_FIELD_PHYSNAME (f
, j
);
472 /* Next search non-virtual bases. If it's in a virtual base,
473 we're out of luck. */
474 for (i
= 0; i
< TYPE_N_BASECLASSES (domain
); i
++)
477 struct type
*basetype
;
479 if (BASETYPE_VIA_VIRTUAL (domain
, i
))
482 pos
= TYPE_BASECLASS_BITPOS (domain
, i
) / 8;
483 basetype
= TYPE_FIELD_TYPE (domain
, i
);
484 /* Recurse with a modified adjustment. We don't need to adjust
486 if (adjustment
>= pos
&& adjustment
< pos
+ TYPE_LENGTH (basetype
))
487 return gnuv3_find_method_in (basetype
, voffset
, adjustment
- pos
);
493 /* GNU v3 implementation of cplus_print_method_ptr. */
496 gnuv3_print_method_ptr (const gdb_byte
*contents
,
498 struct ui_file
*stream
)
505 domain
= TYPE_DOMAIN_TYPE (type
);
507 /* Extract the pointer to member. */
508 ptr_value
= extract_typed_address (contents
, builtin_type_void_func_ptr
);
509 contents
+= TYPE_LENGTH (builtin_type_void_func_ptr
);
510 adjustment
= extract_signed_integer (contents
,
511 TYPE_LENGTH (builtin_type_long
));
513 if (!gdbarch_vbit_in_delta (current_gdbarch
))
515 vbit
= ptr_value
& 1;
516 ptr_value
= ptr_value
^ vbit
;
520 vbit
= adjustment
& 1;
521 adjustment
= adjustment
>> 1;
524 /* Check for NULL. */
525 if (ptr_value
== 0 && vbit
== 0)
527 fprintf_filtered (stream
, "NULL");
531 /* Search for a virtual method. */
535 const char *physname
;
537 /* It's a virtual table offset, maybe in this class. Search
538 for a field with the correct vtable offset. First convert it
539 to an index, as used in TYPE_FN_FIELD_VOFFSET. */
540 voffset
= ptr_value
/ TYPE_LENGTH (builtin_type_long
);
542 physname
= gnuv3_find_method_in (domain
, voffset
, adjustment
);
544 /* If we found a method, print that. We don't bother to disambiguate
545 possible paths to the method based on the adjustment. */
548 char *demangled_name
= cplus_demangle (physname
,
549 DMGL_ANSI
| DMGL_PARAMS
);
550 if (demangled_name
!= NULL
)
552 fprintf_filtered (stream
, "&virtual ");
553 fputs_filtered (demangled_name
, stream
);
554 xfree (demangled_name
);
560 /* We didn't find it; print the raw data. */
563 fprintf_filtered (stream
, "&virtual table offset ");
564 print_longest (stream
, 'd', 1, ptr_value
);
567 print_address_demangle (ptr_value
, stream
, demangle
);
571 fprintf_filtered (stream
, ", this adjustment ");
572 print_longest (stream
, 'd', 1, adjustment
);
576 /* GNU v3 implementation of cplus_method_ptr_size. */
579 gnuv3_method_ptr_size (void)
581 return 2 * TYPE_LENGTH (builtin_type_void_data_ptr
);
584 /* GNU v3 implementation of cplus_make_method_ptr. */
587 gnuv3_make_method_ptr (gdb_byte
*contents
, CORE_ADDR value
, int is_virtual
)
589 int size
= TYPE_LENGTH (builtin_type_void_data_ptr
);
591 /* FIXME drow/2006-12-24: The adjustment of "this" is currently
592 always zero, since the method pointer is of the correct type.
593 But if the method pointer came from a base class, this is
594 incorrect - it should be the offset to the base. The best
595 fix might be to create the pointer to member pointing at the
596 base class and cast it to the derived class, but that requires
597 support for adjusting pointers to members when casting them -
598 not currently supported by GDB. */
600 if (!gdbarch_vbit_in_delta (current_gdbarch
))
602 store_unsigned_integer (contents
, size
, value
| is_virtual
);
603 store_unsigned_integer (contents
+ size
, size
, 0);
607 store_unsigned_integer (contents
, size
, value
);
608 store_unsigned_integer (contents
+ size
, size
, is_virtual
);
612 /* GNU v3 implementation of cplus_method_ptr_to_value. */
614 static struct value
*
615 gnuv3_method_ptr_to_value (struct value
**this_p
, struct value
*method_ptr
)
617 const gdb_byte
*contents
= value_contents (method_ptr
);
619 struct type
*final_type
, *method_type
;
621 struct value
*adjval
;
624 final_type
= TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr
)));
625 final_type
= lookup_pointer_type (final_type
);
627 method_type
= TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr
)));
629 ptr_value
= extract_typed_address (contents
, builtin_type_void_func_ptr
);
630 contents
+= TYPE_LENGTH (builtin_type_void_func_ptr
);
631 adjustment
= extract_signed_integer (contents
,
632 TYPE_LENGTH (builtin_type_long
));
634 if (!gdbarch_vbit_in_delta (current_gdbarch
))
636 vbit
= ptr_value
& 1;
637 ptr_value
= ptr_value
^ vbit
;
641 vbit
= adjustment
& 1;
642 adjustment
= adjustment
>> 1;
645 /* First convert THIS to match the containing type of the pointer to
646 member. This cast may adjust the value of THIS. */
647 *this_p
= value_cast (final_type
, *this_p
);
649 /* Then apply whatever adjustment is necessary. This creates a somewhat
650 strange pointer: it claims to have type FINAL_TYPE, but in fact it
651 might not be a valid FINAL_TYPE. For instance, it might be a
652 base class of FINAL_TYPE. And if it's not the primary base class,
653 then printing it out as a FINAL_TYPE object would produce some pretty
656 But we don't really know the type of the first argument in
657 METHOD_TYPE either, which is why this happens. We can't
658 dereference this later as a FINAL_TYPE, but once we arrive in the
659 called method we'll have debugging information for the type of
660 "this" - and that'll match the value we produce here.
662 You can provoke this case by casting a Base::* to a Derived::*, for
664 *this_p
= value_cast (builtin_type_void_data_ptr
, *this_p
);
665 adjval
= value_from_longest (builtin_type_long
, adjustment
);
666 *this_p
= value_add (*this_p
, adjval
);
667 *this_p
= value_cast (final_type
, *this_p
);
671 LONGEST voffset
= ptr_value
/ TYPE_LENGTH (builtin_type_long
);
672 return gnuv3_get_virtual_fn (value_ind (*this_p
), method_type
, voffset
);
675 return value_from_pointer (lookup_pointer_type (method_type
), ptr_value
);
678 /* Determine if we are currently in a C++ thunk. If so, get the address
679 of the routine we are thunking to and continue to there instead. */
682 gnuv3_skip_trampoline (struct frame_info
*frame
, CORE_ADDR stop_pc
)
684 CORE_ADDR real_stop_pc
, method_stop_pc
;
685 struct minimal_symbol
*thunk_sym
, *fn_sym
;
686 struct obj_section
*section
;
687 char *thunk_name
, *fn_name
;
689 real_stop_pc
= gdbarch_skip_trampoline_code
690 (current_gdbarch
, frame
, stop_pc
);
691 if (real_stop_pc
== 0)
692 real_stop_pc
= stop_pc
;
694 /* Find the linker symbol for this potential thunk. */
695 thunk_sym
= lookup_minimal_symbol_by_pc (real_stop_pc
);
696 section
= find_pc_section (real_stop_pc
);
697 if (thunk_sym
== NULL
|| section
== NULL
)
700 /* The symbol's demangled name should be something like "virtual
701 thunk to FUNCTION", where FUNCTION is the name of the function
703 thunk_name
= SYMBOL_DEMANGLED_NAME (thunk_sym
);
704 if (thunk_name
== NULL
|| strstr (thunk_name
, " thunk to ") == NULL
)
707 fn_name
= strstr (thunk_name
, " thunk to ") + strlen (" thunk to ");
708 fn_sym
= lookup_minimal_symbol (fn_name
, NULL
, section
->objfile
);
712 method_stop_pc
= SYMBOL_VALUE_ADDRESS (fn_sym
);
713 real_stop_pc
= gdbarch_skip_trampoline_code
714 (current_gdbarch
, frame
, method_stop_pc
);
715 if (real_stop_pc
== 0)
716 real_stop_pc
= method_stop_pc
;
722 init_gnuv3_ops (void)
724 vtable_type_gdbarch_data
= gdbarch_data_register_post_init (build_gdb_vtable_type
);
726 gnu_v3_abi_ops
.shortname
= "gnu-v3";
727 gnu_v3_abi_ops
.longname
= "GNU G++ Version 3 ABI";
728 gnu_v3_abi_ops
.doc
= "G++ Version 3 ABI";
729 gnu_v3_abi_ops
.is_destructor_name
=
730 (enum dtor_kinds (*) (const char *))is_gnu_v3_mangled_dtor
;
731 gnu_v3_abi_ops
.is_constructor_name
=
732 (enum ctor_kinds (*) (const char *))is_gnu_v3_mangled_ctor
;
733 gnu_v3_abi_ops
.is_vtable_name
= gnuv3_is_vtable_name
;
734 gnu_v3_abi_ops
.is_operator_name
= gnuv3_is_operator_name
;
735 gnu_v3_abi_ops
.rtti_type
= gnuv3_rtti_type
;
736 gnu_v3_abi_ops
.virtual_fn_field
= gnuv3_virtual_fn_field
;
737 gnu_v3_abi_ops
.baseclass_offset
= gnuv3_baseclass_offset
;
738 gnu_v3_abi_ops
.print_method_ptr
= gnuv3_print_method_ptr
;
739 gnu_v3_abi_ops
.method_ptr_size
= gnuv3_method_ptr_size
;
740 gnu_v3_abi_ops
.make_method_ptr
= gnuv3_make_method_ptr
;
741 gnu_v3_abi_ops
.method_ptr_to_value
= gnuv3_method_ptr_to_value
;
742 gnu_v3_abi_ops
.skip_trampoline
= gnuv3_skip_trampoline
;
745 extern initialize_file_ftype _initialize_gnu_v3_abi
; /* -Wmissing-prototypes */
748 _initialize_gnu_v3_abi (void)
752 register_cp_abi (&gnu_v3_abi_ops
);