diff --git a/ecl/hql/CMakeLists.txt b/ecl/hql/CMakeLists.txt index f1a76567b09..32ea50dadaa 100644 --- a/ecl/hql/CMakeLists.txt +++ b/ecl/hql/CMakeLists.txt @@ -167,6 +167,9 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) #Compiler complains about an unused function yyunput, and make sure that any warnings are not reported as errors set_source_files_properties (hqllex.cpp PROPERTIES COMPILE_FLAGS " -Wno-unused-function -Wno-error") + + #Compiler complains about a variable is set but not used + set_source_files_properties (hqlgram.cpp PROPERTIES COMPILE_FLAGS " -Wno-error=unused-but-set-variable -Wno-error=class-memaccess") endif() if (WIN32) diff --git a/ecl/hql/hqlexpr.cpp b/ecl/hql/hqlexpr.cpp index 2f0937f1bec..7b86bb23ab3 100644 --- a/ecl/hql/hqlexpr.cpp +++ b/ecl/hql/hqlexpr.cpp @@ -1146,8 +1146,8 @@ void HqlParseContext::finishMeta(bool isSeparateFile, bool success, bool generat { #if 0 IPropertyTree* tos = curMeta().meta; -# This is disabled as the location of the cache file needs to be -# in the original location for now. This may re-visited in the future. +// This is disabled as the location of the cache file needs to be +// in the original location for now. This may re-visited in the future. if (isSeparateFile && hasCacheLocation()) { StringBuffer fullName; diff --git a/ecl/hqlcpp/hqlresource.cpp b/ecl/hqlcpp/hqlresource.cpp index 61bdc871029..3e722954d86 100644 --- a/ecl/hqlcpp/hqlresource.cpp +++ b/ecl/hqlcpp/hqlresource.cpp @@ -5549,7 +5549,9 @@ void EclResourcer::removeDuplicateIndependentLinks(CSplitterInfo & connections, ResourcerInfo & sinkInfo = *queryResourceInfo(sink); if (allInputsPulledIndependently(sink)) { +#ifdef TRACE_BALANCED unsigned numRemoved = 0; +#endif for (unsigned j=info.balancedLinks.ordinality()-1; j > i; j--) { CSplitterLink & next = info.balancedLinks.item(j); @@ -5557,7 +5559,9 @@ void EclResourcer::removeDuplicateIndependentLinks(CSplitterInfo & connections, { info.balancedLinks.remove(j); sinkInfo.balancedLinks.zap(next); +#ifdef TRACE_BALANCED numRemoved++; +#endif } } diff --git a/roxie/ccd/ccdqueue.cpp b/roxie/ccd/ccdqueue.cpp index 8219a9bbfb4..a396eca03cc 100644 --- a/roxie/ccd/ccdqueue.cpp +++ b/roxie/ccd/ccdqueue.cpp @@ -1262,7 +1262,6 @@ class RoxieQueue : public CInterface, implements IThreadFactory bool remove(RoxiePacketHeader &x) { - unsigned scanLength = 0; ISerializedRoxieQueryPacket *found = nullptr; { CriticalBlock qc(qcrit); @@ -1273,7 +1272,6 @@ class RoxieQueue : public CInterface, implements IThreadFactory ISerializedRoxieQueryPacket *queued = waiting.item(i); if (queued) { - scanLength++; if (queued->queryHeader().matchPacket(x)) { waiting.set(i, NULL); diff --git a/system/jlib/jdebug.cpp b/system/jlib/jdebug.cpp index df6cc1a3802..2ca2586b909 100644 --- a/system/jlib/jdebug.cpp +++ b/system/jlib/jdebug.cpp @@ -3286,7 +3286,6 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe } while (reader.nextln()) { const char *ln = reader.ln; - unsigned n=0; if (*ln) { offset_t start = readHexNum(ln); if (last&&(last!=start)) { @@ -3360,7 +3359,6 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe recs[t].total += ssz; if (ssz>recs[t].largest) recs[t].largest = ssz; - n++; last = end; #ifndef __64BIT__ if ((end<0xffffffff)&&(end>=0xc0000000)) // rest is OS (32-bit only) diff --git a/testing/unittests/jlibtests.cpp b/testing/unittests/jlibtests.cpp index b8470d825b5..b7054529417 100644 --- a/testing/unittests/jlibtests.cpp +++ b/testing/unittests/jlibtests.cpp @@ -65,6 +65,7 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_TEST(testEnsureTraceID); CPPUNIT_TEST(manualTestsEventsOutput); CPPUNIT_TEST(manualTestsDeclaredFailures); + CPPUNIT_TEST(manualTestScopeEnd); //CPPUNIT_TEST(testJTraceJLOGExporterprintResources); //CPPUNIT_TEST(testJTraceJLOGExporterprintAttributes); @@ -196,7 +197,7 @@ class JlibTraceTest : public CppUnit::TestFixture { Owned emptyMockHTTPHeaders = createProperties(); { - Owned serverSpan = queryTraceManager().createServerSpan("spanWithEventsNoAtts", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("spanWithEventsNoAtts", emptyMockHTTPHeaders); Owned emptyEventAtts = createProperties(); serverSpan->addSpanEvent("event1", emptyEventAtts); } @@ -206,12 +207,12 @@ class JlibTraceTest : public CppUnit::TestFixture twoEventAtt->setProp("key2", ""); { - Owned serverSpan = queryTraceManager().createServerSpan("spanWithEvent1Att", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("spanWithEvent1Att", emptyMockHTTPHeaders); serverSpan->addSpanEvent("event2", twoEventAtt); }//{ "type": "span", "name": "spanWithEvents1Att", "trace_id": "3b9f55aaf8fab51fb0d73a32db7d704f", "span_id": "2a25a44ae0b3abe0", "start": 1709696036335278770, "duration": 3363911469, "events":[ { "name": "event2", "time_stamp": 1709696038413023245, "attributes": {"key": "value" } } ] } { - Owned serverSpan = queryTraceManager().createServerSpan("spanWith2Events", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("spanWith2Events", emptyMockHTTPHeaders); serverSpan->addSpanEvent("event1", twoEventAtt); serverSpan->addSpanEvent("event2", twoEventAtt); }//{ "type": "span", "name": "spanWith2Events", "trace_id": "ff5c5919b9c5f85913652b77f289bf0b", "span_id": "82f91ca1f9d469c1", "start": 1709698012480805016, "duration": 2811601377, "events":[ { "name": "event1", "time_stamp": 1709698013294323139, "attributes": {"key": "value" } },{ "name": "event2", "time_stamp": 1709698014500350802, "attributes": {"key": "value" } } ] } @@ -275,25 +276,25 @@ class JlibTraceTest : public CppUnit::TestFixture { Owned emptyMockHTTPHeaders = createProperties(); { - Owned serverSpan = queryTraceManager().createServerSpan("defaultErrorSpan", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("defaultErrorSpan", emptyMockHTTPHeaders); serverSpan->recordError(); }//{ "type": "span", "name": "defaultErrorSpan", "trace_id": "209b5d8cea0aec9785d2dfa3117e37ad", "span_id": "ab72e76c2f2466c2", "start": 1709675278129335702, "duration": 188292867932, "status": "Error", "kind": "Server", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675465508149013, "attributes": {"escaped": 0 } } ] } { - Owned serverSpan = queryTraceManager().createServerSpan("defaultErrorSpanStruct", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("defaultErrorSpanStruct", emptyMockHTTPHeaders); SpanError error; serverSpan->recordError(error); }//{ "type": "span", "name": "defaultErrorSpanStruct", "trace_id": "19803a446b971f2e0bdddc9c00db50fe", "span_id": "04c93a91ab8785a2", "start": 1709675487767044352, "duration": 2287497219, "status": "Error", "kind": "Server", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675489216412154, "attributes": {"escaped": 0 } } ] } { - Owned serverSpan = queryTraceManager().createServerSpan("failedErrorSpanEscaped", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("failedErrorSpanEscaped", emptyMockHTTPHeaders); SpanError * error = new SpanError("hello"); error->setSpanStatus(true, true); serverSpan->recordError(*error); }//{ "type": "span", "name": "failedErrorSpanEscaped", "trace_id": "634f386c18a6140544c980e0d5a15905", "span_id": "e2f59c48f63a8f82", "start": 1709675508231168974, "duration": 7731717678, "status": "Error", "kind": "Server", "description": "hello", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675512164430668, "attributes": {"escaped": 1,"message": "hello" } } ] } { - Owned serverSpan = queryTraceManager().createServerSpan("failedErrEscapedMsgErrCode", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("failedErrEscapedMsgErrCode", emptyMockHTTPHeaders); SpanError * error = new SpanError(); error->setSpanStatus(true, true); error->setError("hello", 34); @@ -301,22 +302,22 @@ class JlibTraceTest : public CppUnit::TestFixture }//failedErrEscapedMsgErrCode { - Owned serverSpan = queryTraceManager().createServerSpan("containsErrorAndMessageSpan", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("containsErrorAndMessageSpan", emptyMockHTTPHeaders); serverSpan->recordError(SpanError("Error Message!!")); }//{ "type": "span", "name": "containsErrorAndMessageSpan", "trace_id": "9a6e00ea309bc0427733f9b2d452f9e2", "span_id": "de63e9c69b64e411", "start": 1709675552302360510, "duration": 5233037523, "status": "Error", "kind": "Server", "description": "Error Message!!", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675555149852711, "attributes": {"escaped": 0,"message": "Error Message!!" } } { - Owned serverSpan = queryTraceManager().createServerSpan("containsErrorAndMessageFailedNotEscapedSpan", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("containsErrorAndMessageFailedNotEscapedSpan", emptyMockHTTPHeaders); serverSpan->recordError(SpanError("Error Message!!", 23, true, false)); }//{ "type": "span", "name": "containsErrorAndMessageFailedNotEscapedSpan", "trace_id": "02f4b2d215f8230b15063862f8a91e41", "span_id": "c665ec371d6db147", "start": 1709675573581678954, "duration": 3467489486, "status": "Error", "kind": "Server", "description": "Error Message!!", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675576145074240, "attributes": {"code": 23,"escaped": 0,"message": "Error Message!!" } } ] } { - Owned serverSpan = queryTraceManager().createServerSpan("mockExceptionSpanNotFailedNotEscaped", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("mockExceptionSpanNotFailedNotEscaped", emptyMockHTTPHeaders); serverSpan->recordException( makeStringExceptionV(76,"Mock exception"), false, false); }//{ "type": "span", "name": "mockExceptionSpanNotFailedNotEscaped", "trace_id": "e01766474db05ce9085943fa3955cd73", "span_id": "7da620e96e10e42c", "start": 1709675595987480704, "duration": 2609091267, "status": "Unset", "kind": "Server", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675597728975355, "attributes": {"code": 76,"escaped": 0,"message": "Mock exception" } } ] { - Owned serverSpan = queryTraceManager().createServerSpan("thrownExceptionSpan", emptyMockHTTPHeaders); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("thrownExceptionSpan", emptyMockHTTPHeaders); try { throw makeStringExceptionV( 356, "Mock thrown exception"); @@ -328,6 +329,28 @@ class JlibTraceTest : public CppUnit::TestFixture } }//{ "type": "span", "name": "thrownExceptionSpan", "trace_id": "4d6225e1cefdc6823d1134c71c522426", "span_id": "07f7bd070e008f53", "start": 1709675614823881961, "duration": 4665288686, "status": "Unset", "kind": "Server", "instrumented_library": "unittests", "events":[ { "name": "Exception", "time_stamp": 1709675616485586471, "attributes": {"code": 356,"escaped": 1,"message": "Mock thrown exception" } } ] } } + //not able to programmatically test yet, but can visually inspect trace output + void manualTestScopeEnd() + { + Owned savedSpan; + { + SpanFlags flags = SpanFlags::EnsureTraceId; + Owned emptyMockHTTPHeaders = createProperties(); + OwnedSpanScope serverSpan = queryTraceManager().createServerSpan("mySpan", emptyMockHTTPHeaders, flags); + DBGLOG("mySpan is alive"); + savedSpan.set(serverSpan); + }//{ "type": "span", "name": "mySpan", "trace_id": "fe266416e7d588113a5131394d913ab4", "span_id": "7ac62328b04442c5", "start": 1709824793826023368, "duration": 16952 } + //NB: Duration for the span should be << 100,000,000ns + //If logging is asynchronous the log message may appear after the following logging line + DBGLOG("mySpan is finished"); + Sleep(100); + + //Check that the attributes are still accessible even though the span has ended + Owned retrievedSpanCtxAttributes = createProperties(); + savedSpan->getSpanContext(retrievedSpanCtxAttributes.get()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("traceID"))); + savedSpan.clear(); + } void testTraceDisableConfig() { diff --git a/tools/hidl/hidlcomp.cpp b/tools/hidl/hidlcomp.cpp index 93ec23cf067..f9dba61e2d7 100644 --- a/tools/hidl/hidlcomp.cpp +++ b/tools/hidl/hidlcomp.cpp @@ -2254,10 +2254,8 @@ void ModuleInfo::write_body_class() } outf("}, %d };\n\n",version); - int fn=0; for (ProcInfo *pi=procs; pi; pi=pi->next) { - fn++; pi->write_body_method_structs2(name); } outs("\n");