jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2012 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 "instrumentation.h" |
| 18 | #include "runtime.h" |
| 19 | #include "thread.h" |
| 20 | #include "trace.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | extern "C" const void* artInstrumentationMethodEntryFromCode(AbstractMethod* method, Thread* self, |
| 25 | uintptr_t lr) { |
| 26 | Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 27 | Trace* trace = instrumentation->GetTrace(); |
| 28 | InstrumentationStackFrame instrumentation_frame = InstrumentationStackFrame(method, lr); |
| 29 | self->PushInstrumentationStackFrame(instrumentation_frame); |
| 30 | |
| 31 | trace->LogMethodTraceEvent(self, method, Trace::kMethodTraceEnter); |
| 32 | |
| 33 | return instrumentation->GetSavedCodeFromMap(method); |
| 34 | } |
| 35 | |
| 36 | extern "C" uintptr_t artInstrumentationMethodExitFromCode() { |
| 37 | Trace* trace = Runtime::Current()->GetInstrumentation()->GetTrace(); |
| 38 | InstrumentationStackFrame instrumentation_frame = Thread::Current()->PopInstrumentationStackFrame(); |
| 39 | AbstractMethod* method = instrumentation_frame.method_; |
| 40 | uintptr_t lr = instrumentation_frame.return_pc_; |
| 41 | |
| 42 | trace->LogMethodTraceEvent(Thread::Current(), method, Trace::kMethodTraceExit); |
| 43 | |
| 44 | return lr; |
| 45 | } |
| 46 | |
| 47 | } // namespace art |