Skip to content

Commit

Permalink
Collect number of process FDs and /proc/self/limits (#90)
Browse files Browse the repository at this point in the history
* Collect /proc/self/limits on Linux

* Keep config but commented out

* WIP: Use nix=0.26 to make mach build happy

* Fix build

* Fixup deny

* Bump stream count

---------

Co-authored-by: Alexandre Lissy <[email protected]>
Co-authored-by: Jake Shadle <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2023
1 parent 9b32db7 commit 349a65d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# If you have a global config to use LLD on your machine, you might need to enable
# this config to produce binaries that pass tests
# [target.'cfg(all(target_os = "linux", target_arch = "x86_64"))']
# rustflags = [
# "-C",
# "link-arg=-fuse-ld=lld",
# # LLD by default uses xxhash for build ids now, which breaks tests that assume
# # GUIDS or longer
# "-C",
# "link-arg=-Wl,--build-id=sha1",
# ]
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ byteorder = "1.4"
cfg-if = "1.0"
crash-context = "0.6"
memoffset = "0.9"
minidump-common = "0.19"
minidump-common = "0.19.1"
scroll = "0.11"
tempfile = "3.8"
thiserror = "1.0"
Expand Down
13 changes: 12 additions & 1 deletion src/linux/minidump_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl MinidumpWriter {
) -> Result<()> {
// A minidump file contains a number of tagged streams. This is the number
// of streams which we write.
let num_writers = 16u32;
let num_writers = 17u32;

let mut header_section = MemoryWriter::<MDRawHeader>::alloc(buffer)?;

Expand Down Expand Up @@ -323,6 +323,17 @@ impl MinidumpWriter {
// Write section to file
dir_section.write_to_file(buffer, Some(dirent))?;

let dirent = match self.write_file(buffer, &format!("/proc/{}/limits", self.blamed_thread))
{
Ok(location) => MDRawDirectory {
stream_type: MDStreamType::MozLinuxLimits as u32,
location,
},
Err(_) => Default::default(),
};
// Write section to file
dir_section.write_to_file(buffer, Some(dirent))?;

let dirent = thread_names_stream::write(buffer, dumper)?;
// Write section to file
dir_section.write_to_file(buffer, Some(dirent))?;
Expand Down
3 changes: 3 additions & 0 deletions tests/linux_minidump_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ contextual_tests! {
let _ = dump
.get_raw_stream(LinuxDsoDebug as u32)
.expect("Couldn't find LinuxDsoDebug");
let _ = dump
.get_raw_stream(MozLinuxLimits as u32)
.expect("Couldn't find MozLinuxLimits");
}

fn test_write_with_additional_memory(context: Context) {
Expand Down

0 comments on commit 349a65d

Please sign in to comment.