How can I check memgrick on every instance of a process without starting it using valgrind command parameters

how can I execute memcheck valgrind for each process instance without starting it using the valgrind command parameters.

Is there a way to save the monitoring parameters saved in the process, and not start the process every time with the valgrind command?

In Microsoft Application Verifier, if an application is specified for control, then any number of instances of this application is monitored, whether its child process is running or not.

Any ideas to do the same in Valgrind?

I tried the --trace-children = yes variant of valgrind memcheck ... but my xyz application signals another zzz application to start a new xyz (process) intuition that I want to analyze. in this case, valgrind exits when xyz finishes the zzz signaling. it does not track which zzz process has started.

Thanks, Vijay

+3
source share
3 answers

IIRC, Valgrind must run the application because it changes read-only characters to replace common library functions such as mallocetc.

This means that you cannot attach memcheck to an already running process, because it cannot change this section of the program in memory (and this would probably ruin the current state).

, . A Google , memcheck . , bash script, . , myprog newprog, :

]$ mv /path/to/myprog /path/to/newprog

#!/bin/bash
valgrind (options) /path/to/newprog $@

myprog, $@ . , , myprog -a b -c d, valgrind.

C-, execve() , .

, :)

+4

xyz , , valgrind?

, xyz run_me_under_valgrind, xyz, run_me_under_valgrind valgrind.

+2

, script PostgreSQL. ( , , valgrind).

#!/bin/bash
set -e -u -x

# Pop top two elements from path; the first is added by pg_regress
# and the next is us.
function join_by { local IFS="$1"; shift; echo "$*"; }
IFS=':' read -r -a PATHA <<< "$PATH"
export PATH=$(join_by ":" "${PATHA[@]:2}")

NEXT_POSTGRES=$(which postgres)
if [ "${NEXT_POSTGRES}" -ef "./valgrind/postgres" ]; then
    echo "ERROR: attempt to execute self"
    exit 1
fi

echo "Running ${NEXT_POSTGRES} under Valgrind"

valgrind --leak-check=full --show-leak-kinds=definite,possible \
    --gen-suppressions=all --verbose --time-stamp=yes  \
    --log-file=valgrind-$$-%p.log --trace-children=yes \
    --track-origins=yes --read-var-info=yes --malloc-fill=8f \
    --free-fill=9f --num-callers=30 postgres "$@"

PATH, exec postgres . , script postgres, , .

whatis -a, . , .


, ,

   valgrind: mmap(0x58000000, 2347008) failed in UME with error 22 (Invalid argument).
   valgrind: this can be caused by executables with very large text, data or bss segments.

... , valgrind valgrind .

0

Source: https://habr.com/ru/post/1714496/


All Articles