blob: 2af512823e2e1f0296b28b244c412d06843feda5 [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);
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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070084#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_