2d70c7a5eb
BEFORE Unhandled exception: MyException 0. Function: '::baz' url: 'file:///Users/turnidge/dart/bug.dart' line:2 col:3 1. Function: '_OtherClass@11f7ef14._OtherClass@11f7ef14._named@11f7ef14' url: 'file:///Users/turnidge/dart/bug.dart' line:7 col:8 2. Function: '::set:globalVar' url: 'file:///Users/turnidge/dart/bug.dart' line:12 col:3 3. Function: '::_bar@11f7ef14' url: 'file:///Users/turnidge/dart/bug.dart' line:16 col:3 4. Function: 'MyClass.get:field' url: 'file:///Users/turnidge/dart/bug.dart' line:25 col:9 5. Function: 'MyClass.fooHelper' url: 'file:///Users/turnidge/dart/bug.dart' line:30 col:7 6. Function: 'MyClass.foo' url: 'file:///Users/turnidge/dart/bug.dart' line:32 col:14 7. Function: 'MyClass.function' url: 'file:///Users/turnidge/dart/bug.dart' line:21 col:15 8. Function: 'MyClass.MyClass.' url: 'file:///Users/turnidge/dart/bug.dart' line:21 col:18 9. Function: '::function' url: 'file:///Users/turnidge/dart/bug.dart' line:38 col:10 10. Function: '::main' url: 'file:///Users/turnidge/dart/bug.dart' line:38 col:24 AFTER Unhandled exception: MyException #0 baz (file:///Users/turnidge/dart/bug.dart:2:3) #1 _OtherClass._OtherClass._named (file:///Users/turnidge/dart/bug.dart:7:8) #2 globalVar= (file:///Users/turnidge/dart/bug.dart:12:3) #3 _bar (file:///Users/turnidge/dart/bug.dart:16:3) #4 MyClass.field (file:///Users/turnidge/dart/bug.dart:25:9) #5 MyClass.foo.fooHelper (file:///Users/turnidge/dart/bug.dart:30:7) #6 MyClass.foo (file:///Users/turnidge/dart/bug.dart:32:14) #7 MyClass.MyClass.<anonymous closure> (file:///Users/turnidge/dart/bug.dart:21:15) #8 MyClass.MyClass (file:///Users/turnidge/dart/bug.dart:21:18) #9 main.<anonymous closure> (file:///Users/turnidge/dart/bug.dart:38:10) #10 main (file:///Users/turnidge/dart/bug.dart:38:24) Review URL: https://chromiumcodereview.appspot.com//10826191 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10408 260f80e4-7a28-3924-810f-c04153c831b5
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "platform/assert.h"
|
|
|
|
#include <cstdlib>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#include "platform/globals.h"
|
|
|
|
namespace dart {
|
|
|
|
// Exit with a failure code when we miss an EXPECT check.
|
|
static void failed_exit(void) {
|
|
exit(255);
|
|
}
|
|
|
|
void DynamicAssertionHelper::Fail(const char* format, ...) {
|
|
std::stringstream stream;
|
|
stream << file_ << ":" << line_ << ": error: ";
|
|
|
|
va_list arguments;
|
|
va_start(arguments, format);
|
|
char buffer[2 * KB];
|
|
vsnprintf(buffer, sizeof(buffer), format, arguments);
|
|
va_end(arguments);
|
|
stream << buffer << std::endl;
|
|
|
|
// Get the message from the string stream and dump it on stderr.
|
|
std::string message = stream.str();
|
|
fprintf(stderr, "%s", message.c_str());
|
|
|
|
// In case of failed assertions, abort right away. Otherwise, wait
|
|
// until the program is exiting before producing a non-zero exit
|
|
// code through abort.
|
|
// TODO(5411324): replace std::abort with OS::Abort so that we can handle
|
|
// restoring of signal handlers before aborting.
|
|
if (kind_ == ASSERT) {
|
|
std::abort();
|
|
}
|
|
static bool failed = false;
|
|
if (!failed) {
|
|
std::atexit(&failed_exit);
|
|
}
|
|
failed = true;
|
|
}
|
|
|
|
} // namespace dart
|