blob: 4d2aec088e9081d775244ccd5c0b6de999eebdfd [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"
Ian Rogers62d6c772013-02-27 08:32:07 -080022#include "utils.h"
23
24namespace art {
25
26std::string ThrowLocation::Dump() const {
Mathieu Chartierc528dba2013-11-26 12:00:11 -080027 if (method_ != nullptr) {
Ian Rogersabd7be92013-08-15 10:26:54 -070028 return StringPrintf("%s:%d", PrettyMethod(method_).c_str(),
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070029 method_->GetLineNumFromDexPC(dex_pc_));
Ian Rogersabd7be92013-08-15 10:26:54 -070030 } else {
31 return "unknown throw location";
32 }
Ian Rogers62d6c772013-02-27 08:32:07 -080033}
34
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080035void ThrowLocation::VisitRoots(RootCallback* visitor, void* arg) {
Mathieu Chartier423d2a32013-09-12 17:33:56 -070036 if (this_object_ != nullptr) {
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080037 visitor(&this_object_, arg, RootInfo(kRootVMInternal));
Mathieu Chartier423d2a32013-09-12 17:33:56 -070038 DCHECK(this_object_ != nullptr);
Ian Rogers62d6c772013-02-27 08:32:07 -080039 }
Mathieu Chartier423d2a32013-09-12 17:33:56 -070040 if (method_ != nullptr) {
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080041 visitor(reinterpret_cast<mirror::Object**>(&method_), arg, RootInfo(kRootVMInternal));
Mathieu Chartier423d2a32013-09-12 17:33:56 -070042 DCHECK(method_ != nullptr);
Ian Rogers62d6c772013-02-27 08:32:07 -080043 }
44}
45
46} // namespace art