提交 4b7806bb 编写于 作者: S sla

8032250: Add trace event for VM flag changes

Reviewed-by: coleenp, ehelin, egahlin, mgronlun
上级 59a0853d
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "utilities/ostream.hpp" #include "utilities/ostream.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include "utilities/top.hpp" #include "utilities/top.hpp"
#include "trace/tracing.hpp"
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
#include "gc_implementation/g1/g1_globals.hpp" #include "gc_implementation/g1/g1_globals.hpp"
#endif // INCLUDE_ALL_GCS #endif // INCLUDE_ALL_GCS
...@@ -593,6 +594,17 @@ bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) { ...@@ -593,6 +594,17 @@ bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
return true; return true;
} }
template<class E, class T>
static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
{
E e;
e.set_name(name);
e.set_old_value(old_value);
e.set_new_value(new_value);
e.set_origin(origin);
e.commit();
}
bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) {
Flag* result = Flag::find_flag(name, len); Flag* result = Flag::find_flag(name, len);
if (result == NULL) return false; if (result == NULL) return false;
...@@ -606,6 +618,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag ...@@ -606,6 +618,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_bool()) return false; if (!result->is_bool()) return false;
bool old_value = result->get_bool(); bool old_value = result->get_bool();
trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
result->set_bool(*value); result->set_bool(*value);
*value = old_value; *value = old_value;
result->set_origin(origin); result->set_origin(origin);
...@@ -615,6 +628,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag ...@@ -615,6 +628,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag
void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) { void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
faddr->set_bool(value); faddr->set_bool(value);
faddr->set_origin(origin); faddr->set_origin(origin);
} }
...@@ -632,6 +646,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag ...@@ -632,6 +646,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_intx()) return false; if (!result->is_intx()) return false;
intx old_value = result->get_intx(); intx old_value = result->get_intx();
trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
result->set_intx(*value); result->set_intx(*value);
*value = old_value; *value = old_value;
result->set_origin(origin); result->set_origin(origin);
...@@ -641,6 +656,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag ...@@ -641,6 +656,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag
void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) { void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
faddr->set_intx(value); faddr->set_intx(value);
faddr->set_origin(origin); faddr->set_origin(origin);
} }
...@@ -658,6 +674,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl ...@@ -658,6 +674,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_uintx()) return false; if (!result->is_uintx()) return false;
uintx old_value = result->get_uintx(); uintx old_value = result->get_uintx();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uintx(*value); result->set_uintx(*value);
*value = old_value; *value = old_value;
result->set_origin(origin); result->set_origin(origin);
...@@ -667,6 +684,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl ...@@ -667,6 +684,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl
void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) { void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
faddr->set_uintx(value); faddr->set_uintx(value);
faddr->set_origin(origin); faddr->set_origin(origin);
} }
...@@ -684,6 +702,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl ...@@ -684,6 +702,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_uint64_t()) return false; if (!result->is_uint64_t()) return false;
uint64_t old_value = result->get_uint64_t(); uint64_t old_value = result->get_uint64_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uint64_t(*value); result->set_uint64_t(*value);
*value = old_value; *value = old_value;
result->set_origin(origin); result->set_origin(origin);
...@@ -693,6 +712,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl ...@@ -693,6 +712,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl
void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) { void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
faddr->set_uint64_t(value); faddr->set_uint64_t(value);
faddr->set_origin(origin); faddr->set_origin(origin);
} }
...@@ -710,6 +730,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag:: ...@@ -710,6 +730,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_double()) return false; if (!result->is_double()) return false;
double old_value = result->get_double(); double old_value = result->get_double();
trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
result->set_double(*value); result->set_double(*value);
*value = old_value; *value = old_value;
result->set_origin(origin); result->set_origin(origin);
...@@ -719,6 +740,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag:: ...@@ -719,6 +740,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::
void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) { void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
faddr->set_double(value); faddr->set_double(value);
faddr->set_origin(origin); faddr->set_origin(origin);
} }
...@@ -738,6 +760,7 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Fl ...@@ -738,6 +760,7 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Fl
if (result == NULL) return false; if (result == NULL) return false;
if (!result->is_ccstr()) return false; if (!result->is_ccstr()) return false;
ccstr old_value = result->get_ccstr(); ccstr old_value = result->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
char* new_value = NULL; char* new_value = NULL;
if (*value != NULL) { if (*value != NULL) {
new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal); new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
...@@ -760,6 +783,7 @@ void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, F ...@@ -760,6 +783,7 @@ void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, F
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
ccstr old_value = faddr->get_ccstr(); ccstr old_value = faddr->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal); char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
strcpy(new_value, value); strcpy(new_value, value);
faddr->set_ccstr(new_value); faddr->set_ccstr(new_value);
......
...@@ -122,6 +122,46 @@ Declares a structure type that can be used in other events. ...@@ -122,6 +122,46 @@ Declares a structure type that can be used in other events.
<value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/> <value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/>
</event> </event>
<event id="LongFlagChanged" path="vm/flag/long_changed" label="Long Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="LONG" field="old_value" label="Old Value" />
<value type="LONG" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="UnsignedLongFlagChanged" path="vm/flag/ulong_changed" label="Unsigned Long Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="ULONG" field="old_value" label="Old Value" />
<value type="ULONG" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="DoubleFlagChanged" path="vm/flag/double_changed" label="Double Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="DOUBLE" field="old_value" label="Old Value" />
<value type="DOUBLE" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="BooleanFlagChanged" path="vm/flag/boolean_changed" label="Boolean Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="BOOLEAN" field="old_value" label="Old Value" />
<value type="BOOLEAN" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="StringFlagChanged" path="vm/flag/string_changed" label="String Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="UTF8" field="old_value" label="Old Value" />
<value type="UTF8" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<struct id="VirtualSpace"> <struct id="VirtualSpace">
<value type="ADDRESS" field="start" label="Start Address" description="Start address of the virtual space" /> <value type="ADDRESS" field="start" label="Start Address" description="Start address of the virtual space" />
<value type="ADDRESS" field="committedEnd" label="Committed End Address" description="End address of the committed memory for the virtual space" /> <value type="ADDRESS" field="committedEnd" label="Committed End Address" description="End address of the committed memory for the virtual space" />
......
...@@ -150,6 +150,11 @@ Now we can use the content + data type in declaring event fields. ...@@ -150,6 +150,11 @@ Now we can use the content + data type in declaring event fields.
<value type="UTF8" field="phase" label="phase" /> <value type="UTF8" field="phase" label="phase" />
</content_type> </content_type>
<content_type id="FlagValueOrigin" hr_name="Flag Value Origin"
type="U1" jvm_type="FLAGVALUEORIGIN">
<value type="UTF8" field="origin" label="origin" />
</content_type>
</content_types> </content_types>
...@@ -334,6 +339,10 @@ Now we can use the content + data type in declaring event fields. ...@@ -334,6 +339,10 @@ Now we can use the content + data type in declaring event fields.
<!-- VMOPERATIONTYPE --> <!-- VMOPERATIONTYPE -->
<primary_type symbol="VMOPERATIONTYPE" datatype="U2" contenttype="VMOPERATIONTYPE" <primary_type symbol="VMOPERATIONTYPE" datatype="U2" contenttype="VMOPERATIONTYPE"
type="u2" sizeop="sizeof(u2)" /> type="u2" sizeop="sizeof(u2)" />
<!-- FLAGVALUEORIGIN -->
<primary_type symbol="FLAGVALUEORIGIN" datatype="U1"
contenttype="FLAGVALUEORIGIN" type="u1" sizeop="sizeof(u1)" />
</primary_types> </primary_types>
</types> </types>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册