blob: 06b6e8d2773584cfa39bdf624aaef5b85f2469af [file] [log] [blame]
Ian Rogers62d6c772013-02-27 08:32:07 -08001/*
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
Brian Carlstromea46f952013-07-30 01:26:50 -070019#include "mirror/art_method-inl.h"
Ian Rogers62d6c772013-02-27 08:32:07 -080020#include "mirror/class-inl.h"
21#include "mirror/object-inl.h"
22#include "object_utils.h"
23#include "utils.h"
24
25namespace art {
26
27std::string ThrowLocation::Dump() const {
Mathieu Chartierc528dba2013-11-26 12:00:11 -080028 if (method_ != nullptr) {
Ian Rogersabd7be92013-08-15 10:26:54 -070029 return StringPrintf("%s:%d", PrettyMethod(method_).c_str(),
30 MethodHelper(method_).GetLineNumFromDexPC(dex_pc_));
31 } else {
32 return "unknown throw location";
33 }
Ian Rogers62d6c772013-02-27 08:32:07 -080034}
35
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080036void ThrowLocation::VisitRoots(RootCallback* visitor, void* arg) {
Mathieu Chartier423d2a32013-09-12 17:33:56 -070037 if (this_object_ != nullptr) {
Mathieu Chartier815873e2014-02-13 18:02:13 -080038 visitor(&this_object_, arg, 0, kRootVMInternal);
Mathieu Chartier423d2a32013-09-12 17:33:56 -070039 DCHECK(this_object_ != nullptr);
Ian Rogers62d6c772013-02-27 08:32:07 -080040 }
Mathieu Chartier423d2a32013-09-12 17:33:56 -070041 if (method_ != nullptr) {
Mathieu Chartier815873e2014-02-13 18:02:13 -080042 visitor(reinterpret_cast<mirror::Object**>(&method_), arg, 0, kRootVMInternal);
Mathieu Chartier423d2a32013-09-12 17:33:56 -070043 DCHECK(method_ != nullptr);
Ian Rogers62d6c772013-02-27 08:32:07 -080044 }
45}
46
47} // namespace art