blob: d1be4dcfded3c13521da900174b4f87d11d95932 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_
18#define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
20#include "object.h"
Mathieu Chartier590fee92013-09-13 13:46:47 -070021#include "sirt_ref.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080022
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,
Mathieu Chartier590fee92013-09-13 13:46:47 -070053 SirtRef<String>& declaring_class,
54 SirtRef<String>& method_name,
55 SirtRef<String>& file_name,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080056 int32_t line_number)
57 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
58
59 static void SetClass(Class* java_lang_StackTraceElement);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080060 static void ResetClass();
Mathieu Chartierc528dba2013-11-26 12:00:11 -080061 static void VisitRoots(RootVisitor* visitor, void* arg)
62 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080063
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 Carlstromfc0e3212013-07-17 14:40:12 -070085#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_