Memory option "-m" fails with popen_read_line: No stdout [...] get_symbol_offset: Failed
paslandau opened this issue · comments
Pascal Landau commented
Hey,
I'm trying to use the -m
flag on the following test script:
<?php
$i = 0;
while (true) {
$i++;
file_put_contents("/tmp/foo.txt", "hello$i\n", FILE_APPEND);
sleep(1);
}
running as a background process but I get the following error:
popen_read_line: No stdout; cmd=objdump -Tt /usr/bin/php7.3 | awk '/ alloc_globals$/{print $1; exit}'
get_symbol_offset: Failed
Full steps (running as root
):
# php /var/www/current/test.php &
[1] 311
# ~/phpspy/phpspy -p 311 -m
popen_read_line: No stdout; cmd=objdump -Tt /usr/bin/php7.3 | awk '/ alloc_globals$/{print $1; exit}'
get_symbol_offset: Failed
# ps aux | grep test.php
root 311 0.0 0.6 331260 27604 pts/1 S 10:18 0:00 php /var/www/current/test.php
root 328 0.0 0.0 14512 1076 pts/1 S+ 10:19 0:00 grep --color=auto test.php
Using https://github.com/phusion/baseimage-docker to test
$ docker build -t my-phpspy -<<'EOF'
FROM phusion/baseimage:latest
RUN apt-get update -yqq && apt-get install -yqq software-properties-common && \
add-apt-repository -y ppa:ondrej/php \
;
RUN apt-get update -yqq && apt-get install -yqq \
git \
build-essential \
python \
php7.3-cli \
;
RUN cd ~ \
&& git clone --recursive https://github.com/adsr/phpspy.git \
&& cd phpspy \
&& make \
;
EOF
$ docker run -d my-phpspy
Adam commented
Hi @paslandau. The --memory-usage
option needs to know where the alloc_globals
symbol is. This symbol is not exposed via ZEND_API
in php-src so it will only be there if your PHP binary was built with debug symbols. Maybe the ppa you are using has a version with debug symbols? If not you can compile PHP from source. I'll add this to the docs.
Alok Kumar Singh commented
Any other alternative than rebuilding php?