Commit Graph

28 Commits

Author SHA1 Message Date
Mark Wielaard 943a0de067 dwarves_fprintf: DW_TAG_mutable_type doesn't exist.
DW_TAG_mutable_type was a mistake in an early DWARFv3 draft and was
removed in the final version.

http://dwarfstd.org/ShowIssue.php?issue=050223.1

Signed-off-by: Mark Wielaard <mjw@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-07-03 12:34:48 -03:00
Cody P Schafer 1e461ec7e0 dwarves_fprintf: Fix printf types on 64bit linux
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-03-20 15:56:38 -03:00
Arnaldo Carvalho de Melo 222f0067a9 dwarves_fprintf: Don't ignore virtual data members
When computing the size of a class, leave, caused problems in
some cases, links to the reports are in the comments.

Reported-by: Nicolas <nikos42@gmail.com>
Suggested-by: Mark Wielaard <mjw@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-03-20 10:38:03 -03:00
Arnaldo Carvalho de Melo 8c6378fd88 dwarves: Support static class data members
Fixes the following BFA:

[acme@sandy pahole]$ pahole brainfart.o
class ios_base {
	enum _Ios_Openmodeconst    in;                   /*     0     4 */
	typedef enum _Ios_Fmtflags fmtflags;

	/* size: 1, cachelines: 1, members: 1 */
	/* padding: 65533 */
	/* last cacheline: 1 bytes */

	/* BRAIN FART ALERT! 1 != 4 + 0(holes), diff = -3 */

};

That now produces:

[acme@sandy pahole]$ build/pahole brainfart.o
class ios_base {
	static enum _Ios_Openmodeconst    in = 8;        /*     0     0 */
	typedef enum _Ios_Fmtflags fmtflags;

	/* size: 1, cachelines: 0, members: 0, static members: 1 */
	/* last cacheline: 1 bytes */
};
[acme@sandy pahole]$

Reported-by: Nicolas <nikos42@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-08-20 14:42:17 -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
Tal Kelrich 4e5967a2ca Fix crash when pahole called with -R -S 2012-02-26 16:33:05 +02:00
Arnaldo Carvalho de Melo 76f687bf49 dwarf_loader: Fix the build on older systems
RHEL5 and Fedora 11 were not building due to the GNU attributes stuff,
cope with that using a define we know is not present in both RHEL5 and
Fedora 11 to #ifdef those parts. Ugly, but _ELFUTILS_PREREQ, i.e.
elfutils/version.h is not present in RHEL5 either.

Reported-by: Jon Stanley <jstanley@fedoraproject.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2011-03-17 15:33:28 -03:00
Arnaldo Carvalho de Melo dae032ea3f dwarves fprintf: Add extra GNU tags
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 22:23:14 -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 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 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 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 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 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 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 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
Zack Weinberg 1298ce789e dwarves_fprintf: Honour conf.show_only_data_members for the vtable
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Zack Weinberg <zweinberg@mozilla.com>
2009-06-17 15:30:09 -03:00
Arnaldo Carvalho de Melo 4b796de4aa dwarves: export ftype__fprintf_parms
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-08 14:23:46 -03:00
Arnaldo Carvalho de Melo 7c6603189e dwarves: Make all the tags that have an IP to be derived from ip_tag
Next we'll add a new kind of tag, DW_TAG_perf_counter, that will come
from perf.data generated by 'perf report'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-04 17:30:06 -03:00
Arnaldo Carvalho de Melo 071cb5fd75 fprintf: Print "interface" in class__fprintf for Java Interfaces
JAVA support needs to be checked, but from a very quick skim it
looks ok'ish.

First detected with /usr/bin/fstack from frysk.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-25 01:54:21 -03:00
Arnaldo Carvalho de Melo 29e67fce58 dwarf_loader: Add containing_type to dwarf_tag
Sharing the same space with abstract_origin, so that we can remove the last
Dwarf_Off in dwarf_fprintf.c.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-19 14:04:59 -03:00
Arnaldo Carvalho de Melo f84bf73d54 dwarves: Move the fprintf code to a new source file.
$ wc -l dwarves.c dwarves_fprintf.c
 1468 dwarves.c
 1554 dwarves_fprintf.c
 3022 total
$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-19 13:48:51 -03:00