1/*
2 * Copyright (C) 2013 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_THROW_LOCATION_H_
18#define ART_RUNTIME_THROW_LOCATION_H_
19
20#include "base/macros.h"
21#include "root_visitor.h"
22
23#include <stdint.h>
24#include <string>
25
26namespace art {
27
28namespace mirror {
29class ArtMethod;
30class Object;
31}  // mirror
32
33class PACKED(4) ThrowLocation {
34 public:
35  ThrowLocation() {
36    Clear();
37  }
38
39  ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method,
40                uint32_t throw_dex_pc) :
41      this_object_(throw_this_object),
42      method_(throw_method),
43      dex_pc_(throw_dex_pc) {}
44
45  mirror::Object* GetThis() const {
46    return this_object_;
47  }
48
49  mirror::ArtMethod* GetMethod() const {
50    return method_;
51  }
52
53  uint32_t GetDexPc() const {
54    return dex_pc_;
55  }
56
57  void Clear() {
58    this_object_ = NULL;
59    method_ = NULL;
60    dex_pc_ = -1;
61  }
62
63  std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
64
65  void VisitRoots(RootVisitor* visitor, void* arg);
66
67 private:
68  // The 'this' reference of the throwing method.
69  mirror::Object* this_object_;
70  // The throwing method.
71  mirror::ArtMethod* method_;
72  // The instruction within the throwing method.
73  uint32_t dex_pc_;
74};
75
76}  // namespace art
77
78#endif  // ART_RUNTIME_THROW_LOCATION_H_
79