aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-10-09 19:21:39 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-10-09 19:21:39 +0000
commit8e3b41a9061833aa9dc504d68e7446bca4984f16 (patch)
treec156fe7efb3ee9ff8c1cad54a4e65e3b650495f5 /gdb/block.c
parentb6cdc2c1b50937e63d8a9b3a462015912fc3587e (diff)
downloadgdb-8e3b41a9061833aa9dc504d68e7446bca4984f16.zip
gdb-8e3b41a9061833aa9dc504d68e7446bca4984f16.tar.gz
gdb-8e3b41a9061833aa9dc504d68e7446bca4984f16.tar.bz2
gdb/
Implement basic support for DW_TAG_GNU_call_site. * block.c: Include gdbtypes.h and exceptions.h. (call_site_for_pc): New function. * block.h (call_site_for_pc): New declaration. * defs.h: Include hashtab.h. (make_cleanup_htab_delete, core_addr_hash, core_addr_eq): New declarations. * dwarf2-frame.c (dwarf2_frame_ctx_funcs): Install ctx_no_push_dwarf_reg_entry_value. * dwarf2expr.c (read_uleb128, read_sleb128): Support R as NULL. (dwarf_block_to_dwarf_reg): New function. (execute_stack_op) <DW_OP_GNU_entry_value>: Implement it. (ctx_no_push_dwarf_reg_entry_value): New function. * dwarf2expr.h (struct dwarf_expr_context_funcs): New field push_dwarf_reg_entry_value. (ctx_no_push_dwarf_reg_entry_value, dwarf_block_to_dwarf_reg): New declarations. * dwarf2loc.c: Include gdbcmd.h. (dwarf_expr_ctx_funcs): New forward declaration. (entry_values_debug, show_entry_values_debug, call_site_to_target_addr) (dwarf_expr_reg_to_entry_parameter) (dwarf_expr_push_dwarf_reg_entry_value): New. (dwarf_expr_ctx_funcs): Install dwarf_expr_push_dwarf_reg_entry_value. (dwarf2_evaluate_loc_desc_full): Handle NO_ENTRY_VALUE_ERROR. (needs_dwarf_reg_entry_value): New function. (needs_frame_ctx_funcs): Install it. (_initialize_dwarf2loc): New function. * dwarf2loc.h (entry_values_debug): New declaration. * dwarf2read.c (struct dwarf2_cu): New field call_site_htab. (read_call_site_scope): New forward declaration. (process_full_comp_unit): Copy call_site_htab. (process_die): Support DW_TAG_GNU_call_site. (read_call_site_scope): New function. (dwarf2_get_pc_bounds): Support NULL HIGHPC. (dwarf_tag_name): Support DW_TAG_GNU_call_site. (cleanup_htab): Delete. (write_psymtabs_to_index): Use make_cleanup_htab_delete instead of it. * exceptions.h (enum errors): New NO_ENTRY_VALUE_ERROR. * gdb-gdb.py (StructMainTypePrettyPrinter): Support FIELD_LOC_KIND_DWARF_BLOCK. * gdbtypes.h (enum field_loc_kind): New entry FIELD_LOC_KIND_DWARF_BLOCK. (struct main_type): New loc entry dwarf_block. (struct call_site, FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK) (TYPE_FIELD_DWARF_BLOCK): New. * python/py-type.c: Include dwarf2loc.h. (check_types_equal): Support FIELD_LOC_KIND_DWARF_BLOCK. New internal_error call on unknown FIELD_LOC_KIND. * symtab.h (struct symtab): New field call_site_htab. * utils.c (do_htab_delete_cleanup, make_cleanup_htab_delete) (core_addr_hash, core_addr_eq): New functions. gdb/testsuite/ Implement basic support for DW_TAG_GNU_call_site. * gdb.arch/Makefile.in (EXECUTABLES): Add amd64-entry-value. * gdb.arch/amd64-entry-value.cc: New file. * gdb.arch/amd64-entry-value.exp: New file.
Diffstat (limited to 'gdb/block.c')
-rw-r--r--gdb/block.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 776ae53..c165bc2 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -25,6 +25,8 @@
#include "gdb_obstack.h"
#include "cp-support.h"
#include "addrmap.h"
+#include "gdbtypes.h"
+#include "exceptions.h"
/* This is used by struct block to store namespace-related info for
C++ files, namely using declarations and the current namespace in
@@ -160,6 +162,38 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
return 0;
}
+/* Return call_site for specified PC in GDBARCH. PC must match exactly, it
+ must be the next instruction after call (or after tail call jump). Throw
+ NO_ENTRY_VALUE_ERROR otherwise. This function never returns NULL. */
+
+struct call_site *
+call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ struct symtab *symtab;
+ void **slot = NULL;
+
+ /* -1 as tail call PC can be already after the compilation unit range. */
+ symtab = find_pc_symtab (pc - 1);
+
+ if (symtab != NULL && symtab->call_site_htab != NULL)
+ slot = htab_find_slot (symtab->call_site_htab, &pc, NO_INSERT);
+
+ if (slot == NULL)
+ {
+ struct minimal_symbol *msym = lookup_minimal_symbol_by_pc (pc);
+
+ /* DW_TAG_gnu_call_site will be missing just if GCC could not determine
+ the call target. */
+ throw_error (NO_ENTRY_VALUE_ERROR,
+ _("DW_OP_GNU_entry_value resolving cannot find "
+ "DW_TAG_GNU_call_site %s in %s"),
+ paddress (gdbarch, pc),
+ msym == NULL ? "???" : SYMBOL_PRINT_NAME (msym));
+ }
+
+ return *slot;
+}
+
/* Return the blockvector immediately containing the innermost lexical block
containing the specified pc value, or 0 if there is none.
Backward compatibility, no section. */