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

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

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

Powered by Google App Engine
This is Rietveld 408576698