Skip to content

Commit

Permalink
chore(userspace/libsinsp): fixed libsinsp example event type fetcher …
Browse files Browse the repository at this point in the history
…to also use syscall_info_table.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP authored and poiana committed Oct 26, 2022
1 parent 3df9390 commit cc3ea8c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion userspace/libsinsp/examples/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void plaintext_dump(sinsp& inspector)

cout << "[PPID=" << parent_pid << "]:"
<< "[PID=" << thread->m_pid << "]:"
<< "[TYPE=" << get_event_type_name(ev->get_type()) << "]:"
<< "[TYPE=" << get_event_type_name(inspector, ev) << "]:"
<< "[EXE=" << thread->get_exepath() << "]:"
<< "[CMD=" << cmdline << "]"
<< endl;
Expand Down
15 changes: 12 additions & 3 deletions userspace/libsinsp/examples/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ std::string get_event_category_name(ppm_event_category category)
//
// Get the string representation of a ppm_event_type
//
std::string get_event_type_name(uint16_t type)
std::string get_event_type_name(sinsp& inspector, sinsp_evt* ev)
{
if (type < PPM_EVENT_MAX && type != PPME_GENERIC_E && type != PPME_GENERIC_X)
uint16_t type = ev->get_type();
if (type >= PPM_EVENT_MAX)
{
return "UNKNOWN " + to_string(type);
}
if (type != PPME_GENERIC_E && type != PPME_GENERIC_X)
{
return g_infotables.m_event_info[type].name;
}
return "UNKNOWN " + to_string(type);

auto tables = inspector.get_event_info_tables();
sinsp_evt_param *parinfo = ev->get_param(0);
uint16_t ppm_sc = *(uint16_t *)parinfo->m_val;
return tables->m_syscall_info_table[ppm_sc].name;
}
2 changes: 1 addition & 1 deletion userspace/libsinsp/examples/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ std::string get_event_category_name(ppm_event_category category);
//
// Get the string representation of a ppm_event_type
//
std::string get_event_type_name(uint16_t type);
std::string get_event_type_name(sinsp& inspector, sinsp_evt* ev);

0 comments on commit cc3ea8c

Please sign in to comment.