Commit Graph

1036 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 3e40f38821 New release: 1.8
See NEWS file for the summary.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-06 15:41:50 -02:00
Arnaldo Carvalho de Melo 01a7fb50d4 ctf_encoder: Allow specifying a verbose level for cu__encode_ctf
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-06 14:17:29 -02:00
Arnaldo Carvalho de Melo 25cd635806 dwarves: base_type->float_type holds only 12 possible values
So make it a :4 u8 to combine with the previous bitfield. This field is
also seldom used so no expected perf hit.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-05 19:07:51 -02:00
Arnaldo Carvalho de Melo c6d27e325c dwarves: Enlarge vtable_entry
Since we have two bytes after it in a hole, use them for vtable_entry,
hell knows if there isn't any crazy code with that many vtable
entries...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-05 18:35:10 -02:00
Arnaldo Carvalho de Melo 800fd44d6b dwarves: Make two bitfield entries be bool
As we had 14 bits hole, so use them as bools, each taking one byte
but generating better/shorter code.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-05 18:31:16 -02:00
Arnaldo Carvalho de Melo 42bb02cdfb ctf_loader: Fix ptr diff printf specifier
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-05 18:30:30 -02:00
Arnaldo Carvalho de Melo fce01d3a36 dwarf_loader: Support more compact DW_AT_data_member_location form
Description by Mark Wielaard:

Its a more compact expression of struct field offsets. Jakub already
backported it to the 4.4 gcc in rawhide.

http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00437.html It simply means
that when you try to get the field offset based on a
DW_AT_data_member_location you would check dwarf_whatform() of the
attribute to see if it is a simple constant or a location expression
block/ptr.

Suggested-by: Mark Wielaard <mjw@redhat.com>
Reported-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-11-24 12:56:41 -02:00
Arnaldo Carvalho de Melo da0781e405 MANIFEST: Remove the .py extension for regtest
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-11-07 16:59:20 -02:00
Arnaldo Carvalho de Melo 6476d24d73 pahole: Introduce --hex to print offsets and sizes in hexadecimal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-10-20 13:59:12 -02:00
Arnaldo Carvalho de Melo 0412efb401 dwarf_loader: Properly initialize ->size in lexblock__init
When dwarf_lowpc failed we were not initializing ->size, so garbage was
being left there and thing like 'pfunct --sizes' were producing
senseless results.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-20 16:53:19 -03:00
Arnaldo Carvalho de Melo 5859ddcbf1 pahole: don't call class__delete for clones for now
As it is corrupting the obstack and it will be deleted completely at
cu__delete time anyway. Stick a FIXME tho, as it is good to completely
understand and fix this eventually.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-20 16:46:32 -03:00
Arnaldo Carvalho de Melo 0c50ef3a60 dwarves: class_member__clone need to allocate from the obstack
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-20 16:20:06 -03:00
Arnaldo Carvalho de Melo f001b9f688 dwarves: Add a newline to __tag__id_not_found_fprintf output
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:55:20 -03:00
Arnaldo Carvalho de Melo 5be2291b14 dwarves: Teach base_type__name_to_size about "long double"
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:50:14 -03:00
Arnaldo Carvalho de Melo d45a1e7c7c ctf_loader: Make a 'boo!' warning more verbose
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:48:37 -03:00
Arnaldo Carvalho de Melo b4977b20e0 dwarves: __tag__has_type_loop has to handle a NULL type (void)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:39:52 -03:00
Arnaldo Carvalho de Melo 3049d6962f regtest: Use getopt
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:09:44 -03:00
Arnaldo Carvalho de Melo 9720415091 dwarf: Detect type loops
[acme@doppio pahole]$ pahole -F ctf /media/tb/debuginfo/usr/lib/debug/usr/bin/greycstoration4integration.debug > /tmp/bla
<ERROR(tag__size:837): detected type loop: type=572, tag=const_type>
<ERROR(tag__size:837): detected type loop: type=572, tag=const_type>
[acme@doppio pahole]$

These type loops are problems in the CTF encoding, that should be fixed, but
should not cause the core code to segfault on an infinite recursion.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:07:02 -03:00
Arnaldo Carvalho de Melo 428f318599 dwarves_fprintf: '* const' support: 3rd try
[acme@doppio pahole]$ cd tests/jengelh@medozas.de
[acme@doppio jengelh@medozas.de]$ cat test.sh
for F in const_pointer pointer_const const_pointer_const ; do
	printf "%s\n-------------------\n\n" $F
	gcc -c -g $F.c -o $F
	cat $F.c; pahole $F
done
[acme@doppio jengelh@medozas.de]$ ./test.sh
const_pointer
-------------------

struct x {
	const char *s;
} y;
struct x {
	const char  *      s;    /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
pointer_const
-------------------

struct x {
	char *const s;
} y;
struct x {
	char *const        s;    /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
const_pointer_const
-------------------

struct x {
	const char *const s;
} y;
struct x {
	const char  *const s;    /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
[acme@doppio jengelh@medozas.de]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-12 19:42:46 -03:00
Arnaldo Carvalho de Melo 7039a6fc2e regtest: Ask if the changes are ok
If they are, the 'after' file is moved to the 'before' directory.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-12 18:12:44 -03:00
Arnaldo Carvalho de Melo 406944b404 dwarves: Add more __name() routines and remove s()
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-12 18:11:19 -03:00
Arnaldo Carvalho de Melo 7e5b39f944 dwarves_fprintf: Make tag__id_not_found_(f|sn)printf print __LINE__
Helps debugging.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-11 15:10:43 -03:00
Arnaldo Carvalho de Melo a8b3f74b90 ctf: structure_type__encode shouldn encode only DW_TAG_member
C++ is not properly supported in CTF anyway... And this was
causing a bug, so don't encode DW_TAG_inheritance entries.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-11 14:11:22 -03:00
Arnaldo Carvalho de Melo fe101bdf3d dwarves_fprintf: really fix pointers to const
[acme@doppio pahole]$ cat tests/jengelh@medozas.de/const_const.c
struct x {
	const char *const s;
} y;

int main(void)
{
	return !y.s;
}
[acme@doppio pahole]$ pahole tests/jengelh@medozas.de/const_const
struct x {
	const char  *const         s;                /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
[acme@doppio pahole]$

Look again...

One more time...

Looks ok now.

Reported-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-11 01:51:22 -03:00
Arnaldo Carvalho de Melo 846927a3f8 dwarves_fprintf: Properly support pointers to const
I.e.:

[acme@doppio pahole]$ cat tests/jengelh@medozas.de/const_const.c
struct x {
	const char *const s;
} y;

int main(void)
{
	return !y.s;
}
[acme@doppio pahole]$ pahole tests/jengelh@medozas.de/const_const
struct x {
	char const  * const        s;                    /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
[acme@doppio pahole]$

One more reason to devote some time to RTT, i.e. Round Trip Testing, where
pahole will be used to regenerate the source code, then feed the result to
gcc -g, run again, use codiff, that should produce no diff.

Reported-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-10 16:43:00 -03:00
Arnaldo Carvalho de Melo fc1269af2f pahole: Introduce --classes_as_structs
That asks dwarf_fprintf to always use "struct" in places where it would
use "class", because CTF doesn't have the "class" concept, so for
'regtest diffctf' sake, we use this.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 17:22:43 -03:00
Arnaldo Carvalho de Melo 8ad6fa6658 regtest: Allow specifying just a directory
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 16:55:32 -03:00
Arnaldo Carvalho de Melo 7455b9b884 regtest: Introduce diffctf option
To compare DWARF and CTF encodings for the same file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 15:45:32 -03:00
Arnaldo Carvalho de Melo 95734d9437 pahole: Add --first_obj_only
For now --encode_ctf/-Z only encodes the tags in the first object file
(CU) in a multi-obj/CU file, so for regtest sake, for now, introduce
this option.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 15:13:58 -03:00
Arnaldo Carvalho de Melo 3221454ae3 ctf_loader: cope with C++ problems
Probably related to base classes, revisit when trying to support C++ in
CTF, if ever...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 13:15:35 -03:00
Arnaldo Carvalho de Melo d9b4badca2 ctf: Handle dwfl_module_getsymtab errors
That can happen, for instance, when the symtabs are NOBITS. When that
happened we ended up in an infinite loop. Call it earlier and check the
result.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-23 11:47:03 -03:00
Arnaldo Carvalho de Melo cd03ae0eb1 regtest: Add a 'ctf' mode
To encode CTF information from the DWARF one. Next patches will add
support for comparing the CTF and DWARF info.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-22 09:34:12 -03:00
Arnaldo Carvalho de Melo ab554628a1 regtest: Don't run the tools on symlinks
Its redundant and thus slows down the whole regression testing.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-22 09:14:28 -03:00
Arnaldo Carvalho de Melo 641daf5191 regtest: remove the .py extension
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-21 23:03:34 -03:00
Arnaldo Carvalho de Melo 65b3b7a03f regtest: remove temp diff file
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-21 23:03:03 -03:00
Arnaldo Carvalho de Melo 02a419287a dwarves_fprintf: Bump the size passed to tag__name in imported_declaration__fprintf
As it was not enough to cover some, hum, limits in the way C++ encodes piles of
abstractions:

+++ /media/tb/pahole/regtest/after/usr/bin/enfuse.pahole -A.c   2009-08-21 09:04:15.000000000 -0300
@@ -10414,7 +10414,7 @@ struct _Vector_base<enblend::enfuseMain(

        using ::_M_deallocate;

-       using ::__uninitialized_move_a<enblend::enfuseMain(std::list<vigra::ImageImportInfo*, std::allocator<vigra::ImageImportInfo*> >&, vigra::ImageExportInfo&, vigra::Rect2D&) [with ImagePixelType = vigra::RGBValue<unsigned int, 0u, 1u, 2u>]::ImagePyramidType**, enblend::enfuseMain(std::list<vigra::ImageImportInfo*, std::allocator<vigra::ImageImportInfo*> >&, vigra::ImageExportInfo&, vigra::Rect2D&) [with ImagePixelType = vigra::RGBValue<unsigned int, 0u, 1u, 2u>]::ImagePyramidType**, std::allocator<enblend::enfuseMain(ð7K^A;
+       using ::__uninitialized_move_a<enblend::enfuseMain(std::list<vigra::ImageImportInfo*, std::allocator<vigra::ImageImportInfo*> >&, vigra::ImageExportInfo&, vigra::Rect2D&) [with ImagePixelType = vigra::RGBValue<unsigned int, 0u, 1u, 2u>]::ImagePyramidType**, enblend::enfuseMain(std::list<vigra::ImageImportInfo*, std::allocator<vigra::ImageImportInfo*> >&, vigra::ImageExportInfo&, vigra::Rect2D&) [with ImagePixelType = vigra::RGBValue<unsigned int, 0u, 1u, 2u>]::ImagePyramidType**, std::allocator<enblend::enfuseMain(std::list<vigra::ImageImportInfo*, std::allocator<vigra::ImageImportInfo*> >&, vigra::ImageExportInfo&, vigra::Rect2D&) [with ImagePixelType = vigra::RGBValue<unsigned int, 0u, 1u, 2u>]::ImagePyramidType*> >;

        using ::_M_get_Tp_allocator;

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-21 09:05:15 -03:00
Arnaldo Carvalho de Melo 36151b470a dwarves: Make tag__name support variables
As DW_TAG_imported_declaration can also point to one...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-20 22:41:48 -03:00
Arnaldo Carvalho de Melo ca6dc1446c dwarf_loader: Follow const types too in class_member__cache_byte_size
In the same fashion as DW_TAG_volatile_type, as we need to get to the
DW_TAG_base_type at the end of the chain.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-20 19:48:14 -03:00
Arnaldo Carvalho de Melo 68bac65d2e regtest: Convert the regtests to a python script and include it in the repo
I'm using it using a directory with all debuginfo packages in fedora, so
that I can run a before and after with different tools (pahole, pfunct),
and check the differences after some change.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-20 18:47:57 -03:00
Arnaldo Carvalho de Melo bd361e461e dwarf_loader/dwarves_fprintf: Support "using" pointing to data members
If it is C++ add DW_TAG_member entries to cu->tags_table and at
imported_declaration__fprintf fallback to cu__tag() if cu__function()
fails.

The right thing tho, long term, is to have a class for
"DW_TAG_imported_declaration" to register to what kind of tag this
points, if for DW_TAG_subprogram or to DW_TAG_member, the info is in the
DWARF DW_AT_import attribute, but so far we're not decoding it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-20 18:33:52 -03:00
Arnaldo Carvalho de Melo 3de722e9ab dwarves: Delete list entries in reverse order
It doesn't matter when using a traditional malloc/free allocator, but
with obstacks we need to do it in reverse order.

For the usual case where we successfully process an object this doesn't
matter, as when we started using obstacks we don't traverse all the tags
calling their destructors anymore, we just free the whole obstack in one
go.

Noticed when processing object files built from non-supported languages
such as FORTRAN and Pascal, where there are some DWARF tags that are not
supported, which makes the object file load to be prematurely aborted
and that calls destructors for things like classes and functions that in
turn free space for their parameter/member lists, which now have to be
done in reverse order.

We could just stop calling the destructors and then destroying the whole
obstack, but I think that partially processed files are a nice feature,
so keep the interface in a way that both obstacks and traditinal malloc
alocators can be used.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-19 10:32:49 -03:00
Arnaldo Carvalho de Melo d2581fa5aa dwarves_fprintf: Revert experimentation with const rendering
Still doesn't fixes the case "const char * const foo"...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-19 10:04:54 -03:00
Arnaldo Carvalho de Melo 19bbecf668 dwarves: Pass the cu to destructors to free memory on the obstack
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-18 18:21:20 -03:00
Arnaldo Carvalho de Melo f0435286c0 dwarves_reorganize: Fix class__demote_bitfields, we need power of two bytes
There is no such thing as a 3 bytes sized base type. Round it up to 4.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-16 12:26:33 -03:00
Arnaldo Carvalho de Melo dffd3d4ee7 dwarves: Fix cu__find_base_type_by_name when the base_type name is NULL
This shouldn't happen, but if it does, don't return it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-16 12:13:38 -03:00
Arnaldo Carvalho de Melo f7034469a6 dwarves_reorganize: Fix padding calculation
We can't always pad using the module of addr_size, we need to find the
minimum alignment requirement as a power of two < addr_size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-13 13:28:09 -03:00
Arnaldo Carvalho de Melo de44cfece7 pahole: fix class__packable so that it catches bugs in the reorg algo
Where we end up with the same struct but class__size() returns off by
some bytes result. Investigating...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-13 11:59:18 -03:00
Arnaldo Carvalho de Melo f7bbe7dee2 dwarves_fprintf: Support zero sized arrays in the middle of the struct
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-10 12:31:47 -03:00
Arnaldo Carvalho de Melo 44085cc239 reorganize: Adjust padding after moving from the tail
When we move fields from the tail to eliminate holes look if the struct
still correctly fits into a multiple of cu->addr_size.

Unless the struct is explicitely marked __attribute__((packed)) (and we
can't know that for sure) we have to add padding in that case.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-07-11 12:54:46 -03:00
Arnaldo Carvalho de Melo d46525e7ce dwarves: reorganize struct namespace
Oh well, we need to use these tools on these tools from time to time ;-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-07-08 16:53:22 -03:00