From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21892 invoked by alias); 17 Jul 2002 10:47:38 -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 21872 invoked from network); 17 Jul 2002 10:47:35 -0000 Received: from unknown (HELO fw-cam.cambridge.arm.com) (193.131.176.3) by sources.redhat.com with SMTP; 17 Jul 2002 10:47:35 -0000 Received: by fw-cam.cambridge.arm.com; id LAA02964; Wed, 17 Jul 2002 11:47:32 +0100 (BST) Received: from unknown(172.16.1.2) by fw-cam.cambridge.arm.com via smap (V5.5) id xma002415; Wed, 17 Jul 02 11:47:03 +0100 Received: from cam-mail2.cambridge.arm.com (cam-mail2 [172.16.1.91]) by cam-admin0.cambridge.arm.com (8.9.3/8.9.3) with ESMTP id LAA17879; Wed, 17 Jul 2002 11:47:03 +0100 (BST) Received: from sun18.cambridge.arm.com (sun18.cambridge.arm.com [172.16.2.18]) by cam-mail2.cambridge.arm.com (8.9.3/8.9.3) with ESMTP id LAA03162; Wed, 17 Jul 2002 11:47:02 +0100 (BST) Message-Id: <200207171047.LAA03162@cam-mail2.cambridge.arm.com> To: binutils@sources.redhat.com cc: Richard.Earnshaw@arm.com, irickards@arm.com, gdb-patches@sources.redhat.com Reply-To: Richard.Earnshaw@arm.com Organization: ARM Ltd. X-Telephone: +44 1223 400569 (direct+voicemail), +44 1223 400400 (switchbd) X-Fax: +44 1223 400410 X-Address: ARM Ltd., 110 Fulbourn Road, Cherry Hinton, Cambridge CB1 9NJ. X-Url: http://www.arm.com/ Subject: PATCH/RFC handle missing DW_AT_comp_dir attribute Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_-9392021260" Date: Wed, 17 Jul 2002 04:00:00 -0000 From: Richard Earnshaw X-SW-Source: 2002-07/txt/msg00364.txt.bz2 This is a multipart MIME message. --==_Exmh_-9392021260 Content-Type: text/plain; charset=us-ascii Content-length: 554 This problem was found by a colleague while using GDB with the ADS tools. These tools do not set the DW_AT_comp_dir attribute in a compilation unit entry, so GDB will crash trying to reference a NULL pointer. Regardless of whether ADS is correct not to generate this directive (the Dwarf spec appears not to require it to), GDB should not be falling over in this way. The following patch fixes the problem: Ian Rickards * dwarf2.c (concat_filename): If we can't establish the directory just return the filename. --==_Exmh_-9392021260 Content-Type: text/x-patch ; name="bfd-dwf_AT_comp_dir.patch"; charset=us-ascii Content-Description: bfd-dwf_AT_comp_dir.patch Content-Disposition: attachment; filename="bfd-dwf_AT_comp_dir.patch" Content-length: 1202 Index: dwarf2.c =================================================================== RCS file: /cvs/src/src/bfd/dwarf2.c,v retrieving revision 1.32 diff -p -r1.32 dwarf2.c *** dwarf2.c 27 Jun 2002 11:51:42 -0000 1.32 --- dwarf2.c 17 Jul 2002 10:38:03 -0000 *************** concat_filename (table, file) *** 856,868 **** filename = table->files[file - 1].name; if (IS_ABSOLUTE_PATH(filename)) return filename; - else { char* dirname = (table->files[file - 1].dir ? table->dirs[table->files[file - 1].dir - 1] : table->comp_dir); ! return (char*) concat (dirname, "/", filename, NULL); } } --- 856,873 ---- filename = table->files[file - 1].name; if (IS_ABSOLUTE_PATH(filename)) return filename; else { char* dirname = (table->files[file - 1].dir ? table->dirs[table->files[file - 1].dir - 1] : table->comp_dir); ! ! /* Not all tools set DW_AT_comp_dir, so dirname may be unknown. The ! best we can do is return the filename part. */ ! if (dirname == NULL) ! return filename; ! else ! return (char*) concat (dirname, "/", filename, NULL); } } --==_Exmh_-9392021260--