Skip to content

Commit 4d8670a

Browse files
authored
Merge pull request #42 from arnaud-lb/travis
Travis
2 parents af6aee6 + a91d57b commit 4d8670a

File tree

8 files changed

+77
-6
lines changed

8 files changed

+77
-6
lines changed

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
dist: xenial
2+
lang: php
3+
compiler:
4+
- gcc
5+
cache:
6+
directories:
7+
- /home/travis/.phpenv/
8+
env:
9+
global:
10+
- MEMPROF_CFLAGS='-Wall -Werror'
11+
jobs:
12+
allow_failures:
13+
- env: PHP_VERSION=8.0snapshot
14+
fast_finish: true
15+
include:
16+
- env: PHP_VERSION=8.0snapshot
17+
- env: PHP_VERSION=7.4.12
18+
- env: PHP_VERSION=7.3.24
19+
- env: PHP_VERSION=7.2.19
20+
- env: PHP_VERSION=7.1.33
21+
22+
before_install:
23+
- |
24+
# Use a non-zts PHP build
25+
set -e
26+
sudo apt-get install libjudy-dev libonig-dev libzip-dev
27+
if ! [ -f $HOME/.phpenv/memprof-travis-cached ]; then
28+
echo "Building PHP"
29+
git clone git://github.com/php-build/php-build.git $HOME/.phpenv/plugins/php-build
30+
phpenv install --verbose --force $PHP_VERSION
31+
rm -rf $HOME/.phpenv/plugins/php-build
32+
touch $HOME/.phpenv/memprof-travis-cached
33+
else
34+
echo "PHP already built"
35+
fi
36+
phpenv rehash
37+
phpenv global $PHP_VERSION
38+
39+
install:
40+
- .travis/build.sh
41+
script:
42+
- .travis/test.sh

.travis/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -xve
4+
5+
if ! grep -q memprof.so ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; then
6+
echo "extension = $(pwd)/modules/memprof.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
7+
fi
8+
phpenv config-rm xdebug.ini || true
9+
10+
phpize
11+
CFLAGS=$MEMPROF_CFLAGS ./configure
12+
make

.travis/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -xve
4+
5+
export PATH=$TRAVIS_BUILD_DIR/.travis:$PATH
6+
7+
PHP=$(which php)
8+
REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE="$PHP" "$PHP" run-tests.php -s -q --show-diff

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# php-memprof
22

3-
![Supported PHP versions: 7.0 ... 8.x](https://img.shields.io/badge/php-7.0%20...%208.x-blue.svg)
3+
![Supported PHP versions: 7.1 ... 8.x](https://img.shields.io/badge/php-7.1%20...%208.x-blue.svg) [![Build Status](https://travis-ci.com/arnaud-lb/php-memory-profiler.svg?branch=v2)](https://travis-ci.com/arnaud-lb/php-memory-profiler)
44

55
php-memprof is a fast and accurate memory profiling extension for PHP that can be used to detect memory leaks.
66

config.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ if test "$PHP_MEMPROF" != "no"; then
5151
dnl
5252
PHP_SUBST(MEMPROF_SHARED_LIBADD)
5353

54+
ORIG_CFLAGS="$CFLAGS"
55+
CFLAGS=""
56+
5457
AC_MSG_CHECKING(for malloc hooks)
5558
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5659
#include <malloc.h>
@@ -70,6 +73,8 @@ if test "$PHP_MEMPROF" != "no"; then
7073
AC_MSG_RESULT(no)
7174
])
7275

76+
CFLAGS="$ORIG_CFLAGS"
77+
7378
AC_DEFINE([MEMPROF_CONFIGURE_VERSION], 3, [Define configure version])
7479

7580
PHP_NEW_EXTENSION(memprof, memprof.c util.c, $ext_shared)

memprof.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static void memprof_zend_execute_internal(zend_execute_data *execute_data_ptr, z
672672
{
673673
int ignore = 0;
674674

675-
if (execute_data_ptr->func == &zend_pass_function) {
675+
if (&execute_data_ptr->func->internal_function == &zend_pass_function) {
676676
ignore = 1;
677677
} else if (execute_data_ptr->func->common.function_name) {
678678
zend_string * name = execute_data_ptr->func->common.function_name;
@@ -719,13 +719,17 @@ static PHP_INI_MH(OnChangeMemoryLimit)
719719

720720
ret = origOnChangeMemoryLimit(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
721721

722+
if (ret != SUCCESS) {
723+
return ret;
724+
}
725+
722726
if (memprof_enabled && orig_zheap) {
723727
zend_mm_set_heap(orig_zheap);
724-
ret = zend_set_memory_limit(PG(memory_limit));
728+
zend_set_memory_limit(PG(memory_limit));
725729
zend_mm_set_heap(zheap);
726730
}
727731

728-
return ret;
732+
return SUCCESS;
729733
}
730734

731735
static void memprof_enable()

tests/zend_pass_function.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Enable with environment variable
2+
zend_pass_function crash
33
--ENV--
44
MEMPROF_PROFILE=1
55
--FILE--

util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ size_t get_function_name(zend_execute_data * execute_data, char * buf, size_t bu
5656
return snprintf(buf, buf_size, "main");
5757
}
5858

59-
if (execute_data->func == &zend_pass_function) {
59+
if (&execute_data->func->internal_function == &zend_pass_function) {
6060
return snprintf(buf, buf_size, "zend_pass_function");
6161
}
6262

0 commit comments

Comments
 (0)