Skip to content

Commit 0d79129

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
2 parents 7f7f420 + 237080d commit 0d79129

73 files changed

Lines changed: 2662 additions & 268 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/prof_correctness.yml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ jobs:
4747

4848
- name: Build profiler
4949
run: |
50-
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" | sudo tee -a /etc/apt/sources.list
51-
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" | sudo tee -a /etc/apt/sources.list
52-
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
53-
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
54-
sudo apt remove -y clang-*
50+
codename="$(lsb_release -cs)"
51+
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
52+
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list
5553
sudo apt-get update
56-
sudo apt install -y clang-17
54+
sudo apt-get install -y clang-19 lld-19
55+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100
56+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100
57+
sudo update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-19 100
58+
clang --version
59+
ld.lld --version
5760
cd profiling
5861
version_number=$(awk -F' = ' '$1 == "channel" { gsub(/"/, "", $2); print $2 }' rust-toolchain.toml)
5962
curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y --default-toolchain "$version_number"
@@ -77,7 +80,7 @@ jobs:
7780
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
7881
php -v
7982
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
80-
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
83+
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions" "io" "allocation_time_combined"; do
8184
mkdir -p profiling/tests/correctness/"$test_case"/
8285
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
8386
php -d extension="${PWD}/target/profiler-release/libdatadog_php_profiling.so" "profiling/tests/correctness/${test_case}.php"
@@ -95,7 +98,7 @@ jobs:
9598
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
9699
php -v
97100
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
98-
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
101+
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions" "io" "allocation_time_combined"; do
99102
mkdir -p profiling/tests/correctness/"$test_case"/
100103
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
101104
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
@@ -110,26 +113,6 @@ jobs:
110113
USE_ZEND_ALLOC=0 php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
111114
unset DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE
112115
113-
- name: Run allocation_time_combined test (PHP 8.4+)
114-
if: fromJSON(matrix.php-version) >= 8.4
115-
run: |
116-
export DD_PROFILING_LOG_LEVEL=trace
117-
export DD_PROFILING_EXPERIMENTAL_FEATURES_ENABLED=1
118-
export DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE=1
119-
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
120-
php -v
121-
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
122-
mkdir -p profiling/tests/correctness/allocation_time_combined/
123-
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocation_time_combined/test.pprof
124-
export DD_PROFILING_ALLOCATION_ENABLED=yes
125-
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
126-
export DD_PROFILING_WALL_TIME_ENABLED=yes
127-
export DD_PROFILING_EXPERIMENTAL_CPU_TIME_ENABLED=no
128-
export DD_PROFILING_ENDPOINT_COLLECTION_ENABLED=no
129-
export EXECUTION_TIME=5
130-
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocation_time_combined.php
131-
unset DD_PROFILING_ALLOCATION_ENABLED DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE DD_PROFILING_WALL_TIME_ENABLED DD_PROFILING_EXPERIMENTAL_CPU_TIME_ENABLED DD_PROFILING_ENDPOINT_COLLECTION_ENABLED EXECUTION_TIME
132-
133116
- name: Run ZTS tests
134117
if: matrix.phpts == 'zts'
135118
run: |
@@ -182,12 +165,17 @@ jobs:
182165
pprof_path: profiling/tests/correctness/timeline/
183166

184167
- name: Check profiler correctness for allocation_time_combined
185-
if: fromJSON(matrix.php-version) >= 8.4
186168
uses: Datadog/prof-correctness/analyze@main
187169
with:
188170
expected_json: profiling/tests/correctness/allocation_time_combined.json
189171
pprof_path: profiling/tests/correctness/allocation_time_combined/
190172

173+
- name: Check profiler correctness for IO
174+
uses: Datadog/prof-correctness/analyze@main
175+
with:
176+
expected_json: profiling/tests/correctness/io.json
177+
pprof_path: profiling/tests/correctness/io/
178+
191179
- name: Check profiler correctness for exceptions ZTS
192180
if: matrix.phpts == 'zts'
193181
uses: Datadog/prof-correctness/analyze@main

.gitlab-ci.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
stages:
22
- build
33
- tests
4-
- shared-pipeline
54
- deploy
65
- ci-build
76

87
variables:
98
GIT_SUBMODULE_STRATEGY: recursive
109
# Only clone libdatadog submodule by default
1110
GIT_SUBMODULE_PATHS: libdatadog
12-
# Suppress shared-pipeline jobs (package-oci and its downstream) in the
13-
# parent pipeline. They run in the child pipeline (package-gen.yml) where
14-
# package loader artifacts are available. Override to "false" in
15-
# package-trigger so the child pipeline runs them correctly.
16-
SKIP_SHARED_PIPELINE: "true"
1711
RELIABILITY_ENV_BRANCH:
1812
value: "master"
1913
description: "Run a specific datadog-reliability-env branch downstream"
@@ -23,7 +17,6 @@ include:
2317
- project: DataDog/apm-reliability/libdatadog-build
2418
ref: 5826819695d93286569e70ed087ae6bf906ce2c3
2519
file: templates/ci_authenticated_job.yml
26-
- local: .gitlab/one-pipeline.locked.yml
2720
- local: .gitlab/ci-images.yml
2821

2922
generate-templates:
@@ -102,28 +95,3 @@ package-trigger:
10295
GIT_SUBMODULE_PATHS: libdatadog appsec/third_party/cpp-base64 appsec/third_party/libddwaf appsec/third_party/libddwaf-rust appsec/third_party/msgpack-c
10396
NIGHTLY_BUILD: $NIGHTLY_BUILD
10497
RELIABILITY_ENV_BRANCH: $RELIABILITY_ENV_BRANCH
105-
SKIP_SHARED_PIPELINE: "false"
106-
107-
deploy_to_reliability_env:
108-
variables:
109-
SKIP_SHARED_PIPELINE: "false"
110-
111-
# requirements_json_test doesn't check SKIP_SHARED_PIPELINE, suppress explicitly
112-
requirements_json_test:
113-
rules:
114-
- when: never
115-
116-
validate_supported_configurations_v2_local_file:
117-
needs: []
118-
extends: .validate_supported_configurations_v2_local_file
119-
variables:
120-
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
121-
BACKFILLED: "true"
122-
123-
update_central_configurations_version_range_v2:
124-
extends: .update_central_configurations_version_range_v2
125-
variables:
126-
LOCAL_REPO_NAME: "dd-trace-php"
127-
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
128-
LANGUAGE_NAME: "php"
129-
MULTIPLE_RELEASE_LINES: "false"

.gitlab/build-appsec.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ suffix="${1:-}"
1313
echo "Build nts extension"
1414
switch-php "${PHP_VERSION}"
1515
mkdir -p appsec/build ; cd appsec/build
16-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF -DDD_APPSEC_TESTING=OFF ; make -j $MAKE_JOBS
16+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF \
17+
-DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
18+
make -j $MAKE_JOBS
1719
cp -v ddappsec.so "../../appsec_$(uname -m)/ddappsec-$PHP_API${suffix}.so"
1820
cd "../../"
1921

2022
echo "Build zts extension"
2123
switch-php "${PHP_VERSION}-zts"
2224
mkdir -p appsec/build-zts ; cd appsec/build-zts
23-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF -DDD_APPSEC_TESTING=OFF ; make -j $MAKE_JOBS
25+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF \
26+
-DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
27+
make -j $MAKE_JOBS
2428
cp -v ddappsec.so "../../appsec_$(uname -m)/ddappsec-$PHP_API${suffix}-zts.so"
2529
cd "../../"
2630

.gitlab/generate-appsec.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@
8787
script:
8888
- switch-php $SWITCH_PHP_VERSION
8989
- cd appsec/build
90+
- if [[ "$SWITCH_PHP_VERSION" == *"asan"* ]]; then ASAN_FLAG=ON; else ASAN_FLAG=OFF; fi
9091
- "cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_HELPER=OFF
9192
-DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_CXX_LINK_FLAGS='-stdlib=libc++'
92-
-DDD_APPSEC_TESTING=ON -DBOOST_CACHE_PREFIX=$CI_PROJECT_DIR/boost-cache"
93-
- make -j 4 xtest
93+
-DDD_APPSEC_TESTING=ON -DBOOST_CACHE_PREFIX=$CI_PROJECT_DIR/boost-cache
94+
-DENABLE_ASAN=$ASAN_FLAG"
95+
- ASAN_OPTIONS=malloc_context_size=0 make -j 4 xtest
9496

9597
.appsec_integration_tests:
9698
stage: test

.gitlab/generate-package.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@
9696
- local: .gitlab/benchmarks.yml
9797

9898
# One pipeline job overrides
99+
validate_supported_configurations_v2_local_file:
100+
needs: []
101+
extends: .validate_supported_configurations_v2_local_file
102+
variables:
103+
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
104+
BACKFILLED: "true"
105+
106+
update_central_configurations_version_range_v2:
107+
extends: .update_central_configurations_version_range_v2
108+
variables:
109+
LOCAL_REPO_NAME: "dd-trace-php"
110+
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
111+
LANGUAGE_NAME: "php"
112+
MULTIPLE_RELEASE_LINES: "false"
113+
99114
configure_system_tests:
100115
variables:
101116
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,simple_onboarding_appsec,lib-injection,lib-injection-profiling,docker-ssi"

Cargo.lock

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

appsec/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ option(DD_APPSEC_BUILD_EXTENSION "Whether to builder the extension" ON)
3737
option(DD_APPSEC_ENABLE_COVERAGE "Whether to enable coverage calculation" OFF)
3838
option(DD_APPSEC_TESTING "Whether to enable testing" ON)
3939
option(DD_APPSEC_DDTRACE_ALT "Whether to build appsec with cmake" OFF)
40+
option(DD_APPSEC_EXTENSION_STATIC_LIBSTDCXX "Whether to link the extension with -static-libstdc++ (not available on macOS)" OFF)
4041

4142
add_subdirectory(third_party EXCLUDE_FROM_ALL)
4243

appsec/cmake/clang-format.cmake

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1-
find_program(CLANG_FORMAT clang-format)
2-
if(CLANG_FORMAT STREQUAL CLANG_FORMAT-NOTFOUND)
3-
message(STATUS "Cannot find clang-format, either set CLANG_FORMAT or make it discoverable")
4-
return()
1+
set(_LLVM17_FORMAT /opt/homebrew/opt/llvm@17/bin/clang-format)
2+
if(EXISTS ${_LLVM17_FORMAT})
3+
set(CLANG_FORMAT ${_LLVM17_FORMAT})
4+
message(STATUS "Using Homebrew LLVM 17 clang-format: ${CLANG_FORMAT}")
5+
else()
6+
find_program(_CF_VERSIONED clang-format-17)
7+
if(NOT _CF_VERSIONED STREQUAL _CF_VERSIONED-NOTFOUND)
8+
set(CLANG_FORMAT ${_CF_VERSIONED})
9+
else()
10+
find_program(_CF_UNVERSIONED clang-format)
11+
if(NOT _CF_UNVERSIONED STREQUAL _CF_UNVERSIONED-NOTFOUND)
12+
execute_process(
13+
COMMAND ${_CF_UNVERSIONED} --version
14+
OUTPUT_VARIABLE _CF_VERSION
15+
OUTPUT_STRIP_TRAILING_WHITESPACE
16+
ERROR_QUIET)
17+
if(_CF_VERSION MATCHES " 17\\.")
18+
set(CLANG_FORMAT ${_CF_UNVERSIONED})
19+
endif()
20+
endif()
21+
endif()
22+
if(NOT CLANG_FORMAT)
23+
set(CLANG_FORMAT ${CMAKE_CURRENT_LIST_DIR}/clang-tools/clang-format)
24+
if(NOT EXISTS ${CLANG_FORMAT})
25+
message(STATUS "Cannot find clang-format version 17, either set CLANG_FORMAT or make it discoverable")
26+
return()
27+
endif()
28+
message(STATUS "Using Docker-based clang-format wrapper: ${CLANG_FORMAT}")
29+
endif()
530
endif()
631

732
set(FILE_LIST "")

appsec/cmake/clang-tidy.cmake

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
1-
find_program(CLANG_TIDY run-clang-tidy)
2-
if(CLANG_TIDY STREQUAL CLANG_TIDY-NOTFOUND)
3-
message(STATUS "Cannot find clang-tidy, either set CLANG_TIDY or make it discoverable")
4-
return()
1+
# Prefer a locally installed LLVM 17 run-clang-tidy (e.g. via brew install llvm@17)
2+
# over the Docker-based wrapper, since native execution avoids SDK incompatibilities.
3+
set(_LLVM17_BIN /opt/homebrew/opt/llvm@17/bin)
4+
set(_LLVM17_TIDY ${_LLVM17_BIN}/run-clang-tidy)
5+
set(CLANG_TIDY_BINARY_OPT "")
6+
if(EXISTS ${_LLVM17_TIDY})
7+
set(CLANG_TIDY ${_LLVM17_TIDY})
8+
set(CLANG_TIDY_BINARY_OPT -clang-tidy-binary ${_LLVM17_BIN}/clang-tidy)
9+
message(STATUS "Using Homebrew LLVM 17 run-clang-tidy: ${CLANG_TIDY}")
10+
else()
11+
find_program(_RCT_VERSIONED run-clang-tidy-17)
12+
if(NOT _RCT_VERSIONED STREQUAL _RCT_VERSIONED-NOTFOUND)
13+
set(CLANG_TIDY ${_RCT_VERSIONED})
14+
find_program(_CT_VERSIONED clang-tidy-17)
15+
if(NOT _CT_VERSIONED STREQUAL _CT_VERSIONED-NOTFOUND)
16+
set(CLANG_TIDY_BINARY_OPT -clang-tidy-binary ${_CT_VERSIONED})
17+
endif()
18+
else()
19+
find_program(_RCT_UNVERSIONED run-clang-tidy)
20+
if(NOT _RCT_UNVERSIONED STREQUAL _RCT_UNVERSIONED-NOTFOUND)
21+
# Verify version via co-located clang-tidy
22+
get_filename_component(_RCT_DIR ${_RCT_UNVERSIONED} DIRECTORY)
23+
find_program(_CT_COLOCATED clang-tidy HINTS ${_RCT_DIR} NO_DEFAULT_PATH)
24+
if(NOT _CT_COLOCATED STREQUAL _CT_COLOCATED-NOTFOUND)
25+
execute_process(
26+
COMMAND ${_CT_COLOCATED} --version
27+
OUTPUT_VARIABLE _CT_VERSION
28+
OUTPUT_STRIP_TRAILING_WHITESPACE
29+
ERROR_QUIET)
30+
if(_CT_VERSION MATCHES " 17\\.")
31+
set(CLANG_TIDY ${_RCT_UNVERSIONED})
32+
set(CLANG_TIDY_BINARY_OPT -clang-tidy-binary ${_CT_COLOCATED})
33+
endif()
34+
endif()
35+
endif()
36+
endif()
37+
if(NOT CLANG_TIDY)
38+
set(CLANG_TIDY ${CMAKE_CURRENT_LIST_DIR}/clang-tools/run-clang-tidy)
39+
if(NOT EXISTS ${CLANG_TIDY})
40+
message(STATUS "Cannot find clang-tidy version 17, either set CLANG_TIDY or make it discoverable")
41+
return()
42+
endif()
43+
message(STATUS "Using Docker-based run-clang-tidy wrapper: ${CLANG_TIDY}")
44+
endif()
545
endif()
646

747
set(FILE_LIST "")
@@ -20,27 +60,20 @@ if(DD_APPSEC_BUILD_EXTENSION)
2060
append_target_sources(extension)
2161
endif()
2262

23-
execute_process (
24-
COMMAND bash -c "${CLANG_TIDY} --help | grep -qs 'use-color'"
25-
RESULT_VARIABLE USE_COLOR
26-
)
27-
28-
set(COLOR_OPT "")
29-
if (USE_COLOR EQUAL 0)
30-
set(COLOR_OPT -use-color)
31-
endif()
32-
3363
set(TIDY_DEPS "")
3464
if(DD_APPSEC_BUILD_EXTENSION AND TARGET libxml2_build)
3565
list(APPEND TIDY_DEPS libxml2_build)
3666
endif()
67+
if(TARGET boost_build)
68+
list(APPEND TIDY_DEPS boost_build)
69+
endif()
3770

3871
add_custom_target(tidy
39-
COMMAND ${CLANG_TIDY} ${COLOR_OPT} -p ${CMAKE_BINARY_DIR} ${FILE_LIST}
72+
COMMAND ${CLANG_TIDY} ${CLANG_TIDY_BINARY_OPT} -use-color -p ${CMAKE_BINARY_DIR} ${FILE_LIST}
4073
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4174
DEPENDS ${TIDY_DEPS})
4275

4376
add_custom_target(tidy_fix
44-
COMMAND ${CLANG_TIDY} ${COLOR_OPT} -fix -p ${CMAKE_BINARY_DIR} ${FILE_LIST}
77+
COMMAND ${CLANG_TIDY} ${CLANG_TIDY_BINARY_OPT} -use-color -fix -p ${CMAKE_BINARY_DIR} ${FILE_LIST}
4578
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4679
DEPENDS ${TIDY_DEPS})

0 commit comments

Comments
 (0)