1 /*
2  * Copyright (C) 2019 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 #pragma once
18 
19 #include <string>
20 
21 // Forward Declarations.
22 class Pointers;
23 
24 enum AllocEnum : uint8_t {
25   MALLOC = 0,
26   CALLOC,
27   MEMALIGN,
28   REALLOC,
29   FREE,
30   THREAD_DONE,
31 };
32 
33 struct AllocEntry {
34   pid_t tid;
35   AllocEnum type;
36   uint64_t ptr = 0;
37   size_t size = 0;
38   union {
39     uint64_t old_ptr = 0;
40     uint64_t n_elements;
41     uint64_t align;
42   } u;
43 };
44 
45 void AllocGetData(const std::string& line, AllocEntry* entry);
46 
47 bool AllocDoesFree(const AllocEntry& entry);
48 
49 uint64_t AllocExecute(const AllocEntry& entry, Pointers* pointers);
50