Commit Graph

54 Commits

Author SHA1 Message Date
Kui-Feng Lee 724c8fddd7 dwarf_loader: Receive per-thread data on worker threads
Add arguments to steal and thread_exit callbacks of conf_load to
receive per-thread data.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Link: https://lore.kernel.org/r/20220126192039.2840752-2-kuifeng@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-01-28 16:19:29 -03:00
Douglas Raillard 772725a77d dwarves_fprintf: Move cacheline_size into struct conf_fprintf
Remove the global variable and turn it into a member in struct
conf_fprintf, so that it can be used by other parts of the code.

Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-10-28 10:17:59 -03:00
Arnaldo Carvalho de Melo caa219dffc core: base_type__name() doesn't need a 'cu' arg
Another simplification made possible by using a plain char string
instead of string_t, that was only needed in the core as prep work
for CTF encoding.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 790dfbda79 headers: Rebame __unused to __maybe_unused to avoid clashes with system headers
Andrii reported that __unused is a field in /usr/include/bits/stat.h and
vmlinux.h (generated by bpftool), so use the Linux kernel jargon for
this and rename it to '__maybe_unused'.

Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-13 10:25:35 -03:00
Arnaldo Carvalho de Melo 49c27bdd66 core: Allow the loaders to advertise features they have
For instance, DWARF has DW_AT_alignment, and some output features
require that, so let loaders advertise such things, next patch will use
this info.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-15 14:45:27 -03:00
Arnaldo Carvalho de Melo 45ad545944 tag: Introduce tag__is_pointer()
For the usual idiom to ask if a tag is a pointer, removing a bit of
DWARFism and shortening the operation.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-05 15:21:55 -03:00
Arnaldo Carvalho de Melo 89ce57a02e pdwtags: Find holes in structs
The pdwtags prints all tags, so call class__find_holes() for structs so
that we don't print BFAs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-05 11:34:33 -03:00
Domenico Andreoli e714d2eaa1 Adopt SPDX-License-Identifier
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-01-18 15:41:48 -03:00
Arnaldo Carvalho de Melo 44130bf70e dwarves: Update e-mail address
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 14:24:41 -03:00
Arnaldo Carvalho de Melo 10515a7c4d dwarves: Introduce cus__fprintf_load_files_err()
Out of code in pdwtags and pahole, will be used in the other tools.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-15 14:25:58 -03:00
Arnaldo Carvalho de Melo 2566cc2c87 pdwtags: Show proper error messages for files it can't handle
Before it would print no message, only update its exit status, now:

  $ cat foo
  cat: foo: No such file or directory
  $ pdwtags foo
  pdwtags: foo: No such file or directory
  $ pdwtags /dev/null
  ctf__new: cannot get elf header.
  pdwtags: /dev/null: Invalid argument
  $

Reported-by: Eric Blake <eblake@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=949034
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-15 12:29:38 -03:00
Arnaldo Carvalho de Melo a54515fa6e dwarves: Stop using 'self'
As Thomas Gleixner wisely pointed out, using 'self' is stupid, it
doesn't convey useful information, so use sensible names.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-08-17 18:47:15 -03:00
Tom Tromey 2938a70e1e Add support for .debug_types sections.
.debug_types is a new DWARF 4 feature that adds some simple
compression to DWARF.  The basic idea is that identical type
definitions are merged by the linker and put into a new .debug_types
section.

This introduces 'dwarf_off_ref', which is like Dwarf_Off, but carries
a flag indicating if the DIE came from .debug_types.  This allows
future uses to find the DIE properly.

Type units are read a little differently from ordinary CUs.  All type
units are read at once, then types are recoded for them.  (I think
something like this is needed more generally, to support inter-CU
references, but I have not tried that.)

The type unit is also kept around longer, because any other CU may
refer to it.  This necessitated a change to load_steal_kind to replace
the notion of a "stolen" CU with a request by the "stealer" for the
caller to delete the CU when appropriate.

I need elfutils patch 581c3f60e2b1fc7ddaf4260bb5a9cb59f8e3f0d0
to make this work properly; without it I see crashes.

You can make test cases by compiling with '-gdwarf-4 -fdebug-types-section'.
2012-03-22 12:51:20 -06:00
Arnaldo Carvalho de Melo 870afee9ce core: Stop using strings__ptr(strings, i) directly
Instead pass thru cu__strings(cu, i) so that we can figure out if the
underlying debugging format handler can do that more efficiently, such as by
looking up directly the ELF section ".strtab".

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 17:54:43 -03:00
Arnaldo Carvalho de Melo 9bb29daac4 base_type: Don't combine names with attributes
Such as signed, etc. This is in preparation for using directly ctf_strings.
Instead of duplicating it in the global strings table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:12:36 -03:00
Arnaldo Carvalho de Melo 3b3388cb78 pdwtags: Allow specifying the debug format to be decoded
Just like the other dwarves.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:38:41 -03:00
Arnaldo Carvalho de Melo 2b5815842f pdwtags: Print functions and variables too
And separate the different kinds of tags with separator
headers.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-31 15:58:29 -03:00
Arnaldo Carvalho de Melo 2d8700009b pfunct: Introduce --no_parm_names
Because CTF doesn't encodes the names of the parameters and I want to
test the upcoming CTF function section code in ctftwdiff.

$ pfunct -V pahole > /tmp/before
$ pfunct --no_parm_names -V pahole > /tmp/after
$ diff -u /tmp/before /tmp/after | tail -3
-struct structure * structure__new(strings_t name);
+struct structure * structure__new(strings_t);
 /* definitions: 1 */
$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-30 21:47:59 -03:00
Arnaldo Carvalho de Melo 7d643b7d32 pdwtags: Use conf_load.stealer
Just like pahole we want to trow away compile units as we process them.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-23 14:22:23 -03:00
Arnaldo Carvalho de Melo 23df52c620 ctf_loader: One more attempt at handling packed enums
With this a "make allyesconfig" on a 2.6.29-rc8 Linux kernel build left 16
cases flagged by ctfdwdiff, 8 unique ones, out of 6209 single-cu (compile unit)
.o files.

But what this clearly shows is that we really need to detect if a struct is
packed, and wether it is naturally packed or if __attribute__ packed was used,
that way we will have more clues as to if a enum is packed or if the whole
struct where it is used as a type for a/several member(s) is packed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-22 15:02:33 -03:00
Arnaldo Carvalho de Melo f25af978bf pdwtags: cu->types_tables can have some NULL slots
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-16 15:55:48 -03:00
Arnaldo Carvalho de Melo 4d44276d85 coding style: remove trailing whitespaces, etc
Amazing how many crept up over time, should have set the
execute bit of .git/hooks/pre-commit already, duh.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 13:50:36 -03:00
Arnaldo Carvalho de Melo 991c6a3ebb dwarves: Rename cus__loadfl with cus__load_files
Also introducing cus__load, that load just one file.

The new cus__load_files routine now iterates thru the provided array
calling cus__load for each, and that in turn will try first dwarf__load,
and if that fail, i.e. if no DWARF info is found, call ctf__load.

This now allows loading DWARF _and_ CTF files at the same time. This
will be useful in the future when we, from DWARF generate CTF and at the
same time do a codiff, comparing the freshly generated CTF file with the
DWARF it came from.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 10:49:01 -03:00
Arnaldo Carvalho de Melo 8cc4949b00 dwarves: Add destructors
So that at program exit we can verify, using tools, that no memory was
leaked.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-11 12:31:17 -03:00
Arnaldo Carvalho de Melo 250dded466 dwarf: separate dwarf_tag from tag
So that, when not needing the DWARF info, the apps can tell that at load
time, and then the dwarf loader can just free all the dwarf_tags
allocated, reducing memory usage.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-09 14:43:47 -03:00
Arnaldo Carvalho de Melo b902f563b3 dwarves: find holes when adding a fresh compile unit
To take advantage of cache effects and to avoid calling cu__find_holes
more than once on the same struct.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:48:33 -03:00
Arnaldo Carvalho de Melo 9fadbfffba dwarves: use tag__is_function in the tools
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:14:26 -03:00
Arnaldo Carvalho de Melo c178f4698d dwarves: Remove some more DWARF details from the core
Had to be a big sweeping change, but the regression tests shows just
improvements :-)

Now we stop using an id in struct tag, only storing the type, that now
uses 16 bits only, as CTF does.

Each format loader has to go on adding the types to the core, that
figures out if it is a tag that can be on the tag->type field
(tag__is_tag_type).

Formats that already have the types separated and in sequence, such as
CTF, just ask the core to insert in the types_table directly with its
original ID.

For DWARF, we ask the core to put it on the table, in sequence, and return the
index, that is then stashed with the DWARF specific info (original id, type,
decl_line, etc) and hashed by the original id. Later we recode everything,
looking up via the original type, getting the small_id to put on the tag->type.

The underlying debugging info not needed by the core is stashed in tag->priv,
and the DWARF loader now just allocates sizeof(struct dwarf_tag) at the end of
the core tag and points it there, and makes that info available thru
cu->orig_info. In the future we can ask, when loading a cu, that this info be
trown away, so that we reduce the memory footprint for big multi-cu files such
as the Linux kernel.

There is also a routine to ask for inserting a NULL, as we still have
bugs in the CTF decoding and thus some entries are being lost, to avoid
using an undefined pointer when traversing the types_table the ctf
loader puts a NULL there via cu__table_nullify_type_entry() and then
cu__for_each_type skips those.

There is some more cleanups for leftovers that I avoided cleaning to
reduce this changeset.

And also while doing this I saw that enums can appear without any
enumerators and that an array with DW_TAG_GNU_vector is actually a
different tag, encoded this way till we get to DWARF4 ;-)

So now we don't have to lookup on a hash table looking for DWARF
offsets, we can do the more sensible thing of just indexing the
types_tags array.

Now to do some cleanups and try to get the per cu encoder done. Then
order all the cus per number of type entries, pick the one with more,
then go on merging/recoding the types of the others and putting the
parent linkage in place.

Just to show the extent of the changes:

$ codiff /tmp/libdwarves.so.1.0.0 build/libdwarves.so.1.0.0
/home/acme/git/pahole/dwarves.c:
  struct cu                                      | -4048
  struct tag                                     |  -32
  struct ptr_to_member_type                      |  -32
  struct namespace                               |  -32
  struct type                                    |  -32
  struct class                                   |  -32
  struct base_type                               |  -32
  struct array_type                              |  -32
  struct class_member                            |  -32
  struct lexblock                                |  -32
  struct ftype                                   |  -32
  struct function                                |  -64
  struct parameter                               |  -32
  struct variable                                |  -32
  struct inline_expansion                        |  -32
  struct label                                   |  -32
  struct enumerator                              |  -32
 17 structs changed
  tag__follow_typedef                            |   +3
  tag__fprintf_decl_info                         |  +25
  array_type__fprintf                            |   +6
  type__name                                     | -126
  type__find_first_biggest_size_base_type_member |   -3
  typedef__fprintf                               |  +16
  imported_declaration__fprintf                  |   +6
  imported_module__fprintf                       |   +3
  cu__new                                        |  +26
  cu__delete                                     |  +26
  hashtags__hash                                 |  -65
  hash_64                                        | -124
  hlist_add_head                                 |  -78
  hashtags__find                                 | -157
  cu__hash                                       |  -80
  cu__add_tag                                    |  +20
  tag__prefix                                    |   -3
  cu__find_tag_by_id                             |   -2
  cu__find_type_by_id                            |   -3
  cu__find_first_typedef_of_type                 |  +38
  cu__find_base_type_by_name                     |  +68
  cu__find_base_type_by_name_and_size            |  +72
  cu__find_struct_by_name                        |  +59
  cus__find_struct_by_name                       |   +8
  cus__find_tag_by_id                            |   +5
  cus__find_cu_by_name                           |   -6
  lexblock__find_tag_by_id                       | -173
  cu__find_variable_by_id                        | -197
  list__find_tag_by_id                           | -308
  cu__find_parameter_by_id                       |  -60
  tag__ptr_name                                  |   +6
  tag__name                                      |  +15
  variable__type                                 |  +13
  variable__name                                 |   +7
  class_member__size                             |   +6
  parameter__name                                | -119
  tag__parameter                                 |  -14
  parameter__type                                | -143
  type__fprintf                                  |  -29
  union__fprintf                                 |   +6
  class__add_vtable_entry                        |   -9
  type__add_member                               |   -6
  type__clone_members                            |   -3
  enumeration__add                               |   -6
  function__name                                 | -156
  ftype__has_parm_of_type                        |  -39
  class__find_holes                              |  -27
  class__has_hole_ge                             |   -3
  type__nr_members_of_type                       |   +3
  lexblock__account_inline_expansions            |   +3
  cu__account_inline_expansions                  |  -18
  ftype__fprintf_parms                           |  +46
  function__tag_fprintf                          |  +24
  lexblock__fprintf                              |   -6
  ftype__fprintf                                 |   +3
  function__fprintf_stats                        |  -18
  function__size                                 |   -6
  class__vtable_fprintf                          |  -11
  class__fprintf                                 |  -21
  tag__fprintf                                   |  -35
 60 functions changed, 513 bytes added, 2054 bytes removed, diff: -1541

/home/acme/git/pahole/ctf_loader.c:
  struct ctf_short_type      |   +0
 14 structs changed
  type__init                 |  -14
  type__new                  |   -9
  class__new                 |  -12
  create_new_base_type       |   -7
  create_new_base_type_float |   -7
  create_new_array           |   -8
  create_new_subroutine_type |   -9
  create_full_members        |  -18
  create_short_members       |  -18
  create_new_class           |   +1
  create_new_union           |   +1
  create_new_enumeration     |  -19
  create_new_forward_decl    |   -2
  create_new_typedef         |   +3
  create_new_tag             |   -5
  load_types                 |  +16
  class__fixup_ctf_bitfields |   -3
 17 functions changed, 21 bytes added, 131 bytes removed, diff: -110

/home/acme/git/pahole/dwarf_loader.c:
 17 structs changed
  zalloc                           |  -56
  tag__init                        |   +3
  array_type__new                  |  +20
  type__init                       |  -24
  class_member__new                |  +46
  inline_expansion__new            |  +12
  class__new                       |  +81
  lexblock__init                   |  +19
  function__new                    |  +43
  die__create_new_array            |  +20
  die__create_new_parameter        |   +4
  die__create_new_label            |   +4
  die__create_new_subroutine_type  | +113
  die__create_new_enumeration      |  -21
  die__process_class               |  +79
  die__process_namespace           |  +76
  die__create_new_inline_expansion |   +4
  die__process_function            | +147
  __die__process_tag               |  +34
  die__process_unit                |  +56
  die__process                     |  +90
 21 functions changed, 851 bytes added, 101 bytes removed, diff: +750

/home/acme/git/pahole/dwarves.c:
  struct ptr_table             |  +16
  struct cu_orig_info          |  +32
 2 structs changed
  tag__decl_line               |  +68
  tag__decl_file               |  +70
  tag__orig_id                 |  +71
  ptr_table__init              |  +46
  ptr_table__exit              |  +37
  ptr_table__add               | +183
  ptr_table__add_with_id       | +165
  ptr_table__entry             |  +64
  cu__table_add_tag            | +171
  cu__table_nullify_type_entry |  +38
 10 functions changed, 913 bytes added, diff: +913

/home/acme/git/pahole/ctf_loader.c:
 2 structs changed
  tag__alloc          |  +52
 1 function changed, 52 bytes added, diff: +52

/home/acme/git/pahole/dwarf_loader.c:
  struct dwarf_tag                       |  +48
  struct dwarf_cu                        | +4104
 4 structs changed
  dwarf_cu__init                         |  +83
  hashtags__hash                         |  +61
  hash_64                                | +124
  hlist_add_head                         |  +78
  hashtags__find                         | +161
  cu__hash                               |  +95
  tag__is_tag_type                       | +171
  tag__is_type                           |  +85
  tag__is_union                          |  +28
  tag__is_struct                         |  +57
  tag__is_typedef                        |  +28
  tag__is_enumeration                    |  +28
  dwarf_cu__find_tag_by_id               |  +56
  dwarf_cu__find_type_by_id              |  +63
  tag__alloc                             | +114
  __tag__print_type_not_found            | +108
  namespace__recode_dwarf_types          | +346
  tag__namespace                         |  +14
  tag__has_namespace                     |  +86
  tag__is_namespace                      |  +28
  type__recode_dwarf_specification       | +182
  tag__type                              |  +14
  __tag__print_abstract_origin_not_found | +105
  ftype__recode_dwarf_types              | +322
  tag__ftype                             |  +14
  tag__parameter                         |  +14
  lexblock__recode_dwarf_types           | +736
  tag__lexblock                          |  +14
  tag__label                             |  +14
  tag__recode_dwarf_type                 | +766
  tag__ptr_to_member_type                |  +14
  cu__recode_dwarf_types_table           |  +88
  cu__recode_dwarf_types                 |  +48
  dwarf_tag__decl_file                   |  +77
  strings__ptr                           |  +33
  dwarf_tag__decl_line                   |  +59
  dwarf_tag__orig_id                     |  +59
  dwarf_tag__orig_type                   |  +59
 38 functions changed, 4432 bytes added, diff: +4432

build/libdwarves.so.1.0.0:
 147 functions changed, 6782 bytes added, 2286 bytes removed, diff: +4496

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-05 20:40:54 -03:00
Arnaldo Carvalho de Melo 56be29c649 all: Add the --version
Using the argp tricks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 10:57:23 -02:00
Arnaldo Carvalho de Melo 138cc4739c dwarves: Don't pass argp to dwarf_loadfl
Now we just pass a NULL terminated array of filenames, since we got rid
of that ugly -e insertion hack.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09 21:43:56 -02:00
Arnaldo Carvalho de Melo ce2219915d argp: check if child_inputs is NULL
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-18 14:09:13 -02:00
Arnaldo Carvalho de Melo cdf547f418 pdwtags: print pointers and base types too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-07 21:18:29 -03:00
Arnaldo Carvalho de Melo 212b994ab5 strings: Introduce the strings class
And make the dwarves use it, so that we can remove duplicate strings in
a multi-CU file (vmlinux anyone?) and have it ready for insertion in a
compressed DWARF format with just the types, or better, CTF or some new
compressed debugging info format.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 14:34:42 -03:00
Arnaldo Carvalho de Melo efa997ed40 dwarves: Remove type_emissions fields from cus
Now only when one wants to emit this struct is needed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 12:47:42 -03:00
Arnaldo Carvalho de Melo c3f6f8b79f dwarves_emit: Introduce type_emissions
We may want to work on just one object file, not on a multi cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 11:26:51 -03:00
Arnaldo Carvalho de Melo 46d63102eb [DWARVES]: Fixup usage messages
Thanks to Ilpo Järvinen for getting this to my attention.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 09:30:55 -02:00
Arnaldo Carvalho de Melo 5bc698ab1b [DUTIL]: Move __unused definition to dutil.h
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-16 14:47:59 -02:00
Arnaldo Carvalho de Melo ef45383d22 [LIB] lexblock: Show the lexblock low_pc info as offsets from the function where they appear
__wsum csum_partial_copy_to_user(const void  * src, void * dst, int len, __wsum isum, int * errp);
{ /* low_pc=0xffffffff8128ed37 */
        { /* csum_partial_copy_to_user+0x11 */
                long unsigned int flag;                               //    76
                long unsigned int roksum;                             //    76
                current_thread_info(void); /* size=9, low_pc=0xffffffff8128ed4b */ //    76
        } /* lexblock size=32 */
        { /* csum_partial_copy_to_user+0x49 */
                __u16 val16;                                          //    83
                add32_with_carry(unsigned int a,
                                unsigned int b); /* size=8, low_pc=0xffffffff8128ed83 */ //    84
                { /* csum_partial_copy_to_user+0x54 */
                        int __pu_err;                                 //    86
                } /* lexblock size=5 */
        } /* lexblock size=35 */
}/* size: 149 */
/* definitions: 1 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-07-31 14:00:44 -03:00
Arnaldo Carvalho de Melo cf124f1636 [LIB]: Introduce tag__is_struct() for a common idiom
And also to get this less, ho-hum, DWARF specific.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-31 01:53:01 -03:00
Arnaldo Carvalho de Melo 48a1d89ec0 [LIB]: Introduce conf_fprintf.no_semicolon
To indicate wheter the semicolon should be supressed. Useful for
prototype/function emission, etc.

Also move the struct stats to be inside its body, to simplify tag__fprintf,
that now looks at conf.no_semicolon after calling the tag type specific
__fprintf method.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-31 01:39:44 -03:00
Arnaldo Carvalho de Melo c0c76ca287 [PDWTAGS]: Use argp, for now just to select if the decl info is to be shown
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-26 10:29:02 -03:00
Arnaldo Carvalho de Melo 53ede5ee16 [PDWTAGS]: Use conf_fprintf in pdwtags
So that it prints struct stats and decl info (file/line number were tags were
declared).

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-24 17:19:21 -03:00
Arnaldo Carvalho de Melo 262a5d24ea [LIB]: Introduce conf_fprintf
So that we can go on adding more config knobs without requiring adding new
parameters to lots of functions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 16:13:35 -03:00
Arnaldo Carvalho de Melo 711d96943a [LIB]: Use a base_offset when printing inner structs
That way we can have the offsets from the top level struct. If the user wants
to focus some inner struct, just call the tool again specifying the inner
struct name.

Perhaps this is not so clear, shoot me, erm, no, an example should help. Look
at the member offsets (first column in the comment after each member), before
and after:

before:

acme@filo pahole]$ pahole -C tcp_sock --expand_types examples/net
/* <12a> examples/expand.c:18 */
struct tcp_sock {
	struct inet_sock {
		struct sock {
			int        protocol;     /*     0     4 */
			struct spinlock {
				int magic;       /*     0     4 */
				int counter;     /*     4     4 */
			} sklock; /*     4     8 */
			int        b;            /*    12     4 */
			int        c;            /*    16     4 */
		} sk; /*     0    20 */
		long int           daddr;        /*    20     4 */
	} inet; /*     0    24 */
	long int                   cwnd;         /*    24     4 */
	struct spinlock {
		int                magic;        /*     0     4 */
		int                counter;      /*     4     4 */
	} lock; /*    28     8 */
}; /* size: 36, cachelines: 1 */
   /* last cacheline: 36 bytes */

After:

acme@filo pahole]$ pahole -C tcp_sock --expand_types examples/net
/* <12a> examples/expand.c:18 */
struct tcp_sock {
	struct inet_sock {
		struct sock {
			int        protocol;     /*     0     4 */
			struct spinlock {
				int magic;       /*     4     4 */
				int counter;     /*     8     4 */
			} sklock; /*     4     8 */
			int        b;            /*    12     4 */
			int        c;            /*    16     4 */
		} sk; /*     0    20 */
		long int           daddr;        /*    20     4 */
	} inet; /*     0    24 */
	long int                   cwnd;         /*    24     4 */
	struct spinlock {
		int                magic;        /*    28     4 */
		int                counter;      /*    32     4 */
	} lock; /*    28     8 */
}; /* size: 36, cachelines: 1 */
   /* last cacheline: 36 bytes */

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 10:01:54 -03:00
Arnaldo Carvalho de Melo f85781d5b9 [LIB]: Allow of not specifying -e
cus__loadfl will just insert the -e and pass it up to dwfl_standard_argp.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-24 16:09:34 -03:00
Arnaldo Carvalho de Melo 712c9f76d8 [PDWTAGS]: Use libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:54:59 -03:00
Arnaldo Carvalho de Melo c87d8d831a [ALL]: Emit better diagnostic messages
[acme@mica pahole]$ pahole lala
pahole: Permission denied
[acme@mica pahole]$ pahole foo
pahole: No such file or directory
[acme@mica pahole]$ pahole ctracer.c
pahole: couldn't load DWARF info from ctracer.c
[acme@mica pahole]$

Thanks to Matthew Wilcox for noticing how lame it was :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 12:54:46 -03:00
Arnaldo Carvalho de Melo d5a0c78a4c [LIB]: Rename lexblock__print to lexblock__fprintf, for consistency
Also make it return the number of bytes printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:56:16 -02:00
Arnaldo Carvalho de Melo 70f9135467 [LIB]: Rename tag__print to tag__fprintf, for consistency
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-15 11:40:51 -02:00
Arnaldo Carvalho de Melo aab506fdcc [LIB]: Pass a FILE pointer to the __print routines
So that in tools like ctracer we can print to a file, most of the tools just
pass stdout, keeping the previous behaviour.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-01 13:50:28 -02:00