8340334: Update jcmd VM.events max parameter to be INT

Reviewed-by: cjplummer, kevinw
This commit is contained in:
Leonid Mesnik 2024-11-21 01:32:09 +00:00
parent 400eb9b10a
commit 13439113c3
3 changed files with 7 additions and 11 deletions

View File

@ -884,22 +884,18 @@ 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);
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) {
Events::print_one(output(), log_name, max);

View File

@ -889,7 +889,7 @@ public:
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);

View File

@ -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.