diff --git a/.azure/azure-pipelines.ci.yml b/.azure/azure-pipelines.ci.yml deleted file mode 100644 index dfe09fc..0000000 --- a/.azure/azure-pipelines.ci.yml +++ /dev/null @@ -1,168 +0,0 @@ -# -# Continuous Integration (CI) Pipeline -# - -trigger: - batch: true - branches: - include: - - main - - release/* - - feature/* -pr: - branches: - include: - - main - - release/* - - feature/* - -variables: -- name: buildConfiguration - value: 'Release' -- name: runCodesignValidationInjection - value: false -- name: skipComponentGovernanceDetection - value: true - -name: 0.$(Date:yyyy).$(Date:MM).$(DayOfMonth).$(Rev:rr).0 - -stages: -- stage: build - displayName: Build - jobs: - - job: build_clog - displayName: Build CLOG - pool: - vmImage: ubuntu-latest - steps: - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - version: 5.x - installationPath: $(Agent.ToolsDirectory)/dotnet - - task: DotNetCoreCLI@2 - inputs: - command: build - projects: clog.sln - arguments: --configuration $(buildConfiguration) - - task: DotNetCoreCLI@2 - inputs: - command: custom - custom: tool - arguments: restore - displayName: Install dotnet-format - - script: dotnet format --check - displayName: Check formatting -- stage: examples - displayName: Examples - jobs: - - job: build_example - displayName: Build Example - strategy: - matrix: - # linux31: - # imageName: 'ubuntu-latest' - # dotnetVersion: 3.1.x - # mac31: - # imageName: 'macos-10.14' - # dotnetVersion: 3.1.x - # windows31: - # imageName: 'windows-latest' - # dotnetVersion: 3.1.x - linux5: - imageName: 'ubuntu-latest' - dotnetVersion: 5.x - mac5: - imageName: 'macos-10.14' - dotnetVersion: 5.x - windows5: - imageName: 'windows-latest' - dotnetVersion: 5.x - pool: - vmImage: $(imageName) - steps: - - task: UseDotNet@2 - condition: ne(variables.imageName, 'windows-latest') - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - version: $(dotnetVersion) - installationPath: $(Agent.ToolsDirectory)/dotnet - - pwsh: | - if ($IsLinux) { - sudo apt-add-repository ppa:lttng/stable-2.11 - sudo apt-get update - sudo apt-get install -y liblttng-ust-dev - sudo apt-get install -y lttng-tools - } - - $BaseDir = Get-Location - $UploadPath = Join-Path $BaseDir "Logs" - mkdir $UploadPath - - mkdir build - cd build - $env:CLOG_DEVELOPMENT_MODE = 1 - cmake ../examples - cmake --build . - - if ($IsLinux) { - cd clogsample - mkdir log - mkdir log/lttng - lttng create clogsample -o=log/lttng - lttng enable-event --userspace CLOG_* - lttng add-context --userspace --type=vpid --type=vtid - lttng start - - ./clogsample - - lttng stop clogsample - babeltrace --names all log/lttng/* > log/clog.babel - ../buildclog/artifacts/clog2text_lttng -i log/clog.babel -s ../../examples/examples/sidecar/clog.sidecar -o log/clog.log --showTimestamp --showCpuInfo - cat log/clog.log - - cp log/clog.babel "$UploadPath/clogstatictp.babel" - cp ../../examples/examples/sidecar/clog.sidecar "$UploadPath/clog.sidecar" - - rm -rf log/lttng - mkdir log/lttng - - Write-Host "Running with Dynamic Tracepoint Provider" - - lttng create clogsampledyn -o=log/lttng - lttng enable-event --userspace CLOG_* - lttng add-context --userspace --type=vpid --type=vtid - lttng start - - $env:LD_PRELOAD="$PWD/libclogsampletracepointprovider.so" - ./clogsampledynamictp - - $env:LD_PRELOAD="" - - lttng stop clogsampledyn - babeltrace --names all log/lttng/* > log/clog.babel - ../buildclog/artifacts/clog2text_lttng -i log/clog.babel -s ../../examples/examples/sidecar/clog.sidecar -o log/clog.log --showTimestamp --showCpuInfo - cat log/clog.log - - cp log/clog.babel "$UploadPath/clogdynamictp.babel" - cp ../../examples/examples/sidecar/clog.sidecar "$UploadPath/clog.sidecar" - - ls $UploadPath - - } - - displayName: Test Sample Build - - - task: CopyFiles@2 - displayName: Move Build Artifacts - inputs: - sourceFolder: Logs - targetFolder: $(Build.ArtifactStagingDirectory) - - task: PublishBuildArtifacts@1 - displayName: Upload Build Artifacts - inputs: - artifactName: logs - pathToPublish: $(Build.ArtifactStagingDirectory) - parallel: true diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000..b256a8f --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,5 @@ +--- +name: "CodeQL config" + +queries: + - uses: security-extended # security-and-quality (very verbose) diff --git a/.github/workflows/check-clog-linux.yml b/.github/workflows/check-clog-linux.yml new file mode 100644 index 0000000..a889202 --- /dev/null +++ b/.github/workflows/check-clog-linux.yml @@ -0,0 +1,31 @@ +name: CLOG + +on: + push: + branches: + - main + - release/* + pull_request: + branches: + - main + - release/* + +jobs: + validate: + name: Validate(Linux) + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - run: | + sudo apt-add-repository ppa:lttng/stable-2.12 + sudo apt-get update + sudo apt-get install -y liblttng-ust-dev lttng-tools build-essential + + - name: Build CLOG and run Tests + run: ./runTests.ps1 + working-directory: ./examples + shell: pwsh + + diff --git a/.github/workflows/check-clog-windows.yml b/.github/workflows/check-clog-windows.yml new file mode 100644 index 0000000..e4e9943 --- /dev/null +++ b/.github/workflows/check-clog-windows.yml @@ -0,0 +1,25 @@ +name: CLOG + +on: + push: + branches: + - main + - release/* + + pull_request: + branches: + - main + - release/* + +jobs: + validate: + name: Validate(Windows) + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Build CLOG and run Tests + run: ./runTests.ps1 + working-directory: ./examples + shell: pwsh diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..993761f --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,50 @@ +--- +name: "CodeQL" + +on: + push: + branches: + - main + - release/* + pull_request: + # The branches below must be a subset of the branches above + branches: + - main + - release/* + schedule: + - cron: '0 17 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + submodules: 'recursive' + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: cpp,csharp + config-file: ./.github/codeql/codeql-config.yml + + # Build + - run: | + mkdir build + cd build + cmake .. + cmake --build . + cd .. + find + + # Analyze this build. + - run: | + cd build + cmake --build . + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/CMakeLists.txt b/CMakeLists.txt index e90da60..3ea820d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,15 +11,18 @@ function(DOT_NET_BUILD) set(DEPENDENCY_NAME ${ARGV0}) set(DEST_BINARY ${CLOG_ARTIFACT_DIR}/${ARGV1}) set(PROJECT_PATH ${ARGV2}) + set(DOTNET_FRAMEWORK ${ARGV3}) + list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0) - #message(STATUS "---------------------- GENERATING : ${DEPENDENCY_NAME} -------------------") - #message(STATUS "PROJECT : ${PROJECT_PATH}") - #message(STATUS "PRODUCES : ${DEST_BINARY}") - #message(STATUS "DOTNET_RUNTIME : ${DOTNET_RUNTIME}") - #message(STATUS "OUTPUTDIR : ${CLOG_ARTIFACT_DIR}") + message(STATUS "---------------------- GENERATING : ${DEPENDENCY_NAME} -------------------") + message(STATUS "PROJECT : ${PROJECT_PATH}") + message(STATUS "PRODUCES : ${DEST_BINARY}") + message(STATUS "DOTNET_RUNTIME : ${DOTNET_RUNTIME}") + message(STATUS "OUTPUTDIR : ${CLOG_ARTIFACT_DIR}") + message(STATUS "DOTNET_FRAMEWORK : ${DOTNET_FRAMEWORK}") foreach(arg IN LISTS ARGV) #message(STATUS "FILE : ${CMAKE_CURRENT_BINARY_DIR}/${arg}") @@ -32,7 +35,7 @@ function(DOT_NET_BUILD) COMMENT "build CLOG, if this fails with nuget packages inspect your nuget.config and make sure nuget.org is present (add from command line using : dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org)" COMMAND - dotnet publish ${PROJECT_PATH} -o ${CLOG_ARTIFACT_DIR} -f net5.0 + dotnet publish ${PROJECT_PATH} -o ${CLOG_ARTIFACT_DIR} -f ${DOTNET_FRAMEWORK} DEPENDS ${PROJECT_PATH} DEPENDS @@ -47,14 +50,15 @@ function(DOT_NET_LIBRARY_BUILD) set(DEPENDENCY_NAME ${ARGV0}) set(DEST_BINARY ${CLOG_ARTIFACT_DIR}/${DOTNET_RUNTIME}/${ARGV1}) set(PROJECT_PATH ${ARGV2}) + list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0) - #message(STATUS "---------------------- GENERATING : ${DEPENDENCY_NAME} -------------------") - #message(STATUS "PROJECT : ${PROJECT_PATH}") - #message(STATUS "PRODUCES : ${DEST_BINARY}") - #message(STATUS "OUTPUTDIR : ${CLOG_ARTIFACT_DIR}/${DOTNET_RUNTIME}") + ##message(STATUS "---------------------- GENERATING : ${DEPENDENCY_NAME} -------------------") + ##message(STATUS "PROJECT : ${PROJECT_PATH}") + ##message(STATUS "PRODUCES : ${DEST_BINARY}") + ##message(STATUS "OUTPUTDIR : ${CLOG_ARTIFACT_DIR}/${DOTNET_RUNTIME}") foreach(arg IN LISTS ARGV) #message(STATUS "FILE : ${CMAKE_CURRENT_BINARY_DIR}/${arg}") @@ -81,6 +85,9 @@ add_subdirectory(src/clog) add_subdirectory(src/clogutils) if (NOT APPLE) - add_subdirectory(src/clog2text/clog2text_windows) add_subdirectory(src/clog2text/clog2text_lttng) endif() + +if (WIN32) + add_subdirectory(src/clog2text/clog2text_windows) +endif() diff --git a/clog.sln b/clog.sln index e3a1800..00aceeb 100644 --- a/clog.sln +++ b/clog.sln @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clog", "src\clog\clog.cspro EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clogutils", "src\clogutils\clogutils.csproj", "{076A3AA5-DEB6-45AB-B834-5416178BAF44}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "clog2text", "src\clog2text", "{C05DAADF-AA11-4B93-A0B9-CCA2849A6A06}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "clog2text", "clog2text", "{C05DAADF-AA11-4B93-A0B9-CCA2849A6A06}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clog2text_lttng", "src\clog2text\clog2text_lttng\clog2text_lttng.csproj", "{B683F6AC-DEC3-4AFC-B156-77F303EE2986}" EndProject @@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clog2text_windows", "src\cl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "decoderTest", "src\decoderTest\decoderTest.csproj", "{A2079B4E-FF96-4DE5-80E8-8403A17C4347}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "converters", "src\converters", "{FE0B277E-B292-4FF2-8C69-15EECC1A3787}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "converters", "converters", "{FE0B277E-B292-4FF2-8C69-15EECC1A3787}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "syslog2clog", "src\converters\syslog2clog\syslog2clog.csproj", "{E1FA7999-5C45-46B1-9E83-5467264F928E}" EndProject @@ -75,6 +75,22 @@ Global {E1FA7999-5C45-46B1-9E83-5467264F928E}.Release|Any CPU.Build.0 = Release|Any CPU {E1FA7999-5C45-46B1-9E83-5467264F928E}.Release|x64.ActiveCfg = Release|Any CPU {E1FA7999-5C45-46B1-9E83-5467264F928E}.Release|x64.Build.0 = Release|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Debug|x64.ActiveCfg = Debug|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Debug|x64.Build.0 = Debug|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Release|Any CPU.Build.0 = Release|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Release|x64.ActiveCfg = Release|Any CPU + {A8C76D37-6C7C-4617-8A05-7469C07E294D}.Release|x64.Build.0 = Release|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Debug|x64.ActiveCfg = Debug|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Debug|x64.Build.0 = Debug|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Release|Any CPU.Build.0 = Release|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Release|x64.ActiveCfg = Release|Any CPU + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -83,6 +99,8 @@ Global {B683F6AC-DEC3-4AFC-B156-77F303EE2986} = {C05DAADF-AA11-4B93-A0B9-CCA2849A6A06} {1ACE842F-1CA7-49E8-8E43-2C33EAF7E170} = {C05DAADF-AA11-4B93-A0B9-CCA2849A6A06} {E1FA7999-5C45-46B1-9E83-5467264F928E} = {FE0B277E-B292-4FF2-8C69-15EECC1A3787} + {A8C76D37-6C7C-4617-8A05-7469C07E294D} = {FE0B277E-B292-4FF2-8C69-15EECC1A3787} + {A9D4DA06-7428-4639-BFD0-69D63CCD8F3E} = {C05DAADF-AA11-4B93-A0B9-CCA2849A6A06} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {923EC79F-9700-466D-8668-106D7BDECF0D} diff --git a/defaults/CLog.cmake b/defaults/CLog.cmake index c997399..d47a48f 100644 --- a/defaults/CLog.cmake +++ b/defaults/CLog.cmake @@ -23,7 +23,7 @@ function(CLOG_GENERATE_TARGET) foreach(arg IN LISTS ARGV) get_filename_component(RAW_FILENAME ${arg} NAME) set(ARG_CLOG_OUTPUT_DIR ${CMAKE_CLOG_OUTPUT_DIRECTORY}/${library}) - set(ARG_CLOG_FILE ${CMAKE_CLOG_OUTPUT_DIRECTORY}/${library}/${RAW_FILENAME}.clog.h) + set(ARG_CLOG_FILE ${CMAKE_CLOG_OUTPUT_DIRECTORY}/${library}/${RAW_FILENAME}.clog.h) set(ARG_CLOG_C_FILE ${CMAKE_CLOG_OUTPUT_DIRECTORY}/${library}/${library}_${RAW_FILENAME}.clog.h.c) # message(STATUS ">>>>>>> CLOG Source File = ${RAW_FILENAME}") diff --git a/defaults/clog.h b/defaults/clog.h index 3cc0d81..68f54ae 100644 --- a/defaults/clog.h +++ b/defaults/clog.h @@ -42,6 +42,10 @@ #define CLOG_STRUCT(numFields) CLOG_STRUCT_HELPER(numFields) #endif +#define CLOG_ARRAY_HELPER(length, pointer) pointer, length +#define CLOG_ARRAY(length, pointer) CLOG_ARRAY_HELPER(length, pointer) +#define CLOG_STRUCT_HELPER(numFields) numFields +#define CLOG_STRUCT(numFields) CLOG_STRUCT_HELPER(numFields) typedef const void * CLOG_PTR; typedef const unsigned char CLOG_UINT8; typedef const char CLOG_INT8; diff --git a/defaults/defaults.clog_config b/defaults/defaults.clog_config index 50394c3..f79f794 100644 --- a/defaults/defaults.clog_config +++ b/defaults/defaults.clog_config @@ -10,66 +10,6 @@ "CType": "CLOG_PTR", "DefinationEncoding": "!BYTEARRAY!" }, - { - "EncodingType": "Int32Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT32ARRAY!" - }, - { - "EncodingType": "UInt32Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT32ARRAY!" - }, - { - "EncodingType": "Int64Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT64ARRAY!" - }, - { - "EncodingType": "UInt64Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT64ARRAY!" - }, - { - "EncodingType": "ANSI_StringArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!ANSISTRINGARRAY!" - }, - { - "EncodingType": "UNICODE_StringArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UNICODESTRINGARRAY!" - }, - { - "EncodingType": "PointerArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!POINTERARRAY!" - }, - { - "EncodingType": "GUIDArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!GUIDARRAY!" - }, - { - "EncodingType": "Int16Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT16ARRAY!" - }, - { - "EncodingType": "UInt16Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT16ARRAY!" - }, - { - "EncodingType": "Int8Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT8ARRAY!" - }, - { - "EncodingType": "Struct", - "CType": "unsigned long int", - "DefinationEncoding": "!STRUCT!" - }, { "EncodingType": "Int32", "CType": "int", @@ -185,6 +125,11 @@ "CType": "unsigned short", "DefinationEncoding": "hx", }, + { + "EncodingType": "Int16", + "CType": "short", + "DefinationEncoding": "hd", + }, { "EncodingType": "UInt16", "CType": "unsigned short", diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md index f4b4286..379b9ac 100644 --- a/docs/EXAMPLES.md +++ b/docs/EXAMPLES.md @@ -8,6 +8,6 @@ cmake -G "Unix Makefiles" .. cmake -G "Visual Studio 16 2019" -A x64 .. dotnet publish ./src/clog/clog.csproj --self-contained -o /home/chgray/.dotnet/tools -f net5.0 -r win-x64 -dotnet publish ./src/clog/clog.csproj --self-contained -o /home/chgray/.dotnet/tools -f net5.0 -r linux-x64 +dotnet publish ./src/clog/clog.csproj --self-contained -o /home/chgray/.dotnet/tools -f net5.0 -r linux-x64 -p:PublishReadyToRun=true -p:PublishReadyToRunShowWarnings=true https://github.com/chgray/msquic/blob/53198319bd1460a04823eb6859b776b964f145f6/docs/BUILD.md \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 1422d55..59278a2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -8,13 +8,3 @@ Then run ``` dotnet tool install --global --add-source nupkg Microsoft.Logging.CLOG ``` - -# Build (using pwsh) -``` -mkdir build -clog --installDirectory build/clog -cd build -$env:CLOG_DEVELOPMENT_MODE = 1 -cmake .. -cmake --build . -``` diff --git a/examples/clog.sidecar b/examples/clog.sidecar index 3dec198..d4fd9ef 100644 --- a/examples/clog.sidecar +++ b/examples/clog.sidecar @@ -1,21 +1,35 @@ { "Version": 2, "EventBundlesV2": { - "LAUNCHED": { - "ModuleProperites": {}, - "TraceString": "Hello world - we just started here is an int=%d", - "UniqueId": "LAUNCHED", + "DATA_STRING": { + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "4", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "2. I am string %s=hello", + "UniqueId": "DATA_STRING", "splitArgs": [ { - "DefinationEncoding": "d", + "DefinationEncoding": "s", "MacroVariableName": "arg2" } ], "macroName": "TraceInfo" }, "DATABYTEARRAY": { - "ModuleProperites": {}, - "TraceString": "%!BYTEARRAY!", + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "5", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "3. This is a byte array with a custom decoder = %!BYTEARRAY!", "UniqueId": "DATABYTEARRAY", "splitArgs": [ { @@ -26,8 +40,15 @@ "macroName": "TraceInfo" }, "DATACHAR": { - "ModuleProperites": {}, - "TraceString": "This is a char: %c", + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "6", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "4. This is a char: %c; it should equal a", "UniqueId": "DATACHAR", "splitArgs": [ { @@ -38,8 +59,15 @@ "macroName": "TraceInfo" }, "DATAINT": { - "ModuleProperites": {}, - "TraceString": "This is an int: %d", + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "7", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "5. This is an int: %d; it should be 1234", "UniqueId": "DATAINT", "splitArgs": [ { @@ -49,9 +77,35 @@ ], "macroName": "TraceInfo" }, + "DATAINT5": { + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "8", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "6. This is an int: %d; it should be 1234", + "UniqueId": "DATAINT5", + "splitArgs": [ + { + "DefinationEncoding": "d", + "MacroVariableName": "arg2" + } + ], + "macroName": "TraceInfo" + }, "INSTANCE_TEST": { - "ModuleProperites": {}, - "TraceString": "[%p]1:%d 2:%s 3:%c 4:%u 5:%u 6:%u", + "ModuleProperites": { + "MANIFESTED_ETW": { + "EventID": "9", + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + }, + "TraceString": "[%p] 1. 1:%d 2:%s 3:%c 4:%u 5:%hd 6:%lld - you should see 1 2 3 4 5 6", "UniqueId": "INSTANCE_TEST", "splitArgs": [ { @@ -75,20 +129,48 @@ "MacroVariableName": "arg6" }, { - "DefinationEncoding": "u", + "DefinationEncoding": "hd", "MacroVariableName": "arg7" }, { - "DefinationEncoding": "u", + "DefinationEncoding": "lld", "MacroVariableName": "arg8" } ], "macroName": "TraceInstanceInfo" + }, + "INT_ERROR": { + "ModuleProperites": {}, + "TraceString": "7. this is an error %d", + "UniqueId": "INT_ERROR", + "splitArgs": [ + { + "DefinationEncoding": "d", + "MacroVariableName": "arg2" + } + ], + "macroName": "TraceError" + }, + "INT_ERROR_2": { + "ModuleProperites": {}, + "TraceString": "8. this is an error %d with a string %s", + "UniqueId": "INT_ERROR_2", + "splitArgs": [ + { + "DefinationEncoding": "d", + "MacroVariableName": "arg2" + }, + { + "DefinationEncoding": "s", + "MacroVariableName": "arg3" + } + ], + "macroName": "TraceError" } }, "ConfigFile": { "MacroConfigurations": { - "lttng_plus": { + "lttng": { "Modules": [ { "ExportModule": "LTTNG", @@ -96,6 +178,26 @@ } ] }, + "etw_info": { + "Modules": [ + { + "ExportModule": "MANIFESTED_ETW", + "CustomSettings": { + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + } + ] + }, + "etw_errors": { + "Modules": [ + { + "ExportModule": "TRACELOGGING", + "CustomSettings": {} + } + ] + }, "empty": { "Modules": [] } @@ -113,24 +215,50 @@ "EncodedPrefix": null, "EncodedArgNumber": 1, "MacroConfiguration": { - "linux": "lttng_plus", + "linux": "lttng", "macos": "empty", "stubs": "empty", "windows_kernel": "empty", - "windows": "empty" + "windows": "etw_info" }, "CustomSettings": null }, { "MacroName": "TraceInstanceInfo", - "EncodedPrefix": "[%p]", + "EncodedPrefix": "[%p] ", + "EncodedArgNumber": 2, + "MacroConfiguration": { + "linux": "lttng", + "macos": "empty", + "stubs": "empty", + "windows_kernel": "empty", + "windows": "etw_info" + }, + "CustomSettings": null + }, + { + "MacroName": "TraceError", + "EncodedPrefix": null, + "EncodedArgNumber": 1, + "MacroConfiguration": { + "linux": "lttng", + "macos": "empty", + "stubs": "empty", + "windows_kernel": "empty", + "windows": "etw_errors" + }, + "CustomSettings": null + }, + { + "MacroName": "TraceInstanceError", + "EncodedPrefix": "[%p] ", "EncodedArgNumber": 2, "MacroConfiguration": { - "linux": "lttng_plus", + "linux": "lttng", "macos": "empty", "stubs": "empty", "windows_kernel": "empty", - "windows": "empty" + "windows": "etw_errors" }, "CustomSettings": null } @@ -151,262 +279,248 @@ { "EncodingType": "ByteArray", "CType": "CLOG_PTR", + "JavaType": null, "DefinationEncoding": "!BYTEARRAY!" }, - { - "EncodingType": "Int32Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT32ARRAY!" - }, - { - "EncodingType": "Int64Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT64ARRAY!" - }, - { - "EncodingType": "Int16Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT16ARRAY!" - }, - { - "EncodingType": "Int8Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!INT8ARRAY!" - }, - { - "EncodingType": "UInt32Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT32ARRAY!" - }, - { - "EncodingType": "UInt64Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT64ARRAY!" - }, - { - "EncodingType": "UInt16Array", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UINT16ARRAY!" - }, - { - "EncodingType": "UNICODE_StringArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!UNICODESTRINGARRAY!" - }, - { - "EncodingType": "ANSI_StringArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!ANSISTRINGARRAY!" - }, - { - "EncodingType": "PointerArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!POINTERARRAY!" - }, - { - "EncodingType": "GUIDArray", - "CType": "CLOG_PTR", - "DefinationEncoding": "!GUIDARRAY!" - }, - { - "EncodingType": "Struct", - "CType": "unsigned long int", - "DefinationEncoding": "!STRUCT!" - }, { "EncodingType": "Int32", "CType": "int", + "JavaType": null, "DefinationEncoding": "d" }, { "EncodingType": "Int8", "CType": "signed char", + "JavaType": null, "DefinationEncoding": "hhd" }, { "EncodingType": "Int8", "CType": "signed char", + "JavaType": null, "DefinationEncoding": "hhi" }, { "EncodingType": "UInt8", "CType": "unsigned char", + "JavaType": null, "DefinationEncoding": "hhu" }, { "EncodingType": "UInt8", "CType": "unsigned char", + "JavaType": null, "DefinationEncoding": "hhx" }, { "EncodingType": "UInt8", "CType": "unsigned char", + "JavaType": null, "DefinationEncoding": "hhX" }, { "EncodingType": "UInt16", "CType": "unsigned short", + "JavaType": null, "DefinationEncoding": "hu" }, { "EncodingType": "UInt16", "CType": "unsigned short", + "JavaType": null, "DefinationEncoding": "hx" }, + { + "EncodingType": "Int16", + "CType": "short", + "JavaType": null, + "DefinationEncoding": "hd" + }, { "EncodingType": "UInt16", "CType": "unsigned short", + "JavaType": null, "DefinationEncoding": "hX" }, { "EncodingType": "Int32", "CType": "long int", + "JavaType": null, "DefinationEncoding": "ld" }, { "EncodingType": "Int64", "CType": "long long int", + "JavaType": null, "DefinationEncoding": "lld" }, { "EncodingType": "Int64", "CType": "long long int", + "JavaType": null, "DefinationEncoding": "lli" }, { "EncodingType": "UInt64", "CType": "unsigned long long int", + "JavaType": null, "DefinationEncoding": "llu" }, { "EncodingType": "UInt64", "CType": "unsigned long long int", + "JavaType": null, "DefinationEncoding": "llx" }, { "EncodingType": "UInt64", "CType": "unsigned long long int", + "JavaType": null, "DefinationEncoding": "llX" }, { "EncodingType": "Int32", "CType": "long int", + "JavaType": null, "DefinationEncoding": "li" }, { "EncodingType": "UInt32", "CType": "unsigned long int", + "JavaType": null, "DefinationEncoding": "lu" }, { "EncodingType": "UInt32", "CType": "unsigned long int", + "JavaType": null, "DefinationEncoding": "lx" }, { "EncodingType": "UInt32", "CType": "unsigned long int", + "JavaType": null, "DefinationEncoding": "lX" }, { "EncodingType": "UNICODE_String", "CType": "const wchar_t *", + "JavaType": null, "DefinationEncoding": "ls" }, { "EncodingType": "Int64", "CType": "size_t", + "JavaType": null, "DefinationEncoding": "zd" }, { "EncodingType": "Int64", "CType": "size_t", + "JavaType": null, "DefinationEncoding": "zi" }, { "EncodingType": "UInt64", "CType": "size_t", + "JavaType": null, "DefinationEncoding": "zu" }, { "EncodingType": "UInt64", "CType": "size_t", + "JavaType": null, "DefinationEncoding": "zx" }, { "EncodingType": "UInt64", "CType": "size_t", + "JavaType": null, "DefinationEncoding": "zX" }, { "EncodingType": "Int64", "CType": "ptrdiff_t", + "JavaType": null, "DefinationEncoding": "td" }, { "EncodingType": "Int64", "CType": "ptrdiff_t", + "JavaType": null, "DefinationEncoding": "ti" }, { "EncodingType": "UInt64", "CType": "ptrdiff_t", + "JavaType": null, "DefinationEncoding": "tu" }, { "EncodingType": "UInt64", "CType": "ptrdiff_t", + "JavaType": null, "DefinationEncoding": "tx" }, { "EncodingType": "UInt64", "CType": "ptrdiff_t", + "JavaType": null, "DefinationEncoding": "tX" }, { "EncodingType": "Int32", "CType": "int", + "JavaType": null, "DefinationEncoding": "i" }, { "EncodingType": "UInt32", "CType": "unsigned int", + "JavaType": null, "DefinationEncoding": "u" }, { "EncodingType": "UInt32", "CType": "unsigned int", + "JavaType": null, "DefinationEncoding": "x" }, { "EncodingType": "UInt32", "CType": "unsigned int", + "JavaType": null, "DefinationEncoding": "4.4x" }, { "EncodingType": "UInt32", "CType": "unsigned int", + "JavaType": null, "DefinationEncoding": "X" }, { "EncodingType": "UInt8", "CType": "char", + "JavaType": null, "DefinationEncoding": "c", "CustomDecoder": "defaults.clog_config.Types.DecodeChar" }, { "EncodingType": "ANSI_String", "CType": "const char *", + "JavaType": null, "DefinationEncoding": "s" }, { "EncodingType": "UNICODE_String", "CType": "const wchar_t *", + "JavaType": null, "DefinationEncoding": "S" }, { "EncodingType": "Pointer", "CType": "CLOG_PTR", + "JavaType": null, "DefinationEncoding": "p", "CustomDecoder": "defaults.clog_config.Types.DecodePointer" } @@ -421,29 +535,44 @@ "ModuleUniqueness": { "TraceInformation": [ { - "UniquenessHash": "1ba94e38-7860-c45a-131c-13e183be74c5", - "TraceID": "LAUNCHED", - "EncodingString": "Hello world - we just started here is an int=%d" + "UniquenessHash": "cd0737ad-4546-9d2c-6890-1132b9b30214", + "TraceID": "DATA_STRING", + "EncodingString": "2. I am string %s=hello" }, { - "UniquenessHash": "368386b1-58a0-bc3e-cf2b-bdcdb5f8a12e", + "UniquenessHash": "32847a97-a325-9319-c339-fe21e3428571", "TraceID": "DATABYTEARRAY", - "EncodingString": "%!BYTEARRAY!" + "EncodingString": "3. This is a byte array with a custom decoder = %!BYTEARRAY!" }, { - "UniquenessHash": "73633e68-7dc6-9310-40dd-35accdad6932", + "UniquenessHash": "231b0811-0852-d02c-e48d-01554d92d7d6", "TraceID": "DATACHAR", - "EncodingString": "This is a char: %c" + "EncodingString": "4. This is a char: %c; it should equal a" }, { - "UniquenessHash": "348407f0-f2f5-c1de-a153-4005cce7a5ce", + "UniquenessHash": "94b6f09a-1a05-c2da-82ea-8cca90a2fd12", "TraceID": "DATAINT", - "EncodingString": "This is an int: %d" + "EncodingString": "5. This is an int: %d; it should be 1234" + }, + { + "UniquenessHash": "30926746-3fa4-1934-c3dc-5c25217666dd", + "TraceID": "DATAINT5", + "EncodingString": "6. This is an int: %d; it should be 1234" }, { - "UniquenessHash": "6fe4b3c0-ad93-cd49-fc8b-e30c268668f4", + "UniquenessHash": "7c626bda-19d6-8240-ec6e-0271f541602b", "TraceID": "INSTANCE_TEST", - "EncodingString": "[%p]1:%d 2:%s 3:%c 4:%u 5:%u 6:%u" + "EncodingString": "[%p] 1. 1:%d 2:%s 3:%c 4:%u 5:%hd 6:%lld - you should see 1 2 3 4 5 6" + }, + { + "UniquenessHash": "0df07de0-3380-500a-02b5-85c45e74d3a3", + "TraceID": "INT_ERROR", + "EncodingString": "7. this is an error %d" + }, + { + "UniquenessHash": "7aff5a89-7dec-e219-e250-098606338503", + "TraceID": "INT_ERROR_2", + "EncodingString": "8. this is an error %d with a string %s" } ] } diff --git a/examples/clog_examples.clog_config b/examples/clog_examples.clog_config index 5d0a420..69a8251 100644 --- a/examples/clog_examples.clog_config +++ b/examples/clog_examples.clog_config @@ -1,6 +1,6 @@ { "MacroConfigurations": { - "lttng_plus": { + "lttng": { "Modules": [ { "ExportModule": "LTTNG", @@ -8,6 +8,27 @@ } ] }, + "etw_info": { + "Modules": [ + { + "ExportModule": "MANIFESTED_ETW", + "CustomSettings": { + "ETWManifestFile": ".\\clogsample\\clog_examples.man", + "ETW_Provider": "7EBE92EB-B7AE-4720-B842-FA8798950838", + "Level": "win:Informational" + } + } + ] + }, + "etw_errors": { + "Modules": [ + { + "ExportModule": "TRACELOGGING", + "CustomSettings": { + } + } + ] + }, "empty": { "Modules": [] }, @@ -24,23 +45,47 @@ "EncodedPrefix": null, "EncodedArgNumber": 1, "MacroConfiguration": { - "linux": "lttng_plus", + "linux": "lttng", "macos": "empty", "stubs": "empty", "windows_kernel": "empty", - "windows": "empty" + "windows": "etw_info" } }, { "MacroName": "TraceInstanceInfo", - "EncodedPrefix": "[%p]", + "EncodedPrefix": "[%p] ", + "EncodedArgNumber": 2, + "MacroConfiguration": { + "linux": "lttng", + "macos": "empty", + "stubs": "empty", + "windows_kernel": "empty", + "windows": "etw_info" + } + }, + { + "MacroName": "TraceError", + "EncodedPrefix": null, + "EncodedArgNumber": 1, + "MacroConfiguration": { + "linux": "lttng", + "macos": "empty", + "stubs": "empty", + "windows_kernel": "empty", + "windows": "etw_errors" + } + }, + { + "MacroName": "TraceInstanceError", + "EncodedPrefix": "[%p] ", "EncodedArgNumber": 2, "MacroConfiguration": { - "linux": "lttng_plus", + "linux": "lttng", "macos": "empty", "stubs": "empty", "windows_kernel": "empty", - "windows": "empty" + "windows": "etw_errors" } } ], diff --git a/examples/clogsample/CMakeLists.txt b/examples/clogsample/CMakeLists.txt index 2e1904c..7764ce2 100644 --- a/examples/clogsample/CMakeLists.txt +++ b/examples/clogsample/CMakeLists.txt @@ -13,12 +13,17 @@ set(SOURCES # as a normal cmake target dependency # CLOG_GENERATE_TARGET(CLOGSAMPLE_LIB STATIC ${SOURCES}) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/inc) + +if (NOT WIN32) + add_executable(clogsample ${SOURCES}) +else() + add_executable(clogsample ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/inc/clog_examples.rc) +endif() -add_executable(clogsample ${SOURCES}) target_link_libraries(clogsample CLOGSAMPLE_LIB) if (NOT WIN32 AND NOT APPLE) - include(FindLTTngUST) target_link_libraries(clogsample ${LTTNGUST_LIBRARIES}) @@ -29,5 +34,23 @@ if (NOT WIN32 AND NOT APPLE) add_library(clogsampletracepointprovider SHARED $) target_link_libraries(clogsampletracepointprovider ${LTTNGUST_LIBRARIES}) +endif() + + +if(WIN32) + message(STATUS "BUILDING CLOG SAMPLE(Windows)") + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/inc/clog_examples.h + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/inc/clog_examples.rc + DEPENDS clog_examples.man + COMMAND mc.exe -um -h ${CMAKE_CURRENT_BINARY_DIR}/inc -r ${CMAKE_CURRENT_BINARY_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/clog_examples.man) + + set_property(SOURCE simple.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/inc/clog_examples.h) + target_include_directories(clogsample PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/inc) + add_definitions(-DCLOG_ETW) + + configure_file(clog_examples.wprp clog_examples.wprp COPYONLY) + configure_file(clog_examples.man clog_examples.man COPYONLY) endif() diff --git a/examples/clogsample/clog_examples.man b/examples/clogsample/clog_examples.man new file mode 100644 index 0000000..b12bcd5 --- /dev/null +++ b/examples/clogsample/clog_examples.man @@ -0,0 +1,168 @@ + + + + + +