From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id AF55E3858426 for ; Tue, 22 Aug 2023 15:25:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF55E3858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-34ca1aadcccso10186445ab.3 for ; Tue, 22 Aug 2023 08:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1692717912; x=1693322712; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6PM9PAS+n3IHhlk5iF2qfMzRYPjjPXHaS28+Z/HqCyk=; b=R/tXgTIsamBeI4H/ezoguBbhTlSmaSdcPy3wuYWM1QFd9+wPzEje0isX9NwBHGUfdM AvbGbjr65nV5MFggbmB4q5RE4NidAhtXDEh3mJ6C9OGp0IGMT4+VSaRkIxUZTKerUEXb EtQUjQnwslLCDK3RkkZkaZ+0oFkenQy5swVaEuGfIHDVnn/bARH04K44FHo8jyBV3nxS JXUIgP6wSKDeP+PWtRcapH+a1cKIu2vj1jcPzWXyPXMH4oX96UMYWSXXHqnyLX7QidCl euM94ULvodz5shJyf+raAIkidu9eijHRv3GFRNzL6opMtiZl2lEql8ukDh2DfdwgYdQw /bww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692717912; x=1693322712; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6PM9PAS+n3IHhlk5iF2qfMzRYPjjPXHaS28+Z/HqCyk=; b=RaLxqjnDasydiENnTZz3aT0lgvoq6hWD6JX1/4z68E//467CYmqyDF5IDWpn+ws+0A LOkcq7Uiu1IHyhkMj9p+JPm3gFtPjq10jGuwVqP7DLSYzGUPI0sV+vcR7Txyzs2oul/H Y3WfomhElRL+dlhMl25ssaJLPZZO2QuhwLvdG7dsR91YOR+stFoUov4hdO3cxWa0yBo9 XVUuUXCQx22Oi1Zdyerp9QhiQHRaL7kvVV+8a0ieb1/e8dt+7/WHKwRlm2RemOVtdNdr tzNoOIbDHo7CWG8eXBi+NfsOvETXx73NKaVJUDo5BVLEeiDx/Fo2r24TjRi7g7dyg21j k4yg== X-Gm-Message-State: AOJu0YzU5TOdX46Su0jO8etY51puRliHmg4r6Gdn3KlQkG8Olaa1KZF9 EXnRx8bxptsiQ2XGFhkExZf0o5eab//SQOCPYPlR/A== X-Google-Smtp-Source: AGHT+IH76aKz0HeTskH8AExPMZTBaq+YPa6CmSHro6TLuJ88yjQRdULJJTmnnxejq2IX5VOj6lPKyw== X-Received: by 2002:a92:c7c2:0:b0:348:e180:831d with SMTP id g2-20020a92c7c2000000b00348e180831dmr10985906ilk.20.1692717911970; Tue, 22 Aug 2023 08:25:11 -0700 (PDT) Received: from localhost.localdomain (75-166-142-177.hlrn.qwest.net. [75.166.142.177]) by smtp.gmail.com with ESMTPSA id e8-20020a92de48000000b003460b8505easm1721608ilr.19.2023.08.22.08.25.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 08:25:11 -0700 (PDT) From: Tom Tromey Date: Tue, 22 Aug 2023 09:25:07 -0600 Subject: [PATCH 1/8] Move rust_language::lookup_symbol_nonlocal MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230822-array-and-string-like-v1-1-2dcea29b0567@adacore.com> References: <20230822-array-and-string-like-v1-0-2dcea29b0567@adacore.com> In-Reply-To: <20230822-array-and-string-like-v1-0-2dcea29b0567@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- gdb/rust-lang.c | 37 +++++++++++++++++++++++++++++++++++++ gdb/rust-lang.h | 32 +------------------------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 5eb33d0d3b7..f56aa94a48a 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1684,6 +1684,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 @@ class rust_language : public language_defn 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. */ -- 2.40.1