mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02: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 */
|
/* vma helpers */
|
||||||
void vma_set_name(void *addr, size_t size, const char *type, const char *name);
|
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 */
|
#endif /* _HAPROXY_TOOLS_H */
|
||||||
|
17
src/tools.c
17
src/tools.c
@ -6477,11 +6477,13 @@ int openssl_compare_current_name(const char *name)
|
|||||||
* heap as much as possible below that.
|
* heap as much as possible below that.
|
||||||
*
|
*
|
||||||
* <type> and <name> are mandatory
|
* <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
|
* The function does nothing if naming API is not available, and naming errors
|
||||||
* are ignored.
|
* 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);
|
long pagesize = sysconf(_SC_PAGESIZE);
|
||||||
void *aligned_addr;
|
void *aligned_addr;
|
||||||
@ -6515,14 +6517,17 @@ void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
|||||||
* except [, ], \, $ and '.
|
* except [, ], \, $ and '.
|
||||||
* As a result, when looking for /proc/<pid>/maps, we can see the anonymous range
|
* As a result, when looking for /proc/<pid>/maps, we can see the anonymous range
|
||||||
* as follow :
|
* 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)
|
* (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)
|
* (MAP_PRIVATE)
|
||||||
*/
|
*/
|
||||||
char fullname[80];
|
char fullname[80];
|
||||||
int rn;
|
int rn;
|
||||||
|
|
||||||
|
if (id != ~0)
|
||||||
|
rn = snprintf(fullname, sizeof(fullname), "%s:%s-%u", type, name, id);
|
||||||
|
else
|
||||||
rn = snprintf(fullname, sizeof(fullname), "%s:%s", type, name);
|
rn = snprintf(fullname, sizeof(fullname), "%s:%s", type, name);
|
||||||
|
|
||||||
if (rn >= 0) {
|
if (rn >= 0) {
|
||||||
@ -6541,6 +6546,12 @@ void vma_set_name(void *addr, size_t size, const char *type, const char *name)
|
|||||||
#endif
|
#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)
|
#if defined(RTLD_DEFAULT) || defined(RTLD_NEXT)
|
||||||
/* redefine dlopen() so that we can detect unexpected replacement of some
|
/* redefine dlopen() so that we can detect unexpected replacement of some
|
||||||
* critical symbols, typically init/alloc/free functions coming from alternate
|
* critical symbols, typically init/alloc/free functions coming from alternate
|
||||||
|
Loading…
Reference in New Issue
Block a user