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

Side by Side Diff: runtime/vm/assert.cc

Issue 9189003: Move assert.h/assert.cc from runtime/vm to runtime/platform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check for correct rebase Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assert.h ('k') | runtime/vm/assert_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include <cstdlib>
6 #include <sstream>
7 #include <string>
8
9 #include "vm/assert.h"
10
11 namespace dart {
12
13 // Exit with a failure code when we miss an EXPECT check.
14 static void failed_exit(void) {
15 exit(255);
16 }
17
18 void DynamicAssertionHelper::Fail(const char* format, ...) {
19 std::stringstream stream;
20 stream << file_ << ":" << line_ << ": error: ";
21
22 va_list arguments;
23 va_start(arguments, format);
24 char buffer[KB];
25 vsnprintf(buffer, sizeof(buffer), format, arguments);
26 va_end(arguments);
27 stream << buffer << std::endl;
28
29 // Get the message from the string stream and dump it on stderr.
30 std::string message = stream.str();
31 fprintf(stderr, "%s", message.c_str());
32
33 // In case of failed assertions, abort right away. Otherwise, wait
34 // until the program is exiting before producing a non-zero exit
35 // code through abort.
36 // TODO(5411324): replace std::abort with OS::Abort so that we can handle
37 // restoring of signal handlers before aborting.
38 if (kind_ == ASSERT) {
39 std::abort();
40 }
41 static bool failed = false;
42 if (!failed) {
43 std::atexit(&failed_exit);
44 }
45 failed = true;
46 }
47
48 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assert.h ('k') | runtime/vm/assert_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698