diff --git a/userspace/libsinsp/utils.cpp b/userspace/libsinsp/utils.cpp index c104575ae5..42a6da6d12 100644 --- a/userspace/libsinsp/utils.cpp +++ b/userspace/libsinsp/utils.cpp @@ -861,54 +861,6 @@ bool sinsp_utils::glob_match(const char *pattern, const char *string, const bool #endif } -#ifndef _WIN32 -#ifdef __GLIBC__ -void sinsp_utils::bt(void) -{ - static const char start[] = "BACKTRACE ------------"; - static const char end[] = "----------------------"; - - void *bt[1024]; - int bt_size; - char **bt_syms; - int i; - - bt_size = backtrace(bt, 1024); - bt_syms = backtrace_symbols(bt, bt_size); - libsinsp_logger()->format("%s", start); - for (i = 1; i < bt_size; i++) - { - libsinsp_logger()->format("%s", bt_syms[i]); - } - libsinsp_logger()->format("%s", end); - - free(bt_syms); -} -#endif // __GLIBC__ -#endif // _WIN32 - -bool sinsp_utils::find_first_env(std::string &out, const std::vector &env, const std::vector &keys) -{ - for (const auto& key : keys) - { - for(const auto& env_var : env) - { - if((env_var.size() > key.size()) && !env_var.compare(0, key.size(), key) && (env_var[key.size()] == '=')) - { - out = env_var.substr(key.size()+1); - return true; - } - } - } - return false; -} - -bool sinsp_utils::find_env(std::string &out, const std::vector &env, const std::string &key) -{ - const std::vector keys = { key }; - return find_first_env(out, env, keys); -} - void sinsp_utils::split_container_image(const std::string &image, std::string &hostname, std::string &port, @@ -973,30 +925,6 @@ void sinsp_utils::split_container_image(const std::string &image, } } -void sinsp_utils::parse_suppressed_types(const std::vector& supp_strs, - std::vector* supp_ids) -{ - for (auto ii = 0; ii < PPM_EVENT_MAX; ii++) - { - auto iter = std::find(supp_strs.begin(), supp_strs.end(), - event_name_by_id(ii)); - if (iter != supp_strs.end()) - { - supp_ids->push_back(static_cast(ii)); - } - } -} - -const char* sinsp_utils::event_name_by_id(uint16_t id) -{ - if (id >= PPM_EVENT_MAX) - { - ASSERT(false); - return "NA"; - } - return g_infotables.m_event_info[id].name; -} - static int32_t gmt2local(time_t t) { int dt, dir; @@ -1107,34 +1035,6 @@ void sinsp_utils::ts_to_iso_8601(uint64_t ts, OUT std::string* res) // Time utility functions. /////////////////////////////////////////////////////////////////////////////// -bool sinsp_utils::parse_iso_8601_utc_string(const std::string& time_str, uint64_t &ns) -{ -#ifndef _WIN32 - tm tm_time{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - char* rem = strptime(time_str.c_str(), "%Y-%m-%dT%H:%M:", &tm_time); - if(rem == NULL || *rem == '\0') - { - return false; - } - tm_time.tm_isdst = -1; // strptime does not set this, signal timegm to determine DST - ns = timegm(&tm_time) * ONE_SECOND_IN_NS; - - // Handle the possibly fractional seconds now. Also verify - // that the string ends with Z. - double fractional_secs; - if(sscanf(rem, "%lfZ", &fractional_secs) != 1) - { - return false; - } - - ns += (fractional_secs * ONE_SECOND_IN_NS); - - return true; -#else - throw sinsp_exception("parse_iso_8601_utc_string() not implemented on Windows"); -#endif -} - time_t get_epoch_utc_seconds(const std::string& time_str, const std::string& fmt) { #ifndef _WIN32 diff --git a/userspace/libsinsp/utils.h b/userspace/libsinsp/utils.h index 3ef31f824e..68e087f34b 100644 --- a/userspace/libsinsp/utils.h +++ b/userspace/libsinsp/utils.h @@ -122,9 +122,6 @@ class sinsp_utils static void bt(void); #endif // _WIN32 - static bool find_first_env(std::string &out, const std::vector &env, const std::vector &keys); - static bool find_env(std::string &out, const std::vector &env, const std::string &key); - static void split_container_image(const std::string &image, std::string &hostname, std::string &port, @@ -133,20 +130,10 @@ class sinsp_utils std::string &digest, bool split_repo = true); - static void parse_suppressed_types(const std::vector& supp_strs, - std::vector* supp_ids); - - static const char* event_name_by_id(uint16_t id); - static void ts_to_string(uint64_t ts, OUT std::string* res, bool date, bool ns); static void ts_to_iso_8601(uint64_t ts, OUT std::string* res); - // Limited version of iso 8601 time string parsing, that assumes a - // timezone of Z for UTC, but does support parsing fractional seconds, - // unlike get_epoch_utc_seconds_* below. - static bool parse_iso_8601_utc_string(const std::string& time_str, uint64_t &ns); - // // Convert caps from their numeric representation to a space-separated string list //