From: Tom Tromey Date: Fri, 4 Aug 2023 20:00:33 +0000 (-0600) Subject: Move rust_language::lookup_symbol_nonlocal X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e1a482ad96a2105c9d3a972de06b510379c14d7e;p=binutils-gdb.git Move rust_language::lookup_symbol_nonlocal This moves rust_language::lookup_symbol_nonlocal to rust-lang.c. There's no need to have it in rust-lang.h and moving it lets us avoid adding new includes in a later patch. --- diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 0b4a7d47c95..57bef01d343 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1675,6 +1675,43 @@ rust_language::is_string_type_p (struct type *type) const && strcmp (type->name (), "&str") == 0)); } +/* See language.h. */ + +struct block_symbol +rust_language::lookup_symbol_nonlocal + (const char *name, const struct block *block, + const domain_enum domain) const +{ + struct block_symbol result = {}; + + const char *scope = block == nullptr ? "" : block->scope (); + symbol_lookup_debug_printf + ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", + name, host_address_to_string (block), scope, + domain_name (domain)); + + /* Look up bare names in the block's scope. */ + std::string scopedname; + if (name[cp_find_first_component (name)] == '\0') + { + if (scope[0] != '\0') + { + scopedname = std::string (scope) + "::" + name; + name = scopedname.c_str (); + } + else + name = NULL; + } + + if (name != NULL) + { + result = lookup_symbol_in_static_block (name, block, domain); + if (result.symbol == NULL) + result = lookup_global_symbol (name, block, domain); + } + return result; +} + /* Single instance of the Rust language class. */ static rust_language rust_language_defn; diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index efe721c5707..85c93a9dcec 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -144,37 +144,7 @@ public: struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override - { - struct block_symbol result = {}; - - const char *scope = block == nullptr ? "" : block->scope (); - symbol_lookup_debug_printf - ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", - name, host_address_to_string (block), scope, - domain_name (domain)); - - /* Look up bare names in the block's scope. */ - std::string scopedname; - if (name[cp_find_first_component (name)] == '\0') - { - if (scope[0] != '\0') - { - scopedname = std::string (scope) + "::" + name; - name = scopedname.c_str (); - } - else - name = NULL; - } - - if (name != NULL) - { - result = lookup_symbol_in_static_block (name, block, domain); - if (result.symbol == NULL) - result = lookup_global_symbol (name, block, domain); - } - return result; - } + const domain_enum domain) const override; /* See language.h. */