Skip to content

Commit e11e20d

Browse files
psx95cloud-profiler-teamaalexand
authored
Sync Java Agent (#63)
* Internal Change PiperOrigin-RevId: 514417320 * Internal Code Change PiperOrigin-RevId: 515270706 * Add missing proto build steps to Makefile builds PiperOrigin-RevId: 518057341 * Internal Code Change PiperOrigin-RevId: 520552498 * Internal Code Change PiperOrigin-RevId: 520600713 * Internal Code Change PiperOrigin-RevId: 520853442 * Prevent segfaults due to race conditions when Java Heap sampler is enabled. PiperOrigin-RevId: 521492609 * Prevent other segfaults due to race conditions when Java Heap sampler is enabled. PiperOrigin-RevId: 522395875 * Prevent memory leak due to race conditions when Java Heap sampler is enabled. PiperOrigin-RevId: 523535577 * Internal testing logs PiperOrigin-RevId: 533466682 * Internal testing logs PiperOrigin-RevId: 534069370 * Split out ThreadProfile code to a separate target in order to add unit tests. PiperOrigin-RevId: 548381574 * Internal Code Change PiperOrigin-RevId: 555494681 * Remove uses of the deprecated DISALLOW_IMPLICIT_CONSTRUCTORS in favor of explicitly deleted constructors and assignment operators.. PiperOrigin-RevId: 556161979 * Internal Code Change PiperOrigin-RevId: 557667699 * Change `T const&&` to `T`. const r-value vector reference always results in a copy. PiperOrigin-RevId: 572682185 * Fix SIGSEGV in `HeapMonitor` during shutdown PiperOrigin-RevId: 576185633 * Update roots.pem to align with the current public set PiperOrigin-RevId: 576940801 * Fix potential crash in shutdown due to null jvmti_ pointer. PiperOrigin-RevId: 578310101 * Update profile.proto to match pprof's original. PiperOrigin-RevId: 578657868 * Fix ClangTidy warnings and format code. PiperOrigin-RevId: 580609161 * Make HeapMonitor::Enable()'s use_jvm_trace parameter default to false. We plan to delete code path for use_jvm_trace == true in the future. PiperOrigin-RevId: 588853678 * Allow users to configure the max number of garbage traces via a parameter to HeapMonitor::Enable(). PiperOrigin-RevId: 589244025 * Fix overflow in heap_sampler when a single object's size is greater than 2147483647. Changed type for sample size from jint (int32_t) to jlong (int64_t). PiperOrigin-RevId: 591017093 * Internal Code Change PiperOrigin-RevId: 594103049 * Unconditionally define `DISALLOW_COPY_AND_ASSIGN` PiperOrigin-RevId: 595165882 * Automated Code Change PiperOrigin-RevId: 598691690 * Sync changes to profile.proto. PiperOrigin-RevId: 599222268 * chore: update gRPC to v1.36.4 PiperOrigin-RevId: 607338479 --------- Co-authored-by: cloud-profiler-team <cloud-profiler-team@google.com> Co-authored-by: aalexand <aalexand@google.com>
1 parent 9ac4fbc commit e11e20d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+586
-383
lines changed

Dockerfile

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ FROM ubuntu:xenial
2020
#
2121
# Dependencies
2222
#
23+
# Install JDK 11 as sampling heap profiler depends on the new JVMTI APIs
24+
# Install Kitware apt repository. This repository contains newer version of
25+
# CMake. CMake > 3.13 is required to use "module" mode for gRPC dependencies.
26+
# See https://github.com/grpc/grpc/blob/master/BUILDING.md#install-after-build.
27+
# Kitware installs CMake v3.20.5
2328

24-
# Install JDK 11 as sampling heap profiler depends on the new JVMTI APIs.
25-
RUN apt-get update && apt-get install -y software-properties-common
26-
RUN add-apt-repository -y ppa:openjdk-r/ppa
27-
RUN apt-get update
29+
RUN apt-get update && apt-get install -y software-properties-common apt-transport-https ca-certificates gnupg wget && \
30+
add-apt-repository -y ppa:openjdk-r/ppa && \
31+
test -f /usr/share/doc/kitware-archive-keyring/copyright || \
32+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
33+
| gpg --dearmor - \
34+
| tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null && \
35+
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ xenial main' \
36+
| tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
37+
apt-get update && \
38+
apt-get install kitware-archive-keyring
2839

2940
# Installing openjdk-11-jdk-headless can be very slow due to repo download
3041
# speed.
@@ -41,6 +52,7 @@ RUN apt-get update && apt-get -y -q install \
4152
libtool \
4253
make \
4354
openjdk-11-jdk-headless \
55+
pkg-config \
4456
unzip \
4557
zlib1g-dev
4658

@@ -81,21 +93,47 @@ RUN mkdir /tmp/glog && cd /tmp/glog && \
8193
make -j && make install && \
8294
cd ~ && rm -rf /tmp/glog
8395

84-
# gRPC & protobuf
96+
# gRPC & protobuf - build using CMake
8597
# Use the protobuf version from gRPC for everything to avoid conflicting
8698
# versions to be linked in. Disable OpenSSL embedding: when it's on, the build
8799
# process of gRPC puts the OpenSSL static object files into the gRPC archive
88100
# which causes link errors later when the agent is linked with the static
89101
# OpenSSL library itself.
90102
# Limit the number of threads used by make, as unlimited threads causes
91103
# memory exhausted error on the Kokoro VM.
92-
RUN git clone --depth=1 --recursive -b v1.28.1 https://github.com/grpc/grpc.git /tmp/grpc && \
93-
cd /tmp/grpc && \
94-
cd third_party/protobuf && \
95-
./autogen.sh && \
96-
./configure --with-pic CXXFLAGS="$(pkg-config --cflags protobuf)" LIBS="$(pkg-config --libs protobuf)" LDFLAGS="-Wl,--no-as-needed" && \
97-
make -j4 && make install && ldconfig && \
98-
cd ../.. && \
99-
CPPFLAGS="-I /usr/local/ssl/include" LDFLAGS="-L /usr/local/ssl/lib/ -Wl,--no-as-needed" make -j4 CONFIG=opt EMBED_OPENSSL=false V=1 HAS_SYSTEM_OPENSSL_NPN=0 && \
100-
CPPFLAGS="-I /usr/local/ssl/include" LDFLAGS="-L /usr/local/ssl/lib/ -Wl,--no-as-needed" make CONFIG=opt EMBED_OPENSSL=false V=1 HAS_SYSTEM_OPENSSL_NPN=0 install && \
101-
rm -rf /tmp/grpc
104+
# -DCMAKE_CXX_STANDARD=11 is necessary since it is the minimum version supported
105+
# by gRPC dependencies. Xenial sets default version to c++98.
106+
#
107+
# See https://github.com/grpc/grpc/blob/v1.36.4/test/distrib/cpp/run_distrib_test_cmake_pkgconfig.sh
108+
RUN git clone --depth=1 --recursive -b v1.36.4 https://github.com/grpc/grpc.git /tmp/grpc && \
109+
cd /tmp/grpc/ && \
110+
# Install protobuf
111+
mkdir -p third_party/protobuf/cmake/build && \
112+
(cd third_party/protobuf/cmake/build && \
113+
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_STANDARD=11 -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release .. && \
114+
make -j4 install) && \
115+
# Install finish - protobuf
116+
# Install gRPC
117+
mkdir -p cmake/build && \
118+
(cd cmake/build && \
119+
cmake \
120+
-DOPENSSL_ROOT_DIR=/usr/local/ssl \
121+
-DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include \
122+
-DOPENSSL_CRYPTO_LIB=/usr/local/ssl/lib \
123+
-DCMAKE_BUILD_TYPE=Release \
124+
-DCMAKE_CXX_STANDARD=11 \
125+
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \
126+
-DgRPC_INSTALL=ON \
127+
-DgRPC_BUILD_TESTS=OFF \
128+
-DgRPC_ABSL_PROVIDER=module \
129+
-DgRPC_CARES_PROVIDER=module \
130+
-DgRPC_RE2_PROVIDER=module \
131+
-DgRPC_ZLIB_PROVIDER=module \
132+
-DgRPC_PROTOBUF_PROVIDER=package \
133+
-DgRPC_SSL_PROVIDER=package \
134+
../.. && \
135+
make -j4 install) && \
136+
cd ~ && rm -rf /tmp/grpc
137+
138+
ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/ssl/lib/pkgconfig:/usr/local/grpc/lib/pkgconfig:/usr/local/lib64/pkgconfig"
139+
ENV PATH="${PATH}:/usr/local/grpc/bin"

Dockerfile.alpine

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ RUN apk --no-cache add \
4444
# openssl
4545
# This openssl (compiled with -fPIC) is used to statically link into the agent
4646
# shared library.
47-
ENV PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig
4847
ENV JAVA_PATH=/usr/lib/jvm/java-11-openjdk/
4948
RUN mkdir /tmp/openssl && cd /tmp/openssl && \
5049
curl -sL https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz | \
@@ -80,21 +79,43 @@ RUN mkdir /tmp/glog && cd /tmp/glog && \
8079
make -j && make install && \
8180
cd ~ && rm -rf /tmp/glog
8281

83-
# gRPC & protobuf
82+
# gRPC & protobuf - build using CMake
8483
# Use the protobuf version from gRPC for everything to avoid conflicting
8584
# versions to be linked in. Disable OpenSSL embedding: when it's on, the build
8685
# process of gRPC puts the OpenSSL static object files into the gRPC archive
8786
# which causes link errors later when the agent is linked with the static
8887
# OpenSSL library itself.
8988
# Limit the number of threads used by make, as unlimited threads causes
9089
# memory exhausted error on the Kokoro VM.
91-
RUN git clone --depth=1 --recursive -b v1.28.1 https://github.com/grpc/grpc.git /tmp/grpc && \
92-
cd /tmp/grpc && \
93-
cd third_party/protobuf && \
94-
./autogen.sh && \
95-
./configure --with-pic CXXFLAGS="$(pkg-config --cflags protobuf)" LIBS="$(pkg-config --libs protobuf)" LDFLAGS="-Wl,--no-as-needed" && \
96-
make -j4 && make install && ldconfig / && \
97-
cd ../.. && \
98-
CPPFLAGS="-I /usr/local/ssl/include" LDFLAGS="-L /usr/local/ssl/lib/ -Wl,--no-as-needed" make -j4 CONFIG=opt EMBED_OPENSSL=false V=1 HAS_SYSTEM_OPENSSL_NPN=0 && \
99-
CPPFLAGS="-I /usr/local/ssl/include" LDFLAGS="-L /usr/local/ssl/lib/ -Wl,--no-as-needed" make CONFIG=opt EMBED_OPENSSL=false V=1 HAS_SYSTEM_OPENSSL_NPN=0 install && \
100-
rm -rf /tmp/grpc
90+
#
91+
# See https://github.com/grpc/grpc/blob/v1.36.4/test/distrib/cpp/run_distrib_test_cmake_pkgconfig.sh
92+
RUN git clone --depth=1 --recursive -b v1.36.4 https://github.com/grpc/grpc.git /tmp/grpc && \
93+
cd /tmp/grpc/ && \
94+
# Install protobuf
95+
mkdir -p third_party/protobuf/cmake/build && \
96+
(cd third_party/protobuf/cmake/build && \
97+
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release .. && \
98+
make -j4 install) && \
99+
# Install gRPC
100+
mkdir -p cmake/build && \
101+
cd cmake/build && \
102+
cmake \
103+
-DOPENSSL_ROOT_DIR=/usr/local/ssl \
104+
-DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include \
105+
-DOPENSSL_CRYPTO_LIB=/usr/local/ssl/lib \
106+
-DCMAKE_BUILD_TYPE=Release \
107+
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \
108+
-DgRPC_INSTALL=ON \
109+
-DgRPC_BUILD_TESTS=OFF \
110+
-DgRPC_ABSL_PROVIDER=module \
111+
-DgRPC_CARES_PROVIDER=module \
112+
-DgRPC_RE2_PROVIDER=module \
113+
-DgRPC_ZLIB_PROVIDER=module \
114+
-DgRPC_PROTOBUF_PROVIDER=package \
115+
-DgRPC_SSL_PROVIDER=package \
116+
../.. && \
117+
make -j4 install && \
118+
cd ~ && rm -rf /tmp/grpc
119+
120+
ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/ssl/lib/pkgconfig:/usr/local/grpc/lib/pkgconfig:/usr/local/lib64/pkgconfig"
121+
ENV PATH="${PATH}:/usr/local/grpc/bin"

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ CFLAGS = \
3030
-Wno-array-bounds \
3131
-g0 \
3232
-DSTANDALONE_BUILD \
33-
-D_GNU_SOURCE
33+
-D_GNU_SOURCE \
34+
$(shell pkg-config --cflags protobuf grpc)
3435

3536
ifeq ($(machine_type),$(filter $(machine_type),aarch64 arm64))
3637
# Building on an ARM64 machine.
@@ -50,7 +51,7 @@ endif
5051
SRC_ROOT_PATH=.
5152

5253
PROTOC ?= /usr/local/bin/protoc
53-
PROTOC_GEN_GRPC ?= /usr/local/bin/grpc_cpp_plugin
54+
GRPC_CPP_PLUGIN_PATH ?= /usr/local/grpc/bin/grpc_cpp_plugin
5455

5556
PROFILE_PROTO_PATH ?= third_party/perftools/profiles/proto
5657
JAVA_AGENT_PATH ?= src
@@ -82,6 +83,8 @@ PROFILER_API_SOURCES = \
8283
$(GENFILES_PATH)/google/api/client.pb.cc \
8384
$(GENFILES_PATH)/google/api/http.pb.cc \
8485
$(GENFILES_PATH)/google/api/launch_stage.pb.cc \
86+
$(GENFILES_PATH)/google/api/resource.pb.cc \
87+
$(GENFILES_PATH)/google/api/field_behavior.pb.cc \
8588
$(GENFILES_PATH)/google/devtools/cloudprofiler/v2/profiler.grpc.pb.cc \
8689
$(GENFILES_PATH)/google/devtools/cloudprofiler/v2/profiler.pb.cc \
8790
$(GENFILES_PATH)/google/protobuf/duration.pb.cc \
@@ -160,7 +163,7 @@ HEADERS = \
160163

161164
VERSION_SCRIPT = $(JAVA_AGENT_PATH)/cloud_profiler_java_agent.lds
162165
OPT_FLAGS = -O3
163-
LDFLAGS = -static-libstdc++ -shared
166+
LDFLAGS = -L/usr/local/lib -static-libstdc++ -shared $(shell pkg-config --libs --static protobuf grpc++)
164167
LDS_FLAGS = -Wl,-z,defs -Wl,--version-script=$(VERSION_SCRIPT)
165168

166169
LIB_ROOT_PATH ?= /usr/local
@@ -176,17 +179,6 @@ LIBS1= \
176179
$(LIB_ROOT_PATH)/lib/libglog.a \
177180
$(LIB_ROOT_PATH)/lib/libgflags.a \
178181

179-
LIBS2= \
180-
$(LIB_ROOT_PATH)/lib/libprotobuf.a \
181-
$(LIB_ROOT_PATH)/ssl/lib/libssl.a \
182-
$(LIB_ROOT_PATH)/ssl/lib/libcrypto.a \
183-
-lz \
184-
185-
GRPC_LIBS= \
186-
$(LIB_ROOT_PATH)/lib/libgrpc++.a \
187-
$(LIB_ROOT_PATH)/lib/libgrpc.a \
188-
$(LIB_ROOT_PATH)/lib/libgpr.a \
189-
190182
# Detect if running on Alpine and modify various flags
191183
ifeq ("$(wildcard /etc/alpine-release)","/etc/alpine-release")
192184
# musl only supports global dynamic tls model, and is documented as
@@ -212,7 +204,7 @@ clean:
212204

213205
$(TARGET_AGENT): $(SOURCES) $(HEADERS)
214206
mkdir -p $(dir $@)
215-
$(CC) $(INCLUDES) $(CFLAGS) $(OPT_FLAGS) $(LDFLAGS) $(SOURCES) $(LIBS1) $(GRPC_LIBS) $(LIBS2) -o $@ $(LDS_FLAGS)
207+
$(CC) $(INCLUDES) $(CFLAGS) $(OPT_FLAGS) $(SOURCES) $(LIBS1) $(LDFLAGS) -o $@ $(LDS_FLAGS)
216208

217209
$(TARGET_NOTICES): $(JAVA_AGENT_PATH)/NOTICES
218210
mkdir -p $(dir $@)
@@ -225,7 +217,7 @@ $(GENFILES_PATH)/%profiler.pb.h $(GENFILES_PATH)/%profiler.pb.cc : third_party/g
225217
$(GENFILES_PATH)/%profiler.grpc.pb.h $(GENFILES_PATH)/%profiler.grpc.pb.cc : third_party/googleapis/%profiler.proto
226218
mkdir -p $(dir $@)
227219
$(PROTOC) -Ithird_party/googleapis -I$(PROTOBUF_INCLUDE_PATH) \
228-
--plugin=protoc-gen-grpc=$(PROTOC_GEN_GRPC) --grpc_out=services_namespace=grpc:$(GENFILES_PATH) $<
220+
--plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) --grpc_out=services_namespace=grpc:$(GENFILES_PATH) $<
229221

230222
$(GENFILES_PATH)/%annotations.pb.h $(GENFILES_PATH)/%annotations.pb.cc : third_party/googleapis/%annotations.proto
231223
mkdir -p $(dir $@)
@@ -235,6 +227,14 @@ $(GENFILES_PATH)/%launch_stage.pb.h $(GENFILES_PATH)/%launch_stage.pb.cc : third
235227
mkdir -p $(dir $@)
236228
$(PROTOC) -Ithird_party/googleapis -I$(PROTOBUF_INCLUDE_PATH) --cpp_out=$(GENFILES_PATH) $<
237229

230+
$(GENFILES_PATH)/%resource.pb.h $(GENFILES_PATH)/%resource.pb.cc : third_party/googleapis/%resource.proto
231+
mkdir -p $(dir $@)
232+
$(PROTOC) -Ithird_party/googleapis -I$(PROTOBUF_INCLUDE_PATH) --cpp_out=$(GENFILES_PATH) $<
233+
234+
$(GENFILES_PATH)/%field_behavior.pb.h $(GENFILES_PATH)/%field_behavior.pb.cc : third_party/googleapis/%field_behavior.proto
235+
mkdir -p $(dir $@)
236+
$(PROTOC) -Ithird_party/googleapis -I$(PROTOBUF_INCLUDE_PATH) --cpp_out=$(GENFILES_PATH) $<
237+
238238
$(GENFILES_PATH)/%client.pb.h $(GENFILES_PATH)/%client.pb.cc : third_party/googleapis/%client.proto
239239
mkdir -p $(dir $@)
240240
$(PROTOC) -Ithird_party/googleapis -I$(PROTOBUF_INCLUDE_PATH) --cpp_out=$(GENFILES_PATH) $<

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ while getopts ":d:m:v:" opt; do
3838
m)
3939
TARGET=$OPTARG
4040
if [[ "${TARGET}" == "arm64" ]]; then
41-
if [[ "${MACHINE_TYPE}" != "aarch64" ]] || [[ "${MACHINE_TYPE}" != "arm64" ]]; then
41+
if [[ "${MACHINE_TYPE}" != "aarch64" ]] && [[ "${MACHINE_TYPE}" != "arm64" ]]; then
4242
echo "-m arm64 is supported only when running on an ARM64 system."
4343
exit;
4444
fi

src/cloud_env.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <cstdlib>
1818
#include <sstream>
1919
#include <string>
20+
#include <vector>
2021

2122
#include "src/clock.h"
2223
#include "src/http.h"

src/cloud_env.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef CLOUD_PROFILER_AGENT_JAVA_CLOUD_ENV_H_
1818
#define CLOUD_PROFILER_AGENT_JAVA_CLOUD_ENV_H_
1919

20+
#include <string>
21+
2022
#include "src/globals.h"
2123

2224
namespace cloud {
@@ -29,6 +31,11 @@ class HTTPRequest;
2931
class CloudEnv {
3032
public:
3133
CloudEnv();
34+
35+
// This type is neither copyable nor movable.
36+
CloudEnv(const CloudEnv&) = delete;
37+
CloudEnv& operator=(const CloudEnv&) = delete;
38+
3239
virtual ~CloudEnv() {}
3340

3441
// Returns the current cloud project ID.
@@ -68,7 +75,6 @@ class CloudEnv {
6875
std::string zone_name_;
6976
std::string service_;
7077
std::string service_version_;
71-
DISALLOW_COPY_AND_ASSIGN(CloudEnv);
7278
};
7379

7480
// Returns the default instance of a cloud env object. The returned

src/entry.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <limits.h>
1616

1717
#include <string>
18+
#include <vector>
1819

1920
#include "src/globals.h"
2021
#include "src/string.h"
@@ -122,11 +123,10 @@ void JNICALL OnVMInit(jvmtiEnv *jvmti, JNIEnv *jni_env, jthread thread) {
122123
}
123124

124125
if (FLAGS_cprof_enable_heap_sampling) {
125-
// TODO: Allow using the JVM's stack tracer with a flag once
126-
// we can get the current context in a cloud build.
127-
google::javaprofiler::HeapMonitor::Enable(
128-
jvmti, jni_env, FLAGS_cprof_heap_sampling_interval,
129-
false /* use_jvm_trace */);
126+
if (!google::javaprofiler::HeapMonitor::Enable(
127+
jvmti, jni_env, FLAGS_cprof_heap_sampling_interval)) {
128+
LOG(WARNING) << "Failed to start HeapMonitor.";
129+
}
130130
}
131131

132132
worker->Start(jni_env);

src/globals.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <jvmti.h>
2424
#include <stdint.h>
2525

26+
#include <string>
2627
#include <unordered_map>
2728

2829
#include "third_party/javaprofiler/jvmti_error.h"
@@ -103,6 +104,10 @@ class JvmtiScopedPtr {
103104

104105
JvmtiScopedPtr(jvmtiEnv *jvmti, T *ref) : jvmti_(jvmti), ref_(ref) {}
105106

107+
// This type is neither copyable nor movable.
108+
JvmtiScopedPtr(const JvmtiScopedPtr &) = delete;
109+
JvmtiScopedPtr &operator=(const JvmtiScopedPtr &) = delete;
110+
106111
~JvmtiScopedPtr() {
107112
if (NULL != ref_) {
108113
JVMTI_ERROR(jvmti_->Deallocate((unsigned char *)ref_));
@@ -121,8 +126,6 @@ class JvmtiScopedPtr {
121126
private:
122127
jvmtiEnv *jvmti_;
123128
T *ref_;
124-
125-
DISALLOW_IMPLICIT_CONSTRUCTORS(JvmtiScopedPtr);
126129
};
127130

128131
// Things that should probably be user-configurable

src/http.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "src/http.h"
1616

17+
#include <string>
18+
1719
#include "curl/curl.h"
1820

1921
namespace cloud {

src/http.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef CLOUD_PROFILER_AGENT_JAVA_HTTP_H_
1818
#define CLOUD_PROFILER_AGENT_JAVA_HTTP_H_
1919

20+
#include <string>
21+
2022
#include "src/globals.h"
2123

2224
typedef void CURL;
@@ -31,6 +33,11 @@ const int kHTTPStatusOK = 200;
3133
class HTTPRequest {
3234
public:
3335
HTTPRequest();
36+
37+
// This type is neither copyable nor movable.
38+
HTTPRequest(const HTTPRequest&) = delete;
39+
HTTPRequest& operator=(const HTTPRequest&) = delete;
40+
3441
virtual ~HTTPRequest();
3542

3643
virtual void AddAuthBearerHeader(const std::string& token);
@@ -51,7 +58,6 @@ class HTTPRequest {
5158

5259
CURL* curl_;
5360
struct curl_slist* headers_;
54-
DISALLOW_COPY_AND_ASSIGN(HTTPRequest);
5561
};
5662

5763
} // namespace profiler

0 commit comments

Comments
 (0)