Compare commits
2 Commits
9120d29691
...
ad0dadccec
Author | SHA1 | Date |
---|---|---|
|
ad0dadccec | |
|
ee14b3e328 |
|
@ -261,7 +261,7 @@ public:
|
||||||
* @brief Accesses a field with the given accessor and reads its value.
|
* @brief Accesses a field with the given accessor and reads its value.
|
||||||
*/
|
*/
|
||||||
template<typename T, typename Val = T>
|
template<typename T, typename Val = T>
|
||||||
inline void get_dynamic_field(const field_accessor<T>& a, Val& out) {
|
inline void get_dynamic_field(const field_accessor<T>& a, Val& out) const {
|
||||||
_check_defsptr(a.info(), false);
|
_check_defsptr(a.info(), false);
|
||||||
get_dynamic_field(a.info(), reinterpret_cast<void*>(&out));
|
get_dynamic_field(a.info(), reinterpret_cast<void*>(&out));
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ protected:
|
||||||
* according to the type definitions supported in libsinsp::state::typeinfo.
|
* according to the type definitions supported in libsinsp::state::typeinfo.
|
||||||
* For strings, "out" is considered of type const char**.
|
* For strings, "out" is considered of type const char**.
|
||||||
*/
|
*/
|
||||||
virtual void get_dynamic_field(const field_info& i, void* out) {
|
virtual void get_dynamic_field(const field_info& i, void* out) const {
|
||||||
const auto* buf = _access_dynamic_field(i.m_index);
|
const auto* buf = _access_dynamic_field(i.m_index);
|
||||||
if(i.info().type_id() == SS_PLUGIN_ST_STRING) {
|
if(i.info().type_id() == SS_PLUGIN_ST_STRING) {
|
||||||
*((const char**)out) = ((const std::string*)buf)->c_str();
|
*((const char**)out) = ((const std::string*)buf)->c_str();
|
||||||
|
@ -360,7 +360,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void* _access_dynamic_field(size_t index) {
|
inline void* _access_dynamic_field(size_t index) const {
|
||||||
if(!m_dynamic_fields) {
|
if(!m_dynamic_fields) {
|
||||||
throw sinsp_exception("dynamic struct has no field definitions");
|
throw sinsp_exception("dynamic struct has no field definitions");
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<void*> m_fields;
|
mutable std::vector<void*> m_fields;
|
||||||
std::shared_ptr<field_infos> m_dynamic_fields;
|
std::shared_ptr<field_infos> m_dynamic_fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ private:
|
||||||
template<>
|
template<>
|
||||||
inline void libsinsp::state::dynamic_struct::get_dynamic_field<std::string, const char*>(
|
inline void libsinsp::state::dynamic_struct::get_dynamic_field<std::string, const char*>(
|
||||||
const field_accessor<std::string>& a,
|
const field_accessor<std::string>& a,
|
||||||
const char*& out) {
|
const char*& out) const {
|
||||||
_check_defsptr(a.info(), false);
|
_check_defsptr(a.info(), false);
|
||||||
get_dynamic_field(a.info(), reinterpret_cast<void*>(&out));
|
get_dynamic_field(a.info(), reinterpret_cast<void*>(&out));
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ inline void libsinsp::state::dynamic_struct::get_dynamic_field<std::string, cons
|
||||||
template<>
|
template<>
|
||||||
inline void libsinsp::state::dynamic_struct::get_dynamic_field<std::string, std::string>(
|
inline void libsinsp::state::dynamic_struct::get_dynamic_field<std::string, std::string>(
|
||||||
const field_accessor<std::string>& a,
|
const field_accessor<std::string>& a,
|
||||||
std::string& out) {
|
std::string& out) const {
|
||||||
const char* s = NULL;
|
const char* s = NULL;
|
||||||
get_dynamic_field(a, s);
|
get_dynamic_field(a, s);
|
||||||
if(!s) {
|
if(!s) {
|
||||||
|
|
|
@ -83,7 +83,8 @@ public:
|
||||||
inline void set_value(std::pair<Tfirst, Tsecond>* v) { m_value = v; }
|
inline void set_value(std::pair<Tfirst, Tsecond>* v) { m_value = v; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void get_dynamic_field(const dynamic_struct::field_info& i, void* out) override final {
|
virtual void get_dynamic_field(const dynamic_struct::field_info& i,
|
||||||
|
void* out) const override final {
|
||||||
if(i.index() > 1 || i.defs_id() != s_dynamic_fields_id) {
|
if(i.index() > 1 || i.defs_id() != s_dynamic_fields_id) {
|
||||||
throw sinsp_exception(
|
throw sinsp_exception(
|
||||||
"invalid field info passed to pair_table_entry_adapter::get_dynamic_field");
|
"invalid field info passed to pair_table_entry_adapter::get_dynamic_field");
|
||||||
|
@ -115,7 +116,9 @@ private:
|
||||||
std::pair<Tfirst, Tsecond>* m_value;
|
std::pair<Tfirst, Tsecond>* m_value;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void get_dynamic_field(const dynamic_struct::field_info& i, const T* value, void* out) {
|
inline void get_dynamic_field(const dynamic_struct::field_info& i,
|
||||||
|
const T* value,
|
||||||
|
void* out) const {
|
||||||
if(i.info().type_id() == SS_PLUGIN_ST_STRING) {
|
if(i.info().type_id() == SS_PLUGIN_ST_STRING) {
|
||||||
*((const char**)out) = ((const std::string*)value)->c_str();
|
*((const char**)out) = ((const std::string*)value)->c_str();
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,7 +172,8 @@ public:
|
||||||
inline void set_value(T* v) { m_value = v; }
|
inline void set_value(T* v) { m_value = v; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void get_dynamic_field(const dynamic_struct::field_info& i, void* out) override final {
|
virtual void get_dynamic_field(const dynamic_struct::field_info& i,
|
||||||
|
void* out) const override final {
|
||||||
if(i.index() != 0 || i.defs_id() != s_dynamic_fields_id) {
|
if(i.index() != 0 || i.defs_id() != s_dynamic_fields_id) {
|
||||||
throw sinsp_exception(
|
throw sinsp_exception(
|
||||||
"invalid field info passed to value_table_entry_adapter::get_dynamic_field");
|
"invalid field info passed to value_table_entry_adapter::get_dynamic_field");
|
||||||
|
|
|
@ -407,7 +407,7 @@ std::string sinsp_threadinfo::get_exepath() const {
|
||||||
return m_exepath;
|
return m_exepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sinsp_threadinfo::get_container_id() {
|
std::string sinsp_threadinfo::get_container_id() const {
|
||||||
std::string container_id;
|
std::string container_id;
|
||||||
|
|
||||||
const auto accessor = m_params->thread_manager->get_field_accessor(
|
const auto accessor = m_params->thread_manager->get_field_accessor(
|
||||||
|
|
|
@ -115,7 +115,7 @@ public:
|
||||||
\brief Return the container_id associated with this thread, if the container plugins is
|
\brief Return the container_id associated with this thread, if the container plugins is
|
||||||
running, leveraging sinsp state table API.
|
running, leveraging sinsp state table API.
|
||||||
*/
|
*/
|
||||||
std::string get_container_id();
|
std::string get_container_id() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Given the container_id associated with this thread, feetches the container user from
|
\brief Given the container_id associated with this thread, feetches the container user from
|
||||||
|
|
Loading…
Reference in New Issue