public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: Nick Clifton <nickc@redhat.com>
Cc: Joseph Myers <joseph@codesourcery.com>, binutils@sourceware.org
Subject: Re: [PATCH 00/19] libctf, and CTF support for objdump and readelf
Date: Mon, 06 May 2019 16:40:00 -0000	[thread overview]
Message-ID: <878svjtu3e.fsf@esperi.org.uk> (raw)
In-Reply-To: <534c2613-da1e-7b53-338c-2988b44b1b6b@redhat.com> (Nick Clifton's	message of "Fri, 3 May 2019 13:33:10 +0100")

On 3 May 2019, Nick Clifton verbalised:

> Hi Nick,
>
>   OK, so I am going to stop my review of this patch series until we have 
>   some answers to a few high level questions/requirements.  Specifically:
>
>   * Hosting
>
>     Is the binutils project the right place for this code ?  As Joseph 
>     has already mentioned libctf appears to use code from the elfutils 
>     project, so maybe that would be a better home for libctf ?

It uses no code from elfutils: It uses one datatype from elfutils, and
shouldn't really even use that (it should use the stuff from <elf.h>
from glibc). (Thanks for spotting that! It'll be fixed this week.)

>   * Testing
>
>     I did not see a testsuite for the library, nor any additions to
>     the binutils testsuite for the extensions to objdump and readelf.
>     I would not be comfortable adding such a large body of code to the
>     project without some 

Agreed!!! Writing a testsuite is high on our priority list, but we need
compiler and linker support first. There will definitely be a testsuite
in place, probably in large part autogenerated. (The code is not at all
untested: the testing largely consists of generating CTF for the entire
Linux kernel and then letting the fairly sizeable DTrace testsuite run
over it. However, this is obviously not suitable for upstreaming into
binutils: something more systematic is needed, and will exist.)

>   * Documentation
>
>     It would be really good to have the CTF format documented somewhere
>     (semi) permanent and publicly accessible.  It would also be good if
>     there was a libctf.texi document describing how consumers are expected
>     to use the library, and, ideally, providing code examples.

Agreed!

>   * Usefulness
>
>     This may be a bit contentious - but is the CTF format actually being
>     used anywhere, or likely to be used in the near future ?  If this is
>     a project that is just going to be used by a small group, or even just
>     a single company, then I am worried that the code will just bit rot 
>     away and not be actively maintained.

It would be useful for many projects, but it was not easy to adopt it,
and it has been relatively unknown outside of Solaris and FreeBSD
circles.

We have been using it for many years with the Linux kernel and DTrace.
Other projects may adopt it. It is *useful* for many other projects, but
it was quite difficult to generate CTF-format data (from DWARF using a
variety of painful-to-port Solaris tools). I know I wanted it in the
past for various other profilers I was writing, but I didn't use it
because I had no idea it existed. It seems likely to be *useful* for
debuggers and tracers and introspectors of all sorts: anything that
wants to know what type an ELF object is, or what type function
arguments or return types are, and who wants to be able to decompose
that type into its constitutent pieces and chase pointers from it and
make sense of the results seems likely to be able to make use of CTF.

In particular, GDB, perf, and sysprof could definitely make use of it,
as could systemtap, rr, and honestly I'm only limited here by not
knowing the names of more obscure debugger projects. Right now these
either cannot do useful things with datatypes at all, or require all the
DWARF debuginfo to be present to do anything, and given that many of
these things are systemwide continuous debuggers, the debuginfo is
almost never present when the debugger points at a victim program and
tries to print out argument info or whatever.

I'm fairly confident that having type information for C programs as
widely and easily available as it is, for, say, Lisp programs (with a
cost, often, of only a few kilobytes) is a generally good thing. We're
making a start by adding CTF support to GCC, GNU ld and GDB.


Size-wise it really is pretty small. Let's try a few samples (with a
notably unscientific construction method). The first five numeric
columns are a count of types, and CTF sizes in bytes (the sizes of
specific sections: all uncompressed sizes but the first 'size' number.
"DWARF size" is the size of .debug_info.)

                       CTF
Program          types size (uncompressed)  stringsize  typesize   DWARF size
coreutils ls     396   10324 (26216)        13148       13068      74241
GAS 2.30         1123  55748 (172731)       106079      66652      1001453
emacs 26.1.50    3546  104276 (284479)      142231      142248     3912261
X.org 1.20.3     7266  152196 (473797)      201421      272376     4163434
GhostScript 9.26 7873  181036 (538901)      243293      295608     7943132
Gtk 3.24.7       9236  208612 (620926)      328174      292752     6106925

So a shrinkage over DWARF of roughly 80%, and usually less than 5% of
the size of the binary whose types are described. With planned format
and generation improvements, I expect that a 90% shrinkage over DWARF is
probably achievable without too much effort. (More than that might
require pruning out individual unused bits, a fairly radical change.)

  reply	other threads:[~2019-05-06 16:40 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 22:57 Nick Alcock
2019-04-30 22:57 ` [PATCH 02/19] include: new header ctf-api.h Nick Alcock
2019-05-02 15:07   ` Nick Clifton
2019-05-03 11:23     ` Nick Alcock
2019-04-30 22:57 ` [PATCH 01/19] include: new header ctf.h: file format description Nick Alcock
2019-05-01 16:57   ` Nick Clifton
2019-05-01 21:29     ` Jim Wilson
2019-05-03 11:15       ` Nick Alcock
2019-04-30 22:57 ` [PATCH 05/19] libctf: error handling Nick Alcock
2019-05-02 16:10   ` Nick Clifton
2019-05-03 19:31     ` Nick Alcock
2019-04-30 22:57 ` [PATCH 15/19] libctf: mmappable archives Nick Alcock
2019-04-30 22:57 ` [PATCH 13/19] libctf: type copying Nick Alcock
2019-04-30 22:57 ` [PATCH 09/19] libctf: opening Nick Alcock
2019-04-30 22:57 ` [PATCH 06/19] libctf: hashing Nick Alcock
2019-05-02 16:16   ` Nick Clifton
2019-05-03 19:33     ` Nick Alcock
2019-04-30 22:57 ` [PATCH 10/19] libctf: ELF file opening Nick Alcock
2019-04-30 22:57 ` [PATCH 19/19] binutils: CTF support for objdump and readelf Nick Alcock
2019-04-30 22:57 ` CTF format overview Nick Alcock
2019-04-30 22:57 ` [PATCH 08/19] libctf: creation functions Nick Alcock
2019-04-30 22:57 ` [PATCH 11/19] libctf: core type lookup Nick Alcock
2019-04-30 22:57 ` [PATCH 04/19] libctf: low-level list manipulation and helper utilities Nick Alcock
2019-05-02 16:04   ` Nick Clifton
2019-05-03 19:25     ` Nick Alcock
2019-04-30 22:57 ` [PATCH 14/19] libctf: library version enforcement Nick Alcock
2019-04-30 22:57 ` [PATCH 03/19] libctf: lowest-level memory allocation and debug-dumping wrappers Nick Alcock
2019-05-02 15:29   ` Nick Clifton
2019-05-03 19:12     ` Nick Alcock
2019-04-30 22:57 ` [PATCH 12/19] libctf: lookups by name and symbol Nick Alcock
2019-04-30 22:58 ` [PATCH 18/19] libctf: build system Nick Alcock
2019-05-01  0:13 ` [PATCH 17/19] libctf: debug dumping Nick Alcock
2019-05-01  0:19 ` [PATCH 16/19] libctf: labels Nick Alcock
2019-05-01  1:57 ` [PATCH 07/19] libctf: implementation definitions related to file creation Nick Alcock
2019-05-01 16:02 ` [PATCH 00/19] libctf, and CTF support for objdump and readelf Nick Clifton
2019-05-01 16:16   ` Jose E. Marchesi
2019-05-03 10:47     ` Nick Alcock
2019-05-02 15:22 ` Joseph Myers
2019-05-03 12:33   ` Nick Clifton
2019-05-06 16:40     ` Nick Alcock [this message]
2019-05-08 14:34     ` Michael Matz
2019-05-08 16:01       ` Nick Clifton
2019-05-08 16:20         ` Nick Alcock
2019-05-03 14:23   ` Nick Alcock
     [not found]     ` <alpine.DEB.2.21.1905072117440.19308@digraph.polyomino.org.uk>
2019-05-08 11:39       ` Nick Alcock
2019-05-24  8:57     ` Pedro Alves
2019-05-24 16:05       ` Nick Alcock
2019-05-24 16:19         ` Pedro Alves
2019-05-24 20:09           ` Nick Alcock
2019-05-03 16:19 ` Florian Weimer
2019-05-03 19:45   ` Nick Alcock
2019-05-06 12:07     ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878svjtu3e.fsf@esperi.org.uk \
    --to=nick.alcock@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=joseph@codesourcery.com \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).