aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace
diff options
context:
space:
mode:
authorCthulhu <cthulhu@yandex-team.ru>2022-02-10 16:47:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:44 +0300
commit6aced6c854653b75aab9808d5995be5fc4d9fa53 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/lwtrace
parentbcb3e9d0eb2a8188a6a9fe0907a8949ce4881a4e (diff)
downloadydb-6aced6c854653b75aab9808d5995be5fc4d9fa53.tar.gz
Restoring authorship annotation for Cthulhu <cthulhu@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lwtrace')
-rw-r--r--library/cpp/lwtrace/check.h2
-rw-r--r--library/cpp/lwtrace/control.h2
-rw-r--r--library/cpp/lwtrace/custom_action.cpp10
-rw-r--r--library/cpp/lwtrace/custom_action.h12
-rw-r--r--library/cpp/lwtrace/example1/example_query.tr20
-rw-r--r--library/cpp/lwtrace/example1/lwtrace_example1.cpp70
-rwxr-xr-xlibrary/cpp/lwtrace/example1/start_with_query.sh6
-rw-r--r--library/cpp/lwtrace/example1/ya.make24
-rw-r--r--library/cpp/lwtrace/example2/destructive.tr72
-rw-r--r--library/cpp/lwtrace/example2/example_query.tr158
-rw-r--r--library/cpp/lwtrace/example2/lwtrace_example2.cpp186
-rw-r--r--library/cpp/lwtrace/example2/ya.make24
-rw-r--r--library/cpp/lwtrace/example3/example_query.tr18
-rw-r--r--library/cpp/lwtrace/example3/lwtrace_example3.cpp68
-rwxr-xr-xlibrary/cpp/lwtrace/example3/start_with_query.sh2
-rw-r--r--library/cpp/lwtrace/example3/ya.make18
-rw-r--r--library/cpp/lwtrace/example4/example_query.tr18
-rw-r--r--library/cpp/lwtrace/example4/lwtrace_example4.cpp66
-rwxr-xr-xlibrary/cpp/lwtrace/example4/start_with_query.sh4
-rw-r--r--library/cpp/lwtrace/example4/ya.make18
-rw-r--r--library/cpp/lwtrace/preprocessor.h26
-rw-r--r--library/cpp/lwtrace/protos/lwtrace.proto28
-rw-r--r--library/cpp/lwtrace/sleep_action.cpp20
-rw-r--r--library/cpp/lwtrace/sleep_action.h12
-rw-r--r--library/cpp/lwtrace/tests/trace_tests.cpp20
-rw-r--r--library/cpp/lwtrace/trace.cpp84
-rw-r--r--library/cpp/lwtrace/ya.make2
27 files changed, 495 insertions, 495 deletions
diff --git a/library/cpp/lwtrace/check.h b/library/cpp/lwtrace/check.h
index 04d0dc7fd0..71503cbc7b 100644
--- a/library/cpp/lwtrace/check.h
+++ b/library/cpp/lwtrace/check.h
@@ -74,5 +74,5 @@ namespace NLWTrace {
--Value;
}
};
-
+
}
diff --git a/library/cpp/lwtrace/control.h b/library/cpp/lwtrace/control.h
index 6136b29daa..16b24eafd2 100644
--- a/library/cpp/lwtrace/control.h
+++ b/library/cpp/lwtrace/control.h
@@ -251,7 +251,7 @@ namespace NLWTrace {
reader.Push(probe);
}
}
-
+
template <class TReader>
void ReadTraces(TReader& reader) const {
TGuard<TMutex> g(Mtx);
diff --git a/library/cpp/lwtrace/custom_action.cpp b/library/cpp/lwtrace/custom_action.cpp
index dfc713ee9a..a379b34ec0 100644
--- a/library/cpp/lwtrace/custom_action.cpp
+++ b/library/cpp/lwtrace/custom_action.cpp
@@ -1,9 +1,9 @@
#include "custom_action.h"
-#include "control.h"
-
-using namespace NLWTrace;
-
+#include "control.h"
+
+using namespace NLWTrace;
+
TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustomAction& action, TSession* trace) const {
auto iter = Callbacks.find(action.GetName());
if (iter != Callbacks.end()) {
@@ -11,7 +11,7 @@ TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustom
} else {
return nullptr;
}
-}
+}
void TCustomActionFactory::Register(const TString& name, const TCustomActionFactory::TCallback& callback) {
if (Callbacks.contains(name)) {
diff --git a/library/cpp/lwtrace/custom_action.h b/library/cpp/lwtrace/custom_action.h
index 85445b57e5..92a3c66b84 100644
--- a/library/cpp/lwtrace/custom_action.h
+++ b/library/cpp/lwtrace/custom_action.h
@@ -1,16 +1,16 @@
-#pragma once
-
-#include "probe.h"
+#pragma once
+
+#include "probe.h"
#include <library/cpp/lwtrace/protos/lwtrace.pb.h>
-
+
#include <util/generic/hash.h>
#include <functional>
namespace NLWTrace {
class TSession;
-
+
// Custom action can save any stuff (derived from IResource) in TSession object
// IMPORTANT: Derived class will be used from multiple threads! (see example3)
class IResource: public TAtomicRefCount<IResource> {
@@ -60,7 +60,7 @@ namespace NLWTrace {
return Destructive;
}
};
-
+
// Factory to produce custom action executors
class TCustomActionFactory {
public:
diff --git a/library/cpp/lwtrace/example1/example_query.tr b/library/cpp/lwtrace/example1/example_query.tr
index c898ffe035..a06e2a922d 100644
--- a/library/cpp/lwtrace/example1/example_query.tr
+++ b/library/cpp/lwtrace/example1/example_query.tr
@@ -1,10 +1,10 @@
-Blocks {
- ProbeDesc {
- Name: "IterationProbe"
- Provider: "LWTRACE_EXAMPLE_PROVIDER"
- }
- Action {
- PrintToStderrAction { }
- }
-}
-
+Blocks {
+ ProbeDesc {
+ Name: "IterationProbe"
+ Provider: "LWTRACE_EXAMPLE_PROVIDER"
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
diff --git a/library/cpp/lwtrace/example1/lwtrace_example1.cpp b/library/cpp/lwtrace/example1/lwtrace_example1.cpp
index b196a49afb..6b32c405ee 100644
--- a/library/cpp/lwtrace/example1/lwtrace_example1.cpp
+++ b/library/cpp/lwtrace/example1/lwtrace_example1.cpp
@@ -1,39 +1,39 @@
#include <library/cpp/lwtrace/all.h>
-
+
#define LWTRACE_EXAMPLE_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
- PROBE(IterationProbe, GROUPS(), TYPES(i32, double), NAMES("n", "result")) \
- /**/
-
-LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-
-void InitLWTrace() {
- NLWTrace::StartLwtraceFromEnv();
-}
-
+ PROBE(IterationProbe, GROUPS(), TYPES(i32, double), NAMES("n", "result")) \
+ /**/
+
+LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+
+void InitLWTrace() {
+ NLWTrace::StartLwtraceFromEnv();
+}
+
long double Fact(int n) {
- if (n < 0) {
- ythrow yexception() << "N! is undefined for negative N (" << n << ")";
- }
- double result = 1;
- for (; n > 1; --n) {
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
- result *= n;
- }
- return result;
-}
-
-void FactorialCalculator() {
- i32 n;
- Cout << "Enter a number: ";
+ if (n < 0) {
+ ythrow yexception() << "N! is undefined for negative N (" << n << ")";
+ }
+ double result = 1;
+ for (; n > 1; --n) {
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
+ result *= n;
+ }
+ return result;
+}
+
+void FactorialCalculator() {
+ i32 n;
+ Cout << "Enter a number: ";
TString str;
- Cin >> n;
- double factN = Fact(n);
- Cout << n << "! = " << factN << Endl << Endl;
-}
-
-int main() {
- InitLWTrace();
- FactorialCalculator();
- return 0;
-}
+ Cin >> n;
+ double factN = Fact(n);
+ Cout << n << "! = " << factN << Endl << Endl;
+}
+
+int main() {
+ InitLWTrace();
+ FactorialCalculator();
+ return 0;
+}
diff --git a/library/cpp/lwtrace/example1/start_with_query.sh b/library/cpp/lwtrace/example1/start_with_query.sh
index fd6f6cfe33..2b456d7be7 100755
--- a/library/cpp/lwtrace/example1/start_with_query.sh
+++ b/library/cpp/lwtrace/example1/start_with_query.sh
@@ -1,3 +1,3 @@
-#!/bin/bash
-export LWTRACE="example_query.tr"
-./lwtrace-example1
+#!/bin/bash
+export LWTRACE="example_query.tr"
+./lwtrace-example1
diff --git a/library/cpp/lwtrace/example1/ya.make b/library/cpp/lwtrace/example1/ya.make
index c79f3c5408..5ae8c4a48e 100644
--- a/library/cpp/lwtrace/example1/ya.make
+++ b/library/cpp/lwtrace/example1/ya.make
@@ -1,13 +1,13 @@
-PROGRAM(lwtrace-example1)
-
-OWNER(cthulhu)
-
-SRCS(
- lwtrace_example1.cpp
-)
-
-PEERDIR(
+PROGRAM(lwtrace-example1)
+
+OWNER(cthulhu)
+
+SRCS(
+ lwtrace_example1.cpp
+)
+
+PEERDIR(
library/cpp/lwtrace
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/lwtrace/example2/destructive.tr b/library/cpp/lwtrace/example2/destructive.tr
index 79bd1bb3cc..ad955db018 100644
--- a/library/cpp/lwtrace/example2/destructive.tr
+++ b/library/cpp/lwtrace/example2/destructive.tr
@@ -1,36 +1,36 @@
-Blocks {
- ProbeDesc { Name: "IterationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- SleepAction {
- NanoSeconds: 100000000
- }
- }
-}
-
-Blocks {
- ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- StatementAction {
- Type: ST_MOD
- Argument { Variable: "nMod2" }
- Argument { Param: "n" }
- Argument { Value: "2" }
- }
- }
-}
-Blocks {
- ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Predicate {
- Operators {
- Type: OT_EQ
- Argument { Variable: "nMod2" }
- Argument { Value: "0" }
- }
- }
- Action {
- PrintToStderrAction { }
- }
- Action {
- KillAction { }
- }
-}
+Blocks {
+ ProbeDesc { Name: "IterationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ SleepAction {
+ NanoSeconds: 100000000
+ }
+ }
+}
+
+Blocks {
+ ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ StatementAction {
+ Type: ST_MOD
+ Argument { Variable: "nMod2" }
+ Argument { Param: "n" }
+ Argument { Value: "2" }
+ }
+ }
+}
+Blocks {
+ ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Predicate {
+ Operators {
+ Type: OT_EQ
+ Argument { Variable: "nMod2" }
+ Argument { Value: "0" }
+ }
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+ Action {
+ KillAction { }
+ }
+}
diff --git a/library/cpp/lwtrace/example2/example_query.tr b/library/cpp/lwtrace/example2/example_query.tr
index e5fee2c0e3..31b5465860 100644
--- a/library/cpp/lwtrace/example2/example_query.tr
+++ b/library/cpp/lwtrace/example2/example_query.tr
@@ -1,79 +1,79 @@
-Blocks {
- ProbeDesc {
- Name: "StartupProbe"
- Provider: "LWTRACE_EXAMPLE_PROVIDER"
- }
- Action {
- PrintToStderrAction { }
- }
-}
-
-Blocks {
- ProbeDesc { Name: "IterationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- LogAction {
- LogTimestamp: true
- MaxRecords: 2
- }
- }
-}
-
-Blocks {
- ProbeDesc { Name: "ByrefDurationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- LogAction {
- LogTimestamp: true
- MaxRecords: 1
- }
- }
- Action {
- PrintToStderrAction { }
- }
-}
-
-Blocks {
- ProbeDesc { Name: "DurationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- LogAction {
- LogTimestamp: true
- MaxRecords: 1
- }
- }
- Action {
- PrintToStderrAction { }
- }
-}
-
-Blocks {
- ProbeDesc { Name: "ResultProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- PrintToStderrAction { }
- }
- Action {
- LogAction { LogTimestamp: true }
- }
-}
-
-
-Blocks {
- ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Action {
- StatementAction {
- Type: ST_MOD
- Argument { Variable: "nMod2" }
- Argument { Param: "n" }
- Argument { Value: "2" }
- }
- }
-}
-Blocks {
- ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
- Predicate {
- Operators {
- Type: OT_EQ
- Argument { Variable: "nMod2" }
- Argument { Value: "0" }
- }
- }
- Action { LogAction { } }
-}
+Blocks {
+ ProbeDesc {
+ Name: "StartupProbe"
+ Provider: "LWTRACE_EXAMPLE_PROVIDER"
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
+Blocks {
+ ProbeDesc { Name: "IterationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ LogAction {
+ LogTimestamp: true
+ MaxRecords: 2
+ }
+ }
+}
+
+Blocks {
+ ProbeDesc { Name: "ByrefDurationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ LogAction {
+ LogTimestamp: true
+ MaxRecords: 1
+ }
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
+Blocks {
+ ProbeDesc { Name: "DurationProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ LogAction {
+ LogTimestamp: true
+ MaxRecords: 1
+ }
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
+Blocks {
+ ProbeDesc { Name: "ResultProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ PrintToStderrAction { }
+ }
+ Action {
+ LogAction { LogTimestamp: true }
+ }
+}
+
+
+Blocks {
+ ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Action {
+ StatementAction {
+ Type: ST_MOD
+ Argument { Variable: "nMod2" }
+ Argument { Param: "n" }
+ Argument { Value: "2" }
+ }
+ }
+}
+Blocks {
+ ProbeDesc { Name: "AfterInputProbe" Provider: "LWTRACE_EXAMPLE_PROVIDER" }
+ Predicate {
+ Operators {
+ Type: OT_EQ
+ Argument { Variable: "nMod2" }
+ Argument { Value: "0" }
+ }
+ }
+ Action { LogAction { } }
+}
diff --git a/library/cpp/lwtrace/example2/lwtrace_example2.cpp b/library/cpp/lwtrace/example2/lwtrace_example2.cpp
index 6ad4cc96f1..7a4f7a1daf 100644
--- a/library/cpp/lwtrace/example2/lwtrace_example2.cpp
+++ b/library/cpp/lwtrace/example2/lwtrace_example2.cpp
@@ -1,117 +1,117 @@
#include <library/cpp/lwtrace/control.h>
#include <library/cpp/lwtrace/all.h>
-
+
#include <library/cpp/getopt/last_getopt.h>
#include <google/protobuf/text_format.h>
-#include <util/stream/file.h>
-
+#include <util/stream/file.h>
+
#define LWTRACE_EXAMPLE_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
PROBE(StartupProbe, GROUPS(), TYPES(), NAMES()) \
PROBE(IterationProbe, GROUPS(), TYPES(i64, double), NAMES("n", "result")) \
- PROBE(DurationProbe, GROUPS(), TYPES(ui64, i64, double), NAMES("duration", "n", "result")) \
+ PROBE(DurationProbe, GROUPS(), TYPES(ui64, i64, double), NAMES("duration", "n", "result")) \
PROBE(ResultProbe, GROUPS(), TYPES(double), NAMES("factN")) \
PROBE(AfterInputProbe, GROUPS(), TYPES(i32), NAMES("n")) \
- /**/
-
-LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-
+ /**/
+
+LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+
THolder<NLWTrace::TManager> traceManager;
-
-struct TConfig {
- bool UnsafeLWTrace;
+
+struct TConfig {
+ bool UnsafeLWTrace;
TString TraceRequestPath;
-};
-
-void InitLWTrace(TConfig& cfg) {
+};
+
+void InitLWTrace(TConfig& cfg) {
traceManager.Reset(new NLWTrace::TManager(*Singleton<NLWTrace::TProbeRegistry>(), cfg.UnsafeLWTrace));
-}
-
-void AddLWTraceRequest(TConfig& cfg) {
+}
+
+void AddLWTraceRequest(TConfig& cfg) {
TString queryStr = TUnbufferedFileInput(cfg.TraceRequestPath).ReadAll();
- NLWTrace::TQuery query;
- google::protobuf::TextFormat::ParseFromString(queryStr, &query);
- traceManager->New("TraceRequest1", query);
-}
-
-class TLogReader {
-public:
+ NLWTrace::TQuery query;
+ google::protobuf::TextFormat::ParseFromString(queryStr, &query);
+ traceManager->New("TraceRequest1", query);
+}
+
+class TLogReader {
+public:
void Push(TThread::TId tid, const NLWTrace::TCyclicLog::TItem& item) {
- Cout << "tid=" << tid << " probe=" << item.Probe->Event.Name;
- if (item.Timestamp != TInstant::Zero()) {
- Cout << " time=" << item.Timestamp;
- }
- if (item.SavedParamsCount > 0) {
+ Cout << "tid=" << tid << " probe=" << item.Probe->Event.Name;
+ if (item.Timestamp != TInstant::Zero()) {
+ Cout << " time=" << item.Timestamp;
+ }
+ if (item.SavedParamsCount > 0) {
TString paramValues[LWTRACE_MAX_PARAMS];
- item.Probe->Event.Signature.SerializeParams(item.Params, paramValues);
- Cout << " params: ";
- for (size_t i = 0; i < item.SavedParamsCount; ++i) {
- Cout << " " << item.Probe->Event.Signature.ParamNames[i] << "=" << paramValues[i];
- }
- }
- Cout << Endl;
- }
-};
-
-void DisplayLWTraceLog() {
- Cout << "LWTrace log:" << Endl;
- TLogReader reader;
- traceManager->ReadLog("TraceRequest1", reader);
-}
-
+ item.Probe->Event.Signature.SerializeParams(item.Params, paramValues);
+ Cout << " params: ";
+ for (size_t i = 0; i < item.SavedParamsCount; ++i) {
+ Cout << " " << item.Probe->Event.Signature.ParamNames[i] << "=" << paramValues[i];
+ }
+ }
+ Cout << Endl;
+ }
+};
+
+void DisplayLWTraceLog() {
+ Cout << "LWTrace log:" << Endl;
+ TLogReader reader;
+ traceManager->ReadLog("TraceRequest1", reader);
+}
+
long double Fact(i64 n) {
- if (n < 0) {
- ythrow yexception() << "N! is undefined for negative N (" << n << ")";
- }
- double result = 1;
- for (; n > 1; --n) {
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
- GLOBAL_LWPROBE_DURATION(LWTRACE_EXAMPLE_PROVIDER, DurationProbe, n, result);
-
- result *= n;
- }
- return result;
-}
-
-void FactorialCalculator() {
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, StartupProbe);
-
- i32 n;
- Cout << "Enter a number: ";
+ if (n < 0) {
+ ythrow yexception() << "N! is undefined for negative N (" << n << ")";
+ }
+ double result = 1;
+ for (; n > 1; --n) {
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
+ GLOBAL_LWPROBE_DURATION(LWTRACE_EXAMPLE_PROVIDER, DurationProbe, n, result);
+
+ result *= n;
+ }
+ return result;
+}
+
+void FactorialCalculator() {
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, StartupProbe);
+
+ i32 n;
+ Cout << "Enter a number: ";
TString str;
- Cin >> n;
-
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, AfterInputProbe, n);
-
- double factN = Fact(n);
- Cout << n << "! = " << factN << Endl << Endl;
-
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, ResultProbe, factN);
-}
-
-int main(int argc, char** argv) {
- TConfig cfg;
- using namespace NLastGetopt;
- TOpts opts = NLastGetopt::TOpts::Default();
- opts.AddLongOption('u', "unsafe-lwtrace",
+ Cin >> n;
+
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, AfterInputProbe, n);
+
+ double factN = Fact(n);
+ Cout << n << "! = " << factN << Endl << Endl;
+
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, ResultProbe, factN);
+}
+
+int main(int argc, char** argv) {
+ TConfig cfg;
+ using namespace NLastGetopt;
+ TOpts opts = NLastGetopt::TOpts::Default();
+ opts.AddLongOption('u', "unsafe-lwtrace",
"allow destructive LWTrace actions")
.OptionalValue(ToString(true))
.DefaultValue(ToString(false))
.StoreResult(&cfg.UnsafeLWTrace);
- opts.AddLongOption('f', "trace-request",
+ opts.AddLongOption('f', "trace-request",
"specify a file containing LWTrace request")
.DefaultValue("example_query.tr")
.StoreResult(&cfg.TraceRequestPath);
- opts.AddHelpOption('h');
- TOptsParseResult res(&opts, argc, argv);
-
- InitLWTrace(cfg);
-
- AddLWTraceRequest(cfg);
-
- FactorialCalculator();
-
- DisplayLWTraceLog();
-
- return 0;
-}
+ opts.AddHelpOption('h');
+ TOptsParseResult res(&opts, argc, argv);
+
+ InitLWTrace(cfg);
+
+ AddLWTraceRequest(cfg);
+
+ FactorialCalculator();
+
+ DisplayLWTraceLog();
+
+ return 0;
+}
diff --git a/library/cpp/lwtrace/example2/ya.make b/library/cpp/lwtrace/example2/ya.make
index a54d2a9d53..22e34239c8 100644
--- a/library/cpp/lwtrace/example2/ya.make
+++ b/library/cpp/lwtrace/example2/ya.make
@@ -1,14 +1,14 @@
-PROGRAM(lwtrace-example2)
-
-OWNER(cthulhu)
-
-SRCS(
- lwtrace_example2.cpp
-)
-
-PEERDIR(
+PROGRAM(lwtrace-example2)
+
+OWNER(cthulhu)
+
+SRCS(
+ lwtrace_example2.cpp
+)
+
+PEERDIR(
library/cpp/lwtrace
library/cpp/getopt
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/lwtrace/example3/example_query.tr b/library/cpp/lwtrace/example3/example_query.tr
index bd22441af3..1f841b0932 100644
--- a/library/cpp/lwtrace/example3/example_query.tr
+++ b/library/cpp/lwtrace/example3/example_query.tr
@@ -1,13 +1,13 @@
-Blocks {
- ProbeDesc {
- Name: "IterationProbe"
- Provider: "LWTRACE_EXAMPLE_PROVIDER"
- }
- Action {
+Blocks {
+ ProbeDesc {
+ Name: "IterationProbe"
+ Provider: "LWTRACE_EXAMPLE_PROVIDER"
+ }
+ Action {
CustomAction {
Name: "MyAction"
Opts: "/dev/stdout"
}
- }
-}
-
+ }
+}
+
diff --git a/library/cpp/lwtrace/example3/lwtrace_example3.cpp b/library/cpp/lwtrace/example3/lwtrace_example3.cpp
index e4e96fbc66..4493dc0077 100644
--- a/library/cpp/lwtrace/example3/lwtrace_example3.cpp
+++ b/library/cpp/lwtrace/example3/lwtrace_example3.cpp
@@ -1,43 +1,43 @@
#include <library/cpp/lwtrace/all.h>
#include <google/protobuf/text_format.h>
#include "my_action.h"
-
+
#define LWTRACE_EXAMPLE_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
- PROBE(IterationProbe, GROUPS(), TYPES(i32, double), NAMES("n", "result")) \
- /**/
-
-LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-
-void InitLWTrace() {
+ PROBE(IterationProbe, GROUPS(), TYPES(i32, double), NAMES("n", "result")) \
+ /**/
+
+LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+
+void InitLWTrace() {
NLWTrace::StartLwtraceFromEnv([=](NLWTrace::TManager& mngr) {
mngr.RegisterCustomAction<TMyActionExecutor>();
});
-}
-
+}
+
long double Fact(int n) {
- if (n < 0) {
- ythrow yexception() << "N! is undefined for negative N (" << n << ")";
- }
- double result = 1;
- for (; n > 1; --n) {
- GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
- result *= n;
- }
- return result;
-}
-
-void FactorialCalculator() {
- i32 n;
- Cout << "Enter a number: ";
+ if (n < 0) {
+ ythrow yexception() << "N! is undefined for negative N (" << n << ")";
+ }
+ double result = 1;
+ for (; n > 1; --n) {
+ GLOBAL_LWPROBE(LWTRACE_EXAMPLE_PROVIDER, IterationProbe, n, result);
+ result *= n;
+ }
+ return result;
+}
+
+void FactorialCalculator() {
+ i32 n;
+ Cout << "Enter a number: ";
TString str;
- Cin >> n;
- double factN = Fact(n);
- Cout << n << "! = " << factN << Endl << Endl;
-}
-
-int main() {
- InitLWTrace();
- FactorialCalculator();
- return 0;
-}
+ Cin >> n;
+ double factN = Fact(n);
+ Cout << n << "! = " << factN << Endl << Endl;
+}
+
+int main() {
+ InitLWTrace();
+ FactorialCalculator();
+ return 0;
+}
diff --git a/library/cpp/lwtrace/example3/start_with_query.sh b/library/cpp/lwtrace/example3/start_with_query.sh
index f7f58ef929..5cd221856f 100755
--- a/library/cpp/lwtrace/example3/start_with_query.sh
+++ b/library/cpp/lwtrace/example3/start_with_query.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash
echo "Executing program with following trace query:"
cat example_query.tr
echo -n "Press any key to start program"
diff --git a/library/cpp/lwtrace/example3/ya.make b/library/cpp/lwtrace/example3/ya.make
index e226b1e041..c5b31586e9 100644
--- a/library/cpp/lwtrace/example3/ya.make
+++ b/library/cpp/lwtrace/example3/ya.make
@@ -1,13 +1,13 @@
PROGRAM(lwtrace-example3)
-
+
OWNER(serxa)
-
-SRCS(
+
+SRCS(
lwtrace_example3.cpp
-)
-
-PEERDIR(
+)
+
+PEERDIR(
library/cpp/lwtrace
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/lwtrace/example4/example_query.tr b/library/cpp/lwtrace/example4/example_query.tr
index 73f28b7123..46cd25ce91 100644
--- a/library/cpp/lwtrace/example4/example_query.tr
+++ b/library/cpp/lwtrace/example4/example_query.tr
@@ -1,10 +1,10 @@
-Blocks {
- ProbeDesc {
+Blocks {
+ ProbeDesc {
Name: "BackTrack"
- Provider: "LWTRACE_EXAMPLE_PROVIDER"
- }
- Action {
- PrintToStderrAction { }
- }
-}
-
+ Provider: "LWTRACE_EXAMPLE_PROVIDER"
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
diff --git a/library/cpp/lwtrace/example4/lwtrace_example4.cpp b/library/cpp/lwtrace/example4/lwtrace_example4.cpp
index b2b23b1096..7b55a07c75 100644
--- a/library/cpp/lwtrace/example4/lwtrace_example4.cpp
+++ b/library/cpp/lwtrace/example4/lwtrace_example4.cpp
@@ -1,49 +1,49 @@
#include <library/cpp/lwtrace/all.h>
-
+
#define LWTRACE_EXAMPLE_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
PROBE(BackTrack, GROUPS(), TYPES(NLWTrace::TSymbol), NAMES("frame")) \
- /**/
-
-LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
-
+ /**/
+
+LWTRACE_DECLARE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+LWTRACE_DEFINE_PROVIDER(LWTRACE_EXAMPLE_PROVIDER)
+
LWTRACE_USING(LWTRACE_EXAMPLE_PROVIDER);
#define MY_BACKTRACK() LWPROBE(BackTrack, LWTRACE_LOCATION_SYMBOL)
-void InitLWTrace() {
- NLWTrace::StartLwtraceFromEnv();
-}
-
+void InitLWTrace() {
+ NLWTrace::StartLwtraceFromEnv();
+}
+
long double Fact(int n) {
MY_BACKTRACK();
- if (n < 0) {
+ if (n < 0) {
MY_BACKTRACK();
- ythrow yexception() << "N! is undefined for negative N (" << n << ")";
- }
- double result = 1;
- for (; n > 1; --n) {
+ ythrow yexception() << "N! is undefined for negative N (" << n << ")";
+ }
+ double result = 1;
+ for (; n > 1; --n) {
MY_BACKTRACK();
- result *= n;
- }
+ result *= n;
+ }
MY_BACKTRACK();
- return result;
-}
-
-void FactorialCalculator() {
+ return result;
+}
+
+void FactorialCalculator() {
MY_BACKTRACK();
- i32 n;
- Cout << "Enter a number: ";
+ i32 n;
+ Cout << "Enter a number: ";
TString str;
- Cin >> n;
- double factN = Fact(n);
- Cout << n << "! = " << factN << Endl << Endl;
-}
-
-int main() {
- InitLWTrace();
+ Cin >> n;
+ double factN = Fact(n);
+ Cout << n << "! = " << factN << Endl << Endl;
+}
+
+int main() {
+ InitLWTrace();
MY_BACKTRACK();
- FactorialCalculator();
+ FactorialCalculator();
MY_BACKTRACK();
- return 0;
-}
+ return 0;
+}
diff --git a/library/cpp/lwtrace/example4/start_with_query.sh b/library/cpp/lwtrace/example4/start_with_query.sh
index 09079b0a31..5bc195c1ae 100755
--- a/library/cpp/lwtrace/example4/start_with_query.sh
+++ b/library/cpp/lwtrace/example4/start_with_query.sh
@@ -1,3 +1,3 @@
-#!/bin/bash
-export LWTRACE="example_query.tr"
+#!/bin/bash
+export LWTRACE="example_query.tr"
./lwtrace-example4
diff --git a/library/cpp/lwtrace/example4/ya.make b/library/cpp/lwtrace/example4/ya.make
index efc9413906..a3004340a8 100644
--- a/library/cpp/lwtrace/example4/ya.make
+++ b/library/cpp/lwtrace/example4/ya.make
@@ -1,13 +1,13 @@
PROGRAM(lwtrace-example4)
-
+
OWNER(serxa)
-
-SRCS(
+
+SRCS(
lwtrace_example4.cpp
-)
-
-PEERDIR(
+)
+
+PEERDIR(
library/cpp/lwtrace
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/lwtrace/preprocessor.h b/library/cpp/lwtrace/preprocessor.h
index c6da7cedd3..40865467b2 100644
--- a/library/cpp/lwtrace/preprocessor.h
+++ b/library/cpp/lwtrace/preprocessor.h
@@ -34,7 +34,7 @@
// 2. FOREACH_PARAMTYPE(FOREACH_PARAMTYPE_MACRO, your_p1_value, your_p1_value)
// FOREACH_PARAMTYPE(FOREACH_PARAMTYPE_MACRO, your_p1_another_value, your_p1_another_value)
// 3. #undef FOREACH_PARAMTYPE_MACRO
-// Type order matters!
+// Type order matters!
#define FOREACH_PARAMTYPE(MACRO, ...) \
MACRO("i64", i64, I64, ##__VA_ARGS__) \
MACRO("ui64", ui64, Ui64, ##__VA_ARGS__) \
@@ -49,13 +49,13 @@
MACRO(NULL, TNil, Nil, ##__VA_ARGS__) \
/**/
-// Used for math statements
+// Used for math statements
#define FOR_MATH_PARAMTYPE(MACRO, ...) \
MACRO("i64", i64, I64, ##__VA_ARGS__) \
MACRO("ui64", ui64, Ui64, ##__VA_ARGS__) \
MACRO("check", NLWTrace::TCheck, Check, ##__VA_ARGS__) \
- /**/
-
+ /**/
+
// Use for code generation to handle parameter lists
// NOTE: this is the only place to change if more parameters needed
#define FOREACH_PARAMNUM(MACRO, ...) \
@@ -78,22 +78,22 @@
MACRO(16, ##__VA_ARGS__) \
/**/
-#define FOREACH_LEFT_TYPE(MACRO, ...) \
+#define FOREACH_LEFT_TYPE(MACRO, ...) \
MACRO(__VA_ARGS__, OT_VARIABLE) \
MACRO(__VA_ARGS__, OT_LITERAL) \
MACRO(__VA_ARGS__, OT_PARAMETER) \
- /**/
-
-#define FOREACH_RIGHT_TYPE(MACRO, ...) \
+ /**/
+
+#define FOREACH_RIGHT_TYPE(MACRO, ...) \
MACRO(__VA_ARGS__, OT_VARIABLE) \
MACRO(__VA_ARGS__, OT_LITERAL) \
MACRO(__VA_ARGS__, OT_PARAMETER) \
- /**/
-
-#define FOREACH_DESTINATION_TYPE(MACRO, ...) \
+ /**/
+
+#define FOREACH_DESTINATION_TYPE(MACRO, ...) \
MACRO(__VA_ARGS__, OT_VARIABLE) \
- /**/
-
+ /**/
+
// Auxilary macros
#define LWTRACE_EXPAND(x) x
#define LWTRACE_EAT(...)
diff --git a/library/cpp/lwtrace/protos/lwtrace.proto b/library/cpp/lwtrace/protos/lwtrace.proto
index 29e0fa1fe6..0051095719 100644
--- a/library/cpp/lwtrace/protos/lwtrace.proto
+++ b/library/cpp/lwtrace/protos/lwtrace.proto
@@ -22,15 +22,15 @@ enum EOperatorType {
OT_GE = 5;
}
-message TArgument {
+message TArgument {
string Param = 1;
bytes Value = 2;
string Variable = 3;
-}
-
+}
+
message TOperator {
EOperatorType Type = 1;
- repeated TArgument Argument = 8;
+ repeated TArgument Argument = 8;
}
message TPredicate {
@@ -47,10 +47,10 @@ message TLogAction {
message TPrintToStderrAction {
}
-message TKillAction {
+message TKillAction {
}
-message TSleepAction {
+message TSleepAction {
uint64 NanoSeconds = 1;
}
@@ -59,7 +59,7 @@ message TCustomAction {
repeated string Opts = 2;
}
-enum EStatementType {
+enum EStatementType {
ST_MOV = 0;
ST_ADD = 1;
ST_SUB = 2;
@@ -70,13 +70,13 @@ enum EStatementType {
ST_SUB_EQ = 7;
ST_INC = 8;
ST_DEC = 9;
-}
-
-message TStatementAction {
+}
+
+message TStatementAction {
EStatementType Type = 1;
- repeated TArgument Argument = 2;
-}
-
+ repeated TArgument Argument = 2;
+}
+
message TRunLogShuttleAction {
bool Ignore = 1;
uint64 ShuttlesCount = 2;
@@ -106,7 +106,7 @@ message TAction {
message TBlock {
TProbeDesc ProbeDesc = 1;
TPredicate Predicate = 2;
- repeated TAction Action = 3;
+ repeated TAction Action = 3;
}
message TQuery {
diff --git a/library/cpp/lwtrace/sleep_action.cpp b/library/cpp/lwtrace/sleep_action.cpp
index d50ab843f7..74977528db 100644
--- a/library/cpp/lwtrace/sleep_action.cpp
+++ b/library/cpp/lwtrace/sleep_action.cpp
@@ -1,15 +1,15 @@
#include "sleep_action.h"
-
-#include "control.h"
-#include <util/system/datetime.h>
-
+#include "control.h"
+
+#include <util/system/datetime.h>
+
#include <stdlib.h>
-using namespace NLWTrace;
-using namespace NLWTrace::NPrivate;
-
+using namespace NLWTrace;
+using namespace NLWTrace::NPrivate;
+
bool TSleepActionExecutor::DoExecute(TOrbit&, const TParams&) {
- NanoSleep(NanoSeconds);
- return true;
-}
+ NanoSleep(NanoSeconds);
+ return true;
+}
diff --git a/library/cpp/lwtrace/sleep_action.h b/library/cpp/lwtrace/sleep_action.h
index 868c4dd492..26f89bd88c 100644
--- a/library/cpp/lwtrace/sleep_action.h
+++ b/library/cpp/lwtrace/sleep_action.h
@@ -1,13 +1,13 @@
-#pragma once
-
-#include "probe.h"
-
+#pragma once
+
+#include "probe.h"
+
namespace NLWTrace {
namespace NPrivate {
class TSleepActionExecutor: public IExecutor {
private:
ui64 NanoSeconds;
-
+
public:
TSleepActionExecutor(const TProbe*, ui64 nanoSeconds)
: IExecutor()
@@ -16,6 +16,6 @@ namespace NLWTrace {
}
bool DoExecute(TOrbit& orbit, const TParams& params) override;
};
-
+
}
}
diff --git a/library/cpp/lwtrace/tests/trace_tests.cpp b/library/cpp/lwtrace/tests/trace_tests.cpp
index 41b44ca53a..6762e344a7 100644
--- a/library/cpp/lwtrace/tests/trace_tests.cpp
+++ b/library/cpp/lwtrace/tests/trace_tests.cpp
@@ -4,7 +4,7 @@
#include <google/protobuf/text_format.h>
-#include <util/system/pipe.h>
+#include <util/system/pipe.h>
#include <util/generic/ymath.h>
#include <util/string/printf.h>
#include <util/string/vector.h>
@@ -461,7 +461,7 @@ namespace NLWTrace {
ui64 duration = (t1.NanoSeconds() - t0.NanoSeconds());
Cout << "multiple sleep tested, expected 100000000 ns, measured " << duration << " ns" << Endl;
}
-
+
void SleepCheck(const TConfig& cfg) {
TProbes p(cfg.UnsafeLWTrace);
p.Mngr.New("test-sleep", MakeQuery(
@@ -484,7 +484,7 @@ namespace NLWTrace {
ui64 duration = (t1.NanoSeconds() - t0.NanoSeconds()) / (ui64)10;
Cout << "sleep tested, expected 100000000 ns, measured " << duration << " ns" << Endl;
}
-
+
void KillCheckChild(const TConfig& cfg, TPipeHandle& writer) {
TProbes p(cfg.UnsafeLWTrace);
p.Mngr.New("test-kill", MakeQuery(
@@ -506,7 +506,7 @@ namespace NLWTrace {
buffer = 1;
writer.Write(&buffer, 1);
}
-
+
void KillCheckParent(TPipeHandle& reader) {
char buffer = -1;
reader.Read(&buffer, 1);
@@ -518,9 +518,9 @@ namespace NLWTrace {
else
Cout << "\t\tkill executor tested OK." << Endl;
}
-
+
void KillCheck(const TConfig& cfg) {
-#ifdef _unix_
+#ifdef _unix_
TPipeHandle reader;
TPipeHandle writer;
TPipeHandle::Pipe(reader, writer);
@@ -538,11 +538,11 @@ namespace NLWTrace {
KillCheckParent(reader);
reader.Close();
}
-#else
+#else
Cout << "kill action test for windows is not implemented." << Endl;
-#endif
+#endif
}
-
+
void LogIntModFilter(const TConfig& cfg) {
TProbes p(cfg.UnsafeLWTrace);
p.Mngr.New("test-trace", MakeQuery(
@@ -635,7 +635,7 @@ namespace NLWTrace {
"}"));
Cout << "call to probe with int mod filter (always true, mod 10) and log executors: " << p.IntParamTime(cfg) << Endl;
}
-
+
#define FOR_EACH_TEST() \
FOR_EACH_TEST_MACRO(LogIntModFilter) \
FOR_EACH_TEST_MACRO(SleepCheck) \
diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp
index acacf366f1..3c974c85a0 100644
--- a/library/cpp/lwtrace/trace.cpp
+++ b/library/cpp/lwtrace/trace.cpp
@@ -1,8 +1,8 @@
#include "all.h"
-#include "kill_action.h"
+#include "kill_action.h"
#include "log_shuttle.h"
#include "preprocessor.h"
-#include "sleep_action.h"
+#include "sleep_action.h"
#include "stderr_writer.h"
#include "google/protobuf/repeated_field.h"
@@ -74,17 +74,17 @@ namespace NLWTrace {
return &traceVariables[name];
}
return &((*it).second);
- }
-
+ }
+
typedef enum {
OT_LITERAL = 0,
OT_PARAMETER = 1,
OT_VARIABLE = 2
} EOperandType;
-
+
template <class T, EOperandType>
class TOperand;
-
+
template <class T>
class TOperand<T, OT_LITERAL> {
private:
@@ -135,7 +135,7 @@ namespace NLWTrace {
void Inc() {
AtomicIncrement(*Variable);
}
-
+
void Dec() {
AtomicDecrement(*Variable);
}
@@ -166,7 +166,7 @@ namespace NLWTrace {
void Set(const TCheck& value) {
AtomicSet(*Variable, value.Value);
}
-
+
void Add(const TCheck& value) {
AtomicAdd(*Variable, value.Value);
}
@@ -178,7 +178,7 @@ namespace NLWTrace {
void Inc() {
AtomicIncrement(*Variable);
}
-
+
void Dec() {
AtomicDecrement(*Variable);
}
@@ -225,23 +225,23 @@ namespace NLWTrace {
virtual ~IOperandGetter() {
}
};
-
+
template <class T, EOperandType TParam>
class TOperandGetter: public IOperandGetter<T> {
private:
TOperand<T, TParam> Op;
-
+
public:
TOperandGetter(const TOperand<T, TParam>& op)
: Op(op)
{
}
-
+
const T Get(const TParams& params) override {
return Op.Get(params);
}
};
-
+
template <class T>
class TReceiver: public TOperand<T, OT_VARIABLE> {
public:
@@ -250,7 +250,7 @@ namespace NLWTrace {
{
}
};
-
+
template <class TP, class TPredicate>
static bool CmpFunc(TP a, TP b) {
return TPredicate()(a, b);
@@ -306,26 +306,26 @@ namespace NLWTrace {
private:
TFunc Func;
TReceiver<TP> Receiver;
-
+
bool DoExecute(TOrbit&, const TParams&) override {
Func(Receiver);
return true;
}
-
+
public:
TUnaryInplaceStatementExecutor(TReceiver<TP>& receiver)
: Receiver(receiver)
{
}
};
-
+
template <class TP, class TFunc, EOperandType TParam>
class TBinaryInplaceStatementExecutor: public IExecutor {
private:
TFunc Func;
TReceiver<TP> Receiver;
TOperand<TP, TParam> Param;
-
+
bool DoExecute(TOrbit&, const TParams& params) override {
Func(Receiver, Param.Get(params));
return true;
@@ -338,14 +338,14 @@ namespace NLWTrace {
{
}
};
-
+
template <class TP, class TFunc, EOperandType TFirstParam>
class TBinaryStatementExecutor: public IExecutor {
private:
TFunc Func;
TReceiver<TP> Receiver;
TOperand<TP, TFirstParam> FirstParam;
-
+
bool DoExecute(TOrbit&, const TParams& params) override {
Receiver.Set(Func(Receiver.Get(params), FirstParam.Get(params)));
return true;
@@ -464,9 +464,9 @@ namespace NLWTrace {
EOperandType Type;
size_t ParamIdx;
} TArgumentDescription;
-
+
using TArgumentList = TVector<TArgumentDescription>;
-
+
template <class T>
void ParseArguments(const T& op, const TSignature& signature, const TString& exceptionPrefix, size_t expectedArgumentCount, TArgumentList& arguments) {
arguments.clear();
@@ -483,10 +483,10 @@ namespace NLWTrace {
operand.Type = OT_PARAMETER;
operand.ParamIdx = signature.FindParamIndex(arg.GetParam());
if (operand.ParamIdx == size_t(-1)) {
- ythrow yexception() << exceptionPrefix
+ ythrow yexception() << exceptionPrefix
<< " argument #" << argumentIdx << " param '" << arg.GetParam()
<< "' doesn't exist";
- }
+ }
if (firstParamIdx == size_t(-1)) {
firstParamIdx = operand.ParamIdx;
} else {
@@ -499,14 +499,14 @@ namespace NLWTrace {
ythrow yexception() << exceptionPrefix
<< " argument #" << argumentIdx
<< " is empty";
- }
+ }
arguments.push_back(operand);
}
if (arguments.size() != expectedArgumentCount) {
- ythrow yexception() << exceptionPrefix
+ ythrow yexception() << exceptionPrefix
<< " incorrect number of arguments (" << arguments.size()
<< " present, " << expectedArgumentCount << " expected)";
- }
+ }
}
template <class TArg1, class TArg2>
@@ -569,7 +569,7 @@ namespace NLWTrace {
TOperand<t, lt> lhs(traceVariables, var0, val0, arg0.ParamIdx); \
FOREACH_RIGHT_TYPE(FOREACH_OPERAND_TYPE_RT, n, t, v, fn, lt) \
}
-
+
#define FOREACH_PARAMTYPE_MACRO(n, t, v, fn) \
if ((arg0.ParamIdx == size_t(-1) || strcmp(tName0, n) == 0) && (arg1.ParamIdx == size_t(-1) || strcmp(tName1, n) == 0)) { \
FOREACH_LEFT_TYPE(FOREACH_OPERAND_TYPE_LT, n, t, v, fn); \
@@ -680,10 +680,10 @@ namespace NLWTrace {
<< " SleepAction missing parameter 'NanoSeconds'";
}
} else {
- ythrow yexception() << "probe '" << probe->Event.Name << "block #" << bi + 1 << " action #" << i + 1
+ ythrow yexception() << "probe '" << probe->Event.Name << "block #" << bi + 1 << " action #" << i + 1
<< " contains destructive SleepAction, but destructive actions are disabled."
<< " Please, consider using --unsafe-lwtrace command line parameter.";
- }
+ }
} else if (action.HasStatementAction()) {
const TStatementAction& statement = action.GetStatementAction();
TString exceptionPrefix;
@@ -696,24 +696,24 @@ namespace NLWTrace {
expectedArgumentCount = 1;
}
ParseArguments<TStatementAction>(statement, probe->Event.Signature, exceptionPrefix, expectedArgumentCount, arguments);
-
+
TArgumentDescription arg0 = (expectedArgumentCount <= 0) ? TArgumentDescription() : arguments.at(0);
TArgumentDescription arg1 = (expectedArgumentCount <= 1) ? TArgumentDescription() : arguments.at(1);
TArgumentDescription arg2 = (expectedArgumentCount <= 2) ? TArgumentDescription() : arguments.at(2);
-
+
TString var0 = (expectedArgumentCount <= 0) ? "" : statement.GetArgument(0).GetVariable();
TString var1 = (expectedArgumentCount <= 1) ? "" : statement.GetArgument(1).GetVariable();
TString var2 = (expectedArgumentCount <= 2) ? "" : statement.GetArgument(2).GetVariable();
-
+
TString val0 = (expectedArgumentCount <= 0) ? "" : statement.GetArgument(0).GetValue();
TString val1 = (expectedArgumentCount <= 1) ? "" : statement.GetArgument(1).GetValue();
TString val2 = (expectedArgumentCount <= 2) ? "" : statement.GetArgument(2).GetValue();
-
+
const char* tName1 = (expectedArgumentCount <= 1 || arg1.ParamIdx == size_t(-1))
? nullptr : probe->Event.Signature.ParamTypes[arg1.ParamIdx];
const char* tName2 = (expectedArgumentCount <= 2 || arg2.ParamIdx == size_t(-1))
? nullptr : probe->Event.Signature.ParamTypes[arg2.ParamIdx];
-
+
if (arg0.Type == OT_VARIABLE) {
switch (statement.GetType()) {
#define PARSE_UNARY_INPLACE_STATEMENT_MACRO(n, t, v, fn) \
@@ -723,7 +723,7 @@ namespace NLWTrace {
actExec.Reset(new TExec(receiver)); \
break; \
}
-
+
#define PARSE_BINARY_INPLACE_STATEMENT_MACRO2(n, t, v, fn, ft) \
if (arg1.Type == ft) { \
typedef TBinaryInplaceStatementExecutor<t, fn<TReceiver<t>, t>, ft> TExec; \
@@ -814,11 +814,11 @@ namespace NLWTrace {
}
#undef CREATE_OPERAND_GETTER_N
#undef TERNARY_ON_TYPE
-#undef IMPLEMENT_TERNARY_STATEMENT
-#undef PARSE_TERNARY_STATEMENT_MACRO
-#undef PARSE_BINARY_STATEMENT_MACRO
-#undef PARSE_BINARY_INPLACE_STATEMENT_MACRO
-#undef PARSE_UNARY_INPLACE_STATEMENT_MACRO
+#undef IMPLEMENT_TERNARY_STATEMENT
+#undef PARSE_TERNARY_STATEMENT_MACRO
+#undef PARSE_BINARY_STATEMENT_MACRO
+#undef PARSE_BINARY_INPLACE_STATEMENT_MACRO
+#undef PARSE_UNARY_INPLACE_STATEMENT_MACRO
} else {
ythrow yexception() << "block #" << bi + 1 << " action #" << i + 1
<< " has not supported action '" << action.ShortDebugString() << "'";
@@ -835,7 +835,7 @@ namespace NLWTrace {
if (!probe->Attach(exec.Get())) {
ythrow yexception() << "block #" << bi + 1
<< " cannot be attached to probe '" << probe->Event.Name << "': no free slots";
- }
+ }
Probes.push_back(std::make_pair(probe, exec.Release()));
#else
Y_UNUSED(bi);
diff --git a/library/cpp/lwtrace/ya.make b/library/cpp/lwtrace/ya.make
index 2c5f63e268..d9accb3006 100644
--- a/library/cpp/lwtrace/ya.make
+++ b/library/cpp/lwtrace/ya.make
@@ -15,7 +15,7 @@ SRCS(
perf.cpp
probes.cpp
shuttle.cpp
- sleep_action.cpp
+ sleep_action.cpp
start.cpp
stderr_writer.cpp
symbol.cpp