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 "base/macros.h"
21 #include "object.h"
22 
23 namespace art HIDDEN {
24 
25 template<class T> class Handle;
26 struct StackTraceElementOffsets;
27 
28 namespace mirror {
29 
30 // C++ mirror of java.lang.StackTraceElement
31 class MANAGED StackTraceElement final : public Object {
32  public:
33   MIRROR_CLASS("Ljava/lang/StackTraceElement;");
34 
35   ObjPtr<String> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
36 
37   ObjPtr<String> GetMethodName() REQUIRES_SHARED(Locks::mutator_lock_);
38 
39   ObjPtr<String> GetFileName() REQUIRES_SHARED(Locks::mutator_lock_);
40 
GetLineNumber()41   int32_t GetLineNumber() REQUIRES_SHARED(Locks::mutator_lock_) {
42     return GetField32(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_));
43   }
44 
45   static ObjPtr<StackTraceElement> Alloc(Thread* self,
46                                          Handle<String> declaring_class,
47                                          Handle<String> method_name,
48                                          Handle<String> file_name,
49                                          int32_t line_number)
50       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
51 
52  private:
53   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
54   HeapReference<String> declaring_class_;
55   HeapReference<String> file_name_;
56   HeapReference<String> method_name_;
57   int32_t line_number_;
58 
59   template<bool kTransactionActive>
60   void Init(ObjPtr<String> declaring_class,
61             ObjPtr<String> method_name,
62             ObjPtr<String> file_name,
63             int32_t line_number)
64       REQUIRES_SHARED(Locks::mutator_lock_);
65 
66   friend struct art::StackTraceElementOffsets;  // for verifying offset information
67   DISALLOW_IMPLICIT_CONSTRUCTORS(StackTraceElement);
68 };
69 
70 }  // namespace mirror
71 }  // namespace art
72 
73 #endif  // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_
74