From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23396 invoked by alias); 13 Aug 2002 20:50:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23379 invoked from network); 13 Aug 2002 20:50:04 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by sources.redhat.com with SMTP; 13 Aug 2002 20:50:04 -0000 Received: (from jimb@localhost) by zenia.red-bean.com (8.11.6/8.11.6) id g7DKeB006647; Tue, 13 Aug 2002 15:40:11 -0500 To: david carlton Cc: gdb-patches@sources.redhat.com Subject: Re: dwarf2_build_psymtabs should check that .debug_line exists References: <15697.45810.578860.108712@jackfruit.Stanford.EDU> From: Jim Blandy In-Reply-To: <15697.45810.578860.108712@jackfruit.Stanford.EDU> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 Date: Tue, 13 Aug 2002 13:50:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-08/txt/msg00312.txt.bz2 david carlton writes: > I was reading through dwarf2read.c when I noticed that > dwarf2_build_psymtabs() doesn't check to see if the file that you're > debugging has a .debug_line section before initializing > dwarf_line_buffer. This is potentially unfortunate: > dwarf2_build_psymtabs() is called when dwarf2_has_info() returns 1, > but dwarf2_has_info() only checks to see if the file that you're > debugging has .debug_info and .debug_abbrev sections. > > It is, of course, quite rare for a file to have .debug_info and > .debug_abbrev sections but not to have a .debug_line section; so, > obviously this isn't a serious problem. And, even if you produce such > a file (using objcopy -R .debug_line, say), it's still pretty hard to > cause GDB to signal an error, but with some effort I did manage to do > so. (I can submit a PR with details, if anybody wants.) Given that > dwarf2_build_psymtabs() is careful to make sure all the other > .debug_XXX sections exist, it should certainly also check to make sure > that .debug_line exists. > > By the way, I checked to see where the contents of the .debug_line > section are used; as far as I can tell, it's only used in > dwarf2read.c(dwarf_decode_line_header), and that function does have a > check in it to make sure that dwarf_line_buffer is non-NULL. So this > fix is probably better than the other obvious fix, namely to have > dwarf2_has_info() ensure that the file has a .debug_line section. Yes, this all makes good sense. Well, dwarf_decode_line_header stashes pointers into the debug_line_buffer in the struct line_header it returns. So dwarf_decode_lines uses dwarf_line_buffer, too. It looks to me like read_file_scope shouldn't call dwarf_decode_macros either when line_header is zero. Could you add that to your patch, and re-post it?