Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stephan Rohr <stephan.rohr@intel.com>
To: gdb-patches@sourceware.org
Cc: eliz@gnu.org, guinevere@redhat.com, tom@tromey.com
Subject: [PATCH v4 1/1] gdb: remove check for minimal symbols in 'start_command'
Date: Mon, 27 Jan 2025 07:42:11 -0800	[thread overview]
Message-ID: <20250127154211.2509613-2-stephan.rohr@intel.com> (raw)
In-Reply-To: <20250127154211.2509613-1-stephan.rohr@intel.com>

From: "Rohr, Stephan" <stephan.rohr@intel.com>

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);
 }
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2025-01-27 15:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-27 15:42 [PATCH v4 0/1] gdb: remove minimal symbol check " Stephan Rohr
2025-01-27 15:42 ` Stephan Rohr [this message]
2025-01-27 23:28   ` [PATCH v4 1/1] gdb: remove check for minimal symbols " Kevin Buettner
2025-01-28 17:47     ` Tom Tromey
2025-02-10 17:09     ` Guinevere Larsen
2025-02-11 14:51       ` Tom Tromey
2025-02-11 15:53         ` Rohr, Stephan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250127154211.2509613-2-stephan.rohr@intel.com \
    --to=stephan.rohr@intel.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox