From patchwork Tue Mar 25 12:42:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 109164 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7CE93857437 for ; Tue, 25 Mar 2025 12:46:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7CE93857437 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Jo3CROZt X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id A93EE3857732 for ; Tue, 25 Mar 2025 12:43:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A93EE3857732 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A93EE3857732 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742906600; cv=none; b=mSzVAKeQxjayxs8bx/P/k+ZCwcv6LFnmmoAUWTyCYiWY/YU1itbPc9bikHS6iNzM24jRCUd51KjobGsrshuvFHa2ptEZ/zpsmQWoTN64I5aTtOO7aOErHZDGs+VXZfCBokpBSTjnndwuk4TkknhuXlkJGs2FLYbvO5abwyZprF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742906600; c=relaxed/simple; bh=kkJgW3CltFH5MLpp/t0yZS9MpUknmROKRHfVqVFUW8g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AYjhcpWqP14v1M4YrJhrzA5qH7VV6uXG8/8FVwRkUq9kIg4IuUJpkcOoJJnJLTFxNfcc7AyQeLrBhY7/ZsE44JOJOedLjISzGrnfxxLT2E1Kt3JegoQRmLY7wpS+euxI+cMtX9bw2eA8eeMChUjRoB2IPYY4M7w71Bp+3H0oPD4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A93EE3857732 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742906600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4/ckSIfOeKKgUD4bVVmUDEGTkxlgRWAkSxJbB8q6P1w=; b=Jo3CROZtlJdzVk8OfpO8n9ePyhmGQsgjzQu5LEMEg0/1aBRbUkJ9hVCkrOmwHJ4VI07BG5 HQzxPn43bdaQPqtdWdsAg3Cvr0IhdCXrewWpvaQKNzLl+6/U61/R0z4h1yc5A8R1YTN6BK WwpPd49BeWbl3e+nO9fpOSSwzBeBJCE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-bMSUeBFwPR-fLRqurHxMYA-1; Tue, 25 Mar 2025 08:43:17 -0400 X-MC-Unique: bMSUeBFwPR-fLRqurHxMYA-1 X-Mimecast-MFC-AGG-ID: bMSUeBFwPR-fLRqurHxMYA_1742906596 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42B8D180035E; Tue, 25 Mar 2025 12:43:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.117]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 817C0180B48C; Tue, 25 Mar 2025 12:43:14 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen , Tom Tromey Subject: [PATCH v3 1/2] gdb: Remove compile-related attributes from struct language Date: Tue, 25 Mar 2025 09:42:48 -0300 Message-ID: <20250325124249.4023627-2-guinevere@redhat.com> In-Reply-To: <20250325124249.4023627-1-guinevere@redhat.com> References: <20250325124249.4023627-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -ofJkFDVW5sioeXITZP-Q1P3GvAkbfYsMyaB7GKHcqg_1742906596 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org The following patch will add a configure option to disable the compile subsystem at compilation time. To do that, nearly all code that interfaces with compile should be confined to the compile sub-folder. This commit is the first step, removing the compile-related method from the language struct and adding 2 new functions to compile.c that do the same job in a slightly different way. Adding things to the language struct is a more extendable way to add support for languages, but considering compile is quite bit-rotted and questionably supported, I don't think it will be extended any time soon, and using ifdefs to handle disabling compile with configure felt like a messier solution. There should be no visible changes after this commit. Approved-By: Tom Tromey --- gdb/c-lang.c | 32 -------------------------- gdb/c-lang.h | 38 ------------------------------ gdb/compile/compile-internal.h | 39 +++++++++++++++++++++++++++++++ gdb/compile/compile.c | 42 +++++++++++++++++++++++++++++++--- gdb/language.c | 8 ------- gdb/language.h | 32 -------------------------- 6 files changed, 78 insertions(+), 113 deletions(-) diff --git a/gdb/c-lang.c b/gdb/c-lang.c index c28493fc66b..55922344bfc 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -806,22 +806,6 @@ class c_language : public language_defn c_language_arch_info (gdbarch, lai); } - /* See language.h. */ - std::unique_ptr get_compile_instance () const override - { - return c_get_compile_context (); - } - - /* See language.h. */ - std::string compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, - CORE_ADDR expr_pc) const override - { - return c_compute_program (inst, input, gdbarch, expr_block, expr_pc); - } - /* See language.h. */ bool can_print_type_offsets () const override @@ -942,22 +926,6 @@ class cplus_language : public language_defn return cp_lookup_transparent_type (name, flags); } - /* See language.h. */ - std::unique_ptr get_compile_instance () const override - { - return cplus_get_compile_context (); - } - - /* See language.h. */ - std::string compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, - CORE_ADDR expr_pc) const override - { - return cplus_compute_program (inst, input, gdbarch, expr_block, expr_pc); - } - /* See language.h. */ unsigned int search_name_hash (const char *name) const override { diff --git a/gdb/c-lang.h b/gdb/c-lang.h index 0e733d810d8..06b7ad0b8f4 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -25,7 +25,6 @@ struct ui_file; struct language_arch_info; struct type_print_options; struct parser_state; -struct compile_instance; #include "compile/compile.h" #include "value.h" @@ -132,43 +131,6 @@ extern bool c_is_string_type_p (struct type *type); extern int c_textual_element_type (struct type *, char); -/* Create a new instance of the C compiler and return it. This - function never returns NULL, but rather throws an exception on - failure. This is suitable for use as the - language_defn::get_compile_instance method. */ - -extern std::unique_ptr c_get_compile_context (); - -/* Create a new instance of the C++ compiler and return it. This - function never returns NULL, but rather throws an exception on - failure. This is suitable for use as the - language_defn::get_compile_instance method. */ - -extern std::unique_ptr cplus_get_compile_context (); - -/* This takes the user-supplied text and returns a new bit of code to - compile. - - This is used as the compute_program language method; see that - for a description of the arguments. */ - -extern std::string c_compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, - CORE_ADDR expr_pc); - -/* This takes the user-supplied text and returns a new bit of code to compile. - - This is used as the compute_program language method; see that - for a description of the arguments. */ - -extern std::string cplus_compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, - CORE_ADDR expr_pc); - /* Return the canonical form of the C symbol NAME. If NAME is already canonical, return nullptr. */ diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h index f4cc9ee4984..789782dccaf 100644 --- a/gdb/compile/compile-internal.h +++ b/gdb/compile/compile-internal.h @@ -80,4 +80,43 @@ class compile_file_names std::string m_object_file; }; +struct compile_instance; + +/* Create a new instance of the C compiler and return it. This + function never returns NULL, but rather throws an exception on + failure. This is suitable for use as the + language_defn::get_compile_instance method. */ + +extern std::unique_ptr c_get_compile_context (); + +/* Create a new instance of the C++ compiler and return it. This + function never returns NULL, but rather throws an exception on + failure. This is suitable for use as the + language_defn::get_compile_instance method. */ + +extern std::unique_ptr cplus_get_compile_context (); + +/* This takes the user-supplied text and returns a new bit of code to + compile. + + This is used as the compute_program language method; see that + for a description of the arguments. */ + +extern std::string c_compute_program (compile_instance *inst, + const char *input, + struct gdbarch *gdbarch, + const struct block *expr_block, + CORE_ADDR expr_pc); + +/* This takes the user-supplied text and returns a new bit of code to compile. + + This is used as the compute_program language method; see that + for a description of the arguments. */ + +extern std::string cplus_compute_program (compile_instance *inst, + const char *input, + struct gdbarch *gdbarch, + const struct block *expr_block, + CORE_ADDR expr_pc); + #endif /* GDB_COMPILE_COMPILE_INTERNAL_H */ diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index d6bcc1f61f1..43987f9b2b7 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -527,6 +527,41 @@ print_callback (void *ignore, const char *message) gdb_puts (message, gdb_stderr); } +/* Helper for compile_to_object, to find the compile context + based on the current language. */ +static std::unique_ptr +get_language_compile_context () +{ + switch (current_language->la_language) + { + case language_c: + return c_get_compile_context (); + case language_cplus: + return cplus_get_compile_context (); + default: + return {}; + } +} + +/* Helper for compile_to_object, to call the correct + compute_program based on the current language. */ +static std::string +compute_program_language (compile_instance *inst, const char *input, + struct gdbarch *gdbarch, + const struct block *block, + CORE_ADDR pc) +{ + switch (current_language->la_language) + { + case language_c: + return c_compute_program (inst, input, gdbarch, block, pc); + case language_cplus: + return cplus_compute_program (inst, input, gdbarch, block, pc); + default: + gdb_assert_not_reached ("Unsupported language"); + } +} + /* Process the compilation request. On success it returns the object and source file names. On an error condition, error () is called. */ @@ -550,7 +585,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, /* Set up instance and context for the compiler. */ std::unique_ptr compiler - = current_language->get_compile_instance (); + = get_language_compile_context (); + if (compiler == nullptr) error (_("No compiler support for language %s."), current_language->name ()); @@ -582,8 +618,8 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, error (_("Neither a simple expression, or a multi-line specified.")); std::string code - = current_language->compute_program (compiler.get (), input, gdbarch, - expr_block, expr_pc); + = compute_program_language (compiler.get (), input, gdbarch, + expr_block, expr_pc); if (compile_debug) gdb_printf (gdb_stdlog, "debug output:\n\n%s", code.c_str ()); diff --git a/gdb/language.c b/gdb/language.c index a8548a2e82f..4208c23b723 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -677,14 +677,6 @@ language_defn::is_string_type_p (struct type *type) const return c_is_string_type_p (type); } -/* See language.h. */ - -std::unique_ptr -language_defn::get_compile_instance () const -{ - return {}; -} - /* The default implementation of the get_symbol_name_matcher_inner method from the language_defn class. Matches with strncmp_iw. */ diff --git a/gdb/language.h b/gdb/language.h index e6bfa3c68f1..5e9599df25c 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -36,7 +36,6 @@ struct value_print_options; struct type_print_options; struct lang_varobj_ops; struct parser_state; -class compile_instance; struct completion_match_for_lcd; class innermost_block_tracker; @@ -390,37 +389,6 @@ struct language_defn symbol_name_matcher_ftype *get_symbol_name_matcher (const lookup_name_info &lookup_name) const; - /* If this language allows compilation from the gdb command line, - then this method will return an instance of struct gcc_context - appropriate to the language. If compilation for this language is - generally supported, but something goes wrong then an exception - is thrown. If compilation is not supported for this language - then this method returns NULL. */ - - virtual std::unique_ptr get_compile_instance () const; - - /* This method must be overridden if 'get_compile_instance' is - overridden. - - This takes the user-supplied text and returns a new bit of code - to compile. - - INST is the compiler instance being used. - INPUT is the user's input text. - GDBARCH is the architecture to use. - EXPR_BLOCK is the block in which the expression is being - parsed. - EXPR_PC is the PC at which the expression is being parsed. */ - - virtual std::string compute_program (compile_instance *inst, - const char *input, - struct gdbarch *gdbarch, - const struct block *expr_block, - CORE_ADDR expr_pc) const - { - gdb_assert_not_reached ("language_defn::compute_program"); - } - /* Hash the given symbol search name. */ virtual unsigned int search_name_hash (const char *name) const; From patchwork Tue Mar 25 12:42:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 109163 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1CFD3857358 for ; Tue, 25 Mar 2025 12:45:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1CFD3857358 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H/kjVHpT X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 644673857C4F for ; Tue, 25 Mar 2025 12:43:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 644673857C4F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 644673857C4F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742906602; cv=none; b=px6u1hSvBfhNM/gsZImHxIPUyjnu4YuwmsX8H6A20UKaejATznOZt9fe0TI6ZNVwcVGmL5rH5K6ECev1AEiaFVXzg9uMszH/A92vsa2fO2+hfR4L6eC71Iql+RMwqtd22mMfPqacfM7J0AVuD77nwJR3OZX3VgERrHlVC0skpBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742906602; c=relaxed/simple; bh=W2+riuDOuyEy+O3ocbSxyOf9QObYdfMIkaequbWChOQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dH2Lb2GEMBwsGSkA9bQyq6HAfrIlsjpYNbsECrI3F4cqoKADQXEQUJ9+5DHJ8pedsuZdaOsUbFBd9BIoeHg/Cn55z1nU/peuu//kFegF9EsOz9YwKVNiP5lybhzlNEzJPVRp2kjFkp19U0qG/l9P4G7cVeQXDAwmew37HM5NsDc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 644673857C4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742906602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5ouuYz2C5RMLR7iGGnAA0TrGwCg/zoQdQefrUdFRTU=; b=H/kjVHpTy4OpYoMj2AbEak5S+w/GPqvjcSz6uHLLFSJciKaI85Q9vtlbb1wZ+iJW5aGTiy VJ8uhemJ9wA+Ejjx+bzyvi6wXHYawi9wCVACsm/ABSDdmh5SaMhNQ0+cVaLlOHuB3ZV5FS VEFHJyw7yda5wOGPM/rA7f7n6SEDXCM= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-Z4dZ6XCVMhq741tUkOsAcA-1; Tue, 25 Mar 2025 08:43:20 -0400 X-MC-Unique: Z4dZ6XCVMhq741tUkOsAcA-1 X-Mimecast-MFC-AGG-ID: Z4dZ6XCVMhq741tUkOsAcA_1742906600 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C753318EBE85; Tue, 25 Mar 2025 12:43:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.117]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C03AF180B48C; Tue, 25 Mar 2025 12:43:16 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen , Eli Zaretskii Subject: [PATCH v3 2/2] gdb: add configure option to disable compile Date: Tue, 25 Mar 2025 09:42:49 -0300 Message-ID: <20250325124249.4023627-3-guinevere@redhat.com> In-Reply-To: <20250325124249.4023627-1-guinevere@redhat.com> References: <20250325124249.4023627-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: O4LU5H4lqWf36Al-QOqZPR_zGhmcemo8wPwLkPAOPhw_1742906600 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org GDB's compile subsystem is deeply tied to GDB's ability to understand DWARF. A future patch will add the option to disable DWARF at configure time, but for that to work, the compile subsystem will need to be entirely disabled as well, so this patch adds that possibility. I also think there is motive for a security conscious user to disable compile for it's own sake. Considering that the code is quite unmaintained, and depends on an equally unmaintained gcc plugin, there is a case to be made that this is an unnecessary increase in the attack surface if a user knows they won't use the subsystem. Additionally, this can make compilation slightly faster and the final binary is around 3Mb smaller. But these are all secondary to the main goal of being able to disable dwarf at configure time. To be able to achieve optional compilation, some of the code that interfaces with compile had to be changed. All parts that directly called compile things have been wrapped by ifdefs checking for compile support. The file compile/compile.c has been setup in a similar way to how python's and guile's main file has been setup, still being compiled but only for with placeholder command. Finally, to avoid several new errors, a new TCL proc was introduced to gdb.exp, allow_compile_tests, which checks if the "compile" command is recognized before the inferior is started and otherwise skips the compile tests. All tests in the gdb.compile subfolder have been updated to use that, and the test gdb.base/filename-completion also uses this. The proc skip_compile_feature_tests to recognize when the subsystem has been disabled at compile time. Reviewed-By: Eli Zaretskii --- gdb/Makefile.in | 3 +- gdb/NEWS | 4 ++ gdb/README | 3 ++ gdb/cli/cli-script.c | 4 ++ gdb/compile/compile.c | 39 +++++++++++++++---- gdb/config.in | 3 ++ gdb/configure | 39 ++++++++++++++++++- gdb/configure.ac | 20 ++++++++++ gdb/dwarf2/loc.c | 12 ++++++ .../gdb.base/filename-completion.exp | 14 ++++--- .../gdb.compile/compile-cplus-anonymous.exp | 2 + .../gdb.compile/compile-cplus-array-decay.exp | 2 + .../gdb.compile/compile-cplus-inherit.exp | 2 + .../gdb.compile/compile-cplus-member.exp | 2 + .../gdb.compile/compile-cplus-method.exp | 2 + .../gdb.compile/compile-cplus-namespace.exp | 2 + .../gdb.compile/compile-cplus-nested.exp | 2 + .../gdb.compile/compile-cplus-print.exp | 2 + .../gdb.compile/compile-cplus-virtual.exp | 2 + gdb/testsuite/gdb.compile/compile-cplus.exp | 2 + gdb/testsuite/gdb.compile/compile-ifunc.exp | 2 + gdb/testsuite/gdb.compile/compile-ops.exp | 2 + gdb/testsuite/gdb.compile/compile-print.exp | 2 + gdb/testsuite/gdb.compile/compile-setjmp.exp | 2 + gdb/testsuite/gdb.compile/compile-tls.exp | 2 + gdb/testsuite/gdb.compile/compile.exp | 2 + gdb/testsuite/lib/compile-support.exp | 3 ++ gdb/testsuite/lib/gdb.exp | 6 +++ 28 files changed, 166 insertions(+), 16 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 8f6df5ba7b6..6203bcf606f 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1912,8 +1912,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ $(patsubst %.c,%.o,$(COMMON_SFILES)) \ $(SUBDIR_CLI_OBS) \ $(SUBDIR_MI_OBS) \ - $(SUBDIR_TARGET_OBS) \ - $(SUBDIR_GCC_COMPILE_OBS) + $(SUBDIR_TARGET_OBS) SUBDIRS = doc @subdirs@ data-directory CLEANDIRS = $(SUBDIRS) diff --git a/gdb/NEWS b/gdb/NEWS index 2fdb849a81b..40b0bcf7248 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -108,6 +108,10 @@ qXfer:threads:read * Support for stabs debugging format and the a.out/dbx object format is deprecated, and will be removed in GDB 18. +* A new configure option was added, allowing support for the compile + subsystem to be disabled at configure time, in the form of + --disable-gdb-compile. + *** Changes in GDB 16 * Support for Nios II targets has been removed as this architecture diff --git a/gdb/README b/gdb/README index b6eb3f12c56..8836120d7ca 100644 --- a/gdb/README +++ b/gdb/README @@ -442,6 +442,9 @@ more obscure GDB `configure' options are not listed here. Requires a curses library (ncurses and cursesX are also supported). +`--disable-gdb-compile' + Build GDB without support for the 'compile' command. + `--with-curses' Use the curses library instead of the termcap library, for text-mode terminal operations. diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 5decf3b9d5c..c14480f84ed 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -660,9 +660,13 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) } case compile_control: +#if defined(HAVE_COMPILE) eval_compile_command (cmd, NULL, cmd->control_u.compile.scope, cmd->control_u.compile.scope_data); ret = simple_control; +#else + error (_("compile support has not been compiled into gdb")); +#endif break; case define_control: diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 43987f9b2b7..01f43ad103d 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -46,16 +46,17 @@ #include "gdbsupport/scoped_ignore_signal.h" #include "gdbsupport/buildargv.h" +/* Hold "compile" commands. */ + +static struct cmd_list_element *compile_command_list; + +#ifdef HAVE_COMPILE /* Initial filename for temporary files. */ #define TMP_PREFIX "/tmp/gdbobj-" -/* Hold "compile" commands. */ - -static struct cmd_list_element *compile_command_list; - /* Debug flag for "compile" commands. */ bool compile_debug; @@ -852,6 +853,18 @@ compile_instance::compile (const char *filename, int verbose_level) #undef FORWARD +#else /* HAVE_COMPILE */ + +/* The "compile" prefix command, when support was disabled. */ + +static void +compile_command (const char *args, int from_tty) +{ + error (_("This command is not supported.")); +} + +#endif /* HAVE_COMPILE */ + /* See compile.h. */ cmd_list_element *compile_cmd_element = nullptr; @@ -859,14 +872,25 @@ void _initialize_compile (); void _initialize_compile () { - struct cmd_list_element *c = NULL; - compile_cmd_element = add_prefix_cmd ("compile", class_obscure, - compile_command, _("\ + compile_command, +#ifdef HAVE_COMPILE + _("\ Command to compile source code and inject it into the inferior."), +#else /* HAVE_COMPILE */ + _("\ +Command to compile source code and inject it into the inferior.\n\ +\n\ +Code compilation and injection is not supported in this copy of GDB.\n\ +This command is only a placeholder."), +#endif /* HAVE_COMPILE */ &compile_command_list, 1, &cmdlist); add_com_alias ("expression", compile_cmd_element, class_obscure, 0); +#ifdef HAVE_COMPILE + + struct cmd_list_element *c = NULL; + const auto compile_opts = make_compile_options_def_group (nullptr); static const std::string compile_code_help @@ -973,4 +997,5 @@ It should be absolute filename of the gcc executable.\n\ If empty the default target triplet will be searched in $PATH."), NULL, show_compile_gcc, &setlist, &showlist); +#endif /* HAVE_COMPILE */ } diff --git a/gdb/config.in b/gdb/config.in index db63aeaec75..86ff67d2898 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -104,6 +104,9 @@ the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE +/* Define if compiling support to gdb compile. */ +#undef HAVE_COMPILE + /* Define to 1 if you have the header file. */ #undef HAVE_CURSESX_H diff --git a/gdb/configure b/gdb/configure index 3080413fdc9..e8a649f2ef0 100755 --- a/gdb/configure +++ b/gdb/configure @@ -956,6 +956,7 @@ with_libexpat_type with_python with_python_libdir with_guile +enable_gdb_compile enable_source_highlight with_sysroot with_system_gdbinit @@ -1650,6 +1651,8 @@ Optional Features: --enable-gdbtk enable gdbtk graphical user interface (GUI) --enable-profiling enable profiling of GDB --enable-codesign=CERT sign gdb with 'codesign -s CERT' + --enable-gdb-compile enable support for the compile subsystem, default + 'yes' --enable-source-highlight enable source-highlight for source listings --enable-werror treat compile warnings as errors @@ -11500,7 +11503,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11503 "configure" +#line 11506 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11606,7 +11609,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11609 "configure" +#line 11612 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -28968,6 +28971,38 @@ else fi +# ---------------------------- # +# Check for compile support. # +# ---------------------------- # + +# Check whether --enable-gdb-compile was given. +if test "${enable_gdb_compile+set}" = set; then : + enableval=$enable_gdb_compile; + case $enableval in + yes | no) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-gdb-compile" "$LINENO" 5 + ;; + esac + +else + enable_gdb_compile=yes +fi + + +if test "${enable_gdb_compile}" == yes; then + +$as_echo "#define HAVE_COMPILE 1" >>confdefs.h + + CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_GCC_COMPILE_OBS)" +else + # Even if compile support is not enabled, we need this file to define + # the "compile" command. + CONFIG_OBS="$CONFIG_OBS compile/compile.o" + CONFIG_SRCS="$CONFIG_SRCS compile/compile.c" +fi + # ---------------------------- # # Check for source highlight. # # ---------------------------- # diff --git a/gdb/configure.ac b/gdb/configure.ac index eafbf5ac358..2411b10ca40 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1221,6 +1221,26 @@ AC_SUBST(GUILE_CPPFLAGS) AC_SUBST(GUILE_LIBS) AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" != no) +# ---------------------------- # +# Check for compile support. # +# ---------------------------- # + +AC_ARG_ENABLE([gdb-compile], + AS_HELP_STRING([--enable-gdb-compile], + [enable support for the compile subsystem, default 'yes']), + [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdb-compile])], + [enable_gdb_compile=yes]) + +if test "${enable_gdb_compile}" == yes; then + AC_DEFINE(HAVE_COMPILE, 1, [Define if compiling support to gdb compile.]) + CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_GCC_COMPILE_OBS)" +else + # Even if compile support is not enabled, we need this file to define + # the "compile" command. + CONFIG_OBS="$CONFIG_OBS compile/compile.o" + CONFIG_SRCS="$CONFIG_SRCS compile/compile.c" +fi + # ---------------------------- # # Check for source highlight. # # ---------------------------- # diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 7c12c0d4d4d..8f666945122 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1784,6 +1784,7 @@ dwarf2_compile_property_to_c (string_file *stream, CORE_ADDR pc, struct symbol *sym) { +#if defined (HAVE_COMPILE) const dwarf2_property_baton *baton = prop->baton (); const gdb_byte *data; size_t size; @@ -1810,6 +1811,9 @@ dwarf2_compile_property_to_c (string_file *stream, gdbarch, registers_used, per_cu->addr_size (), data, data + size, per_cu, per_objfile); +#else + gdb_assert_not_reached ("Compile support was disabled"); +#endif } /* Compute the correct symbol_needs_kind value for the location @@ -3852,6 +3856,7 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream, std::vector ®isters_used, CORE_ADDR pc, const char *result_name) { +#if defined (HAVE_COMPILE) struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym); unsigned int addr_size = dlbaton->per_cu->addr_size (); @@ -3863,6 +3868,9 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream, sym, pc, gdbarch, registers_used, addr_size, dlbaton->data, dlbaton->data + dlbaton->size, dlbaton->per_cu, dlbaton->per_objfile); +#else + gdb_assert_not_reached ("Compile support was disabled"); +#endif } /* The set of location functions used with the DWARF-2 expression @@ -4088,6 +4096,7 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream, std::vector ®isters_used, CORE_ADDR pc, const char *result_name) { +#if defined (HAVE_COMPILE) struct dwarf2_loclist_baton *dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym); unsigned int addr_size = dlbaton->per_cu->addr_size (); @@ -4103,6 +4112,9 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream, data, data + size, dlbaton->per_cu, dlbaton->per_objfile); +#else + gdb_assert_not_reached ("Compile support was disabled"); +#endif } /* The set of location functions used with the DWARF-2 expression diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp index 03ead592f0b..a1dd9746c20 100644 --- a/gdb/testsuite/gdb.base/filename-completion.exp +++ b/gdb/testsuite/gdb.base/filename-completion.exp @@ -381,11 +381,15 @@ proc run_mid_line_completion_tests { root cmd } { proc run_quoting_and_escaping_tests { root } { # Test all the commands which allow quoting of filenames, and # which require whitespace to be escaped in unquoted filenames. - foreach_with_prefix cmd { file exec-file symbol-file add-symbol-file \ - remove-symbol-file \ - "target core" "target exec" "target tfile" \ - "maint print c-tdesc" "compile file" \ - "save gdb-index" "save gdb-index -dwarf-5" } { + set all_cmds { file exec-file symbol-file add-symbol-file \ + remove-symbol-file \ + "target core" "target exec" "target tfile" \ + "maint print c-tdesc" "save gdb-index" + "save gdb-index -dwarf-5" } + if { [allow_compile_tests] } { + lappend all_cmds "compile file" + } + foreach_with_prefix cmd $all_cmds { # Try each test placing the filename as the first argument # then again with a quoted string immediately after the # command. This works because the filename completer will diff --git a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp b/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp index 3e76d38dc10..ddad6281ebf 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-anonymous.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp b/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp index 505a4e12eb3..c7d15ce0913 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-array-decay.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++ additional_flags=-std=c++11}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp b/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp index 1a5f60a75dc..9ef1e832f3d 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-inherit.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-member.exp b/gdb/testsuite/gdb.compile/compile-cplus-member.exp index 5ffbb30df82..ac9111c83e4 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-member.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-member.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-method.exp b/gdb/testsuite/gdb.compile/compile-cplus-method.exp index 0a0e0fa18a3..bcbfbb05e4b 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-method.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-method.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp b/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp index 3ab8ece4bf1..2abc3663d1c 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-namespace.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp b/gdb/testsuite/gdb.compile/compile-cplus-nested.exp index 19efd4f7506..247d270a231 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-nested.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-nested.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-print.exp b/gdb/testsuite/gdb.compile/compile-cplus-print.exp index 594f94a6ac9..e4413f01d0e 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-print.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-print.exp @@ -19,6 +19,8 @@ standard_testfile require is_c_compiler_gcc +require allow_compile_tests + set options {} if [test_compiler_info gcc*] { lappend options additional_flags=-g3 diff --git a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp b/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp index 8761df56db5..a7702084133 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus-virtual.exp @@ -23,6 +23,8 @@ require allow_cplus_tests require is_c_compiler_gcc +require allow_compile_tests + if {[prepare_for_testing $testfile $testfile $srcfile \ {debug nowarnings c++}]} { return -1 diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp index 711f299574d..35ae692acc7 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp @@ -19,6 +19,8 @@ standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c require is_c_compiler_gcc +require allow_compile_tests + set options {} if { [test_compiler_info gcc*] || [test_compiler_info clang*] } { lappend options additional_flags=-g3 diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp index b004bd7bb61..e490890c5d6 100644 --- a/gdb/testsuite/gdb.compile/compile-ifunc.exp +++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp @@ -17,6 +17,8 @@ load_lib compile-support.exp require allow_ifunc_tests +require allow_compile_tests + standard_testfile require is_c_compiler_gcc diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp index f75e02cedf3..cfbe2b0356c 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.exp +++ b/gdb/testsuite/gdb.compile/compile-ops.exp @@ -22,6 +22,8 @@ load_lib dwarf.exp # This test can only be run on targets which support DWARF-2 and use gas. require dwarf2_support +require allow_compile_tests + require is_c_compiler_gcc standard_testfile .c -dbg.S diff --git a/gdb/testsuite/gdb.compile/compile-print.exp b/gdb/testsuite/gdb.compile/compile-print.exp index f8f22973e3e..61ce7501df7 100644 --- a/gdb/testsuite/gdb.compile/compile-print.exp +++ b/gdb/testsuite/gdb.compile/compile-print.exp @@ -19,6 +19,8 @@ standard_testfile require is_c_compiler_gcc +require allow_compile_tests + if { [prepare_for_testing "failed to prepare" "$testfile"] } { return -1 } diff --git a/gdb/testsuite/gdb.compile/compile-setjmp.exp b/gdb/testsuite/gdb.compile/compile-setjmp.exp index f387a054ea9..ad8732b773d 100644 --- a/gdb/testsuite/gdb.compile/compile-setjmp.exp +++ b/gdb/testsuite/gdb.compile/compile-setjmp.exp @@ -19,6 +19,8 @@ standard_testfile .c compile-setjmp-mod.c require is_c_compiler_gcc +require allow_compile_tests + if { [prepare_for_testing "failed to prepare" $testfile] } { return -1 } diff --git a/gdb/testsuite/gdb.compile/compile-tls.exp b/gdb/testsuite/gdb.compile/compile-tls.exp index 2f8dc5ade2c..45e290e808e 100644 --- a/gdb/testsuite/gdb.compile/compile-tls.exp +++ b/gdb/testsuite/gdb.compile/compile-tls.exp @@ -19,6 +19,8 @@ standard_testfile .c require is_c_compiler_gcc +require allow_compile_tests + if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ executable {debug}] != "" } { return -1 diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index 2c2e3217b19..5128dc62444 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -15,6 +15,8 @@ load_lib compile-support.exp +require allow_compile_tests + standard_testfile .c compile-shlib.c compile-constvar.S compile-nodebug.c require is_c_compiler_gcc diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp index aa8aaf3b7e3..6d7a4ce13ef 100644 --- a/gdb/testsuite/lib/compile-support.exp +++ b/gdb/testsuite/lib/compile-support.exp @@ -45,6 +45,9 @@ proc _do_check_compile {expr} { # This appears to be a bug in the compiler plugin. set result "apparent compiler plugin bug" } + -re "This command is not supported." { + set result "compiler disabled at configure time" + } -re "\r\n$gdb_prompt $" { } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3349da7a263..8486ff05e57 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2799,6 +2799,12 @@ gdb_caching_proc allow_python_tests {} { return [expr {[string first "--with-python" $output] != -1}] } +# Return a 1 if GDB was configured to support compile commands. +gdb_caching_proc allow_compile_tests {} { + set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS -ex \"compile int x = 1\" -batch"] + return [expr {[string first "The program must be running" $output] != -1}] +} + # Return a 1 for configurations that use system readline rather than the # in-repo copy.