2020-04-03 21:11:46 +02:00
|
|
|
/*
|
|
|
|
* Utility functions to read our own memory map
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Linaro Ltd
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2021-06-05 19:49:38 +02:00
|
|
|
#ifndef SELFMAP_H
|
|
|
|
#define SELFMAP_H
|
2020-04-03 21:11:46 +02:00
|
|
|
|
2023-08-06 19:10:44 +02:00
|
|
|
#include "qemu/interval-tree.h"
|
|
|
|
|
2020-04-03 21:11:46 +02:00
|
|
|
typedef struct {
|
2023-08-06 19:10:44 +02:00
|
|
|
IntervalTreeNode itree;
|
2020-04-03 21:11:46 +02:00
|
|
|
|
|
|
|
/* flags */
|
|
|
|
bool is_read;
|
|
|
|
bool is_write;
|
|
|
|
bool is_exec;
|
|
|
|
bool is_priv;
|
|
|
|
|
2023-08-09 04:43:51 +02:00
|
|
|
dev_t dev;
|
|
|
|
ino_t inode;
|
2023-08-06 19:10:44 +02:00
|
|
|
uint64_t offset;
|
|
|
|
const char *path;
|
2020-04-03 21:11:46 +02:00
|
|
|
} MapInfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* read_self_maps:
|
|
|
|
*
|
2023-08-06 19:10:44 +02:00
|
|
|
* Read /proc/self/maps and return a tree of MapInfo structures.
|
2020-04-03 21:11:46 +02:00
|
|
|
*/
|
2023-08-06 19:10:44 +02:00
|
|
|
IntervalTreeRoot *read_self_maps(void);
|
2020-04-03 21:11:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* free_self_maps:
|
2023-08-06 19:10:44 +02:00
|
|
|
* @info: an interval tree
|
2020-04-03 21:11:46 +02:00
|
|
|
*
|
2023-08-06 19:10:44 +02:00
|
|
|
* Free a tree of MapInfo structures.
|
2020-04-03 21:11:46 +02:00
|
|
|
*/
|
2023-08-06 19:10:44 +02:00
|
|
|
void free_self_maps(IntervalTreeRoot *root);
|
2020-04-03 21:11:46 +02:00
|
|
|
|
2022-05-06 15:49:11 +02:00
|
|
|
#endif /* SELFMAP_H */
|