Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 May 2020 17:31:58 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r534280 - in head/devel: . dwarves dwarves/files
Message-ID:  <202005071731.047HVwu3055079@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem (src committer)
Date: Thu May  7 17:31:57 2020
New Revision: 534280
URL: https://svnweb.freebsd.org/changeset/ports/534280

Log:
  devel/dwarves: Add new port
  
  Approved by:	jrm
  Differential Revision:	https://reviews.freebsd.org/D24746

Added:
  head/devel/dwarves/
  head/devel/dwarves/Makefile   (contents, props changed)
  head/devel/dwarves/distinfo   (contents, props changed)
  head/devel/dwarves/files/
  head/devel/dwarves/files/patch-CMakeLists.txt   (contents, props changed)
  head/devel/dwarves/files/patch-dtagnames.c   (contents, props changed)
  head/devel/dwarves/files/patch-dwarves__fprintf.c   (contents, props changed)
  head/devel/dwarves/files/patch-freebsd__compat.h   (contents, props changed)
  head/devel/dwarves/files/patch-lib_bpf_src_btf.c   (contents, props changed)
  head/devel/dwarves/files/patch-lib_bpf_src_libbpf.c   (contents, props changed)
  head/devel/dwarves/pkg-descr   (contents, props changed)
  head/devel/dwarves/pkg-plist   (contents, props changed)
Modified:
  head/devel/Makefile

Modified: head/devel/Makefile
==============================================================================
--- head/devel/Makefile	Thu May  7 17:27:03 2020	(r534279)
+++ head/devel/Makefile	Thu May  7 17:31:57 2020	(r534280)
@@ -503,6 +503,7 @@
     SUBDIR += duplo
     SUBDIR += dwarf2json
     SUBDIR += dwarfdump
+    SUBDIR += dwarves
     SUBDIR += dxa65
     SUBDIR += dyncall
     SUBDIR += e00compr

Added: head/devel/dwarves/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/Makefile	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,63 @@
+# Created by: Conrad Meyer <cem@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	dwarves
+DISTVERSION=	1.17
+CATEGORIES=	devel
+MASTER_SITES=	https://fedorapeople.org/~acme/dwarves/
+
+MAINTAINER=	cem@FreeBSD.org
+COMMENT=	Debugging Information Manipulation Tools (pahole & friends)
+
+LICENSE=	BSD2CLAUSE GPLv2 LGPL21
+LICENSE_COMB=	multi
+LICENSE_FILE_BSD2CLAUSE=	${WRKSRC}/lib/bpf/LICENSE.BSD-2-Clause
+LICENSE_FILE_GPLv2=	${WRKSRC}/COPYING
+LICENSE_FILE_LGPL21=	${WRKSRC}/lib/bpf/LICENSE.LPGL-2.1
+
+IGNORE_FreeBSD_11=	inherited from dependency devel/elfutils
+
+BUILD_DEPENDS=	gnulib>=0:devel/gnulib
+LIB_DEPENDS=	libargp.so:devel/argp-standalone \
+		libdw.so:devel/elfutils
+
+USES=		cmake gettext python:3.7+,env shebangfix tar:xz
+USE_GCC=	9+
+USE_LDCONFIG=	yes
+
+SHEBANG_FILES=	btfdiff fullcircle ostra/ostra-cg ostra/python/ostra.py
+
+CFLAGS+=	-I${WRKSRC}
+
+OPTIONS_DEFINE=		MANPAGES
+OPTIONS_DEFAULT=	MANPAGES
+OPTIONS_SUB=		yes
+
+post-patch:
+	${REINPLACE_CMD} -e 's,#include <malloc.h>,#include <stdlib.h>,' \
+	    ${WRKSRC}/*.c
+	@${MKDIR} ${WRKSRC}/asm \
+	    ${WRKSRC}/bits \
+	    ${WRKSRC}/linux
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/asm/bitsperlong.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/asm/errno.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/asm/posix_types.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/asm/types.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/asm/unistd.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/bits/reg.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/endian.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/exitfail.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/gettext.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/linux/limits.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/linux/types.h
+	${LN} -s ${WRKSRC}/freebsd_compat.h ${WRKSRC}/vasnprintf.h
+
+pre-configure:
+	${CP} -a \
+	    ${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.c ${WRKSRC}/obstack.h
+
+.include <bsd.port.mk>

Added: head/devel/dwarves/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/distinfo	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1584128313
+SHA256 (dwarves-1.17.tar.xz) = f196b0604c16a3812031ed2cd4c14d27fef889186b514a16db2d2f52717aef70
+SIZE (dwarves-1.17.tar.xz) = 309028

Added: head/devel/dwarves/files/patch-CMakeLists.txt
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-CMakeLists.txt	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,48 @@
+--- CMakeLists.txt.orig	2020-03-13 17:13:35 UTC
++++ CMakeLists.txt
+@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMA
+ # Try to parse this later, Helio just showed me a KDE4 example to support
+ # x86-64 builds.
+ # the following are directories where stuff will be installed to
+-set(__LIB "" CACHE STRING "Define suffix of directory name (32/64)" )
++set(__LIB "lib" CACHE STRING "Define suffix of directory name (32/64)" )
+ 
+ macro(_set_fancy _var _value _comment)
+ 	if (NOT DEFINED ${_var})
+@@ -76,7 +76,7 @@ endif()
+ 
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
+ 
+-file(GLOB libbpf_sources "lib/bpf/src/*.c")
++set(libbpf_sources lib/bpf/src/btf.c lib/bpf/src/hashmap.c lib/bpf/src/libbpf.c)
+ add_library(bpf OBJECT ${libbpf_sources})
+ set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1)
+ target_include_directories(bpf PRIVATE
+@@ -85,13 +85,13 @@ target_include_directories(bpf PRIVATE
+ 
+ set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings
+ 		     ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c
+-		     dwarf_loader.c dutil.c elf_symtab.c rbtree.c)
++		     dwarf_loader.c dutil.c elf_symtab.c rbtree.c obstack.c)
+ add_library(dwarves SHARED ${dwarves_LIB_SRCS} $<TARGET_OBJECTS:bpf>)
+ set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1)
+ set_target_properties(dwarves PROPERTIES INTERFACE_LINK_LIBRARIES "")
+ target_include_directories(dwarves PRIVATE
+ 			   ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
+-target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES})
++target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES} libargp.so libintl.so)
+ 
+ set(dwarves_emit_LIB_SRCS dwarves_emit.c)
+ add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS})
+@@ -153,9 +153,10 @@ install(FILES dwarves.h dwarves_emit.h dwarves_reorgan
+ 	      btf_encoder.h config.h ctf_encoder.h ctf.h
+ 	      elfcreator.h elf_symtab.h hash.h libbtf.h libctf.h
+ 	DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/)
+-install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/)
++install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1/)
+ install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ install(PROGRAMS btfdiff fullcircle DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
++install(FILES changes-v1.17 README README.btf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/dwarves)
+ install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python)
+ install(FILES lib/Makefile lib/ctracer_relay.c lib/ctracer_relay.h lib/linux.blacklist.cu
+ 	DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime)

Added: head/devel/dwarves/files/patch-dtagnames.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-dtagnames.c	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,35 @@
+--- dtagnames.c.orig	2019-05-01 15:06:45 UTC
++++ dtagnames.c
+@@ -7,16 +7,31 @@
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+-#include <malloc.h>
++#ifdef __FreeBSD__
++#include <err.h>
++#include <malloc_np.h>
++#else
++#endif
+ 
+ #include "dwarves.h"
+ #include "dutil.h"
+ 
+ static void print_malloc_stats(void)
+ {
++#ifdef __FreeBSD__
++	int error;
++	size_t allocated, sz;
++
++	sz = sizeof(allocated);
++	error = mallctl("stats.active", &allocated, &sz, NULL, 0);
++	if (error != 0)
++		errc(1, error, "mallctl(stats.active)");
++	fprintf(stderr, "size: %zu\n", allocated);
++#else
+ 	struct mallinfo m = mallinfo();
+ 
+ 	fprintf(stderr, "size: %u\n", m.uordblks);
++#endif
+ }
+ 
+ static int class__tag_name(struct tag *tag, struct cu *cu __unused,

Added: head/devel/dwarves/files/patch-dwarves__fprintf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-dwarves__fprintf.c	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,25 @@
+--- dwarves_fprintf.c.orig	2020-05-06 22:11:18 UTC
++++ dwarves_fprintf.c
+@@ -7,6 +7,8 @@
+   Copyright (C) 2007..2009 Arnaldo Carvalho de Melo <acme@redhat.com>
+ */
+ 
++#include <sys/param.h>
++
+ #include <dwarf.h>
+ #include <errno.h>
+ #include <stdio.h>
+@@ -1910,12 +1912,7 @@ void cus__print_error_msg(const char *progname, const 
+ void dwarves__fprintf_init(uint16_t user_cacheline_size)
+ {
+ 	if (user_cacheline_size == 0) {
+-		long sys_cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
+-
+-		if (sys_cacheline_size > 0)
+-			cacheline_size = sys_cacheline_size;
+-		else
+-			cacheline_size = 64; /* Fall back to a sane value */
++		cacheline_size = CACHE_LINE_SIZE;
+ 	} else
+ 		cacheline_size = user_cacheline_size;
+ }

Added: head/devel/dwarves/files/patch-freebsd__compat.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-freebsd__compat.h	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,56 @@
+--- freebsd_compat.h.orig	2020-05-07 14:22:21 UTC
++++ freebsd_compat.h
+@@ -0,0 +1,53 @@
++#pragma once
++
++#include <sys/cdefs.h>
++#include <sys/stat.h>
++#include <errno.h>
++#include <limits.h>
++#include <stdint.h>
++#include <stdlib.h>
++
++#include <libintl.h>
++
++/* asm/bitsperlong.h */
++/*
++ * In FreeBSD, __ILP32__ / __LP64__ are canonical, but gcc does not correctly
++ * emit __ILP32__ in 32-bit mode, at least on i386.
++ */
++#if __SIZEOF_LONG__ == 4 /* defined(__ILP32__) */
++#define	__BITS_PER_LONG	32
++#elif __SIZEOF_LONG__ == 8 /* defined(__LP64__) */
++#define	__BITS_PER_LONG	64
++#else
++#error "I'm a teapot"
++#endif
++
++/* asm/types.h */
++typedef uint8_t __u8;
++typedef uint16_t __u16;
++typedef uint32_t __u32;
++typedef uint64_t __u64;
++typedef int8_t __s8;
++typedef int16_t __s16;
++typedef int32_t __s32;
++typedef int64_t __s64;
++
++/* linux/types.h */
++typedef uint16_t __be16;
++typedef uint32_t __be32;
++typedef uint64_t __be64;
++typedef uint16_t __le16;
++typedef uint32_t __le32;
++typedef uint64_t __le64;
++#define	__aligned_u64	__u64 __attribute__((aligned(8)))
++
++/* "exitfail.h" */
++#define	exit_failure	EXIT_FAILURE
++
++/* search.h */
++static inline void
++tdestroy(void *vroot __unused, void (*freefct)(void *) __unused)
++{
++
++	/* XXX: Just leak the memory for now. */
++}

Added: head/devel/dwarves/files/patch-lib_bpf_src_btf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-lib_bpf_src_btf.c	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,47 @@
+--- lib/bpf/src/btf.c.orig	2020-03-12 19:57:29 UTC
++++ lib/bpf/src/btf.c
+@@ -436,6 +436,7 @@ done:
+ 	return btf;
+ }
+ 
++#ifndef __FreeBSD__
+ static bool btf_check_endianness(const GElf_Ehdr *ehdr)
+ {
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+@@ -684,6 +685,7 @@ done:
+ 	free(log_buf);
+ 	return err;
+ }
++#endif /* !FreeBSD */
+ 
+ int btf__fd(const struct btf *btf)
+ {
+@@ -704,6 +706,7 @@ const char *btf__name_by_offset(const struct btf *btf,
+ 		return NULL;
+ }
+ 
++#ifndef __FreeBSD__
+ int btf__get_from_id(__u32 id, struct btf **btf)
+ {
+ 	struct bpf_btf_info btf_info = { 0 };
+@@ -767,6 +770,7 @@ exit_free:
+ 
+ 	return err;
+ }
++#endif /* !FreeBSD */
+ 
+ int btf__get_map_kv_tids(const struct btf *btf, const char *map_name,
+ 			 __u32 expected_key_size, __u32 expected_value_size,
+@@ -2936,6 +2940,7 @@ static int btf_dedup_remap_types(struct btf_dedup *d)
+ 	return 0;
+ }
+ 
++#ifndef __FreeBSD__
+ static struct btf *btf_load_raw(const char *path)
+ {
+ 	struct btf *btf;
+@@ -3021,3 +3026,4 @@ struct btf *libbpf_find_kernel_btf(void)
+ 	pr_warn("failed to find valid kernel BTF\n");
+ 	return ERR_PTR(-ESRCH);
+ }
++#endif /* !FreeBSD */

Added: head/devel/dwarves/files/patch-lib_bpf_src_libbpf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/files/patch-lib_bpf_src_libbpf.c	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,48 @@
+--- lib/bpf/src/libbpf.c.orig	2020-03-12 19:57:29 UTC
++++ lib/bpf/src/libbpf.c
+@@ -29,18 +29,12 @@
+ #include <linux/kernel.h>
+ #include <linux/bpf.h>
+ #include <linux/btf.h>
+-#include <linux/filter.h>
+ #include <linux/list.h>
+ #include <linux/limits.h>
+-#include <linux/perf_event.h>
+-#include <linux/ring_buffer.h>
+-#include <linux/version.h>
+-#include <sys/epoll.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+-#include <sys/vfs.h>
+ #include <sys/utsname.h>
+ #include <sys/resource.h>
+ #include <tools/libc_compat.h>
+@@ -73,11 +67,13 @@
+ 
+ #define __printf(a, b)	__attribute__((format(printf, a, b)))
+ 
++#ifndef __FreeBSD__
+ static struct bpf_map *bpf_object__add_map(struct bpf_object *obj);
+ static struct bpf_program *bpf_object__find_prog_by_idx(struct bpf_object *obj,
+ 							int idx);
+ static const struct btf_type *
+ skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
++#endif /* !__FreeBSD__ */
+ 
+ static int __base_pr(enum libbpf_print_level level, const char *format,
+ 		     va_list args)
+@@ -111,6 +107,7 @@ void libbpf_print(enum libbpf_print_level level, const
+ 	va_end(args);
+ }
+ 
++#ifndef __FreeBSD__
+ static void pr_perm_msg(int err)
+ {
+ 	struct rlimit limit;
+@@ -8396,3 +8387,4 @@ void bpf_object__destroy_skeleton(struct bpf_object_sk
+ 	free(s->progs);
+ 	free(s);
+ }
++#endif /* !__FreeBSD__ */

Added: head/devel/dwarves/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/pkg-descr	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,5 @@
+Pahole and the dwarves is a collection of libraries and tools for manipulating
+DWARF debuginfo in ELF binaries, as well as BTF and CTF compressed type
+metadata for tracing (i.e., Dtrace, eBPF).
+
+WWW: https://acmel.wordpress.com

Added: head/devel/dwarves/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/dwarves/pkg-plist	Thu May  7 17:31:57 2020	(r534280)
@@ -0,0 +1,48 @@
+bin/btfdiff
+bin/codiff
+bin/ctracer
+bin/dtagnames
+bin/fullcircle
+bin/pahole
+bin/pdwtags
+bin/pfunct
+bin/pglobal
+bin/prefcnt
+bin/scncopy
+bin/syscse
+bin/ostra-cg
+include/dwarves/btf_encoder.h
+include/dwarves/config.h
+include/dwarves/ctf_encoder.h
+include/dwarves/ctf.h
+include/dwarves/dutil.h
+include/dwarves/dwarves.h
+include/dwarves/dwarves_emit.h
+include/dwarves/dwarves_reorganize.h
+include/dwarves/elfcreator.h
+include/dwarves/elf_symtab.h
+include/dwarves/gobuffer.h
+include/dwarves/hash.h
+include/dwarves/libbtf.h
+include/dwarves/libctf.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/linux.blacklist.cu
+%%DATADIR%%/runtime/ctracer_relay.c
+%%DATADIR%%/runtime/ctracer_relay.h
+%%DATADIR%%/runtime/python/ostra.py
+%%DOCSDIR%%/changes-v1.17
+%%DOCSDIR%%/README
+%%DOCSDIR%%/README.btf
+%%MANPAGES%%man/man1/pahole.1.gz



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005071731.047HVwu3055079>