aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorjmd <jmd@FreeBSD.org>2017-04-02 01:58:59 +0800
committerjmd <jmd@FreeBSD.org>2017-04-02 01:58:59 +0800
commitf66d7c64c8b217e30ea4b9dfe40f10fd2ae4c6c0 (patch)
tree4abd33c67d210df1e8d6d75aa4eb516b942b13c4 /java
parentce0df77c655f5f42ab1881341aa2e09d18c7729e (diff)
downloadfreebsd-ports-gnome-f66d7c64c8b217e30ea4b9dfe40f10fd2ae4c6c0.tar.gz
freebsd-ports-gnome-f66d7c64c8b217e30ea4b9dfe40f10fd2ae4c6c0.tar.zst
freebsd-ports-gnome-f66d7c64c8b217e30ea4b9dfe40f10fd2ae4c6c0.zip
new port: java/lightweight-java-profiler
A port of the lightweight-java-profiler (ljp). ljp acts as a bare-bones agentlib to produce profiling stacks that can be digested, e.g., by Brendan Gregg's flamegraph scripts. Reviewed by: mat, swills (mentor) Approved by: swills (mentor) Differential Revision: https://reviews.freebsd.org/D10194
Diffstat (limited to 'java')
-rw-r--r--java/Makefile1
-rw-r--r--java/lightweight-java-profiler/Makefile47
-rw-r--r--java/lightweight-java-profiler/distinfo3
-rw-r--r--java/lightweight-java-profiler/files/patch-Makefile41
-rw-r--r--java/lightweight-java-profiler/files/patch-src_display.cc11
-rw-r--r--java/lightweight-java-profiler/files/patch-src_entry.cc20
-rw-r--r--java/lightweight-java-profiler/files/patch-src_globals.h23
-rw-r--r--java/lightweight-java-profiler/pkg-descr9
-rw-r--r--java/lightweight-java-profiler/pkg-message3
9 files changed, 158 insertions, 0 deletions
diff --git a/java/Makefile b/java/Makefile
index e8d4ab2b4281..a66594396517 100644
--- a/java/Makefile
+++ b/java/Makefile
@@ -90,6 +90,7 @@
SUBDIR += junit
SUBDIR += jxgrabkey
SUBDIR += langspec
+ SUBDIR += lightweight-java-profiler
SUBDIR += linux-oracle-jdk18
SUBDIR += linux-oracle-jre18
SUBDIR += mmake
diff --git a/java/lightweight-java-profiler/Makefile b/java/lightweight-java-profiler/Makefile
new file mode 100644
index 000000000000..57e877cf83d1
--- /dev/null
+++ b/java/lightweight-java-profiler/Makefile
@@ -0,0 +1,47 @@
+# Created by: Johannes Dieterich <jmd@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME= lightweight-java-profiler
+PORTVERSION= g20170308
+CATEGORIES= java devel
+
+MAINTAINER= jmd@FreeBSD.org
+COMMENT= Lightweight Java profiler which can be used for flamegraphs
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/COPYING
+
+BUILD_DEPENDS= bash>=0:shells/bash
+RUN_DEPENDS= bash>=0:shells/bash
+
+ONLY_FOR_ARCHS= amd64 i386
+ONLY_FOR_ARCHS_REASON= assembly only available for x86
+
+USE_GITHUB= yes
+GH_ACCOUNT= inevity
+GH_TAGNAME= e8041b5
+
+USE_JAVA= yes
+JAVA_VERSION= 1.8
+
+USE_LDCONFIG= yes
+USES= gmake shebangfix
+
+SHEBANG_FILES= Makefile
+
+MAKE_ENV= JAVA_HOME=${LOCALBASE}/openjdk8
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == "i386"
+MAKE_ENV+= BITS=32
+.else
+MAKE_ENV+= BITS=64
+.endif
+
+PLIST_FILES= lib/liblagent.so
+
+do-install:
+ ${INSTALL_LIB} ${WRKSRC}/build/liblagent.so ${STAGEDIR}/${LOCALBASE}/lib/liblagent.so
+
+.include <bsd.port.post.mk>
diff --git a/java/lightweight-java-profiler/distinfo b/java/lightweight-java-profiler/distinfo
new file mode 100644
index 000000000000..8336d2e06bca
--- /dev/null
+++ b/java/lightweight-java-profiler/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1490927903
+SHA256 (inevity-lightweight-java-profiler-g20170308-e8041b5_GH0.tar.gz) = b5a64716586407ff69c3c77a0621e6b65e9580686ae9ec29b145becd65fa678e
+SIZE (inevity-lightweight-java-profiler-g20170308-e8041b5_GH0.tar.gz) = 16120
diff --git a/java/lightweight-java-profiler/files/patch-Makefile b/java/lightweight-java-profiler/files/patch-Makefile
new file mode 100644
index 000000000000..d492da56611c
--- /dev/null
+++ b/java/lightweight-java-profiler/files/patch-Makefile
@@ -0,0 +1,41 @@
+--- Makefile.orig 2017-03-31 01:58:22 UTC
++++ Makefile
+@@ -1,7 +1,7 @@
+-SHELL:=/bin/bash
++SHELL:=/usr/bin/env bash
+ UNAME:=$(shell uname | tr '[A-Z]' '[a-z]')
+
+-BITS?=32
++#BITS?=32
+ ifeq ($(UNAME), darwin)
+ READLINK_ARGS:=""
+ PLATFORM_WARNINGS:=-Weverything -Wno-c++98-compat-pedantic -Wno-padded \
+@@ -23,6 +23,13 @@ else ifeq ($(UNAME), linux)
+ HEADERS:=include
+ CC=g++
+ LDFLAGS=-Wl,--fatal-warnings
++else ifeq ($(UNAME), freebsd)
++ READLINK_ARGS:=""
++ PLATFORM_WARNINGS:=-Weverything -Wno-c++98-compat-pedantic -Wno-padded \
++ -Wno-missing-prototypes
++ PLATFORM_COPTS:=-std=c++11
++ HEADERS:=include
++ LDFLAGS=-Wl,-fatal_warnings
+ endif
+
+ JAVA_HOME := $(shell \
+@@ -32,11 +39,11 @@ JAVA_HOME := $(shell \
+ [[ -n "$${JAVA_HOME}" ]] || (echo "Cannot find JAVA_HOME" && exit) ; \
+ echo $${JAVA_HOME})
+ AGENT=liblagent.so
+-LIBS=-ldl
+-BUILD_DIR ?= $(shell mkdir build-$(BITS) 2> /dev/null ; echo build-$(BITS))
++LIBS=-lc
++BUILD_DIR ?= $(shell mkdir build 2> /dev/null ; echo build)
+ SRC_DIR:=${PWD}/src
+ OPT?=-O2
+-GLOBAL_WARNINGS=-Wall -Werror -Wformat-security -Wno-char-subscripts \
++GLOBAL_WARNINGS=-Wall -Wformat-security -Wno-char-subscripts \
+ -Wno-sign-compare -Wno-strict-overflow -Wwrite-strings -Wnon-virtual-dtor \
+ -Woverloaded-virtual
+ GLOBAL_COPTS=-fdiagnostics-show-option -fno-exceptions \
diff --git a/java/lightweight-java-profiler/files/patch-src_display.cc b/java/lightweight-java-profiler/files/patch-src_display.cc
new file mode 100644
index 000000000000..b01d0400482b
--- /dev/null
+++ b/java/lightweight-java-profiler/files/patch-src_display.cc
@@ -0,0 +1,11 @@
+--- src/display.cc.orig 2015-04-15 08:00:23 UTC
++++ src/display.cc
+@@ -20,7 +20,7 @@ void StackTracesPrinter::PrintStackTrace
+ if (traces[i].count != 0) {
+ total += traces[i].count;
+ count++;
+- fprintf(file_, "%"PRIdPTR" ", traces[i].count);
++ fprintf(file_, "%" PRIdPTR" ", traces[i].count);
+ PrintStackTrace(&traces[i]);
+ fprintf(file_, "\n");
+ }
diff --git a/java/lightweight-java-profiler/files/patch-src_entry.cc b/java/lightweight-java-profiler/files/patch-src_entry.cc
new file mode 100644
index 000000000000..f70fbbc63406
--- /dev/null
+++ b/java/lightweight-java-profiler/files/patch-src_entry.cc
@@ -0,0 +1,20 @@
+--- src/entry.cc.orig 2015-04-15 08:00:23 UTC
++++ src/entry.cc
+@@ -182,7 +182,7 @@ static void SetFileFromOption(char *equa
+ if (Globals::OutFile == NULL) {
+ fprintf(stderr, "Could not open file %s: ", file_name);
+ perror(NULL);
+- exit(1);
++ _exit(1);
+ }
+ }
+
+@@ -207,7 +207,7 @@ static void ParseArguments(char *options
+ char path[PATH_MAX];
+ if (getcwd(path, PATH_MAX) == NULL) {
+ fprintf(stderr, "cwd too long?\n");
+- exit(0);
++ _exit(0);
+ }
+ size_t pathlen = strlen(path);
+ strncat(path, "/", PATH_MAX - (pathlen++));
diff --git a/java/lightweight-java-profiler/files/patch-src_globals.h b/java/lightweight-java-profiler/files/patch-src_globals.h
new file mode 100644
index 000000000000..fd9eb3a9e977
--- /dev/null
+++ b/java/lightweight-java-profiler/files/patch-src_globals.h
@@ -0,0 +1,23 @@
+--- src/globals.h.orig 2015-04-15 08:00:23 UTC
++++ src/globals.h
+@@ -179,18 +179,13 @@ class Accessors {
+ #endif
+ };
+
+-#if defined(__GNUC__) && (defined(i386) || defined(__x86_64))
+ #if defined(__x86_64__)
+ #define __CAS_INSTR "lock; cmpxchgq %1,%2"
+ #define __ADD_INSTR "lock; xaddq %0,%1"
+-#else // defined(__x86_64__)
++#else
+ #define __CAS_INSTR "lock; cmpxchgl %1,%2"
+ #define __ADD_INSTR "lock; xaddl %0,%1"
+-#endif // defined(__x86_64__)
+-#else // defined(__GNUC__) && (defined(i386) || defined(__x86_64))
+-#error \
+- "Cannot compile with non-x86. Add support for atomic ops, if you want it"
+-#endif // defined(__GNUC__) && (defined(i386) || defined(__x86_64))
++#endif
+
+ inline intptr_t NoBarrier_CompareAndSwap(volatile intptr_t *ptr,
+ intptr_t old_value,
diff --git a/java/lightweight-java-profiler/pkg-descr b/java/lightweight-java-profiler/pkg-descr
new file mode 100644
index 000000000000..fd0d538e2c73
--- /dev/null
+++ b/java/lightweight-java-profiler/pkg-descr
@@ -0,0 +1,9 @@
+lightweight-java-profiler
+
+a lightweight Java profiler which can be used for flamegraphs
+
+The lightweight Java profiler acts as an agent library and generates
+execution stacks. These can be fed into flamegraph utils to profile
+Java applications at minimal cost.
+
+WWW: https://github.com/inevity/lightweight-java-profiler
diff --git a/java/lightweight-java-profiler/pkg-message b/java/lightweight-java-profiler/pkg-message
new file mode 100644
index 000000000000..f957b294f48b
--- /dev/null
+++ b/java/lightweight-java-profiler/pkg-message
@@ -0,0 +1,3 @@
+To use the lightweight-java-profiler, you can invoke Java as follows:
+
+java -agentpath:path/to/liblagent.so[:file=fname] It will spit out stack traces into traces.txt (or into the optional fname passed to the agent). The current implementation samples every 1/100th of a second. It stores the first 3000 stack traces it encounters; additional stack traces will be ignored, but duplicate stack traces will continue to be counted indefinitely (or until the counter overflows, which will take a while).