Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 7880621

Browse files
Cloud Debugger TeamHamidreza Asaadi
authored andcommitted
Internal commit.
PiperOrigin-RevId: 238673108 Change-Id: I91c981ad6f230b92744a9d8081e42edb5bcef689
1 parent 7504d5b commit 7880621

File tree

15 files changed

+47
-34
lines changed

15 files changed

+47
-34
lines changed

src/agent/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ CFLAGS += \
3333
THIRD_PARTY_LIB_PATH ?= /usr/local/lib
3434
THIRD_PARTY_INCLUDE_PATH ?= /usr/local/include
3535
SYSTEM_LIB_PATH ?= /usr/lib/x86_64-linux-gnu
36-
ASM_JAR_PATH ?= /usr/lib/asm-7.0/lib/asm-7.0.jar
37-
ASM_COMMONS_JAR_PATH ?= /usr/lib/asm-7.0/lib/asm-commons-7.0.jar
38-
ASM_UTIL_JAR_PATH ?= /usr/lib/asm-7.0/lib/asm-util-7.0.jar
36+
ASM_JAR_PATH ?= /usr/lib/asm-7.1/lib/asm-7.1.jar
37+
ASM_COMMONS_JAR_PATH ?= /usr/lib/asm-7.1/lib/asm-commons-7.1.jar
38+
ASM_DEPRECATED_JAR_PATH ?= /usr/lib/asm-7.1/lib/asm-deprecated-7.1.jar
39+
ASM_UTIL_JAR_PATH ?= /usr/lib/asm-7.1/lib/asm-util-7.1.jar
3940
GOOGLE_API_JAVA_CLIENT_PATH ?= /usr/lib/google-api-java-client
4041
JARJAR_PATH ?= ../../build/jarjar.jar
4142
JAVA_BUILD ?= maven
@@ -245,9 +246,10 @@ ifeq ($(JAVA_BUILD),maven)
245246
cp internals/target/cdbg_java_agent_internals-SNAPSHOT-jar-with-dependencies.jar $(INTERNALS_JAR_FULL)
246247
else
247248
mkdir -p internals/target
248-
cd internals ; $(JAVAC) -g:none -cp $(ASM_JAR_PATH):$(ASM_COMMONS_JAR_PATH):$(ASM_UTIL_JAR_PATH):$(GSON_JAR_PATH):$(GOOGLE_API_CLIENT_JARS_CLASS_PATH):$(SNAKE_YAML_JAR_PATH) -d target src/main/java/com/google/devtools/cdbg/debuglets/java/*.java
249+
cd internals ; $(JAVAC) -g:none -cp $(ASM_JAR_PATH):$(ASM_COMMONS_JAR_PATH):$(ASM_DEPRECATED_JAR_PATH):$(ASM_UTIL_JAR_PATH):$(GSON_JAR_PATH):$(GOOGLE_API_CLIENT_JARS_CLASS_PATH):$(SNAKE_YAML_JAR_PATH) -d target src/main/java/com/google/devtools/cdbg/debuglets/java/*.java
249250
cd internals/target ; jar xf $(ASM_JAR_PATH) ; rm -rf META-INF
250251
cd internals/target ; jar xf $(ASM_COMMONS_JAR_PATH) ; rm -rf META-INF
252+
cd internals/target ; jar xf $(ASM_DEPRECATED_JAR_PATH) ; rm -rf META-INF
251253
cd internals/target ; jar xf $(ASM_UTIL_JAR_PATH) ; rm -rf META-INF
252254
cd internals/target ; jar xf $(GSON_JAR_PATH) ; rm -rf META-INF
253255
cd internals/target ; jar xf $(SNAKE_YAML_JAR_PATH) ; rm -rf META-INF

src/agent/callbacks_monitor.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ class CallbacksMonitor {
4040

4141
typedef std::list<OngoingCall>::iterator Id;
4242

43-
CallbacksMonitor(
43+
explicit CallbacksMonitor(
4444
int max_call_duration_ms,
4545
std::function<int64()> fn_gettime = MonotonicClockMillis)
4646
: max_call_duration_ms_(max_call_duration_ms),
4747
fn_gettime_(fn_gettime),
48-
last_unhealthy_time_ms_(-1) {
49-
}
48+
last_unhealthy_time_ms_(-1) {}
5049

5150
~CallbacksMonitor() {
5251
if (!ongoing_calls_.empty()) {

src/agent/canary_control.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
#include "messages.h"
2020
#include "model_util.h"
2121

22-
namespace devtools {
23-
namespace cdbg {
24-
25-
// Number of attempts to register or approve a canary breakpoint before
26-
// failing the operation.
27-
static constexpr int kMaxAttempts = 3;
28-
2922
// The "ApproveHealtyBreakpoints" method is called from worker thread every
3023
// cycle of "ListActiveBreakpoints", which is once every 40 seconds. The
3124
// constant of 35 seconds is deliberately a bit shorter than that so that the
@@ -35,6 +28,13 @@ ABSL_FLAG(
3528
"Time interval after which an enabled canary breakpoint is considered as "
3629
"safe for a global rollout (from this debuglet's perspective)");
3730

31+
namespace devtools {
32+
namespace cdbg {
33+
34+
// Number of attempts to register or approve a canary breakpoint before
35+
// failing the operation.
36+
static constexpr int kMaxAttempts = 3;
37+
3838
CanaryControl::CanaryControl(
3939
CallbacksMonitor* callbacks_monitor,
4040
Bridge* bridge)
@@ -150,4 +150,3 @@ void CanaryControl::ApproveHealtyBreakpoints() {
150150

151151
} // namespace cdbg
152152
} // namespace devtools
153-

src/agent/capture_data_collector.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ ABSL_FLAG(
3535
namespace devtools {
3636
namespace cdbg {
3737

38+
// Local utility functions
39+
namespace {
40+
41+
void MergeLabels(std::map<std::string, std::string>* existing_labels,
42+
std::map<std::string, std::string> agent_labels) {
43+
// This will merge in the agent labels with the pre existing client labels
44+
// that may already be present. In the event of a duplicate label the insert
45+
// will favour the pre existing labels an not update the entry. This
46+
// generally should not be an issue as the pre existing client label names are
47+
// chosen with care and there should be no conflicts.
48+
existing_labels->insert(agent_labels.begin(), agent_labels.end());
49+
}
50+
51+
} // namespace
52+
3853
CaptureDataCollector::CaptureDataCollector(JvmEvaluators* evaluators)
3954
: evaluators_(evaluators) {
4055
// Reserve "var_table_index" 0 for memory objects that we didn't capture
@@ -323,8 +338,9 @@ void CaptureDataCollector::Format(BreakpointModel* breakpoint) const {
323338
breakpoint->variable_table.push_back(std::move(object_variable));
324339
}
325340

326-
// Format the breakpoint labels.
327-
breakpoint->labels = breakpoint_labels_provider_->Format();
341+
// Format the breakpoint labels and merge them with the existing client
342+
// labels.
343+
MergeLabels(&breakpoint->labels, breakpoint_labels_provider_->Format());
328344

329345
// Format the end user identity.
330346
if (absl::GetFlag(FLAGS_cdbg_capture_user_id)) {

src/agent/glob_data_visibility_policy.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace {
1515
// reports that methods and fields have their data hidden.
1616
class BlacklistedClassImpl : public DataVisibilityPolicy::Class {
1717
public:
18-
BlacklistedClassImpl(const string& reason) :
19-
reason_(reason) { }
18+
explicit BlacklistedClassImpl(const string& reason) : reason_(reason) {}
2019

2120
bool IsFieldVisible(const string& name, int32 field_modifiers) override {
2221
return true;

src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/SafeCallerException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public static Throwable createNativeMethodNotAllowed(String method) {
8080

8181
/** Determines the binary name of the caller omitting internally generated safe caller methods. */
8282
private static String getCallerName() {
83-
8483
return "<unknown>";
8584
}
8685
}

src/agent/jvm_object_evaluator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class JvmObjectEvaluator : public ObjectEvaluator {
5353
bool pretty_print_stringable = true;
5454
};
5555

56-
JvmObjectEvaluator(
57-
ClassMetadataReader* class_metadata_reader);
56+
explicit JvmObjectEvaluator(ClassMetadataReader* class_metadata_reader);
5857

5958
~JvmObjectEvaluator() override;
6059

src/agent/jvmti_globals.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "jvm_internals.h"
2525
#include "jvmti_buffer.h"
2626
#include "statistician.h"
27+
2728
#include "jvmti_agent.h"
2829
#include "glob_data_visibility_policy.h"
2930
#include "yaml_data_visibility_config_reader.h"
@@ -70,6 +71,7 @@ ABSL_FLAG(string, service_account_email, "",
7071
ABSL_FLAG(string, service_account_json_file, "",
7172
"Path to JSON file containing private key of the service account");
7273
#endif
74+
7375
static devtools::cdbg::JvmtiAgent* g_instance = nullptr;
7476

7577
static devtools::cdbg::JvmInternals* g_internals = nullptr;

src/agent/messages.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ constexpr char DynamicLogOutOfCallQuota[] =
215215

216216
constexpr char CanaryBreakpointUnhealthy[] =
217217
"The snapshot canary has failed and the snapshot cancelled. Please try "
218-
"again at a later time."
219-
;
218+
"again at a later time.";
220219

221220
#define INTERNAL_ERROR_MESSAGE (devtools::cdbg::FormatMessageModel { \
222221
"Internal error at $0:$1", \

src/agent/mutex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <mutex> // NOLINT
2121
#include "common.h"
22+
2223
namespace absl {
2324

2425
// Wrapper class for non-recursive mutex.

0 commit comments

Comments
 (0)