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 #include "throw_location.h"
18 
19 #include "mirror/art_method-inl.h"
20 #include "mirror/class-inl.h"
21 #include "mirror/object-inl.h"
22 #include "utils.h"
23 
24 namespace art {
25 
Dump() const26 std::string ThrowLocation::Dump() const {
27   if (method_ != nullptr) {
28     return StringPrintf("%s:%d", PrettyMethod(method_).c_str(),
29                         method_->GetLineNumFromDexPC(dex_pc_));
30   } else {
31     return "unknown throw location";
32   }
33 }
34 
VisitRoots(RootCallback * visitor,void * arg)35 void ThrowLocation::VisitRoots(RootCallback* visitor, void* arg) {
36   if (this_object_ != nullptr) {
37     visitor(&this_object_, arg, RootInfo(kRootVMInternal));
38     DCHECK(this_object_ != nullptr);
39   }
40   if (method_ != nullptr) {
41     visitor(reinterpret_cast<mirror::Object**>(&method_), arg, RootInfo(kRootVMInternal));
42     DCHECK(method_ != nullptr);
43   }
44 }
45 
46 }  // namespace art
47