From 5f5dda860a78152574f71f4f1095248707e8c7e3 Mon Sep 17 00:00:00 2001 From: Marty T <120425148+tippmar-nr@users.noreply.github.com> Date: Thu, 1 Aug 2024 14:44:02 -0500 Subject: [PATCH 1/4] feat: Improve serverless mode detection (#2661) --- src/Agent/NewRelic/Home/Home.csproj | 2 +- .../InstrumentationConfiguration.h | 26 +++++++++------ .../InstrumentationConfigurationTest.cpp | 32 +++++++++---------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/Agent/NewRelic/Home/Home.csproj b/src/Agent/NewRelic/Home/Home.csproj index 11f2614b9b..d14d4762ed 100644 --- a/src/Agent/NewRelic/Home/Home.csproj +++ b/src/Agent/NewRelic/Home/Home.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h index eee0f162ab..bcc6fbeeb4 100644 --- a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h +++ b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h @@ -126,30 +126,36 @@ namespace NewRelic { namespace Profiler { namespace Configuration return; } - auto lambdaInstPoint = _systemCalls->TryGetEnvironmentVariable(_X("_HANDLER")); + // give precedence to the NEW_RELIC_LAMBDA_HANDLER environment variable + auto lambdaInstPoint = _systemCalls->TryGetEnvironmentVariable(_X("NEW_RELIC_LAMBDA_HANDLER")); if (lambdaInstPoint != nullptr) { - AddInstrumentationPointToCollectionFromEnvironment(*lambdaInstPoint); - _foundServerlessInstrumentationPoint = true; - return; + LogDebug("Found NEW_RELIC_LAMBDA_HANDLER environment variable: ", *lambdaInstPoint); + if (TryAddInstrumentationPointToCollectionFromEnvironment(*lambdaInstPoint)) + { + _foundServerlessInstrumentationPoint = true; + return; + } } - lambdaInstPoint = _systemCalls->TryGetEnvironmentVariable(_X("NEW_RELIC_LAMBDA_HANDLER")); + lambdaInstPoint = _systemCalls->TryGetEnvironmentVariable(_X("_HANDLER")); if (lambdaInstPoint != nullptr) { - AddInstrumentationPointToCollectionFromEnvironment(*lambdaInstPoint); - _foundServerlessInstrumentationPoint = true; + LogDebug("Found _HANDLER environment variable: ", *lambdaInstPoint); + if (TryAddInstrumentationPointToCollectionFromEnvironment(*lambdaInstPoint)) + _foundServerlessInstrumentationPoint = true; } } - void AddInstrumentationPointToCollectionFromEnvironment(xstring_t text) + bool TryAddInstrumentationPointToCollectionFromEnvironment(xstring_t text) { auto segments = Strings::Split(text, _X("::")); if (segments.size() != 3) { LogWarn(text, L" is not a valid method descriptor. It must be in the format 'assembly::class::method'"); - return; + return false; } + LogInfo(L"Serverless mode detected. Assembly: ", segments[0], L" Class: ", segments[1], L" Method: ", segments[2]); InstrumentationPointPtr instrumentationPoint(new InstrumentationPoint()); @@ -167,6 +173,8 @@ namespace NewRelic { namespace Profiler { namespace Configuration (*_instrumentationPointsMap)[instrumentationPoint->GetMatchKey()].insert(instrumentationPoint); _instrumentationPointsSet->insert(instrumentationPoint); + + return true; } private: diff --git a/src/Agent/NewRelic/Profiler/ConfigurationTest/InstrumentationConfigurationTest.cpp b/src/Agent/NewRelic/Profiler/ConfigurationTest/InstrumentationConfigurationTest.cpp index 0c9c941a3f..01a91d5b13 100644 --- a/src/Agent/NewRelic/Profiler/ConfigurationTest/InstrumentationConfigurationTest.cpp +++ b/src/Agent/NewRelic/Profiler/ConfigurationTest/InstrumentationConfigurationTest.cpp @@ -956,7 +956,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te xmlSet->emplace(L"filename", L""); InstrumentationConfiguration instrumentation(xmlSet, nullptr); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::MyMethod")); auto instrumentationPoint = instrumentation.TryGetInstrumentationPoint(std::make_shared()); Assert::IsFalse(instrumentationPoint == nullptr); @@ -968,21 +968,21 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te xmlSet->emplace(L"filename", L""); InstrumentationConfiguration instrumentation(xmlSet, nullptr); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::WrongMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyNamespace.MyClass:MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X(":::MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("::::::MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X(":::MyMethod::")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly:MyNamespace.MyClass:MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly/MyNamespace.MyClass/MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly_MyNamespace.MyClass_MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly MyNamespace.MyClass MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X(" MyAssembly::MyNamespace.MyClass:MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::MyMethod")); - instrumentation.AddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace .MyClass:: MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::WrongMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyNamespace.MyClass:MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X(":::MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("::::::MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X(":::MyMethod::")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly:MyNamespace.MyClass:MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly/MyNamespace.MyClass/MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly_MyNamespace.MyClass_MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly MyNamespace.MyClass MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X(" MyAssembly::MyNamespace.MyClass:MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace.MyClass::MyMethod")); + instrumentation.TryAddInstrumentationPointToCollectionFromEnvironment(_X("MyAssembly::MyNamespace .MyClass:: MyMethod")); auto instrumentationPoint = instrumentation.TryGetInstrumentationPoint(std::make_shared()); Assert::IsFalse(instrumentationPoint == nullptr); From 1a8a6ecc3f09a4a86c973f71c4485a4999e45a16 Mon Sep 17 00:00:00 2001 From: Jacob Affinito Date: Mon, 5 Aug 2024 08:15:16 -0700 Subject: [PATCH 2/4] ci: Change to docker compose v2 due to GH deprecations. (#2664) * ci: Change to docker compose v2 due to GH deprecations. * fix for profiler build --------- Co-authored-by: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com> --- .github/workflows/all_solutions.yml | 8 ++++---- .github/workflows/build_profiler.yml | 5 +++-- .github/workflows/deploy_agent.yml | 6 +++--- build/Linux/linux_packaging.md | 12 ++++++------ build/build.ps1 | 8 ++++---- deploy/linux/README.md | 4 ++-- .../NewRelic/Profiler/build/scripts/build_linux.ps1 | 8 ++++---- .../IntegrationTests/UnboundedServices/README.md | 10 +++++----- .../UnboundedServices/unbounded-services-control.ps1 | 4 ++-- 9 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/all_solutions.yml b/.github/workflows/all_solutions.yml index f8dd45d0ca..4cce3a6e0b 100644 --- a/.github/workflows/all_solutions.yml +++ b/.github/workflows/all_solutions.yml @@ -559,8 +559,8 @@ jobs: fi cd ${{ github.workspace }}/build/Linux - docker-compose build build_rpm - docker-compose run -e AGENT_VERSION=$agentVersion -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm + docker compose build build_rpm + docker compose run -e AGENT_VERSION=$agentVersion -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm shell: bash - name: Archive RPM Package Artifacts @@ -612,8 +612,8 @@ jobs: fi cd ${{ github.workspace }}/build/Linux - docker-compose build build_deb - docker-compose run -e AGENT_VERSION=$agentVersion build_deb + docker compose build build_deb + docker compose run -e AGENT_VERSION=$agentVersion build_deb shell: bash - name: Archive Debian Package Artifacts diff --git a/.github/workflows/build_profiler.yml b/.github/workflows/build_profiler.yml index 1b23d8d98b..cc53c187b1 100644 --- a/.github/workflows/build_profiler.yml +++ b/.github/workflows/build_profiler.yml @@ -139,6 +139,7 @@ jobs: env: profiler_path: ${{ github.workspace }}/src/Agent/NewRelic/Profiler + CORECLR_NEWRELIC_HOME: ${{ github.workspace }}/src/Agent/NewRelic/newrelichome_x64_coreclr_linux # not used but required by Profiler/docker-compose.yml steps: # intentionally disabled for this job, when enabled it causes a failure in the Build Linux Profiler step @@ -164,8 +165,8 @@ jobs: - name: Build Linux Profiler run: | cd ${{ env.profiler_path }} - docker-compose build build - docker-compose run build + docker compose build build + docker compose run build shell: bash - name: Move Profiler to staging folder diff --git a/.github/workflows/deploy_agent.yml b/.github/workflows/deploy_agent.yml index 4e0147fb27..2ddc6f16be 100644 --- a/.github/workflows/deploy_agent.yml +++ b/.github/workflows/deploy_agent.yml @@ -422,12 +422,12 @@ jobs: cd ${{ github.workspace }}/deploy/linux/ find . -name "*.bash" |xargs chmod a+x find . -type f |xargs dos2unix - docker-compose build + docker compose build if [ "${{ inputs.deploy }}" == "true" ] ; then - docker-compose run deploy_packages + docker compose run deploy_packages else echo "Input:deploy was not true. The following deploy command was not run:" - echo "docker-compose run deploy_packages" + echo "docker compose run deploy_packages" fi shell: bash diff --git a/build/Linux/linux_packaging.md b/build/Linux/linux_packaging.md index b540ce7f1f..42fe8b4374 100644 --- a/build/Linux/linux_packaging.md +++ b/build/Linux/linux_packaging.md @@ -4,15 +4,15 @@ The Linux CoreCLR agent can be packaged into .rpm (for Red Hat/Centos/Oracle/SUS 1. From Visual Studio, build the FullAgent solution, `Release` or `Debug` depending on your needs. 2. In Powershell, from `build/Linux`: - 1. `docker-compose build` - 2. `docker-compose run build_rpm` - 3. `docker-compose run build_deb` + 1. `docker compose build` + 2. `docker compose run build_rpm` + 3. `docker compose run build_deb` Optional: sign the .rpm -1. `docker-compose run -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm` +1. `docker compose run -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm` You can do ad hoc testing inside containers using the `test_debian` and/or `test_centos` services and `bash`. - docker-compose run test_debian bash - docker-compose run test_centos bash + docker compose run test_debian bash + docker compose run test_centos bash diff --git a/build/build.ps1 b/build/build.ps1 index 6bd8ebaf8b..4c78b7c0ba 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -79,16 +79,16 @@ Write-Host "====================================" Write-Host "Executing Linux builds in Docker for Agent Version: $agentVersion" Push-Location "$rootDirectory\build\Linux" # Build the docker images -docker-compose build +docker compose build # Build the Debian package -docker-compose run -e AGENT_VERSION=$agentVersion build_deb +docker compose run -e AGENT_VERSION=$agentVersion build_deb # Build the RPM package, signing it if a key was supplied if (!($gpgKeyPath -eq "")) { New-Item keys -Type Directory -Force Copy-Item $gpgKeyPath .\keys\gpg.tar.bz2 -Force - docker-compose run -e AGENT_VERSION=$agentVersion -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm + docker compose run -e AGENT_VERSION=$agentVersion -e GPG_KEYS=/keys/gpg.tar.bz2 build_rpm } else { - docker-compose run -e AGENT_VERSION=$agentVersion build_rpm + docker compose run -e AGENT_VERSION=$agentVersion build_rpm } Pop-Location Write-Host "====================================" diff --git a/deploy/linux/README.md b/deploy/linux/README.md index 67d08ac878..07ef64bcec 100644 --- a/deploy/linux/README.md +++ b/deploy/linux/README.md @@ -32,11 +32,11 @@ To deploy the .rpm and .deb packages for a particular release version (e.g. 10.0 5. Build the Docker container: - docker-compose build + docker compose build 6. Run the deploy (or rollback) process: - docker-compose run deploy_packages + docker compose run deploy_packages Note that the scripts in ./deploy_scripts came from the PHP agent team and have a lot of logic in them to support their particular build/test/release processes, not all of which we are using. However, since we are sharing the same public package sources with the PHP agent, anything this script does needs to be cautious diff --git a/src/Agent/NewRelic/Profiler/build/scripts/build_linux.ps1 b/src/Agent/NewRelic/Profiler/build/scripts/build_linux.ps1 index e4a82654ab..45791ce049 100644 --- a/src/Agent/NewRelic/Profiler/build/scripts/build_linux.ps1 +++ b/src/Agent/NewRelic/Profiler/build/scripts/build_linux.ps1 @@ -11,11 +11,11 @@ Write-Host "********" $baseProfilerPath = (Get-Item (Split-Path $script:MyInvocation.MyCommand.Path)).parent.parent.FullName Push-Location "$baseProfilerPath" -Write-Host "docker-compose build build" -docker-compose build build +Write-Host "docker compose build build" +docker compose build build -Write-Host "docker-compose run build" -docker-compose run build +Write-Host "docker compose run build" +docker compose run build if ($LastExitCode -ne 0) { exit $LastExitCode diff --git a/tests/Agent/IntegrationTests/UnboundedServices/README.md b/tests/Agent/IntegrationTests/UnboundedServices/README.md index 68848f1b2d..8f42412c7a 100644 --- a/tests/Agent/IntegrationTests/UnboundedServices/README.md +++ b/tests/Agent/IntegrationTests/UnboundedServices/README.md @@ -16,21 +16,21 @@ Note: while not a hard requirement, the containers will perform better if you us * This folder has Dockerfiles that set up Linux containerized services and can be used with Docker Desktop's WSL2 backend. Developers should use these containers in their system to run unbounded integration tests. * All commands below should be run from a shell (we've tested Powershell and "git-bash") in the same location as this README. -* Before Docker containers can be used the first time, they need to be built by executing `docker-compose build`. +* Before Docker containers can be used the first time, they need to be built by executing `docker compose build`. ### All To run all services: -`docker-compose up` +`docker compose up` If you don't want to follow the output of the services, you can run them in the background (detached) like this: -`docker-compose up -d` +`docker compose up -d` To stop the services: -`docker-compose down` +`docker compose down` **Note**: launching all of the services takes a lot of time (as much as 15 minutes in our testing) and a lot of system resources. Unless you need to run all of the unbounded integration tests (e.g. if you've made a change to a core part of the test framework as opposed to an individual test or piece of instrumentation) it is not recommended to do this. @@ -38,7 +38,7 @@ To stop the services: It is generally best to only the the service for the tests you happen to be working on at the time (see note above). To run a single service, execute the following: -`docker-compose up ` +`docker compose up ` See the docker-compose.yml file for the names of the services provided. diff --git a/tests/Agent/IntegrationTests/UnboundedServices/unbounded-services-control.ps1 b/tests/Agent/IntegrationTests/UnboundedServices/unbounded-services-control.ps1 index 9500c2eca9..17da6418fc 100644 --- a/tests/Agent/IntegrationTests/UnboundedServices/unbounded-services-control.ps1 +++ b/tests/Agent/IntegrationTests/UnboundedServices/unbounded-services-control.ps1 @@ -20,7 +20,7 @@ Param( Function StartUnboundedServices([string] $scriptPath) { Push-Location "$scriptPath" Write-Host "Launching docker services" - docker-compose up -d + docker compose up -d Write-Host "Waiting $StartDelaySeconds seconds for services to be ready" Start-Sleep $StartDelaySeconds #TODO: something smarter than this Pop-Location @@ -28,7 +28,7 @@ Function StartUnboundedServices([string] $scriptPath) { Function StopUnboundedServices([string] $scriptPath) { Push-Location "$scriptPath" - docker-compose down + docker compose down Pop-Location } From b3c9cd10c47dbe5c4654a1dcb1f90c3adeabe90f Mon Sep 17 00:00:00 2001 From: Chris Hynes <111462425+chynesNR@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:33:49 -0700 Subject: [PATCH 3/4] fix: Revert recent Profiler warning fixes to address reported instability (#2663) --- src/Agent/NewRelic/Home/Home.csproj | 2 +- .../NewRelic/Profiler/Common/CorStandIn.h | 4 +- .../Profiler/Configuration/Configuration.h | 32 +++++++------- .../Configuration/IgnoreInstrumentation.h | 2 +- .../InstrumentationConfiguration.h | 16 +++---- .../Configuration/InstrumentationPoint.h | 6 +-- .../ExceptionHandlerManipulator.h | 6 +-- .../MethodRewriter/FunctionManipulator.h | 2 +- .../Profiler/MethodRewriter/InstructionSet.h | 6 +-- .../InstrumentFunctionManipulator.h | 7 +-- .../Profiler/MethodRewriter/MethodRewriter.h | 4 +- .../Profiler/ModuleInjector/ModuleInjector.h | 1 - .../Profiler/CorProfilerCallbackImpl.h | 17 +++----- .../Profiler/Profiler/CorTokenResolver.h | 2 +- .../NewRelic/Profiler/Profiler/CorTokenizer.h | 2 +- .../NewRelic/Profiler/Profiler/Function.h | 4 +- .../Profiler/Profiler/FunctionHeaderInfo.h | 4 +- .../Profiler/Profiler/FunctionPreprocessor.h | 43 +++++++++---------- .../NewRelic/Profiler/Profiler/OpCodes.h | 12 +----- .../NewRelic/Profiler/Profiler/SystemCalls.h | 2 +- src/Agent/NewRelic/Profiler/Profiler/stdafx.h | 3 -- .../NewRelic/Profiler/RapidXML/rapidxml.hpp | 10 +---- .../NewRelic/Profiler/SignatureParser/Types.h | 10 ++--- 23 files changed, 82 insertions(+), 115 deletions(-) diff --git a/src/Agent/NewRelic/Home/Home.csproj b/src/Agent/NewRelic/Home/Home.csproj index d14d4762ed..23388021b8 100644 --- a/src/Agent/NewRelic/Home/Home.csproj +++ b/src/Agent/NewRelic/Home/Home.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Agent/NewRelic/Profiler/Common/CorStandIn.h b/src/Agent/NewRelic/Profiler/Common/CorStandIn.h index ae80eab51a..0cfc09a524 100644 --- a/src/Agent/NewRelic/Profiler/Common/CorStandIn.h +++ b/src/Agent/NewRelic/Profiler/Common/CorStandIn.h @@ -3,8 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ #pragma warning(push) -// Since this isn't our code, we don't want to mess with it. These warnings can be safely ignored. -#pragma warning(disable: 4458) // Scope hides class member with same name. -#pragma warning(disable: 26495) // Uninitialized member variable, even if it's always set before use. +#pragma warning(disable : 4458) #include #pragma warning(pop) diff --git a/src/Agent/NewRelic/Profiler/Configuration/Configuration.h b/src/Agent/NewRelic/Profiler/Configuration/Configuration.h index 8fbe4a3677..14e816327a 100644 --- a/src/Agent/NewRelic/Profiler/Configuration/Configuration.h +++ b/src/Agent/NewRelic/Profiler/Configuration/Configuration.h @@ -47,10 +47,10 @@ namespace NewRelic { namespace Profiler { namespace Configuration { , _ignoreList(new IgnoreInstrumentationList()) { try { - auto globalNewRelicConfigurationDocument = std::make_shared>(); - globalNewRelicConfigurationDocument->parse(const_cast(globalNewRelicConfiguration.c_str())); + rapidxml::xml_document globalNewRelicConfigurationDocument; + globalNewRelicConfigurationDocument.parse(const_cast(globalNewRelicConfiguration.c_str())); - auto globalNewRelicConfigurationNode = GetConfigurationNode(globalNewRelicConfigurationDocument); + auto globalNewRelicConfigurationNode = GetConfigurationNode(globalNewRelicConfigurationDocument); if (globalNewRelicConfigurationNode == nullptr) { LogError(L"Unable to locate configuration node in the global newrelic.config file."); @@ -58,13 +58,13 @@ namespace NewRelic { namespace Profiler { namespace Configuration { } auto appliedNewRelicConfigurationNode = globalNewRelicConfigurationNode; - auto localNewRelicConfigurationDocument = std::make_shared>(); if (localNewRelicConfiguration.second) { try { - localNewRelicConfigurationDocument->parse(const_cast(localNewRelicConfiguration.first.c_str())); + rapidxml::xml_document localNewRelicConfigurationDocument; + localNewRelicConfigurationDocument.parse(const_cast(localNewRelicConfiguration.first.c_str())); auto localNewRelicConfigurationNode = GetConfigurationNode(localNewRelicConfigurationDocument); if (localNewRelicConfigurationNode == nullptr) @@ -92,7 +92,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { SetLogLevel(appliedNewRelicConfigurationNode); SetInstrumentationData(appliedNewRelicConfigurationNode); SetApplicationPools(appliedNewRelicConfigurationNode); - + } catch (const rapidxml::parse_error& exception) { // We log two separate error messages here because sometimes the logging macros hang when // logging the "where" contents @@ -196,15 +196,15 @@ namespace NewRelic { namespace Profiler { namespace Configuration { return _logLevel; } - bool GetConsoleLogging() const + bool GetConsoleLogging() { return _consoleLogging; } - bool GetLoggingEnabled() const + bool GetLoggingEnabled() { return _loggingEnabled; } - IgnoreInstrumentationListPtr GetIgnoreInstrumentationList() const + IgnoreInstrumentationListPtr GetIgnoreInstrumentationList() { return _ignoreList; } @@ -224,9 +224,9 @@ namespace NewRelic { namespace Profiler { namespace Configuration { std::shared_ptr _systemCalls; IgnoreInstrumentationListPtr _ignoreList; - rapidxml::xml_node* GetConfigurationNode(const std::shared_ptr> document) + rapidxml::xml_node* GetConfigurationNode(const rapidxml::xml_document& document) { - auto configurationNode = document->first_node(_X("configuration"), 0, false); + auto configurationNode = document.first_node(_X("configuration"), 0, false); if (configurationNode == nullptr) { return nullptr; } @@ -294,7 +294,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { _logLevel = TryParseLogLevel(level); } - Logger::Level TryParseLogLevel(const xstring_t& logText) const + Logger::Level TryParseLogLevel(const xstring_t& logText) { if (Strings::AreEqualCaseInsensitive(logText, _X("off"))) { return Logger::Level::LEVEL_ERROR; @@ -423,8 +423,8 @@ namespace NewRelic { namespace Profiler { namespace Configuration { if (applicationConfiguration.empty()) return; - auto document = std::make_shared>(); - document->parse(const_cast(applicationConfiguration.c_str())); + rapidxml::xml_document document; + document.parse(const_cast(applicationConfiguration.c_str())); auto configurationNode = GetConfigurationNode(document); auto appSettingsNode = configurationNode->first_node(_X("appSettings"), 0, false); @@ -468,7 +468,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { static bool IsProcessInProcessList(const ProcessesPtr& processes, const xstring_t& processName) { // check the processes loaded from configuration - for (auto& validProcessName : *processes) { + for (auto validProcessName : *processes) { if (Strings::EndsWith(processName, validProcessName)) { return true; } @@ -498,7 +498,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { return isIis; } - bool ShouldInstrumentApplicationPool(const xstring_t& appPoolId) const + bool ShouldInstrumentApplicationPool(const xstring_t& appPoolId) { if (ApplicationPoolIsOnBlackList(appPoolId, _applicationPoolsBlackList)) { LogInfo(_X("This application pool (") + appPoolId + _X(") is explicitly configured to NOT be instrumented.")); diff --git a/src/Agent/NewRelic/Profiler/Configuration/IgnoreInstrumentation.h b/src/Agent/NewRelic/Profiler/Configuration/IgnoreInstrumentation.h index a98f68e09b..98438898bf 100644 --- a/src/Agent/NewRelic/Profiler/Configuration/IgnoreInstrumentation.h +++ b/src/Agent/NewRelic/Profiler/Configuration/IgnoreInstrumentation.h @@ -50,7 +50,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration } private: - bool Matches(xstring_t assembly, xstring_t className) const + bool Matches(xstring_t assembly, xstring_t className) { if (!Strings::AreEqualCaseInsensitive(AssemblyName, assembly)) { diff --git a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h index bcc6fbeeb4..8678606da5 100644 --- a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h +++ b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationConfiguration.h @@ -33,7 +33,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration , _foundServerlessInstrumentationPoint(false) { // pull instrumentation points from every xml string - for (auto& instrumentationXml : *instrumentationXmls) + for (auto instrumentationXml : *instrumentationXmls) { try { @@ -64,13 +64,13 @@ namespace NewRelic { namespace Profiler { namespace Configuration , _systemCalls(nullptr) , _foundServerlessInstrumentationPoint(false) { - for (auto& instrumentationPoint : *instrumentationPoints) + for (auto instrumentationPoint : *instrumentationPoints) { AddInstrumentationPointToCollectionsIfNotIgnored(instrumentationPoint); } } - uint16_t GetInvalidFileCount() const + uint16_t GetInvalidFileCount() { return _invalidFileCount; } @@ -100,7 +100,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration // We may have multiple matching instrumentation points that target different assembly versions. See if we can find one that meets // the version requirements AssemblyVersion foundVersion(function->GetAssemblyProps()); - for (auto& instPoint : instPoints) + for (auto instPoint : instPoints) { if ((instPoint->MinVersion != nullptr) && (foundVersion < *instPoint->MinVersion)) { @@ -236,9 +236,9 @@ namespace NewRelic { namespace Profiler { namespace Configuration void GetInstrumentationPoints(xstring_t instrumentationXml) { - auto document = std::make_shared>(); - document->parse(const_cast(instrumentationXml.c_str())); - auto extensionNode = document->first_node(_X("extension"), 0, false); + rapidxml::xml_document document; + document.parse(const_cast(instrumentationXml.c_str())); + auto extensionNode = document.first_node(_X("extension"), 0, false); if (extensionNode == nullptr) { LogWarn(L"extension node not found in instrumentation file. Please validate your instrumentation files against extensions/extension.xsd or contact New Relic support."); @@ -405,7 +405,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration // if the ClassName includes multiple classes, we have to split this into multiple instrumentation points auto instrumentationPoints = SplitInstrumentationPointsOnClassNames(instrumentationPoint); - for (auto& iPoint : instrumentationPoints) { + for (auto iPoint : instrumentationPoints) { // finally add the new instrumentation point(s) to our set of instrumentation points // Note that there may be "duplicated" instrumentation points that target different assembly versions diff --git a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationPoint.h b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationPoint.h index 7a08d71e06..17363d4938 100644 --- a/src/Agent/NewRelic/Profiler/Configuration/InstrumentationPoint.h +++ b/src/Agent/NewRelic/Profiler/Configuration/InstrumentationPoint.h @@ -52,7 +52,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration ParametersMatch(other); } - xstring_t ToString() const + xstring_t ToString() { if (Parameters == nullptr) { @@ -63,7 +63,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration } } - xstring_t GetMatchKey() const + xstring_t GetMatchKey() { return Parameters == nullptr ? GetMatchKey(AssemblyName, ClassName, MethodName) @@ -82,7 +82,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration private: - bool ParametersMatch(const InstrumentationPoint& other) const + bool ParametersMatch(const InstrumentationPoint& other) { // nullptr means no parameters attribute was supplied in configuration, suggesting that we should instrument all overloads if (this->Parameters == nullptr) diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/ExceptionHandlerManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/ExceptionHandlerManipulator.h index f955ad9eee..ce5ef9f520 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/ExceptionHandlerManipulator.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/ExceptionHandlerManipulator.h @@ -262,12 +262,12 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter // shift the original clauses up to the correct for (uint32_t i = 0; i < _originalExceptionClauseCount; ++i) { - auto& clause = _exceptionClauses[i]; + auto clause = _exceptionClauses[i]; clause->ShiftOffsets(userCodeOffset); } // append the clauses - for (auto& clause : _exceptionClauses) + for (auto clause : _exceptionClauses) { auto clauseBytes = clause->GetBytes(); bytes->insert(bytes->end(), clauseBytes->begin(), clauseBytes->end()); @@ -276,7 +276,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter return bytes; } - uint32_t GetOriginalExceptionClauseCount() const + uint32_t GetOriginalExceptionClauseCount() { return _originalExceptionClauseCount; } diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/FunctionManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/FunctionManipulator.h index 81bfbccfd8..56bbaf3683 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/FunctionManipulator.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/FunctionManipulator.h @@ -350,7 +350,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter _instructions->Append(CEE_NEWARR, _X("[mscorlib]System.Object")); uint32_t index = 0; - for (auto& func : elementLoadLambdas) + for (auto func : elementLoadLambdas) { auto nextIndex = index++; // get an extra copy of the array (it will be popped off the stack each time we add an element to it) diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/InstructionSet.h b/src/Agent/NewRelic/Profiler/MethodRewriter/InstructionSet.h index 77592897b9..0b4493dd2d 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/InstructionSet.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/InstructionSet.h @@ -403,7 +403,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter void AppendTryEnd() { - auto& exception = _exceptionStack.top(); + auto exception = _exceptionStack.top(); if (exception->_tryLength != 0) { LogError(L"Attempted to set try close on the same exception twice."); @@ -414,7 +414,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter void AppendCatchStart(uint32_t typeToken) { - auto& exception = _exceptionStack.top(); + auto exception = _exceptionStack.top(); if (exception->_handlerOffset != 0) { LogError(L"Attempted to set catch start on the same exception twice."); @@ -439,7 +439,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter void AppendCatchEnd() { - auto& exception = _exceptionStack.top(); + auto exception = _exceptionStack.top(); if (exception->_handlerLength != 0) { LogError(L"Attempted to set catch end on the same exception twice."); diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h b/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h index 5e90471b93..1a11be8a7e 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/InstrumentFunctionManipulator.h @@ -16,10 +16,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter public: InstrumentFunctionManipulator(IFunctionPtr function, InstrumentationSettingsPtr instrumentationSettings) : FunctionManipulator(function), - _instrumentationSettings(instrumentationSettings), - _userExceptionLocalIndex(0), - _resultLocalIndex(0), - _tracerLocalIndex(0) + _instrumentationSettings(instrumentationSettings) { if (_function->Preprocess()) { Initialize(); @@ -231,4 +228,4 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter _resultLocalIndex = AppendReturnTypeLocal(_newLocalVariablesSignature, _methodSignature); } }; -}}} +}}} \ No newline at end of file diff --git a/src/Agent/NewRelic/Profiler/MethodRewriter/MethodRewriter.h b/src/Agent/NewRelic/Profiler/MethodRewriter/MethodRewriter.h index 1f05a83204..3dd98229d7 100644 --- a/src/Agent/NewRelic/Profiler/MethodRewriter/MethodRewriter.h +++ b/src/Agent/NewRelic/Profiler/MethodRewriter/MethodRewriter.h @@ -54,7 +54,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter { auto instrumentationPoints = _instrumentationConfiguration->GetInstrumentationPoints(); - for (auto& instrumentationPoint : *instrumentationPoints) { + for (auto instrumentationPoint : *instrumentationPoints) { _instrumentedAssemblies->emplace(instrumentationPoint->AssemblyName); _instrumentedFunctionNames->emplace(instrumentationPoint->MethodName); @@ -74,7 +74,7 @@ namespace NewRelic { namespace Profiler { namespace MethodRewriter { std::set GetAssemblyInstrumentation(xstring_t assemblyName) { std::set set; - for (auto& instrumentationPoint : *_instrumentationConfiguration->GetInstrumentationPoints().get()) { + for (auto instrumentationPoint : *_instrumentationConfiguration->GetInstrumentationPoints().get()) { if (assemblyName == instrumentationPoint->AssemblyName) { set.emplace(instrumentationPoint); } diff --git a/src/Agent/NewRelic/Profiler/ModuleInjector/ModuleInjector.h b/src/Agent/NewRelic/Profiler/ModuleInjector/ModuleInjector.h index 3fa8619ae9..5217285b75 100644 --- a/src/Agent/NewRelic/Profiler/ModuleInjector/ModuleInjector.h +++ b/src/Agent/NewRelic/Profiler/ModuleInjector/ModuleInjector.h @@ -10,7 +10,6 @@ #include "../Logging/Logger.h" #include "../Sicily/Sicily.h" #include "IModule.h" -#include "../Profiler/Exceptions.h" namespace NewRelic { namespace Profiler { namespace ModuleInjector { diff --git a/src/Agent/NewRelic/Profiler/Profiler/CorProfilerCallbackImpl.h b/src/Agent/NewRelic/Profiler/Profiler/CorProfilerCallbackImpl.h index 268b107e71..aeaf684641 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/CorProfilerCallbackImpl.h +++ b/src/Agent/NewRelic/Profiler/Profiler/CorProfilerCallbackImpl.h @@ -574,7 +574,7 @@ namespace NewRelic { namespace Profiler { std::shared_ptr> GroupByAssemblyName(Configuration::InstrumentationPointSetPtr allInstrumentationPoints) { std::shared_ptr> instrumentationPointsByAssembly = std::make_shared>(); - for (auto& point : *allInstrumentationPoints) { + for (auto point : *allInstrumentationPoints) { Configuration::InstrumentationPointSetPtr instrumentationPoints; auto it = instrumentationPointsByAssembly->find(point->AssemblyName); @@ -632,7 +632,7 @@ namespace NewRelic { namespace Profiler { auto instrumentationXmls = GetInstrumentationXmlsFromDisk(_systemCalls); auto customXml = _customInstrumentation.GetCustomInstrumentationXml(); - for (auto& xmlPair : *customXml) { + for (auto xmlPair : *customXml) { (*instrumentationXmls)[xmlPair.first] = xmlPair.second; } @@ -683,7 +683,7 @@ namespace NewRelic { namespace Profiler { { auto oldIter = instrumentationByAssembly->find(assemblyName); if (oldIter != instrumentationByAssembly->end()) { - auto& points = oldIter->second; + auto points = oldIter->second; return GetMethodDefs(moduleId, points); } @@ -789,15 +789,12 @@ namespace NewRelic { namespace Profiler { ModuleID* moduleIds = new ModuleID[numberMethods]; mdMethodDef* methodIds = new mdMethodDef[numberMethods]; -#pragma warning(push) -#pragma warning(disable : 6386) // Not possible to overrun the buffer since we're using the set size int i = 0; for (auto methodDef : *methodSet) { moduleIds[i] = moduleId; methodIds[i] = methodDef; i++; } -#pragma warning(pop) func(numberMethods, moduleIds, methodIds); @@ -882,7 +879,7 @@ namespace NewRelic { namespace Profiler { bool _isCoreClr = false; - MethodRewriter::MethodRewriterPtr GetMethodRewriter() const + MethodRewriter::MethodRewriterPtr GetMethodRewriter() { return std::atomic_load(&_methodRewriter); } @@ -945,7 +942,7 @@ namespace NewRelic { namespace Profiler { auto filePaths = GetXmlFilesInExtensionsDirectory(systemCalls); - for (auto& filePath : filePaths) { + for (auto filePath : filePaths) { instrumentationXmls->emplace(filePath, ReadFile(filePath)); } @@ -1261,7 +1258,7 @@ namespace NewRelic { namespace Profiler { struct LANGANDCODEPAGE { WORD wLanguage; WORD wCodePage; - } *lpTranslate = nullptr; + } * lpTranslate; //xstring_t expectedProductName = _X("New Relic .NET CoreCLR Agent"); @@ -1280,7 +1277,7 @@ namespace NewRelic { namespace Profiler { if (VerQueryValue(versionInfo, (LPTSTR)szSFI, (LPVOID*)&lpszBuf, &uLen)) { if (expectedProductName == lpszBuf) { - void* block = nullptr; + void* block; UINT blockSize; if (VerQueryValue(versionInfo, L"\\", (LPVOID*)&block, &blockSize)) { auto fileInfo = (VS_FIXEDFILEINFO*)block; diff --git a/src/Agent/NewRelic/Profiler/Profiler/CorTokenResolver.h b/src/Agent/NewRelic/Profiler/Profiler/CorTokenResolver.h index b3db943938..10d7d719d5 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/CorTokenResolver.h +++ b/src/Agent/NewRelic/Profiler/Profiler/CorTokenResolver.h @@ -42,7 +42,7 @@ namespace NewRelic { namespace Profiler xstring_t GetTypeStringsFromTypeSpec(uint32_t typeDefOrRefOrSpecToken) { - uint8_t* signature = 0; + uint8_t* signature; ULONG signatureLength; _metaDataImport->GetTypeSpecFromToken(typeDefOrRefOrSpecToken, (PCCOR_SIGNATURE*)(&signature), &signatureLength); diff --git a/src/Agent/NewRelic/Profiler/Profiler/CorTokenizer.h b/src/Agent/NewRelic/Profiler/Profiler/CorTokenizer.h index f1487fcc90..9b43baa352 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/CorTokenizer.h +++ b/src/Agent/NewRelic/Profiler/Profiler/CorTokenizer.h @@ -304,7 +304,7 @@ namespace NewRelic { namespace Profiler xstring_t ResolveAssemblyForType(xstring_t assemblyName, xstring_t fullQualifiedType) { - auto& coreAssembly = (*_typeNameToAssembly.get())[fullQualifiedType]; + auto coreAssembly = (*_typeNameToAssembly.get())[fullQualifiedType]; return coreAssembly.empty() ? assemblyName : coreAssembly; } }; diff --git a/src/Agent/NewRelic/Profiler/Profiler/Function.h b/src/Agent/NewRelic/Profiler/Profiler/Function.h index c9f8738144..fc586e8eeb 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/Function.h +++ b/src/Agent/NewRelic/Profiler/Profiler/Function.h @@ -431,7 +431,7 @@ namespace NewRelic { namespace Profiler return _functionId; } - ModuleID GetModuleID() const + ModuleID GetModuleID() { return _moduleId; } @@ -536,7 +536,7 @@ namespace NewRelic { namespace Profiler virtual ByteVectorPtr GetSignatureFromToken(mdToken token) override { ULONG signatureLength; - uint8_t* signature = 0; + uint8_t* signature; ThrowOnError(_metaDataImport->GetSigFromToken, token, (PCCOR_SIGNATURE*)&signature, &signatureLength); return std::make_shared(signature, signature + signatureLength); } diff --git a/src/Agent/NewRelic/Profiler/Profiler/FunctionHeaderInfo.h b/src/Agent/NewRelic/Profiler/Profiler/FunctionHeaderInfo.h index eeed2436fb..053a53afde 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/FunctionHeaderInfo.h +++ b/src/Agent/NewRelic/Profiler/Profiler/FunctionHeaderInfo.h @@ -68,7 +68,7 @@ namespace NewRelic { else if (info->instruction == CEE_SWITCH) { counts.switchCount += 1; const unsigned numberArms = ReadNumber(&bodyBytes[pos + 1], 4) & 0xFFFFFFFF; - const unsigned numberBytesTable = (1 + static_cast(numberArms)) * sizeof(DWORD); + const unsigned numberBytesTable = (1 + numberArms) * sizeof(DWORD); const unsigned totalBytesInstruction = 1 + numberBytesTable; pos += totalBytesInstruction; } @@ -209,4 +209,4 @@ namespace NewRelic { } } } -} +} \ No newline at end of file diff --git a/src/Agent/NewRelic/Profiler/Profiler/FunctionPreprocessor.h b/src/Agent/NewRelic/Profiler/Profiler/FunctionPreprocessor.h index a5bc8db7e1..da9f78c57c 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/FunctionPreprocessor.h +++ b/src/Agent/NewRelic/Profiler/Profiler/FunctionPreprocessor.h @@ -140,15 +140,15 @@ namespace NewRelic { } } - OpCodePtr GetOpCode() const + OpCodePtr GetOpCode() { return _opcode; } - unsigned GetOffset() const + unsigned GetOffset() { return _offset; } - bool IsValid() const + bool IsValid() { return _valid; } @@ -177,7 +177,7 @@ namespace NewRelic { { auto offsetOfInstructionFollowingSwitch = _offset + _opcode->totalSize; auto offsetOfArm = _offset + _opcode->instructionSize + sizeof(DWORD); - for (auto& target : *_targets) { + for (auto target : *_targets) { auto jumpLength = target->GetOffset() - offsetOfInstructionFollowingSwitch; auto armLocation = instructions->data() + offsetOfArm; @@ -193,7 +193,7 @@ namespace NewRelic { { // a better person would do this in place but the iter pointer stuff confuses me auto newTargetsList = std::make_shared>(); - for (auto& targetInstruction : *_targets) { + for (auto targetInstruction : *_targets) { if (oldInstruction == targetInstruction) { newTargetsList->push_back(newInstruction); @@ -232,14 +232,11 @@ namespace NewRelic { class BranchInstruction :public Instruction { public: - BranchInstruction(OpCodePtr opCode, unsigned offset) : Instruction(opCode, offset), - _targetInstruction(nullptr), - _targetOffset(0) + BranchInstruction(OpCodePtr opCode, unsigned offset) : Instruction(opCode, offset) { } - BranchInstruction(OpCodePtr opCode, unsigned offset, InstructionPtr target) : Instruction(opCode, offset), - _targetOffset(0) + BranchInstruction(OpCodePtr opCode, unsigned offset, InstructionPtr target) : Instruction(opCode, offset) { _targetInstruction = target; } @@ -387,7 +384,7 @@ namespace NewRelic { } // sanity check the final instruction. If it isn't a RET, we likely mucked up the instruction parsing - auto& lastInstruction = instructions->at(finalInstructionIndex); + auto lastInstruction = instructions->at(finalInstructionIndex); if (lastInstruction->GetOpCode()->instruction != CEE_RET) { LogTrace(L"Expected RET as final instruction but found ", lastInstruction->GetOpCode()->instruction); return nullptr; @@ -399,7 +396,7 @@ namespace NewRelic { lastInstruction->GetOpCode()->Reset(GetOpCode(CEE_NOP)); auto branches = std::make_shared>(); - for (auto& instruction : *instructions.get()) + for (auto instruction : *instructions.get()) { if (instruction.second->GetOpCode()->instruction == CEE_RET) { @@ -435,14 +432,14 @@ namespace NewRelic { // write the instructions into our bytecode vector. that'll reset the offsets // of the instructions so that we can recompute the branch jumps. - for (auto& instruction : *instructions.get()) + for (auto instruction : *instructions.get()) { instruction.second->Write(oldCodeBytes, newByteCode); } // now all instructions contain their final offset, so we can // write the branch instruction offsets - for (auto& branch : *branches) { + for (auto branch : *branches) { branch->WriteBranches(newByteCode, instructions); } @@ -484,7 +481,7 @@ namespace NewRelic { static void NotifyOfInstructionChange(OffsetToInstructionMapPtr instructions, InstructionPtr oldInstruction, InstructionPtr newInstruction) { - for (auto& iter : *instructions) + for (auto iter : *instructions) { iter.second->OnInstructionChange(oldInstruction, newInstruction); } @@ -492,7 +489,7 @@ namespace NewRelic { static bool AllValid(OffsetToInstructionMapPtr instructions) { - for (auto& instruction : *instructions.get()) + for (auto instruction : *instructions.get()) { if (!instruction.second->IsValid()) { return false; @@ -530,7 +527,7 @@ namespace NewRelic { static void PrintInstructions(OffsetToInstructionMapPtr instructions) { #ifdef DEBUG - for (auto& iter : *instructions.get()) + for (auto iter : *instructions.get()) { LogInfo(iter.second->ToString()); } @@ -606,23 +603,23 @@ namespace NewRelic { for (unsigned c = 0; c < sehClauseCount; c++) { COR_ILMETHOD_SECT_EH_CLAUSE_FAT* clause = &sehClauses[c]; - auto& tryInstruction = instructions->at(clause->TryOffset); + auto tryInstruction = instructions->at(clause->TryOffset); //unsigned newTryLength = _oldPositionToNew[clause->TryOffset + clause->TryLength] - _oldPositionToNew[clause->TryOffset]; - auto& tryEndInstruction = instructions->at(clause->TryOffset + clause->TryLength); + auto tryEndInstruction = instructions->at(clause->TryOffset + clause->TryLength); auto tryLength = tryEndInstruction->GetOffset() - tryInstruction->GetOffset(); clause->SetTryLength(tryLength); clause->SetTryOffset(tryInstruction->GetOffset()); - auto& handlerInstruction = instructions->at(clause->HandlerOffset); - auto& handlerEndInstruction = instructions->at(clause->HandlerOffset + clause->HandlerLength); + auto handlerInstruction = instructions->at(clause->HandlerOffset); + auto handlerEndInstruction = instructions->at(clause->HandlerOffset + clause->HandlerLength); auto handlerLength = handlerEndInstruction->GetOffset() - handlerInstruction->GetOffset(); clause->SetHandlerLength(handlerLength); clause->SetHandlerOffset(handlerInstruction->GetOffset()); if (clause->GetFlags() == static_cast(COR_ILEXCEPTION_CLAUSE_FILTER)) { - auto& filterInstruction = instructions->at(clause->FilterOffset); + auto filterInstruction = instructions->at(clause->FilterOffset); clause->SetFilterOffset(filterInstruction->GetOffset()); // There's no FilterLength to adjust. @@ -671,7 +668,7 @@ namespace NewRelic { } // resolve the target instruction(s) of all branches - for (auto& instruction : *branches) + for (auto instruction : *branches) { instruction->ResolveTargets(methodBody, instructions); } diff --git a/src/Agent/NewRelic/Profiler/Profiler/OpCodes.h b/src/Agent/NewRelic/Profiler/Profiler/OpCodes.h index b10a396f25..f517e123be 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/OpCodes.h +++ b/src/Agent/NewRelic/Profiler/Profiler/OpCodes.h @@ -96,16 +96,6 @@ namespace NewRelic { unsigned controlFlow; xstring_t name; - OpCode() : - instruction(0), - instructionSize(0), - arrayOffset(0), - operandSize(0), - totalSize(0), - controlFlow(0) - {} - - void Reset(std::shared_ptr newOpCode) { instruction = newOpCode->instruction; @@ -156,4 +146,4 @@ namespace NewRelic { return GetOpCode((const BYTE*)&opcode, 0); } } -} +} \ No newline at end of file diff --git a/src/Agent/NewRelic/Profiler/Profiler/SystemCalls.h b/src/Agent/NewRelic/Profiler/Profiler/SystemCalls.h index 1b42439c68..fde2daed3f 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/SystemCalls.h +++ b/src/Agent/NewRelic/Profiler/Profiler/SystemCalls.h @@ -44,7 +44,7 @@ namespace NewRelic { namespace Profiler static std::unique_ptr TryGetRegistryStringValue(HKEY rootKey, const xstring_t& path, const xstring_t& valueName) { - DWORD valueSize = 0; + DWORD valueSize; CRegKey key; // open the key diff --git a/src/Agent/NewRelic/Profiler/Profiler/stdafx.h b/src/Agent/NewRelic/Profiler/Profiler/stdafx.h index 654b5cccbf..7f16e03b1e 100644 --- a/src/Agent/NewRelic/Profiler/Profiler/stdafx.h +++ b/src/Agent/NewRelic/Profiler/Profiler/stdafx.h @@ -33,10 +33,7 @@ // Profiler Header Files: -#pragma warning(push) -#pragma warning(disable: 26495) // Uninitialized member variable, even if it's always set before use #include -#pragma warning(pop) // Windows Header Files: #ifndef _WIN32_WINNT diff --git a/src/Agent/NewRelic/Profiler/RapidXML/rapidxml.hpp b/src/Agent/NewRelic/Profiler/RapidXML/rapidxml.hpp index 59cba658fe..a63f265fb6 100644 --- a/src/Agent/NewRelic/Profiler/RapidXML/rapidxml.hpp +++ b/src/Agent/NewRelic/Profiler/RapidXML/rapidxml.hpp @@ -658,8 +658,6 @@ namespace rapidxml : m_name(0) , m_value(0) , m_parent(0) - , m_name_size(0) - , m_value_size(0) { } @@ -809,9 +807,7 @@ namespace rapidxml //! Constructs an empty attribute with the specified type. //! Consider using memory_pool of appropriate xml_document if allocating attributes manually. - xml_attribute() : - m_prev_attribute(nullptr), - m_next_attribute(nullptr) + xml_attribute() { } @@ -906,10 +902,6 @@ namespace rapidxml : m_type(type) , m_first_node(0) , m_first_attribute(0) - , m_last_node(0) - , m_last_attribute(0) - , m_prev_sibling(0) - , m_next_sibling(0) { } diff --git a/src/Agent/NewRelic/Profiler/SignatureParser/Types.h b/src/Agent/NewRelic/Profiler/SignatureParser/Types.h index b6b1f02df8..e5cf551622 100644 --- a/src/Agent/NewRelic/Profiler/SignatureParser/Types.h +++ b/src/Agent/NewRelic/Profiler/SignatureParser/Types.h @@ -475,7 +475,7 @@ namespace NewRelic { namespace Profiler { namespace SignatureParser stream += _type->ToString(tokenResolver); stream.push_back('['); bool first = true; - for (auto& genericArgumentType : *_genericArgumentTypes) + for (auto genericArgumentType : *_genericArgumentTypes) { if (first) first = false; else stream.push_back(','); @@ -493,7 +493,7 @@ namespace NewRelic { namespace Profiler { namespace SignatureParser bytes->push_back(ELEMENT_TYPE_GENERICINST); bytes->insert(bytes->end(), typeBytes->begin(), typeBytes->end()); bytes->insert(bytes->end(), compressedArgCount->begin(), compressedArgCount->end()); - for (auto& argumentType : *_genericArgumentTypes) + for (auto argumentType : *_genericArgumentTypes) { auto argumentTypeBytes = argumentType->ToBytes(); bytes->insert(bytes->end(), argumentTypeBytes->begin(), argumentTypeBytes->end()); @@ -801,11 +801,11 @@ namespace NewRelic { namespace Profiler { namespace SignatureParser _genericParamCount(genericParamCount) {} - xstring_t ToString(ITokenResolverPtr tokenResolver) const + xstring_t ToString(ITokenResolverPtr tokenResolver) { auto stream = xstring_t(); bool firstParam = true; - for (auto& parameter : *_parameters) + for (auto parameter : *_parameters) { if (firstParam) firstParam = false; else stream.push_back(','); @@ -836,7 +836,7 @@ namespace NewRelic { namespace Profiler { namespace SignatureParser auto returnTypeBytes = _returnType->ToBytes(); bytes->insert(bytes->end(), returnTypeBytes->begin(), returnTypeBytes->end()); - for (auto& parameter : *_parameters) + for (auto parameter : *_parameters) { auto parameterBytes = parameter->ToBytes(); bytes->insert(bytes->end(), parameterBytes->begin(), parameterBytes->end()); From b18158f18a0e8ea62ba165e3c6664fce2ec9b5b5 Mon Sep 17 00:00:00 2001 From: dotnet-agent-team-bot <141066016+dotnet-agent-team-bot@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:19:03 -0700 Subject: [PATCH 4/4] chore(main): release 10.28.0 (#2647) --- release-please/.release-please-manifest.json | 2 +- src/Agent/CHANGELOG.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/release-please/.release-please-manifest.json b/release-please/.release-please-manifest.json index 1903f16dff..a635076b65 100644 --- a/release-please/.release-please-manifest.json +++ b/release-please/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "10.27.0" + ".": "10.28.0" } \ No newline at end of file diff --git a/src/Agent/CHANGELOG.md b/src/Agent/CHANGELOG.md index 109d980a3e..8258873a4e 100644 --- a/src/Agent/CHANGELOG.md +++ b/src/Agent/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [10.28.0](https://github.com/newrelic/newrelic-dotnet-agent/compare/v10.27.0...v10.28.0) (2024-08-05) + + +### New features + +* Improve serverless mode detection ([#2661](https://github.com/newrelic/newrelic-dotnet-agent/issues/2661)) ([5f5dda8](https://github.com/newrelic/newrelic-dotnet-agent/commit/5f5dda860a78152574f71f4f1095248707e8c7e3)) +* Set application name via command line with the .msi installer ([#2648](https://github.com/newrelic/newrelic-dotnet-agent/issues/2648)) ([369dcba](https://github.com/newrelic/newrelic-dotnet-agent/commit/369dcbab4f3fa59354f683bae16b711f45be2387)) + + +### Fixes + +* Better Lambda web request input parameter validation. ([#2653](https://github.com/newrelic/newrelic-dotnet-agent/issues/2653)) ([810d4af](https://github.com/newrelic/newrelic-dotnet-agent/commit/810d4aff20457200b4166daa9744cefe8dfc699b)), closes [#2652](https://github.com/newrelic/newrelic-dotnet-agent/issues/2652) +* Revert recent Profiler warning fixes to address reported instability ([#2663](https://github.com/newrelic/newrelic-dotnet-agent/issues/2663)) ([b3c9cd1](https://github.com/newrelic/newrelic-dotnet-agent/commit/b3c9cd10c47dbe5c4654a1dcb1f90c3adeabe90f)) +* SQS instrumentation could cause InvalidOperationException ([#2645](https://github.com/newrelic/newrelic-dotnet-agent/issues/2645)) ([#2646](https://github.com/newrelic/newrelic-dotnet-agent/issues/2646)) ([40b6ad5](https://github.com/newrelic/newrelic-dotnet-agent/commit/40b6ad5b899942eff9241da362a653a010cf2e7f)) + ## [10.27.0](https://github.com/newrelic/newrelic-dotnet-agent/compare/v10.26.0...v10.27.0) (2024-07-15)