Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "stack_trace_element.h" |
| 18 | |
| 19 | #include "class.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame^] | 20 | #include "gc/accounting/card_table-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 21 | #include "object-inl.h" |
| 22 | #include "string.h" |
| 23 | |
| 24 | namespace art { |
| 25 | namespace mirror { |
| 26 | |
| 27 | Class* StackTraceElement::java_lang_StackTraceElement_ = NULL; |
| 28 | |
| 29 | void StackTraceElement::SetClass(Class* java_lang_StackTraceElement) { |
| 30 | CHECK(java_lang_StackTraceElement_ == NULL); |
| 31 | CHECK(java_lang_StackTraceElement != NULL); |
| 32 | java_lang_StackTraceElement_ = java_lang_StackTraceElement; |
| 33 | } |
| 34 | |
| 35 | void StackTraceElement::ResetClass() { |
| 36 | CHECK(java_lang_StackTraceElement_ != NULL); |
| 37 | java_lang_StackTraceElement_ = NULL; |
| 38 | } |
| 39 | |
| 40 | StackTraceElement* StackTraceElement::Alloc(Thread* self, |
| 41 | String* declaring_class, |
| 42 | String* method_name, |
| 43 | String* file_name, |
| 44 | int32_t line_number) { |
| 45 | StackTraceElement* trace = |
| 46 | down_cast<StackTraceElement*>(GetStackTraceElement()->AllocObject(self)); |
| 47 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_), |
| 48 | const_cast<String*>(declaring_class), false); |
| 49 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_), |
| 50 | const_cast<String*>(method_name), false); |
| 51 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_), |
| 52 | const_cast<String*>(file_name), false); |
| 53 | trace->SetField32(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_), |
| 54 | line_number, false); |
| 55 | return trace; |
| 56 | } |
| 57 | |
| 58 | } // namespace mirror |
| 59 | } // namespace art |