Skip to content

Commit f83b1b3

Browse files
Milad FarazmandCommit Bot
authored andcommitted
[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}
1 parent 76c57b5 commit f83b1b3

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

include/libplatform/v8-tracing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const int kTraceMaxNumArgs = 2;
3535
class V8_PLATFORM_EXPORT TraceObject {
3636
public:
3737
union ArgValue {
38-
bool as_bool;
38+
V8_DEPRECATED("use as_uint ? true : false") bool as_bool;
3939
uint64_t as_uint;
4040
int64_t as_int;
4141
double as_double;

src/libplatform/tracing/trace-writer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void JSONTraceWriter::AppendArgValue(uint8_t type,
5959
TraceObject::ArgValue value) {
6060
switch (type) {
6161
case TRACE_VALUE_TYPE_BOOL:
62-
stream_ << (value.as_bool ? "true" : "false");
62+
stream_ << (value.as_uint ? "true" : "false");
6363
break;
6464
case TRACE_VALUE_TYPE_UINT:
6565
stream_ << value.as_uint;

src/libplatform/tracing/tracing-controller.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void AddArgsToTraceProto(
129129
break;
130130
}
131131
case TRACE_VALUE_TYPE_BOOL:
132-
arg->set_bool_value(arg_value.as_bool);
132+
arg->set_bool_value(arg_value.as_uint);
133133
break;
134134
case TRACE_VALUE_TYPE_UINT:
135135
arg->set_uint_value(arg_value.as_uint);

0 commit comments

Comments
 (0)