Skip to content

Commit

Permalink
Rename dso_from_procline to dso_from_proc_line
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavoire committed Oct 5, 2023
1 parent 42c15e0 commit 5555d4b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/dso_hdr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class DsoHdr {
static DsoConstRange get_elf_range(const DsoMap &map, DsoMapConstIt it);

// Helper to create a dso from a line in /proc/pid/maps
static Dso dso_from_procline(int pid, char *line);
static Dso dso_from_proc_line(int pid, char *line);

static DsoFindRes find_res_not_found(const DsoMap &map) {
return {map.end(), false};
Expand Down
4 changes: 2 additions & 2 deletions src/dso_hdr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ bool DsoHdr::pid_backpopulate(PidMapping &pid_mapping, pid_t pid,
size_t sz_buf = 0;

while (-1 != getline(&buf, &sz_buf, proc_map_file_holder.get())) {
Dso dso = dso_from_procline(pid, buf);
Dso dso = dso_from_proc_line(pid, buf);
if (dso._pid == -1) { // invalid dso
continue;
}
Expand All @@ -469,7 +469,7 @@ bool DsoHdr::pid_backpopulate(PidMapping &pid_mapping, pid_t pid,
return true;
}

Dso DsoHdr::dso_from_procline(int pid, char *line) {
Dso DsoHdr::dso_from_proc_line(int pid, char *line) {
// clang-format off
// Example of format
/*
Expand Down
34 changes: 17 additions & 17 deletions test/dso-ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,49 +229,49 @@ static const char *const s_bad_line = "7b5242e44000-7b5242e45000 r-xp 00000000

// clang-format on

TEST(DSOTest, dso_from_procline) {
TEST(DSOTest, dso_from_proc_line) {
LogHandle handle;
Dso no_exec =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_line_noexec));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_line_noexec));
EXPECT_EQ(no_exec._type, DsoType::kStandard);
EXPECT_EQ(no_exec._prot, PROT_READ);
EXPECT_EQ(no_exec._pid, 10);
Dso standard_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_exec_line));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_exec_line));
{ // standard
EXPECT_EQ(standard_dso._type, DsoType::kStandard);
}
{ // vdso
Dso vdso_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_vdso_lib));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_vdso_lib));
EXPECT_EQ(vdso_dso._type, DsoType::kVdso);
}
{ // stack
Dso stack_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_stack_line));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_stack_line));
EXPECT_EQ(stack_dso._type, DsoType::kStack);
}
{ // inode
Dso inode_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_inode_line));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_inode_line));
EXPECT_EQ(inode_dso._type, DsoType::kAnon);
}
{
// jsa
Dso jsa_dso = DsoHdr::dso_from_procline(10, const_cast<char *>(s_jsa_line));
Dso jsa_dso = DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_jsa_line));
EXPECT_EQ(jsa_dso._type, DsoType::kRuntime);
}
{
// dotnet dll
Dso dll_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_dotnet_line));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_dotnet_line));
EXPECT_EQ(dll_dso._type, DsoType::kRuntime);
}
DsoHdr dso_hdr;
{
// check that we don't overlap between lines that end on same byte
Dso standard_dso_2 =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_exec_line2));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_exec_line2));
EXPECT_EQ(standard_dso._type, DsoType::kStandard);
dso_hdr.insert_erase_overlap(std::move(standard_dso_2));
dso_hdr.insert_erase_overlap(std::move(standard_dso));
Expand All @@ -280,43 +280,43 @@ TEST(DSOTest, dso_from_procline) {
{
// check that we erase everything if we have an overlap
Dso standard_dso_3 =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_exec_line3));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_exec_line3));
EXPECT_EQ(standard_dso._type, DsoType::kStandard);
dso_hdr.insert_erase_overlap(std::move(standard_dso_3));
EXPECT_EQ(dso_hdr.get_nb_dso(), 1);
}
{
// check that we still match element number 3
Dso standard_dso_4 =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_exec_line4));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_exec_line4));
ProcessAddress_t end_4 = standard_dso_4._end;
DsoFindRes findres =
dso_hdr.insert_erase_overlap(std::move(standard_dso_4));
EXPECT_EQ(findres.first->second._end, end_4);
}
{
Dso dd_profiling_dso =
DsoHdr::dso_from_procline(10, const_cast<char *>(s_dd_profiling));
DsoHdr::dso_from_proc_line(10, const_cast<char *>(s_dd_profiling));
EXPECT_EQ(dd_profiling_dso._type, DsoType::kDDProfiling);
}
{
Dso jitdump_dso =
DsoHdr::dso_from_procline(3237589, const_cast<char *>(s_jitdump_line));
DsoHdr::dso_from_proc_line(3237589, const_cast<char *>(s_jitdump_line));
EXPECT_EQ(jitdump_dso._type, DsoType::kJITDump);
}
{ // jitdump with a name different from PID (for whole host)
Dso jitdump_dso =
DsoHdr::dso_from_procline(12, const_cast<char *>(s_jitdump_line));
DsoHdr::dso_from_proc_line(12, const_cast<char *>(s_jitdump_line));
EXPECT_EQ(jitdump_dso._type, DsoType::kJITDump);
}
{
// empty file proc line
Dso dso = DsoHdr::dso_from_procline(12, const_cast<char *>(s_empty_file_line));
Dso dso = DsoHdr::dso_from_proc_line(12, const_cast<char *>(s_empty_file_line));
EXPECT_EQ(dso._type, DsoType::kAnon);
}
{
// bad proc line
Dso dso = DsoHdr::dso_from_procline(12, const_cast<char *>(s_bad_line));
Dso dso = DsoHdr::dso_from_proc_line(12, const_cast<char *>(s_bad_line));
EXPECT_EQ(dso._pid, -1);
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ TEST(DSOTest, insert_jitdump) {
// pid from dso line (important for the jitdump name)
pid_t test_pid = 3237589;
Dso jitdump_dso =
DsoHdr::dso_from_procline(test_pid, const_cast<char *>(s_jitdump_line));
DsoHdr::dso_from_proc_line(test_pid, const_cast<char *>(s_jitdump_line));
EXPECT_EQ(jitdump_dso._type, DsoType::kJITDump);
ProcessAddress_t start = jitdump_dso._start;
DsoHdr::PidMapping &pid_mapping = dso_hdr._pid_map[test_pid];
Expand Down

0 comments on commit 5555d4b

Please sign in to comment.