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"
20 #include "gc/accounting/card_table-inl.h"
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
SetClass(Class * java_lang_StackTraceElement)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
ResetClass()35 void StackTraceElement::ResetClass() {
36 CHECK(java_lang_StackTraceElement_ != NULL);
37 java_lang_StackTraceElement_ = NULL;
38 }
39
Alloc(Thread * self,String * declaring_class,String * method_name,String * file_name,int32_t line_number)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 if (LIKELY(trace != NULL)) {
48 trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_),
49 const_cast<String*>(declaring_class), false);
50 trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_),
51 const_cast<String*>(method_name), false);
52 trace->SetFieldObject(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_),
53 const_cast<String*>(file_name), false);
54 trace->SetField32(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_),
55 line_number, false);
56 }
57 return trace;
58 }
59
60 } // namespace mirror
61 } // namespace art
62