mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-02 18:22:04 +00:00
DEBUG: tools: add vma_set_name_id() helper
Just like vma_set_name() from 51a8f134e
("DEBUG: tools: add vma_set_name()
helper"), but also takes <id> as parameter to append "-$id" suffix after
the name in order to differentiate 2 areas that were named using the same
<type> and <name> combination.
example, using mmap + MAP_SHARED|MAP_ANONYMOUS:
7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon_shmem:type:name-id]
Another example, using mmap + MAP_PRIVATE|MAP_ANONYMOUS or using
glibc/malloc() above MMAP_THRESHOLD:
7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon:type:name-id]
This commit is contained in:
parent
23814a44e5
commit
9d37c4b989
@ -1201,5 +1201,6 @@ int openssl_compare_current_name(const char *name);
|
||||
|
||||
/* vma helpers */
|
||||
void vma_set_name(void *addr, size_t size, const char *type, const char *name);
|
||||
void vma_set_name_id(void *addr, size_t size, const char *type, const char *name, unsigned int id);
|
||||
|
||||
#endif /* _HAPROXY_TOOLS_H */
|
||||
|
19
src/tools.c
19
src/tools.c
@ -6477,11 +6477,13 @@ int openssl_compare_current_name(const char *name)
|
||||
* heap as much as possible below that.
|
||||
*
|
||||
* <type> and <name> are mandatory
|
||||
* <id> is optional, if != ~0, will be used to append an id after the name
|
||||
* in order to differentiate 2 entries set using the same <type> and <name>
|
||||
*
|
||||
* The function does nothing if naming API is not available, and naming errors
|
||||
* are ignored.
|
||||
*/
|
||||
void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
||||
void vma_set_name_id(void *addr, size_t size, const char *type, const char *name, unsigned int id)
|
||||
{
|
||||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
void *aligned_addr;
|
||||
@ -6515,15 +6517,18 @@ void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
||||
* except [, ], \, $ and '.
|
||||
* As a result, when looking for /proc/<pid>/maps, we can see the anonymous range
|
||||
* as follow :
|
||||
* `7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon_shmem:scope:name]`
|
||||
* `7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon_shmem:scope:name{-id}]`
|
||||
* (MAP_SHARED)
|
||||
* `7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon:scope:name]`
|
||||
* `7364c4fff000-736508000000 rw-s 00000000 00:01 3540 [anon:scope:name{-id}]`
|
||||
* (MAP_PRIVATE)
|
||||
*/
|
||||
char fullname[80];
|
||||
int rn;
|
||||
|
||||
rn = snprintf(fullname, sizeof(fullname), "%s:%s", type, name);
|
||||
if (id != ~0)
|
||||
rn = snprintf(fullname, sizeof(fullname), "%s:%s-%u", type, name, id);
|
||||
else
|
||||
rn = snprintf(fullname, sizeof(fullname), "%s:%s", type, name);
|
||||
|
||||
if (rn >= 0) {
|
||||
/* Give a name to the map by setting PR_SET_VMA_ANON_NAME attribute
|
||||
@ -6541,6 +6546,12 @@ void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* wrapper for vma_set_name_id() but without id */
|
||||
void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
||||
{
|
||||
vma_set_name_id(addr, size, type, name, ~0);
|
||||
}
|
||||
|
||||
#if defined(RTLD_DEFAULT) || defined(RTLD_NEXT)
|
||||
/* redefine dlopen() so that we can detect unexpected replacement of some
|
||||
* critical symbols, typically init/alloc/free functions coming from alternate
|
||||
|
Loading…
Reference in New Issue
Block a user