From 30672cd2025ab3dcdcd0aff27110e310cb5eba1e Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Wed, 12 Nov 2025 13:59:56 +0300 Subject: [PATCH 1/4] add builtins stubs --- builtin-functions/kphp-light/stdlib/error.txt | 1 - .../kphp-light/stdlib/kphp-toggles.txt | 1 - .../kphp-light/stdlib/kphp-tracing.txt | 20 ++++------ .../diagnostics/error-handling-functions.h | 4 ++ .../stdlib/system/system-functions.h | 2 + runtime-light/stdlib/tracing/tracing-div.h | 13 ++++++- runtime-light/stdlib/tracing/tracing-event.h | 11 ++++++ .../stdlib/tracing/tracing-functions.h | 10 ----- runtime-light/stdlib/tracing/tracing-span.h | 39 ++++++++++--------- 9 files changed, 57 insertions(+), 44 deletions(-) diff --git a/builtin-functions/kphp-light/stdlib/error.txt b/builtin-functions/kphp-light/stdlib/error.txt index ebf1bb1a5a..1089564734 100644 --- a/builtin-functions/kphp-light/stdlib/error.txt +++ b/builtin-functions/kphp-light/stdlib/error.txt @@ -103,5 +103,4 @@ class Random\RandomException extends Exception {} // === UNSUPPORTED === -/** @kphp-extern-func-info stub generation-required */ function kphp_backtrace($pretty ::: bool = true) ::: string[]; diff --git a/builtin-functions/kphp-light/stdlib/kphp-toggles.txt b/builtin-functions/kphp-light/stdlib/kphp-toggles.txt index d025787b91..d2403e28ae 100644 --- a/builtin-functions/kphp-light/stdlib/kphp-toggles.txt +++ b/builtin-functions/kphp-light/stdlib/kphp-toggles.txt @@ -6,7 +6,6 @@ function set_migration_php8_warning ($mask ::: int) ::: void; // === UNSUPPORTED === -/** @kphp-extern-func-info stub generation-required */ function kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() ::: void; function set_json_log_on_timeout_mode(bool $enabled) ::: void; diff --git a/builtin-functions/kphp-light/stdlib/kphp-tracing.txt b/builtin-functions/kphp-light/stdlib/kphp-tracing.txt index af54d04d40..9a592401f2 100644 --- a/builtin-functions/kphp-light/stdlib/kphp-tracing.txt +++ b/builtin-functions/kphp-light/stdlib/kphp-tracing.txt @@ -3,17 +3,14 @@ // ===== UNSUPPORTED ===== final class KphpDiv { - /** @kphp-extern-func-info stub generation-required */ private function __construct(); function generateTraceCtxForChild(int $div_id, int $trace_flags): tuple(int, int); function assignTraceCtx(int $int1, int $int2, ?int $override_div_id): int; - /** @kphp-extern-func-info stub generation-required */ function getStartTimestamp(): float; - /** @kphp-extern-func-info stub generation-required */ function getEndTimestamp(): float; } @@ -23,15 +20,15 @@ final class KphpSpan { function addAttributeString(string $key, string $value) ::: void; function addAttributeInt(string $key, int $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeFloat(string $key, float $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeBool(string $key, bool $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeEnum(string $key, int $enum_id, int $value) ::: void; function addEvent(string $name, ?float $timestamp = null): KphpSpanEvent; - /** @kphp-extern-func-info stub generation-required */ + function addLink(KphpSpan $another) ::: void; @@ -40,20 +37,19 @@ final class KphpSpan { function finish(?float $end_timestamp = null) ::: void; function finishWithError(int $error_code, string $error_msg, ?float $end_timestamp = null) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function exclude() ::: void; } final class KphpSpanEvent { private function __construct(); - /** @kphp-extern-func-info stub generation-required */ function addAttributeString(string $key, string $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeInt(string $key, int $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeFloat(string $key, float $value) ::: void; - /** @kphp-extern-func-info stub generation-required */ + function addAttributeBool(string $key, bool $value) ::: void; } diff --git a/runtime-light/stdlib/diagnostics/error-handling-functions.h b/runtime-light/stdlib/diagnostics/error-handling-functions.h index 97e030b5f3..bacfc91a1f 100644 --- a/runtime-light/stdlib/diagnostics/error-handling-functions.h +++ b/runtime-light/stdlib/diagnostics/error-handling-functions.h @@ -92,6 +92,10 @@ inline array> f$debug_backtrace() noexcept { return {}; } +inline array f$kphp_backtrace([[maybe_unused]] bool pretty = true) noexcept { + return {}; +} + inline int64_t f$error_reporting(Optional new_error_level_opt = {}) noexcept { auto& error_handling_st{ErrorHandlingState::get()}; const int64_t current_error_level{error_handling_st.minimum_log_level}; diff --git a/runtime-light/stdlib/system/system-functions.h b/runtime-light/stdlib/system/system-functions.h index 42c79c8973..0a3d0cf3f3 100644 --- a/runtime-light/stdlib/system/system-functions.h +++ b/runtime-light/stdlib/system/system-functions.h @@ -245,3 +245,5 @@ inline string f$get_kphp_cluster_name() noexcept { kphp::log::warning("called stub get_kphp_cluster_name"); return string{"adm512"}; } + +inline void f$kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() noexcept {} diff --git a/runtime-light/stdlib/tracing/tracing-div.h b/runtime-light/stdlib/tracing/tracing-div.h index 8ada7eb31c..d5a9d65ccf 100644 --- a/runtime-light/stdlib/tracing/tracing-div.h +++ b/runtime-light/stdlib/tracing/tracing-div.h @@ -11,16 +11,25 @@ struct C$KphpDiv : public refcountable_php_classes, private DummyVisitorMethods { using DummyVisitorMethods::accept; + + C$KphpDiv() noexcept = default; }; inline int64_t f$KphpDiv$$assignTraceCtx([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] int64_t int1, [[maybe_unused]] int64_t int2, [[maybe_unused]] const Optional& override_div_id) { - kphp::log::info("called stub KphpDiv::assignTraceCtx"); + return {}; } inline std::tuple f$KphpDiv$$generateTraceCtxForChild([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] int64_t div_id, [[maybe_unused]] int64_t trace_flags) { - kphp::log::info("called stub KphpDiv::generateTraceCtxForChild"); + return {}; +} + +inline double f$KphpDiv$$getStartTimestamp([[maybe_unused]] const class_instance& v$this) noexcept { + return {}; +} + +inline double f$KphpDiv$$getEndTimestamp([[maybe_unused]] const class_instance& v$this) noexcept { return {}; } diff --git a/runtime-light/stdlib/tracing/tracing-event.h b/runtime-light/stdlib/tracing/tracing-event.h index 7c358ba674..520ccafcac 100644 --- a/runtime-light/stdlib/tracing/tracing-event.h +++ b/runtime-light/stdlib/tracing/tracing-event.h @@ -15,3 +15,14 @@ struct C$KphpSpanEvent : public refcountable_php_classes { explicit C$KphpSpanEvent(int32_t span_id) noexcept : span_id(span_id) {} }; + +inline void f$KphpSpanEvent$$addAttributeString([[maybe_unused]] const string& value) noexcept {} + +inline void f$KphpSpanEvent$$addAttributeInt([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] int64_t value) noexcept {} + +inline void f$KphpSpanEvent$$addAttributeFloat([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] double value) noexcept {} + +inline void f$KphpSpanEvent$$addAttributeBool([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] bool value) noexcept {} diff --git a/runtime-light/stdlib/tracing/tracing-functions.h b/runtime-light/stdlib/tracing/tracing-functions.h index de54fa4cc6..5487e51dbe 100644 --- a/runtime-light/stdlib/tracing/tracing-functions.h +++ b/runtime-light/stdlib/tracing/tracing-functions.h @@ -10,50 +10,40 @@ #include "runtime-light/stdlib/tracing/tracing-span.h" inline class_instance f$kphp_tracing_get_current_active_span() noexcept { - kphp::log::info("called stub kphp_tracing_get_current_active_span"); return {}; } inline void f$kphp_tracing_func_enter_branch(int /*$branch_num*/) noexcept { - kphp::log::info("called stub kphp_tracing_func_enter_branch"); } inline class_instance f$kphp_tracing_get_root_span() noexcept { - kphp::log::info("called stub kphp_tracing_get_root_span"); return {}; } inline class_instance f$kphp_tracing_init([[maybe_unused]] const string& root_span_title) noexcept { - kphp::log::info("called stub kphp_tracing_init"); return {}; } inline int64_t f$kphp_tracing_get_level() { - kphp::log::info("called stub kphp_tracing_get_level"); return -1; // Not initialized } inline class_instance f$kphp_tracing_start_span([[maybe_unused]] const string& title, [[maybe_unused]] const string& short_desc, [[maybe_unused]] double start_timestamp) noexcept { - kphp::log::info("called stub kphp_tracing_start_span"); return {}; } template void f$kphp_tracing_register_enums_provider([[maybe_unused]] F&& cb_custom_enums) noexcept { - kphp::log::info("called stub kphp_tracing_register_enums_provider"); } template void f$kphp_tracing_register_on_finish([[maybe_unused]] F&& cb_should_be_flushed) noexcept { - kphp::log::info("called stub kphp_tracing_register_on_finish"); } template void f$kphp_tracing_register_rpc_details_provider([[maybe_unused]] F1&& cb_for_typed, [[maybe_unused]] F2&& cb_for_untyped) noexcept { - kphp::log::info("called stub kphp_tracing_register_rpc_details_provider"); } inline void f$kphp_tracing_set_level([[maybe_unused]] int64_t trace_level) noexcept { - kphp::log::info("called stub kphp_tracing_set_level"); } diff --git a/runtime-light/stdlib/tracing/tracing-span.h b/runtime-light/stdlib/tracing/tracing-span.h index 99458d56f6..09aa3f0e01 100644 --- a/runtime-light/stdlib/tracing/tracing-span.h +++ b/runtime-light/stdlib/tracing/tracing-span.h @@ -20,33 +20,36 @@ struct C$KphpSpan : public refcountable_php_classes, private DummyVi : span_id(span_id) {} }; +inline void f$KphpSpan$$addAttributeString([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] const string& value) noexcept {} + inline void f$KphpSpan$$addAttributeInt([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, - [[maybe_unused]] int64_t value) noexcept { - kphp::log::info("called stub KphpSpan::addAttributeInt"); -} + [[maybe_unused]] int64_t value) noexcept {} -inline void f$KphpSpan$$addAttributeString([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, - [[maybe_unused]] const string& value) noexcept { - kphp::log::info("called stub KphpSpan::addAttributeString"); -} +inline void f$KphpSpan$$addAttributeFloat([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] double value) noexcept {} + +inline void f$KphpSpan$$addAttributeBool([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] bool value) noexcept {} + +inline void f$KphpSpan$$addAttributeEnum([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& key, + [[maybe_unused]] int64_t enum_id, [[maybe_unused]] int64_t value) noexcept {} inline class_instance f$KphpSpan$$addEvent([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& name, [[maybe_unused]] const Optional& manual_timestamp = {}) noexcept { - kphp::log::info("called stub KphpSpan::addEvent"); return {}; } -inline void f$KphpSpan$$finish([[maybe_unused]] const class_instance& v$this, - [[maybe_unused]] const Optional& manual_timestamp = {}) noexcept { - kphp::log::info("called stub KphpSpan::finish"); -} +inline void f$KphpSpan$$addLink([[maybe_unused]] const class_instance& v$this, + [[maybe_unused]] const class_instance& another) noexcept {} inline void f$KphpSpan$$updateName([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] const string& title, - [[maybe_unused]] const string& short_desc) noexcept { - kphp::log::info("called stub KphpSpan::updateName"); -} + [[maybe_unused]] const string& short_desc) noexcept {} + +inline void f$KphpSpan$$finish([[maybe_unused]] const class_instance& v$this, + [[maybe_unused]] const Optional& manual_timestamp = {}) noexcept {} inline void f$KphpSpan$$finishWithError([[maybe_unused]] const class_instance& v$this, [[maybe_unused]] int64_t error_code, - [[maybe_unused]] const string& error_msg, [[maybe_unused]] const Optional& manual_timestamp = {}) { - kphp::log::info("called stub KphpSpan::finishWithError"); -} + [[maybe_unused]] const string& error_msg, [[maybe_unused]] const Optional& manual_timestamp = {}) {} + +inline void f$KphpSpan$$exclude([[maybe_unused]] const class_instance& v$this) noexcept {} From b4fa292af9171d5f46cec96acdfb30c20cc2e5f4 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Wed, 12 Nov 2025 14:03:14 +0300 Subject: [PATCH 2/4] add builtins stubs --- runtime-light/stdlib/tracing/tracing-functions.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/runtime-light/stdlib/tracing/tracing-functions.h b/runtime-light/stdlib/tracing/tracing-functions.h index 5487e51dbe..681342b8e4 100644 --- a/runtime-light/stdlib/tracing/tracing-functions.h +++ b/runtime-light/stdlib/tracing/tracing-functions.h @@ -13,8 +13,7 @@ inline class_instance f$kphp_tracing_get_current_active_span() noexc return {}; } -inline void f$kphp_tracing_func_enter_branch(int /*$branch_num*/) noexcept { -} +inline void f$kphp_tracing_func_enter_branch(int /*$branch_num*/) noexcept {} inline class_instance f$kphp_tracing_get_root_span() noexcept { return {}; @@ -34,16 +33,12 @@ inline class_instance f$kphp_tracing_start_span([[maybe_unused]] con } template -void f$kphp_tracing_register_enums_provider([[maybe_unused]] F&& cb_custom_enums) noexcept { -} +void f$kphp_tracing_register_enums_provider([[maybe_unused]] F&& cb_custom_enums) noexcept {} template -void f$kphp_tracing_register_on_finish([[maybe_unused]] F&& cb_should_be_flushed) noexcept { -} +void f$kphp_tracing_register_on_finish([[maybe_unused]] F&& cb_should_be_flushed) noexcept {} template -void f$kphp_tracing_register_rpc_details_provider([[maybe_unused]] F1&& cb_for_typed, [[maybe_unused]] F2&& cb_for_untyped) noexcept { -} +void f$kphp_tracing_register_rpc_details_provider([[maybe_unused]] F1&& cb_for_typed, [[maybe_unused]] F2&& cb_for_untyped) noexcept {} -inline void f$kphp_tracing_set_level([[maybe_unused]] int64_t trace_level) noexcept { -} +inline void f$kphp_tracing_set_level([[maybe_unused]] int64_t trace_level) noexcept {} From 00ab79d17cf0de4a6c6564ad5239762ce1462325 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Wed, 12 Nov 2025 14:37:53 +0300 Subject: [PATCH 3/4] add stubs tags --- builtin-functions/kphp-light/stdlib/error.txt | 1 + .../kphp-light/stdlib/kphp-toggles.txt | 1 + .../kphp-light/stdlib/kphp-tracing.txt | 33 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/builtin-functions/kphp-light/stdlib/error.txt b/builtin-functions/kphp-light/stdlib/error.txt index 1089564734..4883a22de3 100644 --- a/builtin-functions/kphp-light/stdlib/error.txt +++ b/builtin-functions/kphp-light/stdlib/error.txt @@ -103,4 +103,5 @@ class Random\RandomException extends Exception {} // === UNSUPPORTED === +/** @kphp-extern-func-info stub */ function kphp_backtrace($pretty ::: bool = true) ::: string[]; diff --git a/builtin-functions/kphp-light/stdlib/kphp-toggles.txt b/builtin-functions/kphp-light/stdlib/kphp-toggles.txt index d2403e28ae..9a25568ce3 100644 --- a/builtin-functions/kphp-light/stdlib/kphp-toggles.txt +++ b/builtin-functions/kphp-light/stdlib/kphp-toggles.txt @@ -6,6 +6,7 @@ function set_migration_php8_warning ($mask ::: int) ::: void; // === UNSUPPORTED === +/** @kphp-extern-func-info stub */ function kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() ::: void; function set_json_log_on_timeout_mode(bool $enabled) ::: void; diff --git a/builtin-functions/kphp-light/stdlib/kphp-tracing.txt b/builtin-functions/kphp-light/stdlib/kphp-tracing.txt index 9a592401f2..d74b26c17e 100644 --- a/builtin-functions/kphp-light/stdlib/kphp-tracing.txt +++ b/builtin-functions/kphp-light/stdlib/kphp-tracing.txt @@ -3,70 +3,101 @@ // ===== UNSUPPORTED ===== final class KphpDiv { + /** @kphp-extern-func-info stub */ private function __construct(); + /** @kphp-extern-func-info stub */ function generateTraceCtxForChild(int $div_id, int $trace_flags): tuple(int, int); + /** @kphp-extern-func-info stub */ function assignTraceCtx(int $int1, int $int2, ?int $override_div_id): int; + /** @kphp-extern-func-info stub */ function getStartTimestamp(): float; + /** @kphp-extern-func-info stub */ function getEndTimestamp(): float; } final class KphpSpan { + /** @kphp-extern-func-info stub */ private function __construct(); + /** @kphp-extern-func-info stub */ function addAttributeString(string $key, string $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeInt(string $key, int $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeFloat(string $key, float $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeBool(string $key, bool $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeEnum(string $key, int $enum_id, int $value) ::: void; + /** @kphp-extern-func-info stub */ function addEvent(string $name, ?float $timestamp = null): KphpSpanEvent; + /** @kphp-extern-func-info stub */ function addLink(KphpSpan $another) ::: void; - + /** @kphp-extern-func-info stub */ function updateName(string $title, string $short_desc) ::: void; + /** @kphp-extern-func-info stub */ function finish(?float $end_timestamp = null) ::: void; + /** @kphp-extern-func-info stub */ function finishWithError(int $error_code, string $error_msg, ?float $end_timestamp = null) ::: void; + /** @kphp-extern-func-info stub */ function exclude() ::: void; } final class KphpSpanEvent { + /** @kphp-extern-func-info stub */ private function __construct(); + /** @kphp-extern-func-info stub */ function addAttributeString(string $key, string $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeInt(string $key, int $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeFloat(string $key, float $value) ::: void; + /** @kphp-extern-func-info stub */ function addAttributeBool(string $key, bool $value) ::: void; } +/** @kphp-extern-func-info stub */ function kphp_tracing_init(string $root_span_title): KphpDiv; +/** @kphp-extern-func-info stub */ function kphp_tracing_set_level(int $trace_level): void; +/** @kphp-extern-func-info stub */ function kphp_tracing_get_level(): int; +/** @kphp-extern-func-info stub */ function kphp_tracing_register_on_finish(callable(float $now_timestamp):bool $cb_should_be_flushed); +/** @kphp-extern-func-info stub */ function kphp_tracing_register_enums_provider(callable():tuple(int, string, string[])[] $cb_custom_enums); +/** @kphp-extern-func-info stub */ function kphp_tracing_register_rpc_details_provider(callable(@tl\RpcFunction):string $cb_for_typed, callable(mixed):string $cb_for_untyped); +/** @kphp-extern-func-info stub */ function kphp_tracing_start_span(string $title, string $short_desc, float $start_timestamp): KphpSpan; +/** @kphp-extern-func-info stub */ function kphp_tracing_get_root_span(): KphpSpan; +/** @kphp-extern-func-info stub */ function kphp_tracing_get_current_active_span(): KphpSpan; +/** @kphp-extern-func-info stub */ function kphp_tracing_func_enter_branch(int $branch_num) ::: void; From cdbe90e31954cd9bfd833fcc098596976a69bb68 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov <65451602+astrophysik@users.noreply.github.com> Date: Fri, 14 Nov 2025 15:46:10 +0300 Subject: [PATCH 4/4] change int to int64_t --- runtime-light/stdlib/tracing/tracing-functions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime-light/stdlib/tracing/tracing-functions.h b/runtime-light/stdlib/tracing/tracing-functions.h index 681342b8e4..569af81c34 100644 --- a/runtime-light/stdlib/tracing/tracing-functions.h +++ b/runtime-light/stdlib/tracing/tracing-functions.h @@ -13,7 +13,7 @@ inline class_instance f$kphp_tracing_get_current_active_span() noexc return {}; } -inline void f$kphp_tracing_func_enter_branch(int /*$branch_num*/) noexcept {} +inline void f$kphp_tracing_func_enter_branch(int64_t /*$branch_num*/) noexcept {} inline class_instance f$kphp_tracing_get_root_span() noexcept { return {};