Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 2043233003: Prevent sign extension for pointer trace values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 real = "\"Infinity\""; 254 real = "\"Infinity\"";
255 } 255 }
256 StringAppendF(out, "%s", real.c_str()); 256 StringAppendF(out, "%s", real.c_str());
257 break; 257 break;
258 } 258 }
259 case TRACE_VALUE_TYPE_POINTER: 259 case TRACE_VALUE_TYPE_POINTER:
260 // JSON only supports double and int numbers. 260 // JSON only supports double and int numbers.
261 // So as not to lose bits from a 64-bit pointer, output as a hex string. 261 // So as not to lose bits from a 64-bit pointer, output as a hex string.
262 StringAppendF( 262 StringAppendF(
263 out, "\"0x%" PRIx64 "\"", 263 out, "\"0x%" PRIx64 "\"",
264 static_cast<uint64_t>(reinterpret_cast<intptr_t>(value.as_pointer))); 264 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(value.as_pointer)));
caseq 2016/06/09 16:59:13 can we drop the inner one and do a reinterpret_cas
Kunihiko Sakamoto 2016/06/10 05:19:24 Unfortunately, that doesn't prevent sign extension
265 break; 265 break;
266 case TRACE_VALUE_TYPE_STRING: 266 case TRACE_VALUE_TYPE_STRING:
267 case TRACE_VALUE_TYPE_COPY_STRING: 267 case TRACE_VALUE_TYPE_COPY_STRING:
268 EscapeJSONString(value.as_string ? value.as_string : "NULL", true, out); 268 EscapeJSONString(value.as_string ? value.as_string : "NULL", true, out);
269 break; 269 break;
270 default: 270 default:
271 NOTREACHED() << "Don't know how to print this value"; 271 NOTREACHED() << "Don't know how to print this value";
272 break; 272 break;
273 } 273 }
274 } 274 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text); 417 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text);
418 418
419 *out << value_as_text; 419 *out << value_as_text;
420 } 420 }
421 *out << "}"; 421 *out << "}";
422 } 422 }
423 } 423 }
424 424
425 } // namespace trace_event 425 } // namespace trace_event
426 } // namespace base 426 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698