From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65873 invoked by alias); 8 May 2015 17:23:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 65861 invoked by uid 89); 8 May 2015 17:23:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 08 May 2015 17:23:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 68A74287E3; Fri, 8 May 2015 13:23:11 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IK-7SE4CRyr9; Fri, 8 May 2015 13:23:11 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3FD87287AB; Fri, 8 May 2015 13:23:11 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id B788C40DAA; Fri, 8 May 2015 10:23:10 -0700 (PDT) Date: Fri, 08 May 2015 17:23:00 -0000 From: Joel Brobecker To: Sandra Loosemore Cc: gdb-patches@sourceware.org, Yao Qi Subject: Re: [patch, dwarf2] avoid segfault on missing directory table Message-ID: <20150508172310.GB4767@adacore.com> References: <554CEDD3.80407@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <554CEDD3.80407@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-05/txt/msg00210.txt.bz2 > 2015-05-07 Yao Qi > Sandra Loosemore > > Avoid segfault on missing directory table. > > gdb/ > * dwarf2read.c (setup_type_unit_groups): Do NULL pointer check > to 'lh->include_dirs' before accessing to it. > (psymtab_include_file_name): Likewise. > (dwarf_decode_lines_1): Likewise. > (dwarf_decode_lines): Likewise. > (file_file_name): Likewise. It looks reasonable to me. I might also have added a complaint somewhere, to help diagnoze mysterious behavior caused by the lack of the include_dirs table. But I'm not sure where we would have put that complaint without causing it to be triggered for each and every reference. It's not very important, as the situation is unlikely. OK to push. > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > index 4982922..e2ea7e2 100644 > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c > @@ -9320,7 +9320,7 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu) > const char *dir = NULL; > struct file_entry *fe = &lh->file_names[i]; > > - if (fe->dir_index) > + if (fe->dir_index && lh->include_dirs != NULL) > dir = lh->include_dirs[fe->dir_index - 1]; > dwarf2_start_subfile (fe->name, dir); > > @@ -17396,7 +17396,7 @@ psymtab_include_file_name (const struct line_header *lh, int file_index, > char *copied_name = NULL; > int file_is_pst; > > - if (fe.dir_index) > + if (fe.dir_index && lh->include_dirs != NULL) > dir_name = lh->include_dirs[fe.dir_index - 1]; > > if (!IS_ABSOLUTE_PATH (include_name) > @@ -17595,7 +17595,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, > struct file_entry *fe = &lh->file_names[file - 1]; > const char *dir = NULL; > > - if (fe->dir_index) > + if (fe->dir_index && lh->include_dirs != NULL) > dir = lh->include_dirs[fe->dir_index - 1]; > > dwarf2_start_subfile (fe->name, dir); > @@ -17815,7 +17815,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, > else > { > fe = &lh->file_names[file - 1]; > - if (fe->dir_index) > + if (fe->dir_index && lh->include_dirs != NULL) > dir = lh->include_dirs[fe->dir_index - 1]; > if (!decode_for_pst_p) > { > @@ -17958,7 +17958,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, > struct file_entry *fe; > > fe = &lh->file_names[i]; > - if (fe->dir_index) > + if (fe->dir_index && lh->include_dirs != NULL) > dir = lh->include_dirs[fe->dir_index - 1]; > dwarf2_start_subfile (fe->name, dir); > > @@ -20640,7 +20640,8 @@ file_file_name (int file, struct line_header *lh) > { > struct file_entry *fe = &lh->file_names[file - 1]; > > - if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0) > + if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0 > + || lh->include_dirs == NULL) > return xstrdup (fe->name); > return concat (lh->include_dirs[fe->dir_index - 1], SLASH_STRING, > fe->name, NULL); -- Joel