1 /*
2  * Copyright (C) 2023 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 #ifndef BERBERIS_TEST_UTILS_TESTING_RUN_GENERATED_CODE_H_
18 #define BERBERIS_TEST_UTILS_TESTING_RUN_GENERATED_CODE_H_
19 
20 #include "berberis/guest_state/guest_addr.h"
21 #include "berberis/guest_state/guest_state.h"
22 #include "berberis/runtime_primitives/host_code.h"
23 #include "berberis/runtime_primitives/runtime_library.h"
24 #include "berberis/runtime_primitives/translation_cache.h"
25 
26 namespace berberis {
27 
TestingRunGeneratedCode(ThreadState * state,HostCode code,GuestAddr stop_pc)28 inline void TestingRunGeneratedCode(ThreadState* state, HostCode code, GuestAddr stop_pc) {
29   auto cache = TranslationCache::GetInstance();
30   cache->SetStop(stop_pc);
31   berberis_RunGeneratedCode(state, code);
32   cache->TestingClearStop(stop_pc);
33 }
34 
35 }  // namespace berberis
36 
37 #endif  // BERBERIS_TEST_UTILS_TESTING_RUN_GENERATED_CODE_H_
38