OLD | NEW |
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 "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 15550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15561 index += OS::SNPrint((chars + index), | 15561 index += OS::SNPrint((chars + index), |
15562 (total_len + 1 - index), | 15562 (total_len + 1 - index), |
15563 "%s", | 15563 "%s", |
15564 frame_strings[i]); | 15564 frame_strings[i]); |
15565 } | 15565 } |
15566 chars[total_len] = '\0'; | 15566 chars[total_len] = '\0'; |
15567 return chars; | 15567 return chars; |
15568 } | 15568 } |
15569 | 15569 |
15570 | 15570 |
| 15571 ExceptionStackTrace* Stacktrace::BuildExceptionStackTrace() const { |
| 15572 ExceptionStackTrace* result = new ExceptionStackTrace(8); |
| 15573 String& function_name = String::Handle(); |
| 15574 String& script_uri = String::Handle(); |
| 15575 Script& script = Script::Handle(); |
| 15576 |
| 15577 Function& function = Function::Handle(); |
| 15578 Code& code = Code::Handle(); |
| 15579 for (intptr_t i = 0; i < Length(); i++) { |
| 15580 function = FunctionAtFrame(i); |
| 15581 if (function.IsNull()) { |
| 15582 // Check if null function object indicates a stack trace overflow. |
| 15583 if ((i < (Length() - 1)) && |
| 15584 (FunctionAtFrame(i + 1) != Function::null())) { |
| 15585 function_name = Symbols::Empty().raw(); |
| 15586 script_uri = Symbols::Empty().raw(); |
| 15587 intptr_t line = -1; |
| 15588 intptr_t column = -1; |
| 15589 result->AddFrame( |
| 15590 new ExceptionStackFrame(function_name, script_uri, line, column)); |
| 15591 } |
| 15592 } else if (function.is_visible()) { |
| 15593 code = CodeAtFrame(i); |
| 15594 ASSERT(function.raw() == code.function()); |
| 15595 uword pc = code.EntryPoint() + Smi::Value(PcOffsetAtFrame(i)); |
| 15596 if (code.is_optimized() && expand_inlined()) { |
| 15597 // Traverse inlined frames. |
| 15598 for (InlinedFunctionsIterator it(code, pc); !it.Done(); it.Advance()) { |
| 15599 function = it.function(); |
| 15600 code = it.code(); |
| 15601 ASSERT(function.raw() == code.function()); |
| 15602 uword pc = it.pc(); |
| 15603 ASSERT(pc != 0); |
| 15604 ASSERT(code.EntryPoint() <= pc); |
| 15605 ASSERT(pc < (code.EntryPoint() + code.Size())); |
| 15606 |
| 15607 function_name = function.QualifiedUserVisibleName(); |
| 15608 script = function.script(); |
| 15609 script_uri = script.url(); |
| 15610 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 15611 intptr_t line = -1; |
| 15612 intptr_t column = -1; |
| 15613 if (token_pos >= 0) { |
| 15614 if (script.HasSource()) { |
| 15615 script.GetTokenLocation(token_pos, &line, &column); |
| 15616 } else { |
| 15617 script.GetTokenLocation(token_pos, &line, NULL); |
| 15618 } |
| 15619 } |
| 15620 result->AddFrame( |
| 15621 new ExceptionStackFrame(function_name, script_uri, line, column)); |
| 15622 } |
| 15623 } else { |
| 15624 function_name = function.QualifiedUserVisibleName(); |
| 15625 script = function.script(); |
| 15626 script_uri = script.url(); |
| 15627 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 15628 intptr_t line = -1; |
| 15629 intptr_t column = -1; |
| 15630 if (token_pos >= 0) { |
| 15631 if (script.HasSource()) { |
| 15632 script.GetTokenLocation(token_pos, &line, &column); |
| 15633 } else { |
| 15634 script.GetTokenLocation(token_pos, &line, NULL); |
| 15635 } |
| 15636 } |
| 15637 result->AddFrame( |
| 15638 new ExceptionStackFrame(function_name, script_uri, line, column)); |
| 15639 } |
| 15640 } |
| 15641 } |
| 15642 |
| 15643 return result; |
| 15644 } |
| 15645 |
| 15646 |
15571 void JSRegExp::set_pattern(const String& pattern) const { | 15647 void JSRegExp::set_pattern(const String& pattern) const { |
15572 StorePointer(&raw_ptr()->pattern_, pattern.raw()); | 15648 StorePointer(&raw_ptr()->pattern_, pattern.raw()); |
15573 } | 15649 } |
15574 | 15650 |
15575 | 15651 |
15576 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 15652 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
15577 raw_ptr()->num_bracket_expressions_ = Smi::New(value); | 15653 raw_ptr()->num_bracket_expressions_ = Smi::New(value); |
15578 } | 15654 } |
15579 | 15655 |
15580 | 15656 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15747 return "_MirrorReference"; | 15823 return "_MirrorReference"; |
15748 } | 15824 } |
15749 | 15825 |
15750 | 15826 |
15751 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15827 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15752 JSONObject jsobj(stream); | 15828 JSONObject jsobj(stream); |
15753 } | 15829 } |
15754 | 15830 |
15755 | 15831 |
15756 } // namespace dart | 15832 } // namespace dart |
OLD | NEW |