Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro_alves@portugalmail.pt>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Enhance stabs reader to better deal with forward 	references
Date: Sat, 31 Mar 2007 20:42:00 -0000	[thread overview]
Message-ID: <460EC794.2080309@portugalmail.pt> (raw)
In-Reply-To: <20070329183609.GA3737@adacore.com>

[-- Attachment #1: Type: text/plain, Size: 8439 bytes --]

Hi,

Joel Brobecker wrote:
>>> 2007-02-08  Joel Brobecker  <brobecker@adacore.com>
>>>
>>>         * stabsread.c (add_undefined_type): Add extra parameter.
>>>         Now handles nameless types separately.
>>>         (struct nat): New type.
>>>         (noname_undefs, noname_undefs_allocated, noname_undefs_length):
>>>         New static variables.
>>>         (read_type): Update calls to add_undefined_type.
>>>         (add_undefined_type_noname): New function.
>>>         (add_undefined_type_1): Renames from add_undefined_type.
>>>         (cleanup_undefined_types_noname): New function.
>>>         (cleanup_undefined_types_1): Renames cleanup_undefined_types.
>>>         (cleanup_undefined_types): New handles nameless types separately.
>>>         (_initialize_stabsread): Initialize our new static constants.
>>>
>>>       


Unfortunatelly, this patch broke Cygwin, which still uses stabs by default.

I am getting a SIGSEGV while issuing a breakpoint.
Here is a backtrace showing the problem.

(current_objfile is NULL on the SIGSEGV)

(I love these gdb in gdb in gdb in gdb thingies :) )

 >/usr/bin/gdb --args /usr/local/bin/gdb --args /usr/local/bin/gdb 
./main.exe 5404
GNU gdb 6.5.50.20060706-cvs (cygwin-special)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) r
Starting program: /usr/local/bin/gdb.exe --args /usr/local/bin/gdb 
./main.exe 5404
Loaded symbols for /cygdrive/c/WINDOWS/system32/ntdll.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/kernel32.dll
Loaded symbols for /usr/bin/cygwin1.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/advapi32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/rpcrt4.dll
Loaded symbols for /usr/bin/cygexpat-0.dll
Loaded symbols for /usr/bin/cygiconv-2.dll
Loaded symbols for /usr/bin/cygintl-8.dll
Loaded symbols for /usr/bin/cygncurses-8.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/user32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/gdi32.dll
GNU gdb 6.6.50.20070329-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) b win32_attach

Program received signal SIGSEGV, Segmentation fault.
0x004e003f in dbx_lookup_type (typenums=0x22c110) at 
../../gdb-server_submit/src/gdb/stabsread.c:293
293           if (real_filenum >= N_HEADER_FILES (current_objfile))
(gdb)
#0  0x004e003f in dbx_lookup_type (typenums=0x22c110) at 
../../gdb-server_submit/src/gdb/stabsread.c:293
#1  0x004e7769 in cleanup_undefined_types_noname () at 
../../gdb-server_submit/src/gdb/stabsread.c:4259
#2  0x004e7933 in cleanup_undefined_types () at 
../../gdb-server_submit/src/gdb/stabsread.c:4346
#3  0x00539e5b in end_symtab (end_addr=4269324, objfile=0x10075fe0, 
section=0)
    at ../../gdb-server_submit/src/gdb/buildsym.c:896
#4  0x00502334 in read_ofile_symtab (pst=0x1014e258) at 
../../gdb-server_submit/src/gdb/dbxread.c:2625
#5  0x00501ceb in dbx_psymtab_to_symtab_1 (pst=0x1014e258) at 
../../gdb-server_submit/src/gdb/dbxread.c:2380
#6  0x00501c62 in dbx_psymtab_to_symtab_1 (pst=0x100f0058) at 
../../gdb-server_submit/src/gdb/dbxread.c:2366
#7  0x00501e0e in dbx_psymtab_to_symtab (pst=0x100f0058) at 
../../gdb-server_submit/src/gdb/dbxread.c:2431
#8  0x004044fe in psymtab_to_symtab (pst=0x100f0058) at 
../../gdb-server_submit/src/gdb/symfile.c:287
#9  0x004667a5 in lookup_symbol_aux_psymtabs (block_index=1, 
name=0x22c400 "win32_attach", linkage_name=0x0,
    domain=VAR_DOMAIN, symtab=0x0) at 
../../gdb-server_submit/src/gdb/symtab.c:1368
#10 0x004664c7 in lookup_symbol_aux (name=0x22c400 "win32_attach", 
linkage_name=0x0, block=0x0,
    domain=VAR_DOMAIN, language=language_c, is_a_field_of_this=0x0, 
symtab=0x0)
    at ../../gdb-server_submit/src/gdb/symtab.c:1227
#11 0x004662fe in lookup_symbol_in_language (name=0x22c400 
"win32_attach", block=0x0, domain=VAR_DOMAIN,
    lang=language_c, is_a_field_of_this=0x0, symtab=0x0) at 
../../gdb-server_submit/src/gdb/symtab.c:1133
#12 0x00466367 in lookup_symbol (name=0x22c400 "win32_attach", 
block=0x0, domain=VAR_DOMAIN,
    is_a_field_of_this=0x0, symtab=0x0) at 
../../gdb-server_submit/src/gdb/symtab.c:1154
#13 0x004c6579 in find_imps (symtab=0x0, block=0x0, method=0x10033f3a 
"win32_attach", syms=0x0, nsym=0x22c49c,
    ndebug=0x22c498) at ../../gdb-server_submit/src/gdb/objc-lang.c:1438
#14 0x0048fb17 in decode_objc (argptr=0x22c750, funfirstline=1, 
file_symtab=0x0, canonical=0x22c6dc,
    saved_arg=0x10033f3a "win32_attach") at 
../../gdb-server_submit/src/gdb/linespec.c:1103
#15 0x0048f377 in decode_line_1 (argptr=0x22c750, funfirstline=1, 
default_symtab=0x0, default_line=0,
    canonical=0x22c6dc, not_found_ptr=0x22c6ac) at 
../../gdb-server_submit/src/gdb/linespec.c:728
#16 0x0044118e in parse_breakpoint_sals (address=0x22c750, 
sals=0x22c720, addr_string=0x22c6dc,
    not_found_ptr=0x22c6ac) at 
../../gdb-server_submit/src/gdb/breakpoint.c:5185
#17 0x0044129e in do_captured_parse_breakpoint (ui=0x100696e0, 
data=0x22c6c0)
    at ../../gdb-server_submit/src/gdb/breakpoint.c:5247
#18 0x00412d7c in catch_exception (uiout=0x100696e0, func=0x441267 
<do_captured_parse_breakpoint>,
    func_args=0x22c6c0, mask=6) at 
../../gdb-server_submit/src/gdb/exceptions.c:469
#19 0x00441362 in break_command_1 (arg=0x10033f3a "win32_attach", 
flag=0, from_tty=1, pending_bp=0x0)
    at ../../gdb-server_submit/src/gdb/breakpoint.c:5292
#20 0x00441fb5 in break_command (arg=0x10033f3a "win32_attach", from_tty=1)
    at ../../gdb-server_submit/src/gdb/breakpoint.c:5660
#21 0x0042ca8b in do_cfunc (c=0x10049ca8, args=0x10033f3a 
"win32_attach", from_tty=1)
    at ../../gdb-server_submit/src/gdb/cli/cli-decode.c:62
#22 0x0042ef7d in cmd_func (cmd=0x10049ca8, args=0x10033f3a 
"win32_attach", from_tty=1)
    at ../../gdb-server_submit/src/gdb/cli/cli-decode.c:1666
#23 0x004025b8 in execute_command (p=0x10033f45 "h", from_tty=1) at 
../../gdb-server_submit/src/gdb/top.c:451
#24 0x00424422 in command_handler (command=0x10033f38 "b win32_attach")
    at ../../gdb-server_submit/src/gdb/event-top.c:519
#25 0x00424be4 in command_line_handler (rl=0x1012e3d0 "") at 
../../gdb-server_submit/src/gdb/event-top.c:804
#26 0x00424d38 in gdb_readline2 (client_data=0x0) at 
../../gdb-server_submit/src/gdb/event-top.c:884
#27 0x004242cc in stdin_event_handler (error=0, client_data=0x0)
    at ../../gdb-server_submit/src/gdb/event-top.c:432
#28 0x004394be in handle_file_event (event_file_desc=0) at 
../../gdb-server_submit/src/gdb/event-loop.c:730
#29 0x00438d42 in process_event () at 
../../gdb-server_submit/src/gdb/event-loop.c:343
#30 0x00438d8b in gdb_do_one_event (data=0x0) at 
../../gdb-server_submit/src/gdb/event-loop.c:380
#31 0x00412f9b in catch_errors (func=0x438d57 <gdb_do_one_event>, 
func_args=0x0, errstring=0x649101 "", mask=6)
    at ../../gdb-server_submit/src/gdb/exceptions.c:515
#32 0x004a2f2b in tui_command_loop (data=0x0) at 
../../gdb-server_submit/src/gdb/tui/tui-interp.c:151
#33 0x0041c96a in current_interp_command_loop () at 
../../gdb-server_submit/src/gdb/interps.c:278
#34 0x004010cb in captured_command_loop (data=0x0) at 
../../gdb-server_submit/src/gdb/main.c:101
#35 0x00412f9b in catch_errors (func=0x4010c0 <captured_command_loop>, 
func_args=0x0, errstring=0x61a139 "",
    mask=6) at ../../gdb-server_submit/src/gdb/exceptions.c:515
#36 0x00402110 in captured_main (data=0x22cc70) at 
../../gdb-server_submit/src/gdb/main.c:867
#37 0x00412f9b in catch_errors (func=0x401102 <captured_main>, 
func_args=0x22cc70, errstring=0x61a139 "",
    mask=6) at ../../gdb-server_submit/src/gdb/exceptions.c:515
#38 0x00402146 in gdb_main (args=0x22cc70) at 
../../gdb-server_submit/src/gdb/main.c:876
#39 0x004010ba in main (argc=5, argv=0x10033c40) at 
../../gdb-server_submit/src/gdb/gdb.c:35

I didn't look much into the code, but the attached works for me.

Cheers,
Pedro Alves


[-- Attachment #2: cygstabs_fix.diff --]
[-- Type: text/x-diff, Size: 937 bytes --]

2007-03-31  Pedro Alves  <pedro_alves@portugalmail.pt>

	* dbxread.c (read_ofile_symtab): Move current_objfile
	clearing to after end_stabs.
---
 gdb/dbxread.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: src/gdb/dbxread.c
===================================================================
--- src.orig/gdb/dbxread.c	2005-12-17 21:34:00.000000000 +0000
+++ src/gdb/dbxread.c	2007-03-31 21:31:42.000000000 +0100
@@ -2608,8 +2608,6 @@ read_ofile_symtab (struct partial_symtab
 	}
     }
 
-  current_objfile = NULL;
-
   /* In a Solaris elf file, this variable, which comes from the
      value of the N_SO symbol, will still be 0.  Luckily, text_offset,
      which comes from pst->textlow is correct. */
@@ -2625,6 +2623,8 @@ read_ofile_symtab (struct partial_symtab
   pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
 
   end_stabs ();
+
+  current_objfile = NULL;
 }
 \f
 

  reply	other threads:[~2007-03-31 20:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09 19:40 Joel Brobecker
2007-02-27 16:50 ` Daniel Jacobowitz
2007-02-28  5:48   ` Joel Brobecker
2007-02-28 11:42     ` Daniel Jacobowitz
2007-02-28 20:12   ` Joel Brobecker
2007-03-27 16:29     ` Daniel Jacobowitz
2007-03-29 18:35       ` Joel Brobecker
2007-03-31 20:42         ` Pedro Alves [this message]
2007-04-02  6:59           ` Joel Brobecker
2007-04-02  8:51             ` Pierre Muller
2007-04-02 11:05           ` Daniel Jacobowitz
2007-04-03  0:13             ` Pedro Alves
2007-04-03  3:50               ` Christopher Faylor

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=460EC794.2080309@portugalmail.pt \
    --to=pedro_alves@portugalmail.pt \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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