From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by sourceware.org (Postfix) with ESMTPS id 0EBDC3858D32 for ; Tue, 5 Dec 2023 18:46:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EBDC3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0EBDC3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:4641:c500::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701801971; cv=none; b=MBx7ugQTrRmJUUuAcpJZO4Nod5eVHMawViOkAlOnMpHRgtcwi0vTxxs4wyPN3IshBnLJZuhdbFvuGdBLnGCmKcEaJMBjUjUHgT1yJq7ONxU63KwAVrMAF7Nw90gR423i5TKsU52z9kQ/zl3cQB0t7e21sHaOHbIvsbCZXXR8M6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701801971; c=relaxed/simple; bh=NZn2lJTOoAWnj7aJwxbFyayt2gDAlY4Qku/+8i6t2u4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=HX3nSGoitvcgLrPrSCmNd+/fb9Q67BeDBLrKu//+BwRjDzFqKpSPevpur/2L9P/egLqkxU0WluAqbNIrgLnC/Vft5oIvTGJg0kIXh11UOP6NolxLWe0OqsBLN0xQ9WRHzsAjt5WeSSztKmnZhTzZecy62JJXa1yY6uJM4LaQYbM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9EC3E618D7; Tue, 5 Dec 2023 18:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99FD4C433CA; Tue, 5 Dec 2023 18:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701801967; bh=NZn2lJTOoAWnj7aJwxbFyayt2gDAlY4Qku/+8i6t2u4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mVnS17VnKJkbFGn9w0nUhLSwAyiyVnqkve7HD068q4PQDMuFfAZlRbNdZDSrnbSSQ FT2/W/EgBHadjRpM4oeQ/k1EW1tQnYw8WW/pkXndTaccoVn8QGA8pcy3YQRK0eeAfI 34FnvYuOGlz5DM58Pbj7Eqtr2KEPjgvH35688+6oiU+Ht2/y89DETsSWlFDV47HZKv nKkwdW1lPsa3g8vACdR2VMph3nt9+WLxYCFkHamo6Np270I9crHZ0KWHUADZM4xyT6 oYnklIQ3nBO/hBZ6f+uB3sSp2hubv/EvSx1kfJSl5cbJPDXEUj/BuUr85iGbiaSbhW rGoDrbwy/L/2w== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 14FAB40094; Tue, 5 Dec 2023 15:46:04 -0300 (-03) Date: Tue, 5 Dec 2023 15:46:04 -0300 From: Arnaldo Carvalho de Melo To: Dimitri John Ledkov Cc: dwarves@vger.kernel.org, elfutils-devel@sourceware.org, mark@klomp.org Subject: Re: Porting pahole from dwarf_next_unit() to dwarf_get_units() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Em Tue, Dec 05, 2023 at 04:11:06PM +0000, Dimitri John Ledkov escreveu: > I > > On Tue, 5 Dec 2023, 15:47 Arnaldo Carvalho de Melo, wrote: > > > > Em Tue, Dec 05, 2023 at 01:03:01PM +0000, Dimitri John Ledkov escreveu: > > > Currently pahole warns and does nothing upon hitting > > > DW_TAG_skeleton_unit as implemented at > > > https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=0135ccd632796ab3aff65b7c99b374c4682c2bcf > > > > > > In elfutils, a while back a new API got added that aids with discovery > > > and processing of such tags - > > > https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=79f0e623dcde4b042bb72f636a2211d67d5c0ade > > > > > > It seems to me if pahole is ported from using dwarf_next_unit() to > > > instead use dwarf_get_units() native support can be added for > > > split-dwarf (dwo) files. > > > > That would be awesome! > > > > > I am trying to write such a port, but it is proving to be very > > > difficult. > > > > I did some work on supporting split-dwarf months ago, but got > > sidetracked with other work, BTF related and then the code bitrotted, I > > have to go back looking at it to swap back the details into my brain: > > > > https://git.kernel.org/pub/scm/devel/pahole/pahole.git/log/?h=alt_dwarf > > > > The patches after: > > > > 45c044860c2abce7 dwarf_loader: Sync with LINUX_ELFNOTE_LTO_INFO macro from kernel > > > > Are the ones to suport alt dwarf. > > I will read into those thanks. Hopefully what you've been work ends up less convoluted by using new elfutils functions, but it may be useful to help understand how the internal pahole code deals with Dwarf offsets to reduce them to 32 bits for conversion to CTF/BTF (where it is not really that important as libbpf does this work). > > > I am entirely unfamiliar with neither pahole nor libdw nor > > > the dwarf file format. Thus it is very confusing when both pahole and > > > dwarf library use very similar type names and structs. For example > > > libdw has struct Dwarf_CU and pahole has unrelated dwarf_cu struct. > > > > > What are the differences between dwarf_nextcu(), dwarf_next_unit(), > > > dwarf_get_units() and when should one use each one of them? (or nest > > > them?) > > > > > Is a port of https://git.kernel.org/pub/scm/devel/pahole/pahole.git/tree/dwarf_loader.c?id=0135ccd632796ab3aff65b7c99b374c4682c2bcf > > > to use dwarf_get_units() a right approach and would be welcomed? > > > > Yes, we need to support DWARF5 fully. > ack > > > Is anyone else interested in providing any help, or guidance? > > > > I'm interested, and I think if Mark could help it would be great as > > well. > > I have something that sort of works, but then like aboarts with > invalid free's on exit - which the purist in me cares, but not sure if > it is of practical value or not. > And eu-readelf code also mentions that it deliberary leaks memory, > because life is hard. Off course ;-) Frees on exit are interesting to try to evaluate if things that are not just frees on exit are leaking, when we're sure that is the case, don't free on exit, as its just overhead. > I will try to address or warn about memory leaks to see if stuff > works, and post and RFC. Great, thanks a lot for working on this! - Arnaldo