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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ |
| 18 | #define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
| 20 | #include "object.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 21 | #include "sirt_ref.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | struct StackTraceElementOffsets; |
| 26 | |
| 27 | namespace mirror { |
| 28 | |
| 29 | // C++ mirror of java.lang.StackTraceElement |
| 30 | class 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, |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 53 | SirtRef<String>& declaring_class, |
| 54 | SirtRef<String>& method_name, |
| 55 | SirtRef<String>& file_name, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 56 | int32_t line_number) |
| 57 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 58 | |
| 59 | static void SetClass(Class* java_lang_StackTraceElement); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 60 | static void ResetClass(); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame^] | 61 | static void VisitRoots(RootVisitor* visitor, void* arg) |
| 62 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 63 | |
| 64 | private: |
| 65 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 66 | String* declaring_class_; |
| 67 | String* file_name_; |
| 68 | String* method_name_; |
| 69 | int32_t line_number_; |
| 70 | |
| 71 | static Class* GetStackTraceElement() { |
| 72 | DCHECK(java_lang_StackTraceElement_ != NULL); |
| 73 | return java_lang_StackTraceElement_; |
| 74 | } |
| 75 | |
| 76 | static Class* java_lang_StackTraceElement_; |
| 77 | |
| 78 | friend struct art::StackTraceElementOffsets; // for verifying offset information |
| 79 | DISALLOW_IMPLICIT_CONSTRUCTORS(StackTraceElement); |
| 80 | }; |
| 81 | |
| 82 | } // namespace mirror |
| 83 | } // namespace art |
| 84 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 85 | #endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ |