[tracing] Fix endianness problem when using booleans

All the data types defined under ArgValue are 8 bytes
expect "bool as_bool". When casting to <uint64_t> under
"tracing/trace-event.h", boolean gets placed on the lower
byte of the memory on LE, and on the higher byte on BE machines.
When using a "Union" to read back the value as a boolean, only
the lower byte of the memory location is read which makes it
fine on LE machines, however the value will not be present on BE
machines.

Using an 8 byte data type as boolean will assure the entire filed
is read instead of only the lower byte.

Change-Id: I0740b9c019588c963a4c7878af60c6df04827141
TBR: petermarshall@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1896835
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64859}
This commit is contained in:
Milad Farazmand 2019-11-07 17:07:34 +00:00 committed by Commit Bot
parent 76c57b5630
commit f83b1b3beb
3 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ const int kTraceMaxNumArgs = 2;
class V8_PLATFORM_EXPORT TraceObject {
public:
union ArgValue {
bool as_bool;
V8_DEPRECATED("use as_uint ? true : false") bool as_bool;
uint64_t as_uint;
int64_t as_int;
double as_double;

View File

@ -59,7 +59,7 @@ void JSONTraceWriter::AppendArgValue(uint8_t type,
TraceObject::ArgValue value) {
switch (type) {
case TRACE_VALUE_TYPE_BOOL:
stream_ << (value.as_bool ? "true" : "false");
stream_ << (value.as_uint ? "true" : "false");
break;
case TRACE_VALUE_TYPE_UINT:
stream_ << value.as_uint;

View File

@ -129,7 +129,7 @@ void AddArgsToTraceProto(
break;
}
case TRACE_VALUE_TYPE_BOOL:
arg->set_bool_value(arg_value.as_bool);
arg->set_bool_value(arg_value.as_uint);
break;
case TRACE_VALUE_TYPE_UINT:
arg->set_uint_value(arg_value.as_uint);