Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 55 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cfg-if = { version = "1.0" }
cpu-time = { version = "1.0" }
chrono = { version = "0.4" }
crossbeam-channel = { version = "0.5", default-features = false, features = ["std"] }
dynasmrt = "2.0"
http = { version = "1.4" }
libdd-alloc = { git = "https://github.com/DataDog/libdatadog", tag = "v29.0.0" }
libdd-profiling = { git = "https://github.com/DataDog/libdatadog", tag = "v29.0.0" }
Expand Down
16 changes: 15 additions & 1 deletion profiling/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn main() {
let post_startup_cb = cfg_post_startup_cb(vernum);
let preload = cfg_preload(vernum);
let fibers = cfg_fibers(vernum);
let frameless = cfg_frameless(vernum);
let run_time_cache = cfg_run_time_cache(vernum);
let trigger_time_sample = cfg_trigger_time_sample();
let zend_error_observer = cfg_zend_error_observer(vernum);
Expand All @@ -47,6 +48,7 @@ fn main() {
preload,
run_time_cache,
fibers,
frameless,
trigger_time_sample,
zend_error_observer,
);
Expand Down Expand Up @@ -103,6 +105,7 @@ fn build_zend_php_ffis(
preload: bool,
run_time_cache: bool,
fibers: bool,
frameless: bool,
trigger_time_sample: bool,
zend_error_observer: bool,
) {
Expand Down Expand Up @@ -143,6 +146,7 @@ fn build_zend_php_ffis(
let post_startup_cb = if post_startup_cb { "1" } else { "0" };
let preload = if preload { "1" } else { "0" };
let fibers = if fibers { "1" } else { "0" };
let frameless = if frameless { "1" } else { "0" };
let run_time_cache = if run_time_cache { "1" } else { "0" };
let trigger_time_sample = if trigger_time_sample { "1" } else { "0" };
let zend_error_observer = if zend_error_observer { "1" } else { "0" };
Expand All @@ -159,6 +163,7 @@ fn build_zend_php_ffis(
.define("CFG_POST_STARTUP_CB", post_startup_cb)
.define("CFG_PRELOAD", preload)
.define("CFG_FIBERS", fibers)
.define("CFG_FRAMELESS", frameless)
.define("CFG_RUN_TIME_CACHE", run_time_cache)
.define("CFG_STACK_WALKING_TESTS", stack_walking_tests)
.define("CFG_TRIGGER_TIME_SAMPLE", trigger_time_sample)
Expand Down Expand Up @@ -373,6 +378,16 @@ fn cfg_fibers(vernum: u64) -> bool {
}
}

fn cfg_frameless(vernum: u64) -> bool {
println!("cargo::rustc-check-cfg=cfg(php_frameless)");
if vernum >= 80400 {
println!("cargo:rustc-cfg=php_frameless");
true
} else {
false
}
}

fn cfg_php_feature_flags(vernum: u64) {
println!("cargo::rustc-check-cfg=cfg(php_gc_status, php_zend_compile_string_has_position, php_gc_status_extended, php_frameless, php_opcache_restart_hook, php_zend_mm_set_custom_handlers_ex)");

Expand All @@ -386,7 +401,6 @@ fn cfg_php_feature_flags(vernum: u64) {
println!("cargo:rustc-cfg=php_gc_status_extended");
}
if vernum >= 80400 {
println!("cargo:rustc-cfg=php_frameless");
println!("cargo:rustc-cfg=php_opcache_restart_hook");
println!("cargo:rustc-cfg=php_zend_mm_set_custom_handlers_ex");
}
Expand Down
7 changes: 4 additions & 3 deletions profiling/src/php_ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ bool ddog_php_prof_is_post_startup(void) {
static post_startup_cb_result (*orig_post_startup_cb)(void) = NULL;

static post_startup_cb_result ddog_php_prof_post_startup_cb(void) {
#if CFG_FRAMELESS
ddog_php_prof_post_startup(); // before preload+JIT (which may hardcode the flf handlers)
#endif

if (orig_post_startup_cb) {
post_startup_cb_result (*cb)(void) = orig_post_startup_cb;

Expand Down Expand Up @@ -552,9 +556,6 @@ void ddog_php_test_free_fake_zend_function(zend_function *func) {
free(func);
}

// Stub for zend_flf_functions (PHP 8.4+ frameless calls) to allow tests to link
// without the real PHP runtime. The test doesn't exercise frameless code paths.
__attribute__((weak)) zend_function **zend_flf_functions;
#endif // CFG_STACK_WALKING_TESTS || CFG_TEST

void *opcache_handle = NULL;
Expand Down
4 changes: 4 additions & 0 deletions profiling/src/php_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ void ddog_php_prof_zend_mm_set_custom_handlers(zend_mm_heap *heap,

zend_execute_data* ddog_php_prof_get_current_execute_data();

#if CFG_FRAMELESS
void ddog_php_prof_post_startup();
#endif

#if CFG_FIBERS
zend_fiber* ddog_php_prof_get_active_fiber();
zend_fiber* ddog_php_prof_get_active_fiber_test();
Expand Down
Loading
Loading