Skip to content

Commit

Permalink
Fixed dumping the data
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Jul 7, 2023
1 parent 4f441f1 commit 28bbfdb
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/hotspot/share/vitals/vitals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,19 +760,6 @@ class PrintSamplesClosure : public SampleTable::Closure {
}
};

static void dump_buffer(stringStream* in, outputStream* out, int max_size) {
g_vitals_lock.unlock();
out->print_raw(in->base());
in->reset();

if (in->size() >= (size_t) (max_size - 1)) {
out->cr();
out->print_cr("-- Buffer overflow, truncated (total: " SIZE_FORMAT ").", (size_t) in->count());
}

g_vitals_lock.lock();
}

// sampleTables is a combination of two tables: a short term table and a long term table.
// It takes care to feed new samples into these tables at the appropriate intervals.
class SampleTables : public CHeapObj<mtInternal> {
Expand All @@ -798,6 +785,20 @@ class SampleTables : public CHeapObj<mtInternal> {
// when we want to print the report we may be in no condition to allocate memory.
char _temp_buffer[32 * K];

static void dump_stream(stringStream* in, outputStream* out) {
g_vitals_lock.unlock();
out->print_raw(in->base());

if (in->size() >= (size_t) (sizeof(_temp_buffer) - 1)) {
out->cr();
out->print_cr("-- Buffer overflow, truncated (total: " SIZE_FORMAT ").", (size_t) in->count());
out->cr();
}

g_vitals_lock.lock();
in->reset();
}

static void print_table(const SampleTable* table, outputStream* st,
const ColumnWidths* widths, const print_info_t* pi) {
if (table->is_empty()) {
Expand Down Expand Up @@ -921,7 +922,7 @@ class SampleTables : public CHeapObj<mtInternal> {
print_headers(st, &widths, pi);
print_one_sample(st, sample_now, NULL, &widths, pi);
st->cr();
dump_buffer(st, external_stream, sizeof(_temp_buffer));
dump_stream(st, external_stream);
}

if (!_short_term_table.is_empty()) {
Expand All @@ -935,7 +936,7 @@ class SampleTables : public CHeapObj<mtInternal> {
print_headers(st, &widths, pi);
print_table(&_short_term_table, st, &widths, pi);
st->cr();
dump_buffer(st, external_stream, sizeof(_temp_buffer));
dump_stream(st, external_stream);
}

if (!_long_term_table.is_empty()) {
Expand All @@ -946,7 +947,7 @@ class SampleTables : public CHeapObj<mtInternal> {
print_headers(st, &widths, pi);
print_table(&_long_term_table, st, &widths, pi);
st->cr();
dump_buffer(st, external_stream, sizeof(_temp_buffer));
dump_stream(st, external_stream);
}

if (StoreVitalsExtremas && (_extremum_samples != NULL) && (_last_extremum_samples != NULL)) {
Expand All @@ -972,7 +973,7 @@ class SampleTables : public CHeapObj<mtInternal> {
}
}

dump_buffer(st, external_stream, sizeof(_temp_buffer));
dump_stream(st, external_stream);
}

st->cr();
Expand Down

0 comments on commit 28bbfdb

Please sign in to comment.