[binutils-gdb] gdb: remove check for minimal symbols in 'start_command'

Stephan Rohr srohr@sourceware.org
Tue Feb 11 16:35:19 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d96a6c755fab4cfdd4648e742c34713bcd637475

commit d96a6c755fab4cfdd4648e742c34713bcd637475
Author: Rohr, Stephan <stephan.rohr@intel.com>
Date:   Thu Aug 1 19:46:18 2024 +0200

    gdb: remove check for minimal symbols in 'start_command'
    
    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.
    
    Approved-by: Kevin Buettner <kevinb@redhat.com>
    Reviewed-By: Guinevere Larsen <guinevere@redhat.com>

Diff:
---
 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);
 }


More information about the Gdb-cvs mailing list