Skip to content

Commit

Permalink
Support MUSL compilation of backtrace.c
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelchcki committed Feb 20, 2019
1 parent 081c2f4 commit 4614f7e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ x-aliases:
- .scenarios.lock:/home/circleci/app/.scenarios.lock

services:
'5.4-debug': { <<: *base_php_service, build: 'dockerfiles/debug_php-5.4' }

'5.4-debug': { <<: *base_php_service, image: 'datadog/docker-library:ddtrace_alpine_php-5.4.39-debug' }
'5.4': { <<: *base_php_service, image: 'datadog/docker-library:ddtrace_php_5_4' }
'5.6': { <<: *base_56_service, image: 'datadog/docker-library:ddtrace_php_5_6' }
'5.6-zts': { <<: *base_56_service, image: 'circleci/php:5.6-zts' }
Expand Down
8 changes: 8 additions & 0 deletions src/ext/backtrace.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if defined(__GLIBC__) || defined(__APPLE__)
#include <execinfo.h>
#include <php.h>
#include <signal.h>
Expand Down Expand Up @@ -49,3 +50,10 @@ void ddtrace_install_backtrace_handler(TSRMLS_D) {
handler_installed = 1;
}
}
#else
void ddtrace_install_backtrace_handler(TSRMLS_D) {
#ifdef ZTS
UNUSED(TSRML_C);
#endif // ZTS
}
#endif // GLIBC
2 changes: 2 additions & 0 deletions src/ext/backtrace.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef DD_BACKTRACE_H
#define DD_BACKTRACE_H
#define MAX_STACK_SIZE 1024
#if defined(__GLIBC__) || defined(__APPLE__)
void ddtrace_backtrace_handler(int sig);
#endif
void ddtrace_install_backtrace_handler(TSRMLS_D);

#endif // DD_BACKTRACE_H
4 changes: 4 additions & 0 deletions tests/ext/segfault_backtrace_enabled.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
--TEST--
Dump backtrace when segmentation fault signal is raised and config enables it
--SKIPIF--
<?php
preg_match("/alpine/i", file_get_contents("/etc/os-release")) and die("skip Unsupported LIBC");
?>
--INI--
ddtrace.log_backtrace=1
--FILE--
Expand Down
4 changes: 4 additions & 0 deletions tests/ext/segfault_backtrace_enabled_via_env.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
--TEST--
Dump backtrace when segmentation fault signal is raised and config enables it
--SKIPIF--
<?php
preg_match("/alpine/i", file_get_contents("/etc/os-release")) and die("skip Unsupported LIBC");
?>
--ENV--
DD_LOG_BACKTRACE=1
--FILE--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
--TEST--
Dump backtrace when segmentation fault signal is raised and config enables it
--SKIPIF--
<?php
preg_match("/alpine/i", file_get_contents("/etc/os-release")) and die("skip Unsupported LIBC");
?>
--INI--
ddtrace.log_backtrace=0
--ENV--
Expand Down

0 comments on commit 4614f7e

Please sign in to comment.