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

Unified Diff: runtime/vm/object.cc

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index bb8839db6444d757b384f8f289d91079bd3de852..773d4dc52db0c5bee25e0179d9fe9fe27633f849 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3543,7 +3543,7 @@ RawAbstractTypeArguments* TypeArguments::InstantiateFrom(
RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) {
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in TypeArguments::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in TypeArguments::New: invalid len %"Pd"\n", len);
}
TypeArguments& result = TypeArguments::Handle();
{
@@ -3975,7 +3975,7 @@ bool Function::AreValidArgumentCounts(int num_arguments,
const intptr_t num_hidden_params = NumberOfImplicitParameters();
OS::SNPrint(message_buffer,
kMessageBufferSize,
- "%d passed, %s%d expected",
+ "%"Pd" passed, %s%"Pd" expected",
num_arguments - num_hidden_params,
num_optional_parameters() > 0 ? "at most " : "",
NumberOfParameters() - num_hidden_params);
@@ -3992,7 +3992,7 @@ bool Function::AreValidArgumentCounts(int num_arguments,
const intptr_t num_hidden_params = NumberOfImplicitParameters();
OS::SNPrint(message_buffer,
kMessageBufferSize,
- "%d %spassed, %d expected",
+ "%"Pd" %spassed, %"Pd" expected",
num_positional_args - num_hidden_params,
num_optional_parameters() > 0 ? "positional " : "",
num_fixed_parameters() - num_hidden_params);
@@ -4974,7 +4974,7 @@ RawTokenStream* TokenStream::New(intptr_t len) {
ASSERT(Object::token_stream_class() != Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in TokenStream::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in TokenStream::New: invalid len %"Pd"\n", len);
}
TokenStream& result = TokenStream::Handle();
{
@@ -6535,7 +6535,7 @@ RawInstructions* Instructions::New(intptr_t size) {
ASSERT(Object::instructions_class() != Class::null());
if (size < 0 || size > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Instructions::New: invalid size %ld\n", size);
+ FATAL1("Fatal error in Instructions::New: invalid size %"Pd"\n", size);
}
Instructions& result = Instructions::Handle();
{
@@ -6638,8 +6638,8 @@ RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) {
ASSERT(Object::pc_descriptors_class() != Class::null());
if (num_descriptors < 0 || num_descriptors > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n",
- num_descriptors);
+ FATAL1("Fatal error in PcDescriptors::New: "
+ "invalid num_descriptors %"Pd"\n", num_descriptors);
}
PcDescriptors& result = PcDescriptors::Handle();
{
@@ -6689,7 +6689,7 @@ const char* PcDescriptors::ToCString() const {
// "*" in a printf format specifier tells it to read the field width from
// the printf argument list.
const char* kFormat =
- "0x%-*" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n";
+ "%#-*"Px"\t%s\t%"Pd"\t%"Pd"\t%"Pd"\n";
// First compute the buffer size required.
intptr_t len = 1; // Trailing '\0'.
for (intptr_t i = 0; i < Length(); i++) {
@@ -6736,7 +6736,7 @@ void PcDescriptors::Verify(bool check_ids) const {
// the check for too large number of descriptors.
if (Length() > 3000) {
if (FLAG_trace_compiler) {
- OS::Print("Not checking pc decriptors, length %d\n", Length());
+ OS::Print("Not checking pc decriptors, length %"Pd"\n", Length());
}
return;
}
@@ -6807,7 +6807,7 @@ RawStackmap* Stackmap::New(intptr_t pc_offset,
(payload_size >
(kSmiMax - static_cast<intptr_t>(sizeof(RawStackmap))))) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Stackmap::New: invalid length %" PRIdPTR "\n",
+ FATAL1("Fatal error in Stackmap::New: invalid length %"Pd"\n",
length);
}
{
@@ -6837,7 +6837,7 @@ const char* Stackmap::ToCString() const {
if (IsNull()) {
return "{null}";
} else {
- const char* kFormat = "0x%" PRIxPTR ": ";
+ const char* kFormat = "%#"Px": ";
intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1;
Isolate* isolate = Isolate::Current();
// Guard against integer overflow in the computation of alloc_size.
@@ -6845,7 +6845,7 @@ const char* Stackmap::ToCString() const {
// TODO(kmillikin): We could just truncate the string if someone
// tries to print a 2 billion plus entry stackmap.
if (Length() > (kIntptrMax - fixed_length)) {
- FATAL1("Length() is unexpectedly large (%" PRIdPTR ")", Length());
+ FATAL1("Length() is unexpectedly large (%"Pd")", Length());
}
intptr_t alloc_size = fixed_length + Length();
char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
@@ -6897,7 +6897,7 @@ RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) {
if (num_variables < 0 || num_variables > kMaxElements) {
// This should be caught before we reach here.
FATAL1("Fatal error in LocalVarDescriptors::New: "
- "invalid num_variables %ld\n", num_variables);
+ "invalid num_variables %"Pd"\n", num_variables);
}
LocalVarDescriptors& result = LocalVarDescriptors::Handle();
{
@@ -6957,7 +6957,8 @@ RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
ASSERT(Object::exception_handlers_class() != Class::null());
if (num_handlers < 0 || num_handlers > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ExceptionHandlers::New: invalid num_handlers %ld\n",
+ FATAL1("Fatal error in ExceptionHandlers::New: "
+ "invalid num_handlers %"Pd"\n",
num_handlers);
}
ExceptionHandlers& result = ExceptionHandlers::Handle();
@@ -6979,7 +6980,7 @@ const char* ExceptionHandlers::ToCString() const {
return "No exception handlers\n";
}
// First compute the buffer size required.
- const char* kFormat = "%" PRIdPTR " => 0x%" PRIxPTR "\n";
+ const char* kFormat = "%"Pd" => %#"Px"\n";
intptr_t len = 1; // Trailing '\0'.
for (intptr_t i = 0; i < Length(); i++) {
len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i));
@@ -7077,7 +7078,7 @@ Code::Comments& Code::Comments::New(intptr_t count) {
Comments* comments;
if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Code::Comments::New: invalid count %ld\n", count);
+ FATAL1("Fatal error in Code::Comments::New: invalid count %"Pd"\n", count);
}
if (count == 0) {
comments = new Comments(Object::empty_array());
@@ -7153,7 +7154,7 @@ void Code::set_comments(const Code::Comments& comments) const {
RawCode* Code::New(intptr_t pointer_offsets_length) {
if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n",
+ FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %"Pd"\n",
pointer_offsets_length);
}
ASSERT(Object::code_class() != Class::null());
@@ -7185,7 +7186,7 @@ RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) {
assembler->FinalizeInstructions(region);
Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer();
if (perf_events_writer != NULL) {
- const char* format = "%" PRIxPTR " %" PRIxPTR " %s\n";
+ const char* format = "%#"Px" %#"Px" %s\n";
uword addr = instrs.EntryPoint();
uword size = instrs.size();
intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name);
@@ -7407,7 +7408,7 @@ RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
if (num_variables < 0 || num_variables > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Context::New: invalid num_variables %ld\n",
+ FATAL1("Fatal error in Context::New: invalid num_variables %"Pd"\n",
num_variables);
}
Context& result = Context::Handle();
@@ -7433,7 +7434,7 @@ RawContextScope* ContextScope::New(intptr_t num_variables) {
ASSERT(Object::context_scope_class() != Class::null());
if (num_variables < 0 || num_variables > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ContextScope::New: invalid num_variables %ld\n",
+ FATAL1("Fatal error in ContextScope::New: invalid num_variables %"Pd"\n",
num_variables);
}
intptr_t size = ContextScope::InstanceSize(num_variables);
@@ -8700,7 +8701,7 @@ int Bigint::CompareWith(const Integer& other) const {
RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) {
if (length < 0 || length > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Bigint::Allocate: invalid length %ld\n", length);
+ FATAL1("Fatal error in Bigint::Allocate: invalid length %"Pd"\n", length);
}
ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null());
Bigint& result = Bigint::Handle();
@@ -9467,7 +9468,7 @@ RawOneByteString* OneByteString::New(intptr_t len,
Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in OneByteString::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in OneByteString::New: invalid len %"Pd"\n", len);
}
OneByteString& result = OneByteString::Handle();
{
@@ -9609,7 +9610,7 @@ RawTwoByteString* TwoByteString::New(intptr_t len,
ASSERT(Isolate::Current()->object_store()->two_byte_string_class());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in TwoByteString::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in TwoByteString::New: invalid len %"Pd"\n", len);
}
TwoByteString& result = TwoByteString::Handle();
{
@@ -9742,7 +9743,7 @@ RawFourByteString* FourByteString::New(intptr_t len,
Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in FourByteString::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in FourByteString::New: invalid len %"Pd"\n", len);
}
FourByteString& result = FourByteString::Handle();
{
@@ -9853,7 +9854,8 @@ RawExternalOneByteString* ExternalOneByteString::New(
Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ExternalOneByteString::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in ExternalOneByteString::New: invalid len %"Pd"\n",
+ len);
}
ExternalOneByteString& result = ExternalOneByteString::Handle();
ExternalStringData<uint8_t>* external_data =
@@ -9904,7 +9906,8 @@ RawExternalTwoByteString* ExternalTwoByteString::New(
Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %"Pd"\n",
+ len);
}
ExternalTwoByteString& result = ExternalTwoByteString::Handle();
ExternalStringData<uint16_t>* external_data =
@@ -9945,7 +9948,7 @@ RawExternalFourByteString* ExternalFourByteString::New(
external_four_byte_string_class() != Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ExternalFourByteString::New: invalid len %ld\n",
+ FATAL1("Fatal error in ExternalFourByteString::New: invalid len %"Pd"\n",
len);
}
ExternalFourByteString& result = ExternalFourByteString::Handle();
@@ -10053,7 +10056,7 @@ RawArray* Array::New(intptr_t len, Heap::Space space) {
RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) {
if (len < 0 || len > Array::kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in Array::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in Array::New: invalid len %"Pd"\n", len);
}
Array& result = Array::Handle();
{
@@ -10350,7 +10353,8 @@ RawT* ByteArray::NewExternalImpl(const Class& cls,
Heap::Space space) {
if (len < 0 || len > HandleT::kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ByteArray::NewExternalImpl: invalid len %ld\n", len);
+ FATAL1("Fatal error in ByteArray::NewExternalImpl: invalid len %"Pd"\n",
+ len);
}
HandleT& result = HandleT::Handle();
ExternalByteArrayData<ElementT>* external_data =
@@ -10392,7 +10396,7 @@ template<typename HandleT, typename RawT>
RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) {
if (len < 0 || len > HandleT::kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ByteArray::NewImpl: invalid len %ld\n", len);
+ FATAL1("Fatal error in ByteArray::NewImpl: invalid len %"Pd"\n", len);
}
HandleT& result = HandleT::Handle();
{
@@ -10417,7 +10421,7 @@ RawT* ByteArray::NewImpl(const Class& cls,
Heap::Space space) {
if (len < 0 || len > HandleT::kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in ByteArray::NewImpl: invalid len %ld\n", len);
+ FATAL1("Fatal error in ByteArray::NewImpl: invalid len %"Pd"\n", len);
}
HandleT& result = HandleT::Handle();
{
@@ -11099,7 +11103,7 @@ RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
Class::null());
if (len < 0 || len > kMaxElements) {
// This should be caught before we reach here.
- FATAL1("Fatal error in JSRegexp::New: invalid len %ld\n", len);
+ FATAL1("Fatal error in JSRegexp::New: invalid len %"Pd"\n", len);
}
JSRegExp& result = JSRegExp::Handle();
{
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/os.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698