The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.
Please select the desired protocol below to get the URL.
This URL has Read-Only access.
main_repo / deps / v8 / src / checks.cc @ 40c0f755
History | View | Annotate | Download (3.82 KB)
1 |
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
---|---|
2 |
// Redistribution and use in source and binary forms, with or without
|
3 |
// modification, are permitted provided that the following conditions are
|
4 |
// met:
|
5 |
//
|
6 |
// * Redistributions of source code must retain the above copyright
|
7 |
// notice, this list of conditions and the following disclaimer.
|
8 |
// * Redistributions in binary form must reproduce the above
|
9 |
// copyright notice, this list of conditions and the following
|
10 |
// disclaimer in the documentation and/or other materials provided
|
11 |
// with the distribution.
|
12 |
// * Neither the name of Google Inc. nor the names of its
|
13 |
// contributors may be used to endorse or promote products derived
|
14 |
// from this software without specific prior written permission.
|
15 |
//
|
16 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17 |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18 |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19 |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20 |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23 |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24 |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 |
|
28 |
#include <stdarg.h> |
29 |
|
30 |
#include "v8.h" |
31 |
|
32 |
#include "platform.h" |
33 |
#include "top.h" |
34 |
|
35 |
static int fatal_error_handler_nesting_depth = 0; |
36 |
|
37 |
// Contains protection against recursive calls (faults while handling faults).
|
38 |
extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { |
39 |
fatal_error_handler_nesting_depth++; |
40 |
// First time we try to print an error message
|
41 |
if (fatal_error_handler_nesting_depth < 2) { |
42 |
i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line);
|
43 |
va_list arguments; |
44 |
va_start(arguments, format); |
45 |
i::OS::VPrintError(format, arguments); |
46 |
va_end(arguments); |
47 |
i::OS::PrintError("\n#\n\n");
|
48 |
} |
49 |
// First two times we may try to print a stack dump.
|
50 |
if (fatal_error_handler_nesting_depth < 3) { |
51 |
if (i::FLAG_stack_trace_on_abort) {
|
52 |
// Call this one twice on double fault
|
53 |
i::Top::PrintStack(); |
54 |
} |
55 |
} |
56 |
i::OS::Abort(); |
57 |
} |
58 |
|
59 |
|
60 |
void CheckEqualsHelper(const char* file, |
61 |
int line,
|
62 |
const char* expected_source, |
63 |
v8::Handle<v8::Value> expected, |
64 |
const char* value_source, |
65 |
v8::Handle<v8::Value> value) { |
66 |
if (!expected->Equals(value)) {
|
67 |
v8::String::Utf8Value value_str(value); |
68 |
v8::String::Utf8Value expected_str(expected); |
69 |
V8_Fatal(file, line, |
70 |
"CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s",
|
71 |
expected_source, value_source, *expected_str, *value_str); |
72 |
} |
73 |
} |
74 |
|
75 |
|
76 |
void CheckNonEqualsHelper(const char* file, |
77 |
int line,
|
78 |
const char* unexpected_source, |
79 |
v8::Handle<v8::Value> unexpected, |
80 |
const char* value_source, |
81 |
v8::Handle<v8::Value> value) { |
82 |
if (unexpected->Equals(value)) {
|
83 |
v8::String::Utf8Value value_str(value); |
84 |
V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
|
85 |
unexpected_source, value_source, *value_str); |
86 |
} |
87 |
} |
88 |
|
89 |
|
90 |
void API_Fatal(const char* location, const char* format, ...) { |
91 |
i::OS::PrintError("\n#\n# Fatal error in %s\n# ", location);
|
92 |
va_list arguments; |
93 |
va_start(arguments, format); |
94 |
i::OS::VPrintError(format, arguments); |
95 |
va_end(arguments); |
96 |
i::OS::PrintError("\n#\n\n");
|
97 |
i::OS::Abort(); |
98 |
} |