From 41192b9b996a61b63d319b4928585904217ba8f3 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Fri, 26 Aug 2016 12:25:47 +0100 Subject: [PATCH 01/19] Stop building ostreamplugin --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 556ee50..30b3854 100644 --- a/Package.swift +++ b/Package.swift @@ -275,13 +275,13 @@ let package = Package( Target(name: "cpuplugin", dependencies: [.Target(name: "agentcore")]), Target(name: "envplugin", dependencies: [.Target(name: "agentcore")]), Target(name: "memplugin", dependencies: [.Target(name: "agentcore")]), - Target(name: "ostreamplugin", dependencies: [.Target(name: "agentcore")]), Target(name: "hcapiplugin", dependencies: [.Target(name: "agentcore")]) ], exclude: [ "src/agentcore/ibmras/common/port/aix", "src/agentcore/ibmras/common/port/windows", "src/agentcore/ibmras/common/data", "src/agentcore/ibmras/common/util/memUtils.cpp", + "src/ostreamplugin", "src/paho/Windows Build", "src/paho/build", "src/paho/doc", From 27d971549c5367165323196a4e422a822ad52324 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 13:04:15 +0100 Subject: [PATCH 02/19] Check if library is already open when opening library --- src/ibmras/common/util/LibraryUtils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index d2fc718..508973b 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -58,7 +58,10 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: #if defined(WINDOWS) handle.handle = LoadLibrary(lib.c_str()); #else - handle.handle = dlopen(lib.c_str(), RTLD_LAZY); + handle.handle = dlopen(lib.c_str(), RTLD_LAZY | RTLD_NOLOAD) + if (handle.handle == null) { + handle.handle = dlopen(lib.c_str(), RTLD_LAZY); + } #endif return handle; } From bb7e580b384742e39e8384603ddb7e39d3016da1 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 13:06:54 +0100 Subject: [PATCH 03/19] C requires semi-colons as statement terminators --- src/ibmras/common/util/LibraryUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index 508973b..74d81bd 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -58,7 +58,7 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: #if defined(WINDOWS) handle.handle = LoadLibrary(lib.c_str()); #else - handle.handle = dlopen(lib.c_str(), RTLD_LAZY | RTLD_NOLOAD) + handle.handle = dlopen(lib.c_str(), RTLD_LAZY | RTLD_NOLOAD); if (handle.handle == null) { handle.handle = dlopen(lib.c_str(), RTLD_LAZY); } From 58d3efaf3a018a5996931cf32264defa05e793c4 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 13:10:28 +0100 Subject: [PATCH 04/19] Capital NULL --- src/ibmras/common/util/LibraryUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index 74d81bd..c2342f1 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -59,7 +59,7 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: handle.handle = LoadLibrary(lib.c_str()); #else handle.handle = dlopen(lib.c_str(), RTLD_LAZY | RTLD_NOLOAD); - if (handle.handle == null) { + if (handle.handle == NULL) { handle.handle = dlopen(lib.c_str(), RTLD_LAZY); } #endif From 9d2bad84e1e7302507b0e93e37e9833265499b9e Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 15:50:03 +0100 Subject: [PATCH 05/19] Restrict Mac libraries to those ending in .dylib --- src/ibmras/common/util/LibraryUtils.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index c2342f1..754b02b 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -58,10 +58,13 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: #if defined(WINDOWS) handle.handle = LoadLibrary(lib.c_str()); #else - handle.handle = dlopen(lib.c_str(), RTLD_LAZY | RTLD_NOLOAD); - if (handle.handle == NULL) { - handle.handle = dlopen(lib.c_str(), RTLD_LAZY); +#if defined(__MACH__) || defined(__APPLE__) + std::size_t found = lib.rfind(".dylib", lib.size()-".dylib".size()); + if (found == std::string::npos)) { + return Handle(); } +#endif + handle.handle = dlopen(lib.c_str(), RTLD_LAZY); #endif return handle; } From fc7d5dbb7835f58d8249718c395203b4a59bb72b Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 16:03:38 +0100 Subject: [PATCH 06/19] Limit Mac Library loading to .dylib --- src/ibmras/common/util/LibraryUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index 754b02b..7ebf982 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -59,8 +59,8 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: handle.handle = LoadLibrary(lib.c_str()); #else #if defined(__MACH__) || defined(__APPLE__) - std::size_t found = lib.rfind(".dylib", lib.size()-".dylib".size()); - if (found == std::string::npos)) { + std::size_t found = lib.rfind(".dylib", lib.size() - 6; + if (found == std::string::npos) { return Handle(); } #endif From 091754d4f3636b5f6363fdf10e8441add6926095 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Wed, 31 Aug 2016 16:08:43 +0100 Subject: [PATCH 07/19] Restrict Mac libraries to those ending in .dylib --- src/ibmras/common/util/LibraryUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index 7ebf982..c21e52f 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -59,7 +59,7 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std:: handle.handle = LoadLibrary(lib.c_str()); #else #if defined(__MACH__) || defined(__APPLE__) - std::size_t found = lib.rfind(".dylib", lib.size() - 6; + std::size_t found = lib.rfind(".dylib", lib.size() - 6); if (found == std::string::npos) { return Handle(); } From 47c62d2174882694c8a088dace3354fe1d6a4ef8 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Fri, 9 Sep 2016 10:45:28 +0100 Subject: [PATCH 08/19] Update Package.swift for Swift 3 changes (snapshot 08/23) --- Package.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Package.swift b/Package.swift index 30b3854..79caa17 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,7 @@ import Foundation import PackageDescription -#if os(Linux) - let fm = FileManager.default() -#else - let fm = FileManager.default -#endif - +let fm = FileManager.default ///need to drill down into the omr-agentcore directory from where we are if fm.currentDirectoryPath.contains("omr-agentcore") == false { @@ -155,7 +150,7 @@ if fm.fileExists(atPath: "src/agentcore") == false { let linuxVariations = ["defined(_Linux)", "defined(LINUX)", "defined(_LINUX)", "defined (_LINUX)"] var fileEnum = fm.enumerator(atPath: srcDirPath) while let fn = fileEnum?.nextObject() { - let fileName = String(fn) + let fileName = String(describing: fn) ///only want source files or header files if fileName.hasSuffix(".cpp") || fileName.hasSuffix(".h") { print(fileName) @@ -181,7 +176,7 @@ if fm.fileExists(atPath: "src/agentcore") == false { print("Attempting to enumerate " + targetWorkingDir) fileEnum = fm.enumerator(atPath: targetWorkingDir) while let fn = fileEnum?.nextObject() { - let fileName = String(fn) + let fileName = String(describing: fn) if fileName != "include" { var fileContents = try String(contentsOfFile: fileName, encoding: encoding) fileContents = fileContents.replacingOccurrences(of: "#include \"MQTT", @@ -205,7 +200,7 @@ if fm.fileExists(atPath: "src/agentcore") == false { fileEnum = fm.enumerator(atPath: targetWorkingDir) while let fn = fileEnum?.nextObject() { print(fn) - let fileName = String(fn) + let fileName = String(describing: fn) if fileName != "include" { if fileName.hasSuffix(".cpp") { source = fileName @@ -238,7 +233,7 @@ if fm.fileExists(atPath: "src/agentcore") == false { fileEnum = fm.enumerator(atPath: targetWorkingDir) while let fn = fileEnum?.nextObject() { print(fn) - let fileName = String(fn) + let fileName = String(describing: fn) //ignore the include directory and anything that isn't a header or source file if fileName.hasPrefix(IBMRAS_DIR) && (fileName.hasSuffix(".cpp") || fileName.hasSuffix(".h")) { var fileContents = try String(contentsOfFile: fileName, encoding: encoding) From dbc8c38ffd8d7678299bf0624c67404d640d6442 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Fri, 9 Sep 2016 13:18:35 +0100 Subject: [PATCH 09/19] Create .swift-version --- .swift-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..22ea19a --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +DEVELOPMENT-SNAPSHOT-2016-08-23-a From be1dcd2159b2049cacfc0d3b6c05c3cb62ff291d Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Fri, 9 Sep 2016 14:07:24 +0100 Subject: [PATCH 10/19] Update .swift-version --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 22ea19a..5d4ee6a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-08-23-a +DEVELOPMENT-SNAPSHOT-2016-09-07-a From 15cc369fb5bb691e80deda6d204e7d0d733f8dc3 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 22 Sep 2016 16:29:12 +0100 Subject: [PATCH 11/19] Updating swift-version to Swift 3 GA --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 5d4ee6a..9f55b2c 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-09-07-a +3.0 From 677f04a0c02fb0e565ce12fecc38406ac167447e Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 22 Sep 2016 16:31:51 +0100 Subject: [PATCH 12/19] Adding loader_entrypoint DECL (Windows build break) --- src/ibmras/monitoring/AgentExtensions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/monitoring/AgentExtensions.h b/src/ibmras/monitoring/AgentExtensions.h index db4434a..bef801c 100644 --- a/src/ibmras/monitoring/AgentExtensions.h +++ b/src/ibmras/monitoring/AgentExtensions.h @@ -147,7 +147,7 @@ typedef struct loaderCoreFunctions { } loaderCoreFunctions; -loaderCoreFunctions* loader_entrypoint(); +DECL loaderCoreFunctions* loader_entrypoint(); typedef int (*PLUGIN_INITIALIZE)(const char* properties); typedef pushsource* (*PUSH_SOURCE_REGISTER)(agentCoreFunctions aCF, unsigned int provID); From 46ab5c874d54bf0d08bb2f9071977310bdce5073 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 05:40:03 +0100 Subject: [PATCH 13/19] back() not available on clang compiler --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 9988673..d44d363 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -564,7 +564,7 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // of the running process. This can pose a problem if the filename // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. - while(dummyStr.back() != ')') { + while(dummyStr[dummyStr.npos - 1] != ')') { filestream >> dummyStr; } From 04ee89e37ed7efcec7c486ca41ca27cd8dc92fed Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 14:55:56 +0100 Subject: [PATCH 14/19] Logging dummyStr --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index d44d363..533fdcc 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -564,6 +564,9 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // of the running process. This can pose a problem if the filename // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. + aCF.logMessage(info, "dummyStr = " + dummyStr); + aCF.logMessage(info, "dummyStr.npos - 1 = " + dummyStr.npos - 1); + aCF.logMessage(info, "dummyStr[dummyStr.npos - 1] = " + dummyStr[dummyStr.npos - 1]); while(dummyStr[dummyStr.npos - 1] != ')') { filestream >> dummyStr; } From 4df9a38a362b6dde4060a4c799eb5fcca5ddb5d1 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 15:00:18 +0100 Subject: [PATCH 15/19] Logging dummyStr --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 533fdcc..9d32af8 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -564,9 +564,9 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // of the running process. This can pose a problem if the filename // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. - aCF.logMessage(info, "dummyStr = " + dummyStr); - aCF.logMessage(info, "dummyStr.npos - 1 = " + dummyStr.npos - 1); - aCF.logMessage(info, "dummyStr[dummyStr.npos - 1] = " + dummyStr[dummyStr.npos - 1]); + aCF.logMessage(info, "dummyStr = " + dummyStr.c_str()); + aCF.logMessage(info, "dummyStr.npos - 1 = ".append(dummyStr.npos - 1)); + aCF.logMessage(info, "dummyStr[dummyStr.npos - 1] = ".append(dummyStr[dummyStr.npos - 1])); while(dummyStr[dummyStr.npos - 1] != ')') { filestream >> dummyStr; } From 3743d4174d89bd64972514bd8b4c753568dd7fa8 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 15:10:35 +0100 Subject: [PATCH 16/19] Simplify dummyStr logging --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 9d32af8..1378bbd 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -564,10 +564,8 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // of the running process. This can pose a problem if the filename // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. - aCF.logMessage(info, "dummyStr = " + dummyStr.c_str()); - aCF.logMessage(info, "dummyStr.npos - 1 = ".append(dummyStr.npos - 1)); - aCF.logMessage(info, "dummyStr[dummyStr.npos - 1] = ".append(dummyStr[dummyStr.npos - 1])); - while(dummyStr[dummyStr.npos - 1] != ')') { + aCF.logMessage(info, dummyStr.append(" = dummyStr").c_str()); + while(dummyStr[dummyStr.length - 1] != ')') { filestream >> dummyStr; } From 1e540be5558064a543767adaec2eb9377f6437f0 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 15:12:23 +0100 Subject: [PATCH 17/19] Update cpuplugin.cpp --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 1378bbd..6b48100 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -565,7 +565,7 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. aCF.logMessage(info, dummyStr.append(" = dummyStr").c_str()); - while(dummyStr[dummyStr.length - 1] != ')') { + while(dummyStr[dummyStr.length() - 1] != ')') { filestream >> dummyStr; } From 677a7d9fa3e923a2fa8e856a5601c29d6f77820a Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 15:16:15 +0100 Subject: [PATCH 18/19] More dummystr logging --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 6b48100..b8ab9b4 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -565,6 +565,8 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. aCF.logMessage(info, dummyStr.append(" = dummyStr").c_str()); + aCF.logMessage(info, dummyStr[dummyStr.length()]); + aCF.logMessage(info, dummyStr[dummyStr.length()-1]); while(dummyStr[dummyStr.length() - 1] != ')') { filestream >> dummyStr; } From 703c45418990f8adde3018e959322ea25cdfae26 Mon Sep 17 00:00:00 2001 From: mattcolegate Date: Thu, 29 Sep 2016 15:42:01 +0100 Subject: [PATCH 19/19] Removing back() function as Swift Clang compiler doesn't support --- src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index b8ab9b4..3965448 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -564,10 +564,7 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ) // of the running process. This can pose a problem if the filename // has a space (i.e. (Passenger NodeA)). This checks to read the stream // until the end parenthese is found. - aCF.logMessage(info, dummyStr.append(" = dummyStr").c_str()); - aCF.logMessage(info, dummyStr[dummyStr.length()]); - aCF.logMessage(info, dummyStr[dummyStr.length()-1]); - while(dummyStr[dummyStr.length() - 1] != ')') { + while(dummyStr[dummyStr.length()-1] != ')') { filestream >> dummyStr; }