aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-04 14:00:33 -0600
committerTom Tromey <tromey@adacore.com>2023-09-05 11:02:34 -0600
commite1a482ad96a2105c9d3a972de06b510379c14d7e (patch)
tree74fb69b5da0d49e680680e198c74a668ce4b245c /gdb/rust-lang.c
parent5cd2b85eba535f3623129f617f331210f62afd76 (diff)
downloadgdb-e1a482ad96a2105c9d3a972de06b510379c14d7e.zip
gdb-e1a482ad96a2105c9d3a972de06b510379c14d7e.tar.gz
gdb-e1a482ad96a2105c9d3a972de06b510379c14d7e.tar.bz2
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.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r--gdb/rust-lang.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 0b4a7d4..57bef01 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;