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" |
Hiroshi Yamauchi | 967a0ad | 2013-09-10 16:24:21 -0700 | [diff] [blame^] | 20 | #include "class-inl.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 21 | #include "gc/accounting/card_table-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | #include "object-inl.h" |
| 23 | #include "string.h" |
| 24 | |
| 25 | namespace art { |
| 26 | namespace mirror { |
| 27 | |
| 28 | Class* StackTraceElement::java_lang_StackTraceElement_ = NULL; |
| 29 | |
| 30 | void StackTraceElement::SetClass(Class* java_lang_StackTraceElement) { |
| 31 | CHECK(java_lang_StackTraceElement_ == NULL); |
| 32 | CHECK(java_lang_StackTraceElement != NULL); |
| 33 | java_lang_StackTraceElement_ = java_lang_StackTraceElement; |
| 34 | } |
| 35 | |
| 36 | void StackTraceElement::ResetClass() { |
| 37 | CHECK(java_lang_StackTraceElement_ != NULL); |
| 38 | java_lang_StackTraceElement_ = NULL; |
| 39 | } |
| 40 | |
| 41 | StackTraceElement* StackTraceElement::Alloc(Thread* self, |
| 42 | String* declaring_class, |
| 43 | String* method_name, |
| 44 | String* file_name, |
| 45 | int32_t line_number) { |
| 46 | StackTraceElement* trace = |
| 47 | down_cast<StackTraceElement*>(GetStackTraceElement()->AllocObject(self)); |
Ian Rogers | a436fde | 2013-08-27 23:34:06 -0700 | [diff] [blame] | 48 | if (LIKELY(trace != NULL)) { |
| 49 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_), |
| 50 | const_cast<String*>(declaring_class), false); |
| 51 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_), |
| 52 | const_cast<String*>(method_name), false); |
| 53 | trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_), |
| 54 | const_cast<String*>(file_name), false); |
| 55 | trace->SetField32(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_), |
| 56 | line_number, false); |
| 57 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 58 | return trace; |
| 59 | } |
| 60 | |
| 61 | } // namespace mirror |
| 62 | } // namespace art |