mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
linux-user: factor out reading of /proc/self/maps
Unfortunately reading /proc/self/maps is still considered the gold standard for a process finding out about it's own memory layout. As we will want this data in other contexts soon factor out the code to read and parse the data. Rather than just blindly copying the existing sscanf based code we use a more modern glib version of the parsing code to make a more general purpose map structure. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20200403191150.863-9-alex.bennee@linaro.org>
This commit is contained in:
parent
2f311075b7
commit
01ef6b9e4e
4 changed files with 151 additions and 30 deletions
44
include/qemu/selfmap.h
Normal file
44
include/qemu/selfmap.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Utility functions to read our own memory map
|
||||
*
|
||||
* Copyright (c) 2020 Linaro Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _SELFMAP_H_
|
||||
#define _SELFMAP_H_
|
||||
|
||||
typedef struct {
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
|
||||
/* flags */
|
||||
bool is_read;
|
||||
bool is_write;
|
||||
bool is_exec;
|
||||
bool is_priv;
|
||||
|
||||
unsigned long offset;
|
||||
gchar *dev;
|
||||
uint64_t inode;
|
||||
gchar *path;
|
||||
} MapInfo;
|
||||
|
||||
|
||||
/**
|
||||
* read_self_maps:
|
||||
*
|
||||
* Read /proc/self/maps and return a list of MapInfo structures.
|
||||
*/
|
||||
GSList *read_self_maps(void);
|
||||
|
||||
/**
|
||||
* free_self_maps:
|
||||
* @info: a GSlist
|
||||
*
|
||||
* Free a list of MapInfo structures.
|
||||
*/
|
||||
void free_self_maps(GSList *info);
|
||||
|
||||
#endif /* _SELFMAP_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue