Commit fcded977 authored by cem's avatar cem
Browse files

New port: devel/dwarves

Dwarves is a collection of debuginfo manipulating and inspecting libraries and
programs, including the popular 'pahole' tool.

WWW: https://acmel.wordpress.com/category/kernel-hacking/
Git: http://repo.or.cz/dwarves.git (Github repo is stale)

Sponsored by:	EMC / Isilon Storage Division
parent d69e8816
......@@ -408,6 +408,7 @@
SUBDIR += dulwich
SUBDIR += duplo
SUBDIR += dwarfdump
SUBDIR += dwarves
SUBDIR += dxa65
SUBDIR += dyncall
SUBDIR += e00compr
......
# Created by: Conrad Meyer <cem@FreeBSD.org>
# $FreeBSD$
PORTNAME= dwarves
PORTVERSION= 1.10
CATEGORIES= devel
MASTER_SITES= https://fedorapeople.org/~acme/dwarves/
# http://fedorapeople.org/~acme/dwarves/%{name}-%{version}.tar.bz2
# git: http://repo.or.cz/dwarves.git
# ML: http://news.gmane.org/gmane.comp.debugging.dwarves
MAINTAINER= cem@FreeBSD.org
COMMENT= Debugging Information Manipulation Tools
LICENSE= GPLv2
LICENSE_FILE_GPLv2= $(WRKSRC)/COPYING
LIB_DEPENDS= libargp.so:devel/argp-standalone \
libdw.so:devel/elfutils
BUILD_DEPENDS= cmake>=0:devel/cmake \
gnulib>=0:devel/gnulib
# Source is a tarbomb:
WRKSRC= $(WRKDIR)
USES= cmake:outsource localbase tar:bzip2
USE_LDCONFIG= yes
#CMAKE_VERBOSE= 1
post-patch:
@${CP} -a \
$(LOCALBASE)/share/gnulib/lib/gettext.h \
$(LOCALBASE)/share/gnulib/lib/obstack.c \
$(LOCALBASE)/share/gnulib/lib/obstack.h \
$(WRKSRC)/
@${REINPLACE_CMD} -e 's|_GL_ATTRIBUTE_PURE|__attribute__((__pure__))|g' \
$(WRKSRC)/obstack.h $(WRKSRC)/obstack.c
.include <bsd.port.mk>
TIMESTAMP = 1468468005
SHA256 (dwarves-1.10.tar.bz2) = 557306e1b58b475f689f44095ec62388877b1a8dd06174f97e309994c15bcc14
SIZE (dwarves-1.10.tar.bz2) = 96919
--- CMakeLists.txt.orig 2012-03-20 16:17:25 UTC
+++ CMakeLists.txt
@@ -31,11 +31,14 @@ add_definitions(-D_GNU_SOURCE -DDWARVES_
find_package(DWARF REQUIRED)
find_package(ZLIB REQUIRED)
-_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${__LIB}" "libdir")
+# For argp-standalone
+find_library(ARGP argp ${LOCALBASE}/lib)
+
+_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/lib${__LIB}" "libdir")
set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings
ctf_encoder.c ctf_loader.c libctf.c dwarf_loader.c
- dutil.c elf_symtab.c rbtree.c)
+ dutil.c elf_symtab.c rbtree.c obstack.c)
add_library(dwarves SHARED ${dwarves_LIB_SRCS})
set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1)
set_target_properties(dwarves PROPERTIES LINK_INTERFACE_LIBRARIES "")
@@ -53,11 +56,11 @@ target_link_libraries(dwarves_reorganize
set(codiff_SRCS codiff.c)
add_executable(codiff ${codiff_SRCS})
-target_link_libraries(codiff dwarves)
+target_link_libraries(codiff dwarves ${ARGP})
set(ctracer_SRCS ctracer.c)
add_executable(ctracer ${ctracer_SRCS})
-target_link_libraries(ctracer dwarves dwarves_emit dwarves_reorganize ${ELF_LIBRARY})
+target_link_libraries(ctracer dwarves dwarves_emit dwarves_reorganize ${ELF_LIBRARY} ${ARGP})
set(dtagnames_SRCS dtagnames.c)
add_executable(dtagnames ${dtagnames_SRCS})
@@ -65,19 +68,19 @@ target_link_libraries(dtagnames dwarves)
set(pahole_SRCS pahole.c)
add_executable(pahole ${pahole_SRCS})
-target_link_libraries(pahole dwarves dwarves_reorganize)
+target_link_libraries(pahole dwarves dwarves_reorganize ${ARGP})
set(pdwtags_SRCS pdwtags.c)
add_executable(pdwtags ${pdwtags_SRCS})
-target_link_libraries(pdwtags dwarves)
+target_link_libraries(pdwtags dwarves ${ARGP})
set(pglobal_SRCS pglobal.c)
add_executable(pglobal ${pglobal_SRCS})
-target_link_libraries(pglobal dwarves)
+target_link_libraries(pglobal dwarves ${ARGP})
set(pfunct_SRCS pfunct.c )
add_executable(pfunct ${pfunct_SRCS})
-target_link_libraries(pfunct dwarves dwarves_emit ${ELF_LIBRARY})
+target_link_libraries(pfunct dwarves dwarves_emit ${ELF_LIBRARY} ${ARGP})
set(prefcnt_SRCS prefcnt.c)
add_executable(prefcnt ${prefcnt_SRCS})
@@ -89,7 +92,7 @@ target_link_libraries(scncopy dwarves ${
set(syscse_SRCS syscse.c)
add_executable(syscse ${syscse_SRCS})
-target_link_libraries(syscse dwarves)
+target_link_libraries(syscse dwarves ${ARGP})
install(TARGETS codiff ctracer dtagnames pahole pdwtags
pfunct pglobal prefcnt scncopy syscse RUNTIME DESTINATION
--- ctf_loader.c.orig 2012-03-20 16:17:25 UTC
+++ ctf_loader.c
@@ -11,7 +11,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <stddef.h>
-#include <malloc.h>
#include <string.h>
#include <limits.h>
#include <libgen.h>
--- dtagnames.c.orig 2012-03-20 16:17:25 UTC
+++ dtagnames.c
@@ -9,16 +9,33 @@
#include <stdio.h>
#include <stdlib.h>
-#include <malloc.h>
+
+/* For mallctl */
+#include <err.h>
+#include <errno.h>
+#include <malloc_np.h>
#include "dwarves.h"
#include "dutil.h"
static void print_malloc_stats(void)
{
+#if 0
struct mallinfo m = mallinfo();
fprintf(stderr, "size: %u\n", m.uordblks);
+#else
+ size_t allocated, olen;
+ int rc;
+
+ olen = sizeof(allocated);
+ rc = mallctl("stats.allocated", &allocated, &olen, NULL, 0);
+ if (rc != 0) {
+ errno = rc;
+ err(1, "mallctl stats.allocated");
+ }
+ fprintf(stderr, "size: %zu\n", allocated);
+#endif
}
static int class__tag_name(struct tag *self, struct cu *cu __unused,
--- dutil.h.orig 2012-03-20 16:17:25 UTC
+++ dutil.h
@@ -25,7 +25,9 @@
#define __pure __attribute__ ((pure))
#endif
+#ifndef roundup
#define roundup(x,y) ((((x) + ((y) - 1)) / (y)) * (y))
+#endif
static inline __attribute__((const)) bool is_power_of_2(unsigned long n)
{
--- dwarves.c.orig 2012-03-20 16:17:25 UTC
+++ dwarves.c
@@ -16,6 +16,8 @@
#include <fcntl.h>
#include <fnmatch.h>
#include <libelf.h>
+/* For PATH_MAX */
+#include <limits.h>
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
--- dwarves_fprintf.c.orig 2012-03-20 16:18:48 UTC
+++ dwarves_fprintf.c
@@ -9,6 +9,9 @@
published by the Free Software Foundation.
*/
+/* For CACHE_LINE_SIZE */
+#include <sys/param.h>
+
#include <dwarf.h>
#include <errno.h>
#include <stdio.h>
@@ -74,7 +77,6 @@ static const char *dwarf_tag_names[] = {
[DW_TAG_unspecified_type] = "unspecified_type",
[DW_TAG_partial_unit] = "partial_unit",
[DW_TAG_imported_unit] = "imported_unit",
- [DW_TAG_mutable_type] = "mutable_type",
[DW_TAG_condition] = "condition",
[DW_TAG_shared_type] = "shared_type",
#ifdef STB_GNU_UNIQUE
@@ -1664,7 +1666,14 @@ void cus__print_error_msg(const char *pr
void dwarves__fprintf_init(uint16_t user_cacheline_size)
{
if (user_cacheline_size == 0) {
+#if 0
long sys_cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
+#else
+ /*
+ * CEM: Ideally we could get this programmatically.
+ */
+ long sys_cacheline_size = CACHE_LINE_SIZE;
+#endif
if (sys_cacheline_size > 0)
cacheline_size = sys_cacheline_size;
--- elf_symtab.c.orig 2012-03-20 16:17:25 UTC
+++ elf_symtab.c
@@ -7,8 +7,8 @@
published by the Free Software Foundation.
*/
-#include <malloc.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "dutil.h"
--- exitfail.h.orig 2016-07-14 04:42:52 UTC
+++ exitfail.h
@@ -0,0 +1,2 @@
+#pragma once
+#define exit_failure EXIT_FAILURE
--- libctf.c.orig 2012-03-20 16:17:25 UTC
+++ libctf.c
@@ -1,7 +1,8 @@
+#include <sys/stat.h>
+
#include <fcntl.h>
#include <gelf.h>
#include <limits.h>
-#include <malloc.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
--- pdwtags.c.orig 2012-05-14 22:41:11 UTC
+++ pdwtags.c
@@ -9,7 +9,6 @@
#include <argp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <malloc.h>
#include "dwarves.h"
#include "dutil.h"
--- pglobal.c.orig 2012-03-20 16:17:25 UTC
+++ pglobal.c
@@ -8,7 +8,6 @@
*/
#include <argp.h>
-#include <malloc.h>
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
@@ -92,7 +91,7 @@ static void extvar__add(const struct var
nodep = tsearch(gvar, &tree, extvar__compare);
if (nodep == NULL)
oom("tsearch");
- else if (*nodep != gvar)
+ else if (*nodep != gvar) {
if (gvar->var->declaration) {
gvar->next = (*nodep)->next;
(*nodep)->next = gvar;
@@ -100,6 +99,7 @@ static void extvar__add(const struct var
gvar->next = *nodep;
*nodep = gvar;
}
+ }
}
}
@@ -313,7 +313,10 @@ int main(int argc, char *argv[])
twalk(tree, function_action__walk);
}
+#if 0
+ /* Our search.h doesn't implement tdestroy; leak for now. */
tdestroy(tree, free_node);
+#endif
rc = EXIT_SUCCESS;
out_cus_delete:
cus__delete(cus);
--- prefcnt.c.orig 2012-03-20 16:17:25 UTC
+++ prefcnt.c
@@ -66,9 +66,11 @@ static void refcnt_tag(struct tag *tag,
tag->visited = 1;
- if (tag__is_struct(tag) || tag__is_union(tag))
- type__for_each_member(tag__type(tag), member)
+ if (tag__is_struct(tag) || tag__is_union(tag)) {
+ type__for_each_member(tag__type(tag), member) {
refcnt_member(member, cu);
+ }
+ }
}
static void refcnt_lexblock(const struct lexblock *lexblock, const struct cu *cu)
--- strings.c.orig 2012-03-20 16:17:25 UTC
+++ strings.c
@@ -39,7 +39,10 @@ void strings__delete(struct strings *sel
{
if (self == NULL)
return;
+#if 0
+ /* Our search.h doesn't implement tdestroy; leak for now. */
tdestroy(self->tree, do_nothing);
+#endif
__gobuffer__delete(&self->gb);
free(self);
}
Dwarves is a set of tools that use the debugging information inserted in ELF
binaries by compilers such as GCC, used by well known debuggers such as GDB,
and more recent ones such as systemtap.
Utilities in the dwarves suite include pahole, that can be used to find
alignment holes in structs and classes in languages such as C, C++, but not
limited to these.
It also extracts other information such as CPU cacheline alignment, helping
pack those structures to achieve more cache hits.
A diff like tool, codiff can be used to compare the effects changes in source
code generate on the resulting binaries.
Another tool is pfunct, that can be used to find all sorts of information about
functions, inlines, decisions made by the compiler about inlining, etc.
WWW: http://acmel.wordpress.com/
bin/codiff
bin/ctracer
bin/dtagnames
bin/ostra-cg
bin/pahole
bin/pdwtags
bin/pfunct
bin/pglobal
bin/prefcnt
bin/scncopy
bin/syscse
include/dwarves/dutil.h
include/dwarves/dwarves.h
include/dwarves/dwarves_emit.h
include/dwarves/dwarves_reorganize.h
include/dwarves/gobuffer.h
include/dwarves/list.h
include/dwarves/rbtree.h
include/dwarves/strings.h
lib/libdwarves.so
lib/libdwarves.so.1
lib/libdwarves.so.1.0.0
lib/libdwarves_emit.so
lib/libdwarves_emit.so.1
lib/libdwarves_emit.so.1.0.0
lib/libdwarves_reorganize.so
lib/libdwarves_reorganize.so.1
lib/libdwarves_reorganize.so.1.0.0
%%DATADIR%%/runtime/Makefile
%%DATADIR%%/runtime/ctracer_relay.c
%%DATADIR%%/runtime/ctracer_relay.h
%%DATADIR%%/runtime/linux.blacklist.cu
%%DATADIR%%/runtime/python/ostra.py
share/man/man1/pahole.1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment