Skip to content

Commit

Permalink
8340334: Update jcmd VM.events max parameter to be INT
Browse files Browse the repository at this point in the history
Reviewed-by: cjplummer, kevinw
  • Loading branch information
lmesnik committed Nov 21, 2024
1 parent 400eb9b commit 1343911
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/hotspot/share/services/diagnosticCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,21 +884,17 @@ void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) {
EventLogDCmd::EventLogDCmd(outputStream* output, bool heap) :
DCmdWithParser(output, heap),
_log("log", "Name of log to be printed. If omitted, all logs are printed.", "STRING", false, nullptr),
_max("max", "Maximum number of events to be printed (newest first). If omitted, all events are printed.", "STRING", false, nullptr)
_max("max", "Maximum number of events to be printed (newest first). If omitted or zero, all events are printed.", "INT", false, "0")
{
_dcmdparser.add_dcmd_option(&_log);
_dcmdparser.add_dcmd_option(&_max);
}

void EventLogDCmd::execute(DCmdSource source, TRAPS) {
const char* max_value = _max.value();
int max = -1;
if (max_value != nullptr) {
char* endptr = nullptr;
if (!parse_integer(max_value, &max)) {
output()->print_cr("Invalid max option: \"%s\".", max_value);
return;
}
int max = (int)_max.value();
if (max < 0) {
output()->print_cr("Invalid max option: \"%d\".", max);
return;
}
const char* log_name = _log.value();
if (log_name != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/services/diagnosticCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ class ClassesDCmd : public DCmdWithParser {
class EventLogDCmd : public DCmdWithParser {
protected:
DCmdArgument<char*> _log;
DCmdArgument<char*> _max;
DCmdArgument<jlong> _max;
public:
static int num_arguments() { return 2; }
EventLogDCmd(outputStream* output, bool heap);
Expand Down
2 changes: 1 addition & 1 deletion src/jdk.jcmd/share/man/jcmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ The following commands are available:
- `log`: (Optional) Name of log to be printed.
If omitted, all logs are printed. (STRING, no default value)
- `max`: (Optional) Maximum number of events to be printed (newest first).
If omitted, all events are printed. (STRING, no default value)
If omitted or zero, all events are printed. (INT, 0)

`VM.flags` \[*options*\]
: Print the VM flag options and their current values.
Expand Down

0 comments on commit 1343911

Please sign in to comment.