From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 219463858D1E for ; Thu, 11 Apr 2024 09:55:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 219463858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 219463858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712829315; cv=none; b=uB+MoqnoMiwL0qZ/rcRUGvDJLBtJAszABiPMOguAieDaRuv02vcKB3+O4eOH6RJ57SLcAFKf9lZm16UbRVVeIV2cGmE216G1zSJkz4yXUW7NXXiWQ5rY83M6Xu52cJnSf/K4O+s9gSDmTxQT6bYBJHCAWPK2Yd29mWhnbr9UMYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712829315; c=relaxed/simple; bh=Y8cbauQXX8cK0i8l/yoWLG/Y5lU50xzTiLZQb2cFDUk=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=uI631oRERaYCegPZlOWhDTn4W+0LByT3Wsz3aeB+IJb3JALZOBivN5ej86hiydJ+v3Oz2hLcI+kFLuLElczuPg5Hd/sUUaP4AIvelWgC+k4jF23FWz5WWUUzLz67Qmptplqy0yDht8sNqe98i8SIzCzMpFmU5Md2HPhmw+xNNoI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by gnu.wildebeest.org (Postfix, from userid 1000) id F42193000595; Thu, 11 Apr 2024 11:55:05 +0200 (CEST) Date: Thu, 11 Apr 2024 11:55:05 +0200 From: Mark Wielaard To: Aaron Merey Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] libdw: dwarf_getsrcfiles should not imply dwarf_getsrclines Message-ID: <20240411095505.GH1292@gnu.wildebeest.org> References: <20240410034539.164402-1-amerey@redhat.com> <2a6f04357e6cb900fe055939673a7abc542ae333.camel@klomp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Aaron, On Wed, Apr 10, 2024 at 04:43:53PM -0400, Aaron Merey wrote: > > > - /* Pass the file data structure to the caller. */ > > > - if (filesp != NULL) > > > - *filesp = files; > > > + const char **newdirs = (void *) &newfiles->info[nnewfiles]; > > > + const char **prevdirs = (void *) &prevfiles->info[nprevfiles]; > > > + > > > + /* Copy prevdirs to newdirs. */ > > > + for (size_t n = 0; n < ndirs; n++) > > > + newdirs[n] = prevdirs[n]; > > > > Again slightly off indentation. > > But I also don't fully follow the prevdirs/newdirs copying. > > Why is this? No newdirs are defined here, are there? > > Maybe I don't understand the data-structure used here. > > The directories are the same but we still need to copy them so that > dwarf_getsrcdirs can find newfiles' dir names. > > Dwarf_Files is an unusual structure since it doesn't contain a member > specifically for the array of dirnames. Instead they're stored at > the end of the Dwarf_Fileinfo array member. Aha. Thanks for explaining. Clearly I should not try to review code if I don't understand the underlying data structures. > > So testfile-define-file is actually testfile36.debug but with a new > > line program? How did you edit/insert that one? > > I used xxd to create a hexdump of testfile36.debug and modified the line > program by hand with a text editor. I converted the modified hexdump > back to a binary with xxd -r. > > I chose testfile36.debug because its .debug_line includes multiple > directory and file names. It also contains a single short line program > that was easy to replace with two DW_LNE_define_file opcodes without > corrupting things. Fun. Could you add a small description to tests/run-get-files.sh where testfile-define-file is use so future hackers know how the file was created? All looks good BTW. Please do push (if possible with the above change). Thanks, Mark