diff options
author | Daniel Jacobowitz <drow@false.org> | 2009-06-28 00:20:24 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2009-06-28 00:20:24 +0000 |
commit | edb3359dff90ef8a3352408bfef8ce1438c2b2e1 (patch) | |
tree | 36b3ee7b866889c22ffb06aaa2ad0dfad826ab10 /gdb/symtab.c | |
parent | c7ce8faacb57cd10f919caff6c5018c4526e752e (diff) | |
download | gdb-edb3359dff90ef8a3352408bfef8ce1438c2b2e1.zip gdb-edb3359dff90ef8a3352408bfef8ce1438c2b2e1.tar.gz gdb-edb3359dff90ef8a3352408bfef8ce1438c2b2e1.tar.bz2 |
gdb/
* NEWS: Document inlined function support.
* Makefile.in (SFILES): Add inline-frame.c.
(COMMON_OBS): Add inline-frame.o.
* block.c (contained_in): Rewrite to use lexical nesting.
(block_linkage_function): Skip inlined function blocks.
(block_inlined_p): New.
* block.h (struct block): Update comment.
(block_inlined_p): New prototype.
* blockframe.c (get_frame_block): Handle inlined functions.
(get_frame_function): Do not use block_linkage_function.
(block_innermost_frame): Use get_frame_block and contained_in.
* breakpoint.c (watchpoint_check): Remove extra reinit_frame_cache.
Skip over inlined functions. Simplify epilogue check.
(bpstat_check_breakpoint_conditions): Use get_stack_frame_id.
Update comments.
(set_momentary_breakpoint): Only accept non-inlined frames.
(watch_command_1): Use frame_unwind_caller_pc and
frame_unwind_caller_id instead of get_prev_frame.
(until_break_command): Likewise. Use get_stack_frame_id.
* buildsym.c (end_symtab): Set SYMBOL_SYMTAB for block functions.
* dwarf2loc.c (dwarf_expr_frame_base): Use block_linkage_function.
* dwarf2read.c (process_die): Handle DW_TAG_inlined_subroutine.
(read_func_scope, new_symbol): Likewise. Handle arguments specially
for inlined functions without call site information.
(inherit_abstract_dies): Allow tag mismatch for inlined subroutines.
(die_specification): Treat DW_AT_abstract_origin as a specification.
(read_type_die): Handle DW_TAG_inlined_subroutine.
* frame-unwind.c (frame_unwind_init): Add inline_frame_unwind.
* frame.c (fprint_frame_id): Print inline depth.
(fprint_frame_type): Handle INLINE_FRAME and SENTINEL_FRAME.
(skip_inlined_frames, get_stack_frame_id): New.
(frame_unwind_caller_id): Use skip_inlined_frames.
(frame_id_inlined_p): New.
(frame_id_eq): Make the logic match the comments. Add inline_depth
check.
(frame_id_inner): Handle inlined functions.
(frame_unwind_pc): New function, copied from frame_unwind_caller_pc.
(frame_unwind_caller_pc): Use skip_inlined_frames and frame_unwind_pc.
(get_prev_frame_1): Check for inline frames. Split out frame
allocation to get_prev_frame_raw.
(get_prev_frame_raw): New function.
(get_prev_frame): Handle inline frames.
(get_frame_pc): Use frame_unwind_pc.
(get_frame_address_in_block): Skip inlined frames on both sides.
(pc_notcurrent): Delete.
(find_frame_sal): Rewrite to handle inline call sites. Use
get_frame_address_in_block.
(deprecated_update_frame_pc_hack): Make static.
* frame.h: Update comments.
(struct frame_id): Add inline_depth.
(enum frame_type): Add INLINE_FRAME.
(frame_id_inlined_p, get_stack_frame_id): New prototypes.
* gdbthread.h (struct thread_info): Add step_stack_frame_id field.
* infcmd.c (set_step_frame): New function.
(step_once): Use set_step_frame. Handle inlined functions.
(until_next_command): Use set_step_frame.
(finish_backward), finish_forward): Use get_stack_frame_id.
(finish_command): Support inlined functions.
* inferior.h (set_step_info): New prototype.
* infrun.c (RESUME_ALL): Use minus_one_ptid.
(clear_proceed_status): Clear step_stack_frame_id.
(init_wait_for_inferior): Call clear_inline_frame_state.
(init_execution_control_state): Make static.
(set_step_info): New function.
(init_thread_stepping_state): Do not set the symtab or line here.
(stepped_in_from): New function.
(handle_inferior_event): Handle inlined functions. Use set_step_info.
(insert_step_resume_breakpoint_at_frame): Use get_stack_frame_id.
(struct inferior_status): Add step_stack_frame_id.
(save_inferior_status, restore_inferior_status): Save and restore
step_stack_frame_id.
* inline-frame.c, inline-frame.h: New files.
* minsyms.c (prim_record_minimal_symbol_and_info): Use XCALLOC.
* regcache.c (regcache_write_pc): Call reinit_frame_cache.
* s390-tdep.c (s390_prologue_frame_unwind_cache): Handle INLINE_FRAME.
* stack.c (frame_show_address): New.
(print_frame_info, print_frame): Use it.
(find_frame_funname): Use get_frame_function. Handle inlined blocks.
(frame_info): Mark inlined functions.
(backtrace_command_1): Use get_current_user_frame.
(print_frame_local_vars, print_frame_label_vars): Update comments.
(return_command): Refuse inlined functions.
* symtab.c (lookup_symbol_aux_local): Stop at inlined function
boundaries.
(find_function_start_sal): Avoid inlined functions.
(completion_list_add_fields): New function.
(default_make_symbol_completion_list): Use it. Use block_static_block
and block_global_block. Check for inlined functions.
(skip_prologue_using_sal): Avoid line number comparison across
inlining.
* symtab.h (struct symbol): Add is_inlined.
(SYMBOL_INLINED): New.
* target.c (target_resume): Call clear_inline_frame_state.
* valops.c (value_of_variable): Check block_inlined_p.
gdb/doc/
* gdb.texinfo (Debugging Optimized Code): New chapter.
(Compiling for Debugging): Reference it. Move some
text to the new section.
gdb/testsuite/
* gdb.base/break.exp: Add an XFAIL for gcc/36748.
* gdb.cp/annota2.exp: Accept frames-invalid in more places.
* gdb.opt/Makefile.in (EXECUTABLES): Update.
* gdb.opt/clobbered-registers-O2.exp: Update to GPL v3.
* gdb.opt/inline-bt.c, gdb.opt/inline-bt.exp,
gdb.opt/inline-cmds.c, gdb.opt/inline-cmds.exp,
gdb.opt/inline-locals.c, gdb.opt/inline-locals.exp,
gdb.opt/inline-markers.c: New files.
* lib/gdb.exp (skip_inline_frame_tests): New function.
(skip_inline_var_tests): New function.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 133 |
1 files changed, 96 insertions, 37 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index ee138ff..f677ed0 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1384,10 +1384,13 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name, sym = lookup_symbol_aux_block (name, linkage_name, block, domain); if (sym != NULL) return sym; + + if (BLOCK_FUNCTION (block) != NULL && block_inlined_p (block)) + break; block = BLOCK_SUPERBLOCK (block); } - /* We've reached the static block without finding a result. */ + /* We've reached the edge of the function without finding a result. */ return NULL; } @@ -2654,6 +2657,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline) CORE_ADDR pc; struct symtab_and_line sal; + struct block *b, *function_block; pc = BLOCK_START (block); fixup_symbol_section (sym, objfile); @@ -2707,6 +2711,25 @@ find_function_start_sal (struct symbol *sym, int funfirstline) sal.pc = pc; + /* Check if we are now inside an inlined function. If we can, + use the call site of the function instead. */ + b = block_for_pc_sect (sal.pc, SYMBOL_OBJ_SECTION (sym)); + function_block = NULL; + while (b != NULL) + { + if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b)) + function_block = b; + else if (BLOCK_FUNCTION (b) != NULL) + break; + b = BLOCK_SUPERBLOCK (b); + } + if (function_block != NULL + && SYMBOL_LINE (BLOCK_FUNCTION (function_block)) != 0) + { + sal.line = SYMBOL_LINE (BLOCK_FUNCTION (function_block)); + sal.symtab = SYMBOL_SYMTAB (BLOCK_FUNCTION (function_block)); + } + return sal; } @@ -3707,6 +3730,24 @@ language_search_unquoted_string (char *text, char *p) return p; } +static void +completion_list_add_fields (struct symbol *sym, char *sym_text, + int sym_text_len, char *text, char *word) +{ + if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) + { + struct type *t = SYMBOL_TYPE (sym); + enum type_code c = TYPE_CODE (t); + int j; + + if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) + for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++) + if (TYPE_FIELD_NAME (t, j)) + completion_list_add_name (TYPE_FIELD_NAME (t, j), + sym_text, sym_text_len, text, word); + } +} + /* Type of the user_data argument passed to add_macro_name. The contents are simply whatever is needed by completion_list_add_name. */ @@ -3742,9 +3783,9 @@ default_make_symbol_completion_list (char *text, char *word) struct partial_symtab *ps; struct minimal_symbol *msymbol; struct objfile *objfile; - struct block *b, *surrounding_static_block = 0; + struct block *b; + const struct block *surrounding_static_block, *surrounding_global_block; struct dict_iterator iter; - int j; struct partial_symbol **psym; /* The symbol we are completing on. Points in same buffer as text. */ char *sym_text; @@ -3854,41 +3895,43 @@ default_make_symbol_completion_list (char *text, char *word) } /* Search upwards from currently selected frame (so that we can - complete on local vars. */ + complete on local vars). Also catch fields of types defined in + this places which match our text string. Only complete on types + visible from current context. */ + + b = get_selected_block (0); + surrounding_static_block = block_static_block (b); + surrounding_global_block = block_global_block (b); + if (surrounding_static_block != NULL) + while (b != surrounding_static_block) + { + QUIT; - for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) - { - if (!BLOCK_SUPERBLOCK (b)) - { - surrounding_static_block = b; /* For elmin of dups */ - } + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, + word); + completion_list_add_fields (sym, sym_text, sym_text_len, text, + word); + } - /* Also catch fields of types defined in this places which match our - text string. Only complete on types visible from current context. */ + /* Stop when we encounter an enclosing function. Do not stop for + non-inlined functions - the locals of the enclosing function + are in scope for a nested function. */ + if (BLOCK_FUNCTION (b) != NULL && block_inlined_p (b)) + break; + b = BLOCK_SUPERBLOCK (b); + } - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - QUIT; - COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word); - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - struct type *t = SYMBOL_TYPE (sym); - enum type_code c = TYPE_CODE (t); + /* Add fields from the file's types; symbols will be added below. */ - if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) - { - for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++) - { - if (TYPE_FIELD_NAME (t, j)) - { - completion_list_add_name (TYPE_FIELD_NAME (t, j), - sym_text, sym_text_len, text, word); - } - } - } - } - } - } + if (surrounding_static_block != NULL) + ALL_BLOCK_SYMBOLS (surrounding_static_block, iter, sym) + completion_list_add_fields (sym, sym_text, sym_text_len, text, word); + + if (surrounding_global_block != NULL) + ALL_BLOCK_SYMBOLS (surrounding_global_block, iter, sym) + completion_list_add_fields (sym, sym_text, sym_text_len, text, word); /* Go through the symtabs and check the externs and statics for symbols which match. */ @@ -3907,9 +3950,6 @@ default_make_symbol_completion_list (char *text, char *word) { QUIT; b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - /* Don't do this block twice. */ - if (b == surrounding_static_block) - continue; ALL_BLOCK_SYMBOLS (b, iter, sym) { COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word); @@ -4375,6 +4415,25 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) line mark the prologue -> body transition. */ if (sal.line >= prologue_sal.line) break; + + /* The line number is smaller. Check that it's from the + same function, not something inlined. If it's inlined, + then there is no point comparing the line numbers. */ + bl = block_for_pc (prologue_sal.end); + while (bl) + { + if (block_inlined_p (bl)) + break; + if (BLOCK_FUNCTION (bl)) + { + bl = NULL; + break; + } + bl = BLOCK_SUPERBLOCK (bl); + } + if (bl != NULL) + break; + /* The case in which compiler's optimizer/scheduler has moved instructions into the prologue. We look ahead in the function looking for address ranges whose |