f8eba3c616
gdb 2011-12-06 Joel Brobecker <brobecker@acacore.com> * language.h (struct language_defn): Add new component la_symbol_name_compare. * symfile.h (struct quick_symbol_functions): Update the profile of parameter "name_matcher" for the expand_symtabs_matching method. Update the documentation accordingly. * ada-lang.h (ada_name_for_lookup): Add declaration. * ada-lang.c (ada_name_for_lookup): New function, extracted out from ada_iterate_over_symbols. (ada_iterate_over_symbols): Do not encode symbol name anymore. (ada_expand_partial_symbol_name): Adjust profile. (ada_language_defn): Add value for la_symbol_name_compare field. * linespec.c: #include "ada-lang.h". (iterate_name_matcher): Add language parameter. Replace call to strcmp_iw by call to language->la_symbol_name_compare. (decode_variable): Encode COPY if current language is Ada. * dwarf2read.c (dw2_expand_symtabs_matching): Adjust profile of name_matcher parameter. Adjust call to name_matcher. * psymtab.c (expand_symtabs_matching_via_partial): Likewise. (expand_partial_symbol_names): Update profile of parameter "fun". * psymtab.h (expand_partial_symbol_names): Update profile of parameter "fun". * symtab.c (demangle_for_lookup): Update function documentation. (search_symbols_name_matches): Add language parameter. (expand_partial_symbol_name): Likewise. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Add value for la_symbol_name_compare field. * d-lang.c (d_language_defn): Likewise. * f-lang.c (f_language_defn): Ditto. * jv-lang.c (java_language_defn): Ditto. * m2-lang.c (m2_language_defn): Ditto. * objc-lang.c (objc_language_defn): Ditto. * opencl-lang.c (opencl_language_defn): Ditto. * p-lang.c (pascal_language_defn): Ditto. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Ditto. 2011-12-06 Tom Tromey <tromey@redhat.com> * linespec.c (iterate_over_all_matching_symtabs): Use LA_ITERATE_OVER_SYMBOLS. (lookup_prefix_sym, add_matching_symbols_to_info): Likewise. (find_function_symbols, decode_variable): Remove Ada special case. * language.h (struct language_defn) <la_iterate_over_symbols>: New field. (LA_ITERATE_OVER_SYMBOLS): New macro. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Update. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * d-lang.c (d_language_defn): Update. * f-lang.c (f_language_defn): Update. * jv-lang.c (java_language_defn): Update. * m2-lang.c (m2_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * opencl-lang.c (opencl_language_defn): Update. * p-lang.c (pascal_language_defn): Update. * ada-lang.c (ada_iterate_over_symbols): New function. (ada_language_defn): Update. 2011-12-06 Tom Tromey <tromey@redhat.com> Joel Brobecker <brobecker@acacore.com> PR breakpoints/13105, PR objc/8341, PR objc/8343, PR objc/8366, PR objc/8535, PR breakpoints/11657, PR breakpoints/11970, PR breakpoints/12023, PR breakpoints/12334, PR breakpoints/12856, PR shlibs/8929, PR shlibs/7393: * python/py-type.c (compare_maybe_null_strings): Rename from compare_strings. (check_types_equal): Update. * utils.c (compare_strings): New function. * tui/tui-winsource.c (tui_update_breakpoint_info): Update for location changes. * tracepoint.c (scope_info): Update. (trace_find_line_command): Use DECODE_LINE_FUNFIRSTLINE. * symtab.h (iterate_over_minimal_symbols) (iterate_over_some_symtabs, iterate_over_symtabs) (find_pcs_for_symtab_line, iterate_over_symbols) (demangle_for_lookup): Declare. (expand_line_sal): Remove. * symtab.c (iterate_over_some_symtabs, iterate_over_symtabs) (lookup_symtab_callback): New functions. (lookup_symtab): Rewrite. (demangle_for_lookup): New function, extract from lookup_symbol_in_language. (lookup_symbol_in_language): Use it. (iterate_over_symbols): New function. (find_line_symtab): Update. (find_pcs_for_symtab_line): New functions. (find_line_common): Add 'start' argument. (decode_line_spec): Update. Change argument to 'flags', change interpretation. (append_expanded_sal): Remove. (append_exact_match_to_sals): Remove. (expand_line_sal): Remove. * symfile.h (struct quick_symbol_functions) <lookup_symtab>: Remove. <map_symtabs_matching_filename>: New field. * stack.c (func_command): Only look in the current program space. Use DECODE_LINE_FUNFIRSTLINE. * source.c (line_info): Set pspace on sal. Check program space in the loop. Use DECODE_LINE_LIST_MODE. (select_source_symtab): Use DECODE_LINE_FUNFIRSTLINE. * solib-target.c: Remove DEF_VEC_I(CORE_ADDR). * python/python.c (gdbpy_decode_line): Update. * psymtab.c (partial_map_expand_apply): New function. (partial_map_symtabs_matching_filename): Rename from lookup_partial_symbol. Update arguments. (lookup_symtab_via_partial_symtab): Remove. (psym_functions): Update. * objc-lang.h (parse_selector, parse_method): Don't declare. (find_imps): Update. * objc-lang.c (parse_selector, parse_method): Now static. (find_methods): Change arguments. Fill in a vector of symbol names. (uniquify_strings): New function. (find_imps): Change arguments. * minsyms.c (iterate_over_minimal_symbols): New function. * linespec.h (enum decode_line_flags): New. (struct linespec_sals): New. (struct linespec_result) <canonical>: Remove. <pre_expanded, addr_string, sals>: New fields. (destroy_linespec_result, make_cleanup_destroy_linespec_result) (decode_line_full): Declare. (decode_line_1): Update. * linespec.c (struct address_entry, struct linespec_state, struct collect_info): New types. (add_sal_to_sals_basic, add_sal_to_sals, hash_address_entry) (eq_address_entry, maybe_add_address): New functions. (total_number_of_methods): Remove. (iterate_name_matcher, iterate_over_all_matching_symtabs): New functions. (find_methods): Change arguments. Don't canonicalize input. Simplify logic. (add_matching_methods, add_constructors) (build_canonical_line_spec): Remove. (filter_results, convert_results_to_lsals): New functions. (decode_line_2): Change arguments. Rewrite for new data structures. (decode_line_internal): Rename from decode_line_1. Change arguments. Add cleanups. Update for new data structures. (linespec_state_constructor, linespec_state_destructor) (decode_line_full, decode_line_1): New functions. (decode_indirect): Change arguments. Update. (locate_first_half): Use skip_spaces. (decode_objc): Change arguments. Update for new data structures. Simplify logic. (decode_compound): Change arguments. Add cleanups. Remove fallback code, replace with error. (struct decode_compound_collector): New type. (collect_one_symbol): New function. (lookup_prefix_sym): Change arguments. Update. (compare_symbol_name, add_all_symbol_names_from_pspace) (find_superclass_methods ): New functions. (find_method): Rewrite. (struct symtab_collector): New type. (add_symtabs_to_list, collect_symtabs_from_filename): New functions. (symtabs_from_filename): Change API. Rename from symtab_from_filename. (collect_function_symbols): New function. (find_function_symbols): Change API. Rename from find_function_symbol. Rewrite. (decode_all_digits): Change arguments. Rewrite. (decode_dollar): Change arguments. Use decode_variable. (decode_label): Change arguments. Rewrite. (collect_symbols): New function. (minsym_found): Change arguments. Rewrite. (check_minsym, search_minsyms_for_name) (add_matching_symbols_to_info): New function. (decode_variable): Change arguments. Iterate over all symbols. (symbol_found): Remove. (symbol_to_sal): New function. (init_linespec_result, destroy_linespec_result) (cleanup_linespec_result, make_cleanup_destroy_linespec_result): New functions. (decode_digits_list_mode, decode_digits_ordinary): New functions. * dwarf2read.c (dw2_map_expand_apply): New function. (dw2_map_symtabs_matching_filename): Rename from dw2_lookup_symtab. Change arguments. (dwarf2_gdb_index_functions): Update. * dwarf2loc.c: Remove DEF_VEC_I(CORE_ADDR). * defs.h (compare_strings): Declare. * cli/cli-cmds.c (compare_strings): Move to utils.c. (edit_command, list_command): Use DECODE_LINE_LIST_MODE. Call filter_sals. (compare_symtabs, filter_sals): New functions. * breakpoint.h (struct bp_location) <line_number, source_file>: New fields. (struct breakpoint) <line_number, source_file>: Remove. <filter>: New field. * breakpoint.c (print_breakpoint_location, init_raw_breakpoint) (momentary_breakpoint_from_master, add_location_to_breakpoint): Update for changes to locations. (init_breakpoint_sal): Add 'filter' argument. Set 'filter' on breakpoint. (create_breakpoint_sal): Add 'filter' argument. (remove_sal, expand_line_sal_maybe): Remove. (create_breakpoints_sal): Remove 'sals' argument. Handle pre-expanded sals and the filter. (parse_breakpoint_sals): Use decode_line_full. (check_fast_tracepoint_sals): Use get_sal_arch. (create_breakpoint): Create a linespec_sals. Update. (break_range_command): Use decode_line_full. Update. (until_break_command): Update. (clear_command): Update match conditions for linespec.c changes. Use DECODE_LINE_LIST_MODE. (say_where): Update for changes to locations. (bp_location_dtor): Free 'source_file'. (base_breakpoint_dtor): Free 'filter'. Don't free 'source_file'. (update_static_tracepoint): Update for changes to locations. (update_breakpoint_locations): Disable ranged breakpoint if too many locations match. Update. (addr_string_to_sals): Use decode_line_full. Resolve all sal PCs. (breakpoint_re_set_default): Don't call expand_line_sal_maybe. (decode_line_spec_1): Update. Change argument name to 'flags', change interpretation. * block.h (block_containing_function): Declare. * block.c (block_containing_function): New function. * skip.c (skip_function_command): Update. (skip_re_set): Update. * infcmd.c (jump_command): Use DECODE_LINE_FUNFIRSTLINE. * mi/mi-main.c (mi_cmd_trace_find): Use DECODE_LINE_FUNFIRSTLINE. * NEWS: Add entry. 2011-12-06 Tom Tromey <tromey@redhat.com> * elfread.c (elf_gnu_ifunc_resolver_return_stop): Allow breakpoint's pspace to be NULL. * breakpoint.h (struct breakpoint) <pspace>: Update comment. * breakpoint.c (init_raw_breakpoint): Conditionally set breakpoint's pspace. (init_breakpoint_sal): Don't set breakpoint's pspace. (prepare_re_set_context): Conditionally switch program space. (addr_string_to_sals): Check executing_startup on location's program space. 2011-12-06 Tom Tromey <tromey@redhat.com> * breakpoint.h (enum enable_state) <bp_startup_disabled>: Remove. * breakpoint.c (should_be_inserted): Explicitly check if program space is executing startup. (describe_other_breakpoints): Update. (disable_breakpoints_before_startup): Change executing_startup earlier. Remove loop. (enable_breakpoints_after_startup): Likewise. (init_breakpoint_sal): Don't use bp_startup_disabled. (create_breakpoint): Don't use bp_startup_disabled. (update_global_location_list): Use should_be_inserted. (bkpt_re_set): Update. gdb/testsuite 2011-12-06 Joel Brobecker <brobecker@acacore.com> * gdb.ada/fullname_bp.exp: Add tests for other valid linespecs involving a fully qualified function name. 2011-12-06 Tom Tromey <tromey@redhat.com> * gdb.ada/homonym.exp: Add three breakpoint tests. 2011-12-06 Tom Tromey <tromey@redhat.com> * gdb.base/solib-weak.exp (do_test): Remove kfail. * gdb.trace/tracecmd.exp: Disable pending breakpoints earlier. * gdb.objc/objcdecode.exp: Update for output changes. * gdb.linespec/linespec.exp: New file. * gdb.linespec/lspec.cc: New file. * gdb.linespec/lspec.h: New file. * gdb.linespec/body.h: New file. * gdb.linespec/base/two/thefile.cc: New file. * gdb.linespec/base/one/thefile.cc: New file. * gdb.linespec/Makefile.in: New file. * gdb.cp/templates.exp (test_template_breakpoints): Update for output changes. * gdb.cp/re-set-overloaded.exp: Remove kfail. * gdb.cp/ovldbreak.exp: Update for output changes. "all" test now makes one breakpoint. * gdb.cp/method2.exp (test_break): Update for output changes. * gdb.cp/mb-templates.exp: Update for output changes. * gdb.cp/mb-inline.exp: Update for output changes. * gdb.cp/mb-ctor.exp: Update for output changes. * gdb.cp/ovsrch.exp: Use fully-qualified names. * gdb.base/solib-symbol.exp: Run to main later. Breakpoint now has multiple matches. * gdb.base/sepdebug.exp: Disable pending breakpoints. Update for error message change. * gdb.base/list.exp (test_list_filename_and_number): Update for error message change. * gdb.base/break.exp: Disable pending breakpoints. Update for output changes. * configure.ac: Add gdb.linespec. * configure: Rebuild. * Makefile.in (ALL_SUBDIRS): Add gdb.linespec. gdb/doc 2011-12-06 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Set Breaks): Update for new behavior.
372 lines
9.8 KiB
C
372 lines
9.8 KiB
C
/* Block-related functions for the GNU debugger, GDB.
|
|
|
|
Copyright (C) 2003, 2007, 2008, 2009, 2010, 2011
|
|
Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "block.h"
|
|
#include "symtab.h"
|
|
#include "symfile.h"
|
|
#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
|
|
scope. */
|
|
|
|
struct block_namespace_info
|
|
{
|
|
const char *scope;
|
|
struct using_direct *using;
|
|
};
|
|
|
|
static void block_initialize_namespace (struct block *block,
|
|
struct obstack *obstack);
|
|
|
|
/* Return Nonzero if block a is lexically nested within block b,
|
|
or if a and b have the same pc range.
|
|
Return zero otherwise. */
|
|
|
|
int
|
|
contained_in (const struct block *a, const struct block *b)
|
|
{
|
|
if (!a || !b)
|
|
return 0;
|
|
|
|
do
|
|
{
|
|
if (a == b)
|
|
return 1;
|
|
/* If A is a function block, then A cannot be contained in B,
|
|
except if A was inlined. */
|
|
if (BLOCK_FUNCTION (a) != NULL && !block_inlined_p (a))
|
|
return 0;
|
|
a = BLOCK_SUPERBLOCK (a);
|
|
}
|
|
while (a != NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/* Return the symbol for the function which contains a specified
|
|
lexical block, described by a struct block BL. The return value
|
|
will not be an inlined function; the containing function will be
|
|
returned instead. */
|
|
|
|
struct symbol *
|
|
block_linkage_function (const struct block *bl)
|
|
{
|
|
while ((BLOCK_FUNCTION (bl) == NULL || block_inlined_p (bl))
|
|
&& BLOCK_SUPERBLOCK (bl) != NULL)
|
|
bl = BLOCK_SUPERBLOCK (bl);
|
|
|
|
return BLOCK_FUNCTION (bl);
|
|
}
|
|
|
|
/* Return the symbol for the function which contains a specified
|
|
block, described by a struct block BL. The return value will be
|
|
the closest enclosing function, which might be an inline
|
|
function. */
|
|
|
|
struct symbol *
|
|
block_containing_function (const struct block *bl)
|
|
{
|
|
while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
|
|
bl = BLOCK_SUPERBLOCK (bl);
|
|
|
|
return BLOCK_FUNCTION (bl);
|
|
}
|
|
|
|
/* Return one if BL represents an inlined function. */
|
|
|
|
int
|
|
block_inlined_p (const struct block *bl)
|
|
{
|
|
return BLOCK_FUNCTION (bl) != NULL && SYMBOL_INLINED (BLOCK_FUNCTION (bl));
|
|
}
|
|
|
|
/* Return the blockvector immediately containing the innermost lexical
|
|
block containing the specified pc value and section, or 0 if there
|
|
is none. PBLOCK is a pointer to the block. If PBLOCK is NULL, we
|
|
don't pass this information back to the caller. */
|
|
|
|
struct blockvector *
|
|
blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
|
|
struct block **pblock, struct symtab *symtab)
|
|
{
|
|
struct block *b;
|
|
int bot, top, half;
|
|
struct blockvector *bl;
|
|
|
|
if (symtab == 0) /* if no symtab specified by caller */
|
|
{
|
|
/* First search all symtabs for one whose file contains our pc */
|
|
symtab = find_pc_sect_symtab (pc, section);
|
|
if (symtab == 0)
|
|
return 0;
|
|
}
|
|
|
|
bl = BLOCKVECTOR (symtab);
|
|
|
|
/* Then search that symtab for the smallest block that wins. */
|
|
|
|
/* If we have an addrmap mapping code addresses to blocks, then use
|
|
that. */
|
|
if (BLOCKVECTOR_MAP (bl))
|
|
{
|
|
b = addrmap_find (BLOCKVECTOR_MAP (bl), pc);
|
|
if (b)
|
|
{
|
|
if (pblock)
|
|
*pblock = b;
|
|
return bl;
|
|
}
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
|
|
/* Otherwise, use binary search to find the last block that starts
|
|
before PC. */
|
|
bot = 0;
|
|
top = BLOCKVECTOR_NBLOCKS (bl);
|
|
|
|
while (top - bot > 1)
|
|
{
|
|
half = (top - bot + 1) >> 1;
|
|
b = BLOCKVECTOR_BLOCK (bl, bot + half);
|
|
if (BLOCK_START (b) <= pc)
|
|
bot += half;
|
|
else
|
|
top = bot + half;
|
|
}
|
|
|
|
/* Now search backward for a block that ends after PC. */
|
|
|
|
while (bot >= 0)
|
|
{
|
|
b = BLOCKVECTOR_BLOCK (bl, bot);
|
|
if (BLOCK_END (b) > pc)
|
|
{
|
|
if (pblock)
|
|
*pblock = b;
|
|
return bl;
|
|
}
|
|
bot--;
|
|
}
|
|
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. */
|
|
|
|
struct blockvector *
|
|
blockvector_for_pc (CORE_ADDR pc, struct block **pblock)
|
|
{
|
|
return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc),
|
|
pblock, NULL);
|
|
}
|
|
|
|
/* Return the innermost lexical block containing the specified pc value
|
|
in the specified section, or 0 if there is none. */
|
|
|
|
struct block *
|
|
block_for_pc_sect (CORE_ADDR pc, struct obj_section *section)
|
|
{
|
|
struct blockvector *bl;
|
|
struct block *b;
|
|
|
|
bl = blockvector_for_pc_sect (pc, section, &b, NULL);
|
|
if (bl)
|
|
return b;
|
|
return 0;
|
|
}
|
|
|
|
/* Return the innermost lexical block containing the specified pc value,
|
|
or 0 if there is none. Backward compatibility, no section. */
|
|
|
|
struct block *
|
|
block_for_pc (CORE_ADDR pc)
|
|
{
|
|
return block_for_pc_sect (pc, find_pc_mapped_section (pc));
|
|
}
|
|
|
|
/* Now come some functions designed to deal with C++ namespace issues.
|
|
The accessors are safe to use even in the non-C++ case. */
|
|
|
|
/* This returns the namespace that BLOCK is enclosed in, or "" if it
|
|
isn't enclosed in a namespace at all. This travels the chain of
|
|
superblocks looking for a scope, if necessary. */
|
|
|
|
const char *
|
|
block_scope (const struct block *block)
|
|
{
|
|
for (; block != NULL; block = BLOCK_SUPERBLOCK (block))
|
|
{
|
|
if (BLOCK_NAMESPACE (block) != NULL
|
|
&& BLOCK_NAMESPACE (block)->scope != NULL)
|
|
return BLOCK_NAMESPACE (block)->scope;
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
/* Set BLOCK's scope member to SCOPE; if needed, allocate memory via
|
|
OBSTACK. (It won't make a copy of SCOPE, however, so that already
|
|
has to be allocated correctly.) */
|
|
|
|
void
|
|
block_set_scope (struct block *block, const char *scope,
|
|
struct obstack *obstack)
|
|
{
|
|
block_initialize_namespace (block, obstack);
|
|
|
|
BLOCK_NAMESPACE (block)->scope = scope;
|
|
}
|
|
|
|
/* This returns the using directives list associated with BLOCK, if
|
|
any. */
|
|
|
|
struct using_direct *
|
|
block_using (const struct block *block)
|
|
{
|
|
if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
|
|
return NULL;
|
|
else
|
|
return BLOCK_NAMESPACE (block)->using;
|
|
}
|
|
|
|
/* Set BLOCK's using member to USING; if needed, allocate memory via
|
|
OBSTACK. (It won't make a copy of USING, however, so that already
|
|
has to be allocated correctly.) */
|
|
|
|
void
|
|
block_set_using (struct block *block,
|
|
struct using_direct *using,
|
|
struct obstack *obstack)
|
|
{
|
|
block_initialize_namespace (block, obstack);
|
|
|
|
BLOCK_NAMESPACE (block)->using = using;
|
|
}
|
|
|
|
/* If BLOCK_NAMESPACE (block) is NULL, allocate it via OBSTACK and
|
|
ititialize its members to zero. */
|
|
|
|
static void
|
|
block_initialize_namespace (struct block *block, struct obstack *obstack)
|
|
{
|
|
if (BLOCK_NAMESPACE (block) == NULL)
|
|
{
|
|
BLOCK_NAMESPACE (block)
|
|
= obstack_alloc (obstack, sizeof (struct block_namespace_info));
|
|
BLOCK_NAMESPACE (block)->scope = NULL;
|
|
BLOCK_NAMESPACE (block)->using = NULL;
|
|
}
|
|
}
|
|
|
|
/* Return the static block associated to BLOCK. Return NULL if block
|
|
is NULL or if block is a global block. */
|
|
|
|
const struct block *
|
|
block_static_block (const struct block *block)
|
|
{
|
|
if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
|
|
return NULL;
|
|
|
|
while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
|
|
block = BLOCK_SUPERBLOCK (block);
|
|
|
|
return block;
|
|
}
|
|
|
|
/* Return the static block associated to BLOCK. Return NULL if block
|
|
is NULL. */
|
|
|
|
const struct block *
|
|
block_global_block (const struct block *block)
|
|
{
|
|
if (block == NULL)
|
|
return NULL;
|
|
|
|
while (BLOCK_SUPERBLOCK (block) != NULL)
|
|
block = BLOCK_SUPERBLOCK (block);
|
|
|
|
return block;
|
|
}
|
|
|
|
/* Allocate a block on OBSTACK, and initialize its elements to
|
|
zero/NULL. This is useful for creating "dummy" blocks that don't
|
|
correspond to actual source files.
|
|
|
|
Warning: it sets the block's BLOCK_DICT to NULL, which isn't a
|
|
valid value. If you really don't want the block to have a
|
|
dictionary, then you should subsequently set its BLOCK_DICT to
|
|
dict_create_linear (obstack, NULL). */
|
|
|
|
struct block *
|
|
allocate_block (struct obstack *obstack)
|
|
{
|
|
struct block *bl = obstack_alloc (obstack, sizeof (struct block));
|
|
|
|
BLOCK_START (bl) = 0;
|
|
BLOCK_END (bl) = 0;
|
|
BLOCK_FUNCTION (bl) = NULL;
|
|
BLOCK_SUPERBLOCK (bl) = NULL;
|
|
BLOCK_DICT (bl) = NULL;
|
|
BLOCK_NAMESPACE (bl) = NULL;
|
|
|
|
return bl;
|
|
}
|