Commit Graph

897 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo fc0827327b pahole: Remove a not needed "the" article in the man page.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-23 16:53:54 -03:00
Arnaldo Carvalho de Melo 7bd3c2d828 core: Handle GCC support for vector instructions
So now it recognizes:

908 typedef int __m64 __attribute__ ((__vector_size__ (8))); size: 8
909 int         array __attribute__ ((__vector_size__ (8))); size: 8
910 int         array __attribute__ ((__vector_size__ (4))); size: 4
911 short int   array __attribute__ ((__vector_size__ (2))); size: 2
912 char        array __attribute__ ((__vector_size__ (1))); size: 1

The above output was obtained using pdwtags.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-23 16:31:21 -03:00
Arnaldo Carvalho de Melo 09edf84b74 tag: tag__follow_typedef doesn't change self, make it const
That will allow it to be used in other places were we forward self and it is
const.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-23 16:30:20 -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 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 938690a7e4 pahole: don't print private members inside types when using show_private_classes
As we will show them on the first level. This is yet another thing
required to properly compare te result of "pahole -F ctf foo" with the
output of "pahole -F dwarf foo", as there is no support, that I know of,
for namespacing in ctf.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 14:13:40 -03:00
Arnaldo Carvalho de Melo 790019678d dwarves: Fixup the flat_arrays code
To deal with cases such as this:

$ pahole -C tun_filter drivers/net/tun.o
struct tun_filter {
	__u16           flags;         /*   0  2 */
	__u16           count;         /*   2  2 */
	__u8            addr[0][6];    /*   4  0 */

	/* size: 4, cachelines: 1, members: 3 */
	/* last cacheline: 4 bytes */
};
$ pahole --flat_arrays -C tun_filter drivers/net/tun.o
struct tun_filter {
	__u16           flags;         /*   0  2 */
	__u16           count;         /*   2  2 */
	__u8            addr[0];       /*   4  0 */

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

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 14:05:01 -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 aff24d3517 base_type: floats are 32 bits
Gee, I guess I was nuts when thinking int was dependent on the arch
word-size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 13:38:03 -03:00
Arnaldo Carvalho de Melo da177f87a3 ctf_encoder: Check if something was encoded before saving the info
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 13:20:24 -03:00
Arnaldo Carvalho de Melo 9775df792d dwarf: share the enumerators when recoding an enum bitfield
And this now allows us to properly encode enum bitfields with pahole -Z.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 13:01:25 -03:00
Arnaldo Carvalho de Melo 6454e1dc8b enumeration: Allow sharing the enumerators
Nasty trick, but works and should be properly documented in the sources
and here:

If struct namespace.shared_tags is 1, we actually are reusing the list
of enumerators in another namespace, so we shouldn't delete them, for
that list_for_each_tag now means more for each _unshared_ tag, so that
cu__delete doesn't visits it, double freeing enumerator tags.

type__for_each_enumerator knows that and only for enums we'll set this
->shared_tags bit to 1, so we should be safe...

Disgusting? send me a patch, but without increasing memory or processing
footprints, please ;-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 12:53:43 -03:00
Arnaldo Carvalho de Melo ce97ac9a26 ctf_encoder: Allow encoding a bit_size in enumeration types
As we have to support enum bitfields, so remember the bit_size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 12:51:30 -03:00
Arnaldo Carvalho de Melo a3cd3c4a09 ctf_loader: enums can have a bit_size less than 8 * size(int)
At least in our encoder, as we support enum bitfields, so if it comes
zeroed, as in the other implementation, we assume 8 * sizeof(int), if
not, its the bitsize.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 12:48:25 -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 659c1eae69 strings: Allow calling strings__delete with a NULL pointer
Just like free, and as this is the common exit path of the tools, we
better do that not to segfault when not asking for something. ;-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-20 10:35:57 -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 6564699144 base_type: Add "float" to base_type_name_to_size_table
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 21:52:01 -03:00
Arnaldo Carvalho de Melo fedbfb60ff libctf: Encode VARARGS an extra 0 short at the end of the parm list
We'll see if this is how things should be, but its good enough for me 8)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 20:10:33 -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
Arnaldo Carvalho de Melo dcef613288 libctf: give up "for now" on using libelf to add a section to an existing file
And use what worked so far, that is: if the section is already there,
replacing its contents works, because probably all the relocation was
done... If not, be a chicken and call system("objcopy..."), but...
I'llll be bahck!

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 19:41:14 -03:00
Arnaldo Carvalho de Melo f2495cd1a6 libctf: comment out some debug messages
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 19:17:41 -03:00
Arnaldo Carvalho de Melo d9d63574a3 ctf: Give some more info about UNKNOWN types
And make the output go to stderr.

I guess the best we can do about these is to completely ignore them,
well see...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:25:13 -03:00
Arnaldo Carvalho de Melo 45255ec6b6 pahole: Add --format_path/-F to specify a list of formats to try
For a file with just DWARF info:

$ pahole -F ctf build/pahole
$

But if we ask that it also try dwarf:

$ pahole -F ctf,dwarf build/pahole | head -2
struct _IO_FILE {
	int          _flags;    /*     0     4 */
$

Useful when testing the new CTF support in these tools, as we'll be able to,
from the DWARF info in objects, generate the CTF equivalent and add to the same
object, then run pahole -A -F ctf, pahole -A -F dwarf and compare the outputs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:19:37 -03:00
Arnaldo Carvalho de Melo feab8aa5e3 ctf: Include the initial implementation of a ctf encoder
"pahole -Z foo" will create foo.SUNW_ctf, that if objcopy
--add-section'ed to the right word-sized object will work, sans VARARGS,
that will get fixed soon (as in, probably, tomorrow).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:16:07 -03:00
Arnaldo Carvalho de Melo b27463f995 ctf: class__fixup_ctf_bitfields has to handle enums
As they can be the "integral type" of bitfields.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:14:39 -03:00
Arnaldo Carvalho de Melo fbaab74297 ctf: Stop returning "(anonymous)" in ctf_string
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:14:23 -03:00
Arnaldo Carvalho de Melo f7a428ef24 ctf: Add a filename member to struct ctf
That will be later used when encoding the CTF info.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:14:01 -03:00
Arnaldo Carvalho de Melo 347e70f4d8 cus: Allow passing a debugging format path to cus__load
So that the user can specify what is the order it wants for decodind, as
we can have several debugging formats encoded in different ELF sections.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:13:00 -03:00
Arnaldo Carvalho de Melo eb0284c619 enumeration: type->size for enumerations is in bits, not in bytes
I have to normalize this so that we don't have this special case, but
since we can have enum bitfields....

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 23:01:32 -03:00
Arnaldo Carvalho de Melo bcf24ef40f base_type__name_to_size: Complain when not finding the requested type name
Fragile interface, but its the best I have for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:49:33 -03:00
Arnaldo Carvalho de Melo 7397fab08e base_type_name_to_size: Add "long double long double"
Looks like a stupid glitch, but lets leave this for later for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:47:48 -03:00
Arnaldo Carvalho de Melo da37c56c26 cu: Add a filename member
Will later be used when generating the CTF info, be it in a separate
file, be it on a new ELF section inserted into this filename.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:35:54 -03:00
Arnaldo Carvalho de Melo 0449febc4e gobuffer: Introduce gobuffer__allocate
So that we can also reserve space for things that will be added in
several steps, such as CTF structs, where we first add a struct for the
name, size, nr_members, then several ones for the members.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:14:55 -03:00
Arnaldo Carvalho de Melo 140712f06a cu: Rename cu__find_{type,tag}_by_id to cu__{type,tag}
To shorten the name and to reflect the fact that we're no longer
"finding" a type, but merely accessing an array with a bounds check in
this function.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 12:17:07 -03:00
Arnaldo Carvalho de Melo a56a9a6cfe class_member: Reencode DWARF bitfield types
We now create a new integral type (enum or base_types), creating typedef
chains if needed, while caching the bit_size and bit_offset, so that we
can easily reencode the whole file into CTF.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:58:32 -03:00
Arnaldo Carvalho de Melo dfdfcbbb5c cu: Introduce cu__find_enumeration_by_sname_and_size
Needed for reencoding DWARF bitfields, where we need to create a new
enum that has a bitfield_size bits size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:52:29 -03:00
Arnaldo Carvalho de Melo 83e389677e base_type: Move base_type__name_to_size from the ctf loader to the core
Will be used in more parts.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:48:40 -03:00
Arnaldo Carvalho de Melo ccc808b88e dutil: Move zalloc to dutil
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:08:23 -03:00
Arnaldo Carvalho de Melo 61219b0c3b class_member: cache the byte size of the member
This is the full byte size of the type or the bitfield it is in.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 14:31:18 -03:00
Arnaldo Carvalho de Melo 93eefc6cfb class_member: cache byte_size
This will help us in the next csets when we need to know both the full
size of the base_type used in an bitfield _and_ the size in bits of the
bitfield member.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 13:57:40 -03:00
Arnaldo Carvalho de Melo f879394b87 ctf: improve base_type__name_to_size
Now it does integer comparisions (strings_t) and also covers all the so
far seen base type names in CTF and DWARF land.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 13:47:31 -03:00
Arnaldo Carvalho de Melo ef6c1c63d6 dwarves: Rename the class_member bitfields size and offset members
Because we will need the "bit_offset" and "bit_size" names when converting the
representation of offset and size everywhere to be in bits, not bytes.

At the same time we will keep bitfield_size and bitfield_offset when we convert
from DWARF to CTF and will calculate them when loading CTF, so that the
conversion of the algorithms in dwarves_reorganize, that have all sorts of
subtle issues, can be left for later.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 11:43:17 -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 3ccd3e57b7 ctf: ctf_load can receive a NULL conf_load
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-16 15:53:26 -03:00
Arnaldo Carvalho de Melo 6443161c76 dwarves: Move abstract_origin to dwarf_tag
So that yet another DWARFism is nicely hidden in the DWARF specific
loader.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 22:42:34 -03:00