Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from upstream (take 2) #4

Merged
merged 119 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
985738e
Replace source/target with release in pom.xml
apangin Jan 22, 2024
a175293
#881: --to/from arguments did not work with jfrsync
apangin Jan 24, 2024
7643623
#872: Get rid of libstdc++ streams
apangin Jan 27, 2024
03004b6
#769: Workaround for JDK-8312065 on JDK 8
apangin Jan 28, 2024
f657048
#885: Print error message if JVM fails to load libasyncProfiler.so
apangin Feb 5, 2024
deec218
#884: Record event timestamps early
apangin Feb 6, 2024
e751ea1
#886: Support cstack=vm for slowdebug JVM
apangin Feb 6, 2024
ad05845
Fix Proto encoding of negative integers (#889)
cklin Feb 7, 2024
3b2d969
Fix memory leak of keys from jvmti->GetSystemProperties (#891)
Charmik Feb 14, 2024
6248a87
Updated comment on -j option
apangin Feb 17, 2024
9fe16b6
#892: Resolve tracepoint id in asprof
apangin Feb 21, 2024
7be97a0
Fix DefineClass crash on OpenJ9
apangin Feb 23, 2024
ddc280d
#896: Flame Graph: alt+click to remove stacks
apangin Feb 28, 2024
cbecc6f
#893: Fix [no_Java_frame] on ARM64
apangin Mar 10, 2024
1be8838
Do not parse the same executable twice
apangin Mar 15, 2024
397f450
#759: Discover available profiling signal automatically
apangin Mar 16, 2024
a75ebc7
#905, #895: Converter enhancements
apangin Mar 16, 2024
241f5e3
Build failure due to missing -ldl
apangin Mar 19, 2024
5da0a5f
FlameGraph: search with Command+F key (⌘F) on mac (#906)
qwwdfsad Mar 22, 2024
978fe2c
Pack stack traces in pprof format
apangin Mar 26, 2024
005f7a3
Workaround dependency on GLIBCXX_3.4.20
apangin Apr 10, 2024
059cf13
#917: Allow `-e alloc,cpu,lock` syntax
apangin Apr 18, 2024
ac514e5
#914: Do not set DebugNonSafepoints, if it is already set in the Comm…
apangin Apr 19, 2024
2de2a18
jfrconv: autodetect pb.gz output format
apangin May 1, 2024
26a94a1
Build jfrconv.exe for Windows
apangin May 1, 2024
07e6015
#921: Fix compilation failure on ARM32
apangin May 3, 2024
9733a08
An option to accumulate JFR events in memory instead of flushing to a…
apangin May 7, 2024
b96d09a
Minor refactoring
apangin May 11, 2024
ed7d848
#928: Do not record live object samples between JFR chunks
apangin May 11, 2024
048cafa
#923: Adjust VMStructs for JDK 23
apangin May 13, 2024
0c4cd5c
#934: Fix crash on Zing in a native thread
apangin May 23, 2024
34a9e13
#923: cstack=vm support for JDK 23+
apangin May 24, 2024
2f30dc3
#940: lseek64 is not declared when compiling on Alpine/aarch64
apangin Jun 1, 2024
4753436
JfrReader should read strings in a constant pool
apangin Jun 11, 2024
dbcaa4d
JfrReader should jump over custom events
apangin Jun 11, 2024
33a65c8
#895: Rewrote jfrconv to make it a statically linked executable
apangin Jun 16, 2024
9660e15
Fix jfrconv build rules for macOS
apangin Jun 19, 2024
28fbb13
Handle truncated JFRs
apangin Jun 21, 2024
30f4f32
Cleanup dead code
apangin Jun 25, 2024
f4528de
Added CoC and Contributing Guidelines
apangin Jun 25, 2024
df4af83
Added issue and pull request templates
apangin Jun 25, 2024
0d90f1c
Do not package redundant .md files
apangin Jun 25, 2024
4e9f096
Simplify Makefile
apangin Jun 27, 2024
c253454
#952: Solve musl and glibc compatibility issues
apangin Jul 7, 2024
e38cd32
#952: Docker image for building async-profiler release packages for x…
apangin Jul 7, 2024
76c2024
Test framework and a set of new tests (#812, #951)
roy-soumadipta Jul 9, 2024
174e295
Test framework cleanup and fixes
apangin Jul 14, 2024
bd095f1
#955: Add --libpath option to specify the path of libasyncProfier.so …
yanglong1010 Jul 15, 2024
c9cb0c1
Minor cleanup
apangin Jul 16, 2024
6207d5d
Fix unsafe access to CodeCache
apangin Jul 16, 2024
09f0a8f
#959: JFR converter fails to filter thread states in jfrsync profiles
apangin Jul 18, 2024
7f712bb
Fixed recursion in pthread_create when using native profiling API
apangin Jul 26, 2024
78123a8
Fixed parsing non-PIC executables
apangin Jul 26, 2024
321a712
Added Native API test
apangin Jul 26, 2024
4011896
#929: Load symbols from debuginfod cache (#962)
krk Aug 7, 2024
179b0b1
Minor stylistic changes
apangin Aug 7, 2024
7631114
#843: Fix race between parsing and concurrent unloading of shared lib…
apangin Aug 12, 2024
02670cc
Fixed out-of-bounds array access in getDebuginfodCache()
apangin Aug 14, 2024
b8025a2
Make JfrClass field method public so that G1HeapSummary class has acc…
Alih789 Aug 14, 2024
d92b893
Add flamegraph to collapsed conversion in test framework (#976)
roy-soumadipta Aug 23, 2024
b9a3737
Avoid JVM crash by deleting JNI refs after calling GetMethodDeclaring…
krk Sep 4, 2024
25fa02e
Sample contended locks by overflowing interval bucket (#982)
krk Sep 9, 2024
c122fde
Enable jfr tests (#992)
roy-soumadipta Sep 12, 2024
69e0479
#993: Filter native frames in allocation profile
apangin Sep 13, 2024
e6a1581
Fix KernelTests#notLinux test (#997)
parttimenerd Sep 13, 2024
c299592
#993: Filter native frames in allocation profile: OpenJ9 and stripped…
apangin Sep 15, 2024
6d7f73a
Profiling output respects loglevel (#986)
krk Sep 17, 2024
69c9dda
An option to display instruction addresses (#1002)
apangin Sep 19, 2024
f66056a
Make profiler version and arch tag configurable (#1004)
shipilev Sep 20, 2024
0ed06fa
Tweak tests so that they pass more reliably (#1006)
openorclose Sep 24, 2024
2833cab
Whitespace at EOL
apangin Sep 25, 2024
d66717c
Add new test to validate JFR output with JDK JFR parser. (#1005)
roy-soumadipta Sep 25, 2024
82ebeda
Add missing copyright header. (#1010)
roy-soumadipta Sep 25, 2024
5a093b6
Fixed test compilation warnings
apangin Sep 25, 2024
e504460
#983: Added support for jfr->collapsed conversion
apangin Sep 25, 2024
a386afa
#1003: Support both tracefs and debugfs for kernel tracepoints
apangin Sep 25, 2024
f53bfd4
#1007: Optimize wall clock profiling
apangin Sep 26, 2024
f43a6f8
Lock sampling fixes:
apangin Sep 28, 2024
9db2631
Fixed test compatibility issues
apangin Sep 29, 2024
1ed9df9
Intercept java.util.concurrent locks more efficiently (#1013)
apangin Sep 30, 2024
2d04311
Fixed warnings with -Xcheck:jni
apangin Sep 30, 2024
1291692
Obtain can_generate_sampled_object_alloc_events JVMTI capability only…
openorclose Oct 9, 2024
37ff942
EventAggregator collects both samples and values
apangin Oct 9, 2024
061f03d
An option to coarsen flame graphs (#1018)
apangin Oct 10, 2024
e0885e3
Assert on total wait time in lock contention tests (#1017)
krk Oct 10, 2024
4208d5c
Minor style/formatting changes
apangin Oct 10, 2024
3992d6a
Fixed crashes on Alpine when profiling native apps
apangin Oct 10, 2024
445bafb
Do not fail sudo tests if running under root
apangin Oct 10, 2024
4ee2a5d
Log test args and inputs. (#1021)
krk Oct 11, 2024
74ffc67
Fix flaky tests
apangin Oct 14, 2024
80b59a0
Update tests to pass more reliably (#1022)
openorclose Oct 14, 2024
8c28cd8
Implement builds on each commit using Github Actions (#998)
openorclose Oct 16, 2024
63009d0
Update paths to codebuild runners (#1028)
openorclose Oct 16, 2024
da3f5f3
Reset CallTraceStorage counters before reporting live objects (#1009)
krk Oct 16, 2024
5a90a82
Add GHA to validate required license headers (#1016)
roy-soumadipta Oct 16, 2024
62dca46
Simplify java assertions and add messages to all (#1027)
krk Oct 17, 2024
59d2def
Next generation test runner (#1023)
krk Oct 18, 2024
ecd8f3a
Refactor nightly builds to delete previous release and create a new r…
openorclose Oct 18, 2024
6bd9dfa
Merged Dockerfiles
apangin Oct 20, 2024
08f29f8
Fix possible uninitialized variable access, method_class (#1034)
krk Oct 22, 2024
0432101
#1040: Removed the link to outdated wiki
apangin Oct 24, 2024
f59894d
EventAggregator helper method
apangin Oct 25, 2024
116504c
Initialize rem_* in DwarfParser.parseInstructions (#1039)
krk Oct 26, 2024
870833b
#1007: Use ExecutionSample event for CPU profiling and WallClockSampl…
apangin Nov 2, 2024
adecac7
Print exceptions in test output; measure test run time in seconds
apangin Nov 3, 2024
6c32ce9
#1044: Fall back to ctimer for CPU profiling when perf_events are una…
apangin Nov 4, 2024
6f2c6cc
Nightly builds enhancement (#1047)
openorclose Nov 6, 2024
0cd9726
#1044: Automatically switch on --all-user for non-CPU events if kerne…
apangin Nov 7, 2024
36168a1
#1041: Adjust SP of a caller frame obtained with __builtin_frame_address
apangin Nov 7, 2024
e6a319e
Increase setup_lib_path buf size to PATH_MAX (#1049)
krk Nov 8, 2024
083d85f
Upload hs_err logs to artifacts (#1050)
openorclose Nov 8, 2024
f863502
Initialize CodeCache to NULL (#1051)
krk Nov 11, 2024
603db84
Fix errors in LockTests.datagramSocketLock (#1053)
alvdavi Nov 13, 2024
3cf733d
Unit test fw from scratch and PerfEventType::forName tests (#1036)
krk Nov 18, 2024
6682ad6
Test corretto 11, 17, 21, 23 in CI (#1058)
krk Nov 21, 2024
3e7c839
Merge remote-tracking branch 'upstream/master' into update-from-upstream
aleks-p Nov 21, 2024
80fb581
Fix tests
aleks-p Nov 22, 2024
ee0d73d
Re-add missing bits to Dockerfile
aleks-p Nov 22, 2024
19b8d64
Package the jar on release
aleks-p Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cmake-build-debug/
/test/*.class
.vscode
*.iml
/src/api/**/*.class
22 changes: 22 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
header:
- paths:
- 'src/jattach'
license:
content: |
Copyright The jattach authors
SPDX-License-Identifier: Apache-2.0

comment: on-failure

- paths:
- 'src'
- 'test'
paths-ignore:
- 'src/jattach'
- 'src/res'
license:
content: |
Copyright The async-profiler authors
SPDX-License-Identifier: Apache-2.0

comment: on-failure
44 changes: 33 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
FROM centos:7 as glibc
RUN yum -y update && yum -y install make git gcc-c++ java-11-openjdk-devel glibc-static
ADD ./src /asprof/src
ADD ./Makefile ./LICENSE ./*.md ./JavaHome.class /asprof/
WORKDIR /asprof
RUN make release
# Image for building async-profiler release packages

# Stage 0: download and build musl
FROM public.ecr.aws/debian/debian:10-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
sudo libicu-dev patchelf curl make g++ openjdk-11-jdk-headless gcovr && \
rm -rf /var/cache/apt /var/lib/apt/lists/*

ARG musl_src=musl-1.2.5
ARG musl_sha256=a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4

FROM alpine:3.13 as musl
RUN apk add gcc g++ make openjdk11 linux-headers
ADD https://musl.libc.org/releases/${musl_src}.tar.gz /
RUN echo ${musl_sha256} ${musl_src}.tar.gz | sha256sum -c

RUN ["/bin/bash", "-c", "\
tar xfz ${musl_src}.tar.gz && \
cd /${musl_src} && \
./configure --disable-shared --prefix=/usr/local/musl && \
make -j`nproc` && make install && make clean && \
ln -s /usr/include/$(arch)-linux-gnu/asm /usr/include/{asm-generic,linux} /usr/local/musl/include/"]

# Stage 1: install build tools + copy musl toolchain from the previous step
FROM public.ecr.aws/debian/debian:10-slim

# The following command should be exactly the same as at stage 0 to benefit from caching.
# libicu-dev is needed for the github actions runner
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo libicu-dev patchelf curl make g++ openjdk-11-jdk-headless gcovr && \
rm -rf /var/cache/apt /var/lib/apt/lists/*

COPY --from=0 /usr/local/musl /usr/local/musl

RUN mkdir -p /asprof
ADD ./src /asprof/src
ADD ./Makefile ./LICENSE ./*.md ./JavaHome.class /asprof/
WORKDIR /asprof
RUN make release


FROM scratch
COPY --from=glibc /asprof/*.tar.gz /
COPY --from=musl /asprof/*.tar.gz /
COPY --from=1 /asprof/*.tar.gz /
164 changes: 115 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,58 @@
PROFILER_VERSION=3.0.0.0
PROFILER_VERSION ?= 3.0.0.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not forget: Change this back in case we decide not to bump.


ifeq ($(COMMIT_TAG),true)
PROFILER_VERSION := $(PROFILER_VERSION)-$(shell git rev-parse --short=8 HEAD)
else ifneq ($(COMMIT_TAG),)
PROFILER_VERSION := $(PROFILER_VERSION)-$(COMMIT_TAG)
endif

PACKAGE_NAME=async-profiler-$(PROFILER_VERSION)-$(OS_TAG)-$(ARCH_TAG)
PACKAGE_DIR=/tmp/$(PACKAGE_NAME)

LAUNCHER=bin/asprof
ASPROF=bin/asprof
JFRCONV=bin/jfrconv
LIB_PROFILER=lib/libasyncProfiler.$(SOEXT)
API_JAR=lib/async-profiler.jar
CONVERTER_JAR=lib/converter.jar

CFLAGS=-O3 -fno-exceptions
CXXFLAGS=-O3 -fno-exceptions -fno-omit-frame-pointer -fvisibility=hidden
API_JAR=jar/async-profiler.jar
CONVERTER_JAR=jar/jfr-converter.jar
TEST_JAR=test.jar

CC ?= $(CROSS_COMPILE)gcc
CXX ?= $(CROSS_COMPILE)g++
STRIP=$(CROSS_COMPILE)strip

CFLAGS_EXTRA ?=
CXXFLAGS_EXTRA ?=
CFLAGS=-O3 -fno-exceptions $(CFLAGS_EXTRA)
CXXFLAGS=-O3 -fno-exceptions -fno-omit-frame-pointer -fvisibility=hidden -std=c++11 $(CXXFLAGS_EXTRA)
CPPFLAGS=
DEFS=-DPROFILER_VERSION=\"$(PROFILER_VERSION)\"
INCLUDES=-I$(JAVA_HOME)/include -Isrc/helper
LIBS=-ldl -lpthread
MERGE=true
GCOV ?= gcov

JAVAC=$(JAVA_HOME)/bin/javac
JAR=$(JAVA_HOME)/bin/jar
JAVA=$(JAVA_HOME)/bin/java
JAVA_TARGET=8
JAVAC_OPTIONS=--release $(JAVA_TARGET) -Xlint:-options

LOG_DIR=build/test/logs
LOG_LEVEL=
SKIP=
TEST_FLAGS=-DlogDir=$(LOG_DIR) -DlogLevel=$(LOG_LEVEL) -Dskip=$(SKIP)

SOURCES := $(wildcard src/*.cpp)
HEADERS := $(wildcard src/*.h)
RESOURCES := $(wildcard src/res/*)
JAVA_HELPER_CLASSES := $(wildcard src/helper/one/profiler/*.class)
API_SOURCES := $(wildcard src/api/one/profiler/*.java)
CONVERTER_SOURCES := $(shell find src/converter -name '*.java')
TEST_SOURCES := $(shell find test -name '*.java')
TESTS ?= $(notdir $(patsubst %/,%,$(wildcard test/test/*/)))
CPP_TEST_SOURCES := test/native/testRunner.cpp $(shell find test/native -name '*Test.cpp')
CPP_TEST_HEADER := test/native/testRunner.hpp
CPP_TEST_INCLUDES := -Isrc -Itest/native

ifeq ($(JAVA_HOME),)
export JAVA_HOME:=$(shell java -cp . JavaHome)
Expand All @@ -45,34 +73,27 @@ ifeq ($(OS),Darwin)
MERGE=false
endif
else
CXXFLAGS += -Wl,-z,defs
CXXFLAGS += -U_FORTIFY_SOURCE -Wl,-z,defs -Wl,--exclude-libs,ALL -static-libstdc++ -static-libgcc -fdata-sections -ffunction-sections -Wl,--gc-sections
ifeq ($(MERGE),true)
CXXFLAGS += -fwhole-program
endif
LIBS += -lrt
INCLUDES += -I$(JAVA_HOME)/include/linux
SOEXT=so
PACKAGE_EXT=tar.gz
ifeq ($(findstring musl,$(shell ldd /bin/ls)),musl)
OS_TAG=linux-musl
CXXFLAGS += -static-libgcc -static-libstdc++
else
OS_TAG=linux
endif
OS_TAG=linux
endif

ARCH:=$(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH_TAG=x64
else
ifeq ($(findstring arm,$(ARCH)),arm)
ifeq ($(findstring 64,$(ARCH)),64)
ARCH_TAG=arm64
else
ARCH_TAG=arm32
endif
else ifeq ($(findstring aarch64,$(ARCH)),aarch64)
ifeq ($(ARCH_TAG),)
ARCH:=$(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH_TAG=x64
else ifeq ($(ARCH),aarch64)
ARCH_TAG=arm64
else ifeq ($(ARCH),arm64)
ARCH_TAG=arm64
else ifeq ($(findstring arm,$(ARCH)),arm)
ARCH_TAG=arm32
else ifeq ($(ARCH),ppc64le)
ARCH_TAG=ppc64le
else ifeq ($(ARCH),riscv64)
Expand All @@ -84,50 +105,62 @@ else
endif
endif

STATIC_BINARY=$(findstring musl-gcc,$(CC))
ifneq (,$(STATIC_BINARY))
CFLAGS += -static -fdata-sections -ffunction-sections -Wl,--gc-sections
endif

ifneq (,$(findstring $(ARCH_TAG),x86 x64 arm64))
CXXFLAGS += -momit-leaf-frame-pointer
endif


.PHONY: all release test native clean
.PHONY: all jar release build-test test native clean coverage clean-coverage build-test-java build-test-cpp test-cpp test-java

all: build/bin build/lib build/$(LIB_PROFILER) build/$(LAUNCHER) build/$(API_JAR) build/$(CONVERTER_JAR)
all: build/bin build/lib build/$(LIB_PROFILER) build/$(ASPROF) jar build/$(JFRCONV)

release: JAVA_TARGET=7
jar: build/jar build/$(API_JAR) build/$(CONVERTER_JAR)

release: $(PACKAGE_NAME).$(PACKAGE_EXT)

$(PACKAGE_NAME).tar.gz: $(PACKAGE_DIR)
patchelf --remove-needed ld-linux-x86-64.so.2 --remove-needed ld-linux-aarch64.so.1 $(PACKAGE_DIR)/$(LIB_PROFILER)
tar czf $@ -C $(PACKAGE_DIR)/.. $(PACKAGE_NAME)
rm -r $(PACKAGE_DIR)

$(PACKAGE_NAME).zip: $(PACKAGE_DIR)
# codesign -s "Developer ID" -o runtime --timestamp -v $(PACKAGE_DIR)/build/$(JATTACH) $(PACKAGE_DIR)/build/$(LIB_PROFILER_SO)
truncate -cs -`stat -f "%z" build/$(CONVERTER_JAR)` $(PACKAGE_DIR)/$(JFRCONV)
ifneq ($(GITHUB_ACTIONS), true)
# codesign -s "Developer ID" -o runtime --timestamp -v $(PACKAGE_DIR)/$(ASPROF) $(PACKAGE_DIR)/$(JFRCONV) $(PACKAGE_DIR)/$(LIB_PROFILER)
endif
cat build/$(CONVERTER_JAR) >> $(PACKAGE_DIR)/$(JFRCONV)
ditto -c -k --keepParent $(PACKAGE_DIR) $@
rm -r $(PACKAGE_DIR)

$(PACKAGE_DIR): build/bin build/lib \
build/$(LIB_PROFILER) build/$(LAUNCHER) \
build/$(API_JAR) build/$(CONVERTER_JAR) \
LICENSE *.md
$(PACKAGE_DIR): all LICENSE README.md
mkdir -p $(PACKAGE_DIR)
cp -RP build/* LICENSE *.md $(PACKAGE_DIR)/
cp -RP build/bin build/lib build/jar LICENSE README.md $(PACKAGE_DIR)/
chmod -R 755 $(PACKAGE_DIR)
chmod 644 $(PACKAGE_DIR)/lib/* $(PACKAGE_DIR)/LICENSE $(PACKAGE_DIR)/*.md
chmod 644 $(PACKAGE_DIR)/lib/* $(PACKAGE_DIR)/LICENSE $(PACKAGE_DIR)/README.md

build/%:
mkdir -p $@

build/$(LAUNCHER): src/launcher/* src/jattach/* src/fdtransfer.h
$(CC) $(CPPFLAGS) $(CFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" -o $@ src/launcher/*.cpp src/jattach/*.c
strip $@
build/$(ASPROF): src/main/* src/jattach/* src/fdtransfer.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) -o $@ src/main/*.cpp src/jattach/*.c
$(STRIP) $@

build/$(JFRCONV): src/launcher/* build/$(CONVERTER_JAR)
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) -o $@ src/launcher/*.cpp
$(STRIP) $@
cat build/$(CONVERTER_JAR) >> $@

build/$(LIB_PROFILER): $(SOURCES) $(HEADERS) $(RESOURCES) $(JAVA_HELPER_CLASSES)
ifeq ($(MERGE),true)
for f in src/*.cpp; do echo '#include "'$$f'"'; done |\
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" $(INCLUDES) -fPIC -shared -o $@ -xc++ - $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) -fPIC -shared -o $@ -xc++ - $(LIBS)
else
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" $(INCLUDES) -fPIC -shared -o $@ $(SOURCES) $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) -fPIC -shared -o $@ $(SOURCES) $(LIBS)
endif

build/$(API_JAR): $(API_SOURCES)
Expand All @@ -143,21 +176,54 @@ build/$(CONVERTER_JAR): $(CONVERTER_SOURCES) $(RESOURCES)
$(RM) -r build/converter

%.class: %.java
$(JAVAC) -source $(JAVA_TARGET) -target $(JAVA_TARGET) -Xlint:-options -g:none $^
$(JAVAC) -source 7 -target 7 -Xlint:-options -g:none $^

test: all
test/smoke-test.sh
test/thread-smoke-test.sh
test/alloc-smoke-test.sh
test/load-library-test.sh
test/fdtransfer-smoke-test.sh
echo "All tests passed"
build/test/cpptests: $(CPP_TEST_SOURCES) $(CPP_TEST_HEADER) $(SOURCES) $(HEADERS) $(RESOURCES) $(JAVA_HELPER_CLASSES)
mkdir -p build/test

ifeq ($(MERGE),true)
for f in src/*.cpp test/native/*.cpp; do echo '#include "'$$f'"'; done |\
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) $(CPP_TEST_INCLUDES) -fPIC -o $@ -xc++ - $(LIBS)
else
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) $(CPP_TEST_INCLUDES) -fPIC -o $@ $(SOURCES) $(CPP_TEST_SOURCES) $(LIBS)
endif

build-test-java: all build/$(TEST_JAR)

build-test-cpp: build/test/cpptests

build-test: build-test-cpp build-test-java

test-cpp: build-test-cpp
echo "Running cpp tests..."
build/test/cpptests

test-java: build-test-java
echo "Running tests against $(LIB_PROFILER)"
$(JAVA) $(TEST_FLAGS) -ea -cp "build/test.jar:build/jar/*:build/lib/*" one.profiler.test.Runner $(TESTS)

coverage: override FAT_BINARY=false
coverage: clean-coverage
$(MAKE) test-cpp CXXFLAGS_EXTRA="-fprofile-arcs -ftest-coverage -fPIC -O0 --coverage"
mkdir -p build/test/coverage
cd build/test/ && gcovr -r ../.. --html-details --gcov-executable "$(GCOV)" -o coverage/index.html
rm -rf -- -.gc*

test: test-cpp test-java

build/$(TEST_JAR): $(TEST_SOURCES) build/$(CONVERTER_JAR)
mkdir -p build/test
$(JAVAC) -source $(JAVA_TARGET) -target $(JAVA_TARGET) -Xlint:-options -cp "build/jar/*:build/converter/*" -d build/test $(TEST_SOURCES)
$(JAR) cf $@ -C build/test .

native:
mkdir -p native/linux-x64 native/linux-arm64 native/macos
tar xfO async-profiler-$(PROFILER_VERSION)-linux-x64.tar.gz */build/libasyncProfiler.so > native/linux-x64/libasyncProfiler.so
tar xfO async-profiler-$(PROFILER_VERSION)-linux-arm64.tar.gz */build/libasyncProfiler.so > native/linux-arm64/libasyncProfiler.so
unzip -p async-profiler-$(PROFILER_VERSION)-macos.zip */build/libasyncProfiler.so > native/macos/libasyncProfiler.so
unzip -p async-profiler-$(PROFILER_VERSION)-macos.zip */build/libasyncProfiler.dylib > native/macos/libasyncProfiler.dylib

clean-coverage:
$(RM) -rf build/test/cpptests build/test/coverage

clean:
$(RM) -r build
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ async-profiler can trace the following kinds of events:
- Allocations in Java Heap
- Contented lock attempts, including both Java object monitors and ReentrantLocks

See our [Wiki](https://github.com/async-profiler/async-profiler/wiki) or
[3 hours playlist](https://www.youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr)
to learn about all features.
See our [3 hours playlist](https://www.youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr)
to learn about more features.

## Download

Expand All @@ -31,6 +30,10 @@ Current release (3.0):
async-profiler also comes bundled with IntelliJ IDEA Ultimate 2018.3 and later.
For more information refer to [IntelliJ IDEA documentation](https://www.jetbrains.com/help/idea/cpu-and-allocation-profiling-basic-concepts.html).

[Nightly releases](https://github.com/async-profiler/async-profiler/releases/tag/nightly) (published on each commit to master)

For the build corresponding to a previous commit, go to the corresponding `Publish Nightly Builds` Github Action and scroll down to the artifacts section. These binaries are kept for 30 days.

## Supported platforms

| | Officially maintained builds | Other available ports |
Expand Down Expand Up @@ -350,11 +353,10 @@ $ asprof -d 30 -f /tmp/flamegraph.html 8983
Useful for finding Java heap memory leaks.

* `--lock N` - lock profiling threshold in nanoseconds (or other units).
In lock profiling mode, record contended locks that the JVM has waited for
longer than the specified duration.
In lock profiling mode, sample contended locks when total lock duration
overflows the threshold.

* `-j N` - sets the Java stack profiling depth. This option will be ignored if N is greater
than default 2048.
* `-j N` - sets the maximum stack depth. The default is 2048.
Example: `asprof -j 30 8983`

* `-t` - profile threads separately. Each stack trace will end with a frame
Expand Down Expand Up @@ -456,6 +458,11 @@ $ asprof -d 30 -f /tmp/flamegraph.html 8983
only events between the safepoint request and the start of the VM operation
will be recorded.

* `--jfropts OPTIONS` - comma separated list of JFR recording options.
Currently, the only available option is `mem` supported on Linux 3.17+.
`mem` enables accumulating events in memory instead of flushing
synchronously to a file.

* `--jfrsync CONFIG` - start Java Flight Recording with the given configuration
synchronously with the profiler. The output .jfr file will include all regular
JFR events, except that execution samples will be obtained from async-profiler.
Expand Down
Loading