From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Ch4NE8wWmGexnBwAWB0awg (envelope-from ) for ; Mon, 27 Jan 2025 18:29:16 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XbTC+Euj; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 35D461E105; Mon, 27 Jan 2025 18:29:16 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5ECCB1E05C for ; Mon, 27 Jan 2025 18:29:13 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBC643858D38 for ; Mon, 27 Jan 2025 23:29:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBC643858D38 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=XbTC+Euj 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 2CD9C3858D1E for ; Mon, 27 Jan 2025 23:28:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CD9C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none 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 2CD9C3858D1E 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=1738020522; cv=none; b=GYmEX9xzTkbT9mIl4rRRNkL550qY8M1X8k6YyI2V+1UoNwAi+oUPBd9PT43woKyil8EGquSzoh0Osn+U8KJI4XRr+hZglocWsuhDobP8chLDWwHIFfK95PwYOMU5suNZrz4S6ItW9WNknEMf1b7ywtOMmxfSzShBlg/NklsCwAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738020522; c=relaxed/simple; bh=L6y7C7Jt0B4KprJRGsl06oIFNiRu74huRbPPHJBzJFA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hJlAqevLPHBB9aXx/FRW+QxgBU5P3OYY5Ze9uesniP27cgFGeS8vj/JrSgnuymxOQZG7CtFauLUm9VbWd5ytp2k18orL79Bp7xn+z1uSwuWsdG4etbQ6NfvUrjbyQeJr6yAqg9jUhQvPqe3W+X35HmBG+F15OriPm4AcWfC+DsE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CD9C3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738020521; 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=DL7Mb+UMy94DZFM21cfupy10tNK6msbrjv1NTNa7aYI=; b=XbTC+EujMcmFCswUPj4KJu0MqXW5chkuAoC9pfnyEso7Ydw18zupflV53nKtHZQiOd+GcN cuuQUIymbB1KXpHtwrmYrOiRvr3NJaAZE+ufiZZQ24Q4VswF2fp4kt2kEeyJg1QrvcSJFL ocDeA976urG37MVV+bGps2ti8DtMk/E= Received: from mx-prod-mc-02.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-570-eNcv18vTPB2Qpg4Va89LQw-1; Mon, 27 Jan 2025 18:28:38 -0500 X-MC-Unique: eNcv18vTPB2Qpg4Va89LQw-1 X-Mimecast-MFC-AGG-ID: eNcv18vTPB2Qpg4Va89LQw Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 882411955DCC; Mon, 27 Jan 2025 23:28:37 +0000 (UTC) Received: from f41-zbm-amd (unknown [10.22.80.94]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A37C5180034C; Mon, 27 Jan 2025 23:28:35 +0000 (UTC) Date: Mon, 27 Jan 2025 16:28:30 -0700 From: Kevin Buettner To: Stephan Rohr Cc: gdb-patches@sourceware.org, eliz@gnu.org, guinevere@redhat.com, tom@tromey.com Subject: Re: [PATCH v4 1/1] gdb: remove check for minimal symbols in 'start_command' Message-ID: <20250127162830.5d10b4f7@f41-zbm-amd> In-Reply-To: <20250127154211.2509613-2-stephan.rohr@intel.com> References: <20250127154211.2509613-1-stephan.rohr@intel.com> <20250127154211.2509613-2-stephan.rohr@intel.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GQeQks4xUvrJbOLQC5n3PtQDniGN4naIh-P7K5AwyWA_1738020517 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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~public-inbox=simark.ca@sourceware.org On Mon, 27 Jan 2025 07:42:11 -0800 Stephan Rohr wrote: > From: "Rohr, Stephan" > > GDB aborts the 'start' command if the minimal symbols cannot be > resolved. On Windows, GDB reads the minimal symbols from the COFF > header of the PE file. The symbol table is deprecated and the > number of symbols in the COFF header may be zero: > > https://learn.microsoft.com/en-us/windows/win32/debug/pe-format > > This is reproducible with clang version 18.1.8 on Windows: > > clang++ -g -O0 -gdwarf -fuse-ld=lld test.cpp -o test_clang > > The COFF file header shows: > > FILE HEADER VALUES > 8664 machine (x64) > E number of sections > 66E889EC time date stamp Mon Sep 16 21:41:32 2024 > FB400 file pointer to symbol table > 0 number of symbols > F0 size of optional header > 22 characteristics > > GDB is not able to read the minimal symbols; the `start' command fails > with an error: > > (gdb) start > No symbol table loaded. Use the "file" command. > > Manually inserting a breakpoint in main works fine: > > (gdb) tbreak main > Temporary breakpoint 1 at 0x14000100c: file test.cpp, line 6. > (gdb) run > Starting program: C:\test-clang > > Temporary breakpoint 1, main () at test.cpp:6 > 6 std::cout << "Hello World.\n"; > > Remove the check entirely; a 'NOT_FOUND_ERROR' is thrown if 'main' > cannot be resolved. The error is consumed in 'create_breakpoint ()' > and an error message is displayed to the user. > --- > gdb/infcmd.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/gdb/infcmd.c b/gdb/infcmd.c > index b6b21a46b3d..00703e44b7b 100644 > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -517,12 +517,6 @@ run_command (const char *args, int from_tty) > static void > start_command (const char *args, int from_tty) > { > - /* Some languages such as Ada need to search inside the program > - minimal symbols for the location where to put the temporary > - breakpoint before starting. */ > - if (!have_minimal_symbols (current_program_space)) > - error (_("No symbol table loaded. Use the \"file\" command.")); > - > /* Run the program until reaching the main procedure... */ > run_command_1 (args, from_tty, RUN_STOP_AT_MAIN); > } It's possible to reproduce this behavior on Linux too: $ gcc -static -g -o hello hello.c $ strip --keep-section='.debug*' hello Using a gdb built without this patch: (gdb) file hello Reading symbols from hello... (gdb) start No symbol table loaded. Use the "file" command. Which demonstrates the behavior that you're fixing with this patch. And yet... (gdb) b main Breakpoint 1 at 0x401849: file hello.c, line 6. (gdb) run Starting program: /home/kev/ctests/hello This GDB supports auto-downloading debuginfo from the following URLs: Enable debuginfod for this session? (y or [n]) y Debuginfod has been enabled. To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit. Breakpoint 1, main () at hello.c:6 6 printf("Hello world\n"); ...it's still possible to set a breakpoint on main and run to it. With your patch: (gdb) file hello Reading symbols from hello... (gdb) start Temporary breakpoint 1 at 0x401849: file hello.c, line 6. Starting program: /home/kev/ctests/hello This GDB supports auto-downloading debuginfo from the following URLs: Enable debuginfod for this session? (y or [n]) y Debuginfod has been enabled. To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit. Temporary breakpoint 1, main () at hello.c:6 6 printf("Hello world\n"); The one thing that concerns me is the comment regarding the Ada language and the need to search for minimal symbols. I'm going to give this patch an "Approved-by", but please wait a few days for others to weigh in regarding this concern. Approved-by: Kevin Buettner