Skip to content

Commit 613cc26

Browse files
_collect should not fail due to VMDeath after profiler start
1 parent 999f0c7 commit 613cc26

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

src/arguments.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ Error Arguments::parse(const char* args) {
488488
CASE("inverted")
489489
_inverted = true;
490490

491+
CASE("_collect")
492+
_collect = true;
493+
491494
DEFAULT()
492495
if (_unknown_arg == NULL) _unknown_arg = arg;
493496
}

src/arguments.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Arguments {
207207
bool _nostop;
208208
bool _alluser;
209209
bool _fdtransfer;
210+
bool _collect;
210211
const char* _fdtransfer_path;
211212
int _target_cpu;
212213
int _style;
@@ -269,6 +270,7 @@ class Arguments {
269270
_alluser(false),
270271
_fdtransfer(false),
271272
_fdtransfer_path(NULL),
273+
_collect(false),
272274
_target_cpu(-1),
273275
_style(0),
274276
_features{1, 1, 1, 1, 1, 1},

src/main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ int main(int argc, const char** argv) {
601601
signal(SIGINT, SIG_DFL);
602602
// Do not reset SIGTERM handler to allow graceful shutdown
603603

604-
run_jattach(pid, String("stop,file=") << file << "," << output << format << ",log=" << logfile);
604+
run_jattach(pid, String("stop,_collect,file=") << file << "," << output << format << ",log=" << logfile);
605605
} else {
606606
if (action == "start" || action == "resume") run_fdtransfer(pid, fdtransfer);
607607
run_jattach(pid, String(action) << ",file=" << file << "," << output << format << params << ",log=" << logfile);

src/profiler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,9 @@ Error Profiler::flushJfr() {
13681368

13691369
Error Profiler::dump(Writer& out, Arguments& args) {
13701370
MutexLocker ml(_state_lock);
1371-
if (_state != IDLE && _state != RUNNING) {
1371+
if (args._collect && _state == TERMINATED) {
1372+
return Error::OK;
1373+
} else if (_state != IDLE && _state != RUNNING) {
13721374
return Error("Profiler has not started");
13731375
}
13741376

0 commit comments

Comments
 (0)