]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid internal errors when stepping outside 'main' on MinGW
authorEli Zaretskii <eliz@gnu.org>
Fri, 28 Dec 2018 07:02:04 +0000 (09:02 +0200)
committerEli Zaretskii <eliz@gnu.org>
Fri, 28 Dec 2018 07:02:04 +0000 (09:02 +0200)
When one steps with "next" past the 'main's 'return' statement
in MinGW programs built by mingw.org's tools, PC lands in a
function whose symbol is not in any symtab.  GDB then looks
up the nearest symbol, and should find none, because all those
with addresses below PC are not real functions.  Having
unresolved symbols, whose address is zero, in minsyms tricked
GDB into using these bogus symbols, which then caused
assertion violation and internal_error.  See the discussion at
https://sourceware.org/ml/gdb-patches/2018-12/msg00176.html
for more details.

gdb/ChangeLog
2018-12-28  Eli Zaretskii  <eliz@gnu.org>

* coffread.c (coff_symtab_read): Don't record in minsyms symbols
that are unresolved.  This avoids triggering an internal error
when stepping outside of 'main' in MinGW programs.

gdb/ChangeLog
gdb/coffread.c

index eea0c21d17b73d2d0d5b8c809f89bbd930294911..35f9f18d7d69134880b027272be0753678ef8244 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-28  Eli Zaretskii  <eliz@gnu.org>
+
+       * coffread.c (coff_symtab_read): Don't record in minsyms symbols
+       that are unresolved.  This avoids triggering an internal error
+       when stepping outside of 'main' in MinGW programs.
+
 2018-12-27  Tom Tromey  <tom@tromey.com>
 
        * python/py-utils.c (gdbpy_handle_exception): Translate
index a473b78245e3ec038d808ed53469f5de51ea242d..cab5707382cc4db64fe808f9d13d5d76dcdab8b8 100644 (file)
@@ -877,8 +877,10 @@ coff_symtab_read (minimal_symbol_reader &reader,
          int section = cs_to_section (cs, objfile);
 
          tmpaddr = cs->c_value;
-         record_minimal_symbol (reader, cs, tmpaddr, mst_text,
-                                section, objfile);
+         /* Don't record unresolved symbols.  */
+         if (!(cs->c_secnum <= 0 && cs->c_value == 0))
+           record_minimal_symbol (reader, cs, tmpaddr, mst_text,
+                                  section, objfile);
 
          fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
          fcn_start_addr = tmpaddr;