Skip to content

Commit

Permalink
wip debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vthib committed Dec 14, 2023
1 parent ae954a7 commit 284da2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions boreal/src/scanner/process/sys/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl FragmentedMemory for LinuxProcessMemory {

fn next(&mut self, params: &MemoryParams) -> Option<RegionDescription> {
self.next_position(params);
dbg!(&self.current_region);

self.current_region
.as_ref()
Expand Down Expand Up @@ -326,6 +327,11 @@ impl CurrentRegion {
}

for (page_index, page_bits) in page_details.into_iter().enumerate() {
println!(
"page {:x}: {:x}",
desc.start + page_index * page_size,
page_bits
);
// If page_bits is 0, the page is not in RAM or swap, it has never been fetched
// by the process. Since it is file-backed, keeping the data from the page is
// fine.
Expand All @@ -338,6 +344,7 @@ impl CurrentRegion {
if (page_bits >> 61) & 0x1 != 0 {
continue;
}
println!(" fetching page");

// Since the page may have been modified by the process, fetch it
// from the mem file directly.
Expand Down
1 change: 1 addition & 0 deletions boreal/tests/it/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ rule a {

fn get_vm_rss(pid: u32) -> u64 {
let status = std::fs::read_to_string(format!("/proc/{}/status", pid)).unwrap();
eprintln!("status: {}", status);
let rss_line = status
.split('\n')
.find(|line| line.starts_with("VmRSS"))
Expand Down

0 comments on commit 284da2a

Please sign in to comment.