Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 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 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 19 | #include "mirror/art_method-inl.h" |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 20 | #include "mirror/class-inl.h" |
| 21 | #include "mirror/object-inl.h" |
| 22 | #include "object_utils.h" |
| 23 | #include "utils.h" |
| 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | std::string ThrowLocation::Dump() const { |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 28 | if (method_ != nullptr) { |
Ian Rogers | abd7be9 | 2013-08-15 10:26:54 -0700 | [diff] [blame] | 29 | return StringPrintf("%s:%d", PrettyMethod(method_).c_str(), |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 30 | method_->GetLineNumFromDexPC(dex_pc_)); |
Ian Rogers | abd7be9 | 2013-08-15 10:26:54 -0700 | [diff] [blame] | 31 | } else { |
| 32 | return "unknown throw location"; |
| 33 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 34 | } |
| 35 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 36 | void ThrowLocation::VisitRoots(RootCallback* visitor, void* arg) { |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 37 | if (this_object_ != nullptr) { |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 38 | visitor(&this_object_, arg, 0, kRootVMInternal); |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 39 | DCHECK(this_object_ != nullptr); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 40 | } |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 41 | if (method_ != nullptr) { |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 42 | visitor(reinterpret_cast<mirror::Object**>(&method_), arg, 0, kRootVMInternal); |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 43 | DCHECK(method_ != nullptr); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
| 47 | } // namespace art |