Commit Graph

10 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo a94b511f6c ctfdwdiff: Don't ask for variables and inline expansions in pfunct
As we won't find them in CTF land... I also have to add a new pfunct cmdline
option to ask for inline functions not to be printed, as they aren't on the
symtab.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-31 19:21:46 -03:00
Arnaldo Carvalho de Melo e97d952744 ctf_encoder: Convert DWARF functions to CTF
Finally we can use the Elf file already opened in dwarf_load, call
cu__for_each_cached_symtab_entry to iterate over the symtab entries,
this iterator will first call dwfl_module_getsymtab, that will do the
relocation that will allow us to go from the symtab address to the one
in the DWARF DW_TAG_subprogram tag DW_AT_low_pc attribute.

And voila, for a relatively complex single unit Linux kernel object
file, kernel/sched.o, we go from:

Just DWARF (gcc -g):

$ ls -la kernel/sched.o
1979011 kernel/sched.o

Then we run this to encode the CTF section:

$ pahole -Z kernel/sched.o

And get a file with both DWARF and CTF ELF sections:

$ ls -la kernel/sched.o
2019848 kernel/sched.o

We still need to encode the "OBJECTS", i.e. variables, but this
gets us from 1979011 (just DWARF) to:

$ strip--strip-debug kernel/sched.o
$ ls -la kernel/sched.o
-rw-rw-r-- 1 acme acme 507008 2009-03-30 23:01 kernel/sched.o

25% of the original size.

Of course we don't have inline expansion information, parameter names,
goto labels, etc, but should be good enough for most use cases.

See, without DWARF data, if we ask for it to use DWARF, nothing will be
printed, if we don't speficy the format, it will try first DWARF, it
will not find anything, it will try CTF:

$ pahole -F dwarf kernel/sched.o
$ pahole -C seq_operations kernel/sched.o
struct seq_operations {
	void *  (*start)(struct seq_file *, loff_t *);         /*   0  8 */
        void    (*stop)(struct seq_file *, void *);            /*   8  8 */
	void *  (*next)(struct seq_file *, void *, loff_t *);  /*  16  8 */
	int     (*show)(struct seq_file *, void *);            /*  24  8 */

	/* size: 32, cachelines: 1, members: 4 */
	/* last cacheline: 32 bytes */
};
$ $ pfunct -Vi -f schedule kernel/sched.o
void schedule(void);
{ /* low_pc=0xe01 */
}/* size: 83 */
$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-30 22:54:29 -03:00
Arnaldo Carvalho de Melo c1d567f047 ctfdwdiff: allow specifying just one file again
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-22 13:06:41 -03:00
Arnaldo Carvalho de Melo 17b83fcbf1 ctfdwdiff: Handle files without DWARF info too
Such as some built-in.o files in the Linux kernel build process.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 23:44:12 -03:00
Arnaldo Carvalho de Melo 9a3f5b2c9e ctfdwdiff: Make it work in directories
Looking for all the single-compile unit .o files and acting on those.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 14:34:30 -03:00
Arnaldo Carvalho de Melo ac7778099a pahole: Introduce --fixup_silly_bitfields
$ pahole -C acpi_device_perf_flags ac.o
struct acpi_device_perf_flags {
	u8          reserved:8;           /*     0: 0  1 */

	/* size: 1, cachelines: 1, members: 1 */
	/* last cacheline: 1 bytes */
};
$ pahole --fixup_silly_bitfields -C acpi_device_perf_flags ac.o
struct acpi_device_perf_flags {
	u8          reserved;             /*     0     1 */

	/* size: 1, cachelines: 1, members: 1 */
	/* last cacheline: 1 bytes */
};
$

Used in ctfdwdiff as in CTF land we can't express such sillyness.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 13:54:04 -03:00
Arnaldo Carvalho de Melo 56f4fc831a pahole: Introduce --show_private_classes
By default pahole doesn't prints structs/classes that are only defined
inside functions, so add a knob to aks for that.

This is for the benefit of ctfdwdiff, as in CTF we don't have
expressiveness to tell that a struct is only defined inside a function,
its all in the global table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 11:37:22 -03:00
Arnaldo Carvalho de Melo 57127d45fc pahole: Introduce --flat_array
CTF doesn't have support for multiple array dimensions, so it flattens
the arrays.

This caused a large number of false positives in ctfdwdiff, so introduce
this conf_fprintf option, use it in pahole and ctfdwdiff.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 10:29:50 -03:00
Arnaldo Carvalho de Melo 01c4fa3114 ctfdwdiff: Make it more bulk test friendly
So that I can run it with:

find . -type d | while read dir ; do cd $dir ; ls *.o 2> /dev/null |
while read file ; do ctfdwdiff $file ; done ; cd - ; done

for instance.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 10:11:47 -03:00
Arnaldo Carvalho de Melo 82d5dbe637 ctfdwdiff: Simple shell script for testing the CTF encoder/decoder
First it gets a file with DWARF info, converts that to CTF and adds
a ".SUNW_ctf" ELF section to the file with DWARF info. Double debugging
foo! Pay for one, take two!

For tcp_input.o for instance, the result is:

[acme@doppio pahole]$ cat /tmp/tcp_input.o.diff
--- /tmp/tcp_input.o.ctf.c	2009-03-19 19:48:23.000000000 -0300
+++ /tmp/tcp_input.o.dwarf.c	2009-03-19 19:48:23.000000000 -0300
@@ -1811,7 +1811,7 @@

 	/* XXX 6 bytes hole, try to pack */

-	void (*call)(const struct marker *, void *);	  /* 24  8 */
+	void (*call)(const struct marker *, void *, ...); /* 24  8 */
 	struct marker_probe_closure single;		  /* 32 16 */
 	struct marker_probe_closure * multi;		  /* 48  8 */
 	const char  *               tp_name;		  /* 56  8 */
[acme@doppio pahole]$

Now back to figuring out how to encode a VARARGS marker in CTF...

Ah, to use the script just do:

./ctfdwdiff foo.o

Some will crash, but we're working hard for fuller customer
satisfaction.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 19:50:09 -03:00