Commit Graph

1056 Commits

Author SHA1 Message Date
Tom Tromey 5ef26a053d Remove unused field from debug_fmt_ops
Nothing seemed to use the 'tag__orig_type' method in debug_fmt_ops.
It was simpler to remove it than to try to fix it for the next patch.
2012-03-22 12:43:59 -06:00
Tom Tromey 4df110dcc4 Remove unnecessary call to dwarf_diecu 2012-03-20 12:30:05 -06:00
Arnaldo Carvalho de Melo 4fa85d5b70 Merge pull request #1 from hasturkun/master
Fix crash on pahole -R -S due to NULL dereference
2012-02-26 14:23:33 -08: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 c7fa6a9a40 dwarf loader: Catch some more template tags
Just warn about them not being supported yet.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 22:38:59 -02: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 250b8586d2 dwarf loader: Print tag numerical value in addition to string
So that we can get unknown tag values.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 22:10:18 -02:00
Arnaldo Carvalho de Melo 91a865bd8f dwarf loader: Initialize tag->node
So that we don't have false asserts at tag__delete thinking the tag is in
some list.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 22:09:05 -02:00
Arnaldo Carvalho de Melo 3a0f0df2e5 cmake: Add ${ELF_LIBRARY} to ctracer, scncopy and pfunct
Noticed on fedora 14, probably we were getting this indirectly, go figure.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 15:18:01 -02:00
Arnaldo Carvalho de Melo 525c2644f3 dwarf_loader: Catch DW_TAG_template_{type,value}_parameter
More work is needed to use this information in dwarves_fprintf.c.

Reported-by: Josh Stone <jistone@redhat.com>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=654471
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 14:37:52 -02:00
Arnaldo Carvalho de Melo e1e7fc2f53 dwarves: Add missing #include <sys/stat.h>
Needed because it uses S_ISDIR. In the past this header probably was
being indirectly included. Noticed while building on RHEL6 Beta.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-06-04 09:26:13 -03:00
Arnaldo Carvalho de Melo f95bfb6e5a Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/acme/pahole 2010-05-04 13:36:24 -03:00
Arnaldo Carvalho de Melo c0bdd19f0e pfunct: Introduce '-P'/'--prototypes'
To print all the function prototypes.

Based-on-patch-by: Rakesh Pandit <rakesh.pandit@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-04 13:33:08 -03:00
Arnaldo Carvalho de Melo dfbb7dd53d cmake: fix DWARVES_VERSION definition, should be 1.8
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-04-13 18:02:24 -03:00
Peter Jones a6f5fedf37 scncopy: Fix minor problems with --usage.
- "-s section 0" doesn't really read the same as "-s section0"
- "--help" is something we should allow
- usage should say "scncopy" not "pjoc"

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-01-12 16:37:27 -02:00
Peter Jones c9d1352dfe Add scncopy to CMakeLists.txt
Add scncopy to the build.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-01-12 14:23:54 -02:00
Peter Jones 29ef465cd8 Add scncopy - like object copy but tries not to change section content
This adds scncopy, which is like objcopy with some differences:
- it doesn't try to update section contents, but does try to
  update program headers and such to correctly reflect the section
  contents.
- it doesn't necessarily try to create a binary eu-elflint will like.
  If you don't copy a required section, it won't make it for you.

TODO:
- Make it possible to copy sections to an already existant binary.
- Make phdrs only copy if they're needed, and/or modify old phdrs to
  point to new sections
- Make sure nothing is missing from fixup_dynamic()

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-01-12 14:23:32 -02:00
Rakesh Pandit 537db1da2d libctf: Replaces deprecated elf_getshstrndx with elf_getshdrstrndx
Removes irritating warning while compilation.

Signed-off-by: Rakesh Pandit <rakesh@fedoraproject.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-29 11:36:47 -02:00
Herton Ronaldo Krzesinski 7bc0b0c656 cmake: Avoid uneeded linking/unused libraries in some dwarves libraries and executables
currently mandriva has a packaging script which checks for uneeded linking in
package built files. For dwarves, it displays:

Warning: unused libraries in /usr/lib64/libdwarves_reorganize.so.1.0.0: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/lib64/libdwarves_emit.so.1.0.0: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/ctracer: libz.so.1
 libdw.so.1

Warning: unused libraries in /usr/bin/syscse: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pglobal: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pdwtags: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/prefcnt: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pfunct: libz.so.1
 libdw.so.1

Warning: unused libraries in /usr/bin/pahole: libz.so.1
 libdw.so.1
 libelf.so.1

Warning: unused libraries in /usr/bin/dtagnames: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/codiff: libdw.so.1
 libelf.so.1
 libz.so.1

The patch below fixes the issue (removing uneeded specified libraries and using
LINK_INTERFACE_LIBRARIES property, see
http://www.cmake.org/Wiki/CMake_FAQ#Why_are_libraries_linked_to_my_shared_library_included_when_something_links_to_it.3F)

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-17 15:20:27 -02:00
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