stack_trace_element.h revision 590fee9e8972f872301c2d16a575d579ee564bee
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#ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ 18#define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ 19 20#include "object.h" 21#include "sirt_ref.h" 22 23namespace art { 24 25struct StackTraceElementOffsets; 26 27namespace mirror { 28 29// C++ mirror of java.lang.StackTraceElement 30class MANAGED StackTraceElement : public Object { 31 public: 32 const String* GetDeclaringClass() const { 33 return GetFieldObject<const String*>( 34 OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_), false); 35 } 36 37 const String* GetMethodName() const { 38 return GetFieldObject<const String*>( 39 OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_), false); 40 } 41 42 const String* GetFileName() const { 43 return GetFieldObject<const String*>( 44 OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_), false); 45 } 46 47 int32_t GetLineNumber() const { 48 return GetField32( 49 OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_), false); 50 } 51 52 static StackTraceElement* Alloc(Thread* self, 53 SirtRef<String>& declaring_class, 54 SirtRef<String>& method_name, 55 SirtRef<String>& file_name, 56 int32_t line_number) 57 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 58 59 static void SetClass(Class* java_lang_StackTraceElement); 60 61 static void ResetClass(); 62 63 private: 64 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". 65 String* declaring_class_; 66 String* file_name_; 67 String* method_name_; 68 int32_t line_number_; 69 70 static Class* GetStackTraceElement() { 71 DCHECK(java_lang_StackTraceElement_ != NULL); 72 return java_lang_StackTraceElement_; 73 } 74 75 static Class* java_lang_StackTraceElement_; 76 77 friend struct art::StackTraceElementOffsets; // for verifying offset information 78 DISALLOW_IMPLICIT_CONSTRUCTORS(StackTraceElement); 79}; 80 81} // namespace mirror 82} // namespace art 83 84#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ 85