Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions crates/crashes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ edition.workspace = true
license = "GPL-3.0-or-later"

[dependencies]
async-process.workspace = true
crash-handler.workspace = true
futures.workspace = true
log.workspace = true
minidumper.workspace = true
parking_lot.workspace = true
serde.workspace = true
serde_json.workspace = true

[target.'cfg(not(target_os = "freebsd"))'.dependencies]
async-process.workspace = true
crash-handler.workspace = true
minidumper.workspace = true
paths.workspace = true
system_specs.workspace = true
zstd.workspace = true

Expand All @@ -26,4 +30,4 @@ windows.workspace = true
workspace = true

[lib]
path = "src/crashes.rs"
path = "src/lib.rs"
33 changes: 33 additions & 0 deletions crates/crashes/src/crashes_freebsd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::future::Future;
use std::path::Path;

use futures::future::BoxFuture;
use serde::{Deserialize, Serialize};

pub static REQUESTED_MINIDUMP: std::sync::atomic::AtomicBool =
std::sync::atomic::AtomicBool::new(false);

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct InitCrashHandler {
pub session_id: String,
pub zed_version: String,
pub binary: String,
pub release_channel: String,
pub commit_sha: String,
}

pub fn init<F: Future<Output = ()> + Send + Sync + 'static>(
_crash_init: InitCrashHandler,
_spawn: impl FnOnce(BoxFuture<'static, ()>),
_wait_timer: impl (Fn(std::time::Duration) -> F) + Send + Sync + 'static,
) {
log::info!("crash handler disabled on FreeBSD");
}

pub fn crash_server(_socket: &Path) {
log::info!("crash server disabled on FreeBSD");
}

pub fn set_gpu_info(_specs: ()) {}

pub fn set_user_info(_info: ()) {}
11 changes: 11 additions & 0 deletions crates/crashes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[cfg(not(target_os = "freebsd"))]
mod crashes;

#[cfg(not(target_os = "freebsd"))]
pub use crashes::*;

#[cfg(target_os = "freebsd")]
mod crashes_freebsd;

#[cfg(target_os = "freebsd")]
pub use crashes_freebsd::*;
9 changes: 5 additions & 4 deletions crates/fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,15 @@ impl FileHandle for std::fs::File {
};

let fd = self.as_fd();
let mut kif = MaybeUninit::<libc::kinfo_file>::uninit();
let mut kif = MaybeUninit::<libc::kinfo_file>::zeroed();
// SAFETY: zeroed memory is a valid initial state for kinfo_file.
let kif = unsafe { kif.assume_init_mut() };
kif.kf_structsize = libc::KINFO_FILE_SIZE;

let result = unsafe { libc::fcntl(fd.as_raw_fd(), libc::F_KINFO, kif.as_mut_ptr()) };
let result = unsafe { libc::fcntl(fd.as_raw_fd(), libc::F_KINFO, kif as *mut _) };
anyhow::ensure!(result != -1, "fcntl returned -1");

// SAFETY: `fcntl` will initialize the kif.
let c_str = unsafe { CStr::from_ptr(kif.assume_init().kf_path.as_ptr()) };
let c_str = unsafe { CStr::from_ptr(kif.kf_path.as_ptr()) };
anyhow::ensure!(!c_str.is_empty(), "Could find a path for the file handle");
let path = PathBuf::from(OsStr::from_bytes(c_str.to_bytes()));
Ok(path)
Expand Down
8 changes: 7 additions & 1 deletion crates/gpui/src/gpui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub mod profiler;
test,
target_os = "windows",
target_os = "linux",
target_os = "freebsd",
target_family = "wasm",
feature = "bench"
))]
Expand Down Expand Up @@ -137,7 +138,12 @@ pub use keymap::*;
pub use path_builder::*;
pub use platform::*;
pub use profiler::*;
#[cfg(any(target_os = "windows", target_os = "linux", target_family = "wasm"))]
#[cfg(any(
target_os = "windows",
target_os = "linux",
target_os = "freebsd",
target_family = "wasm"
))]
pub use queue::{PriorityQueueReceiver, PriorityQueueSender};
pub use refineable::*;
pub use scene::*;
Expand Down
2 changes: 2 additions & 0 deletions crates/remote/src/remote_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum RemoteOs {
Linux,
MacOs,
Windows,
FreeBSD,
}

impl RemoteOs {
Expand All @@ -65,6 +66,7 @@ impl RemoteOs {
RemoteOs::Linux => "linux",
RemoteOs::MacOs => "macos",
RemoteOs::Windows => "windows",
RemoteOs::FreeBSD => "freebsd",
}
}

Expand Down
6 changes: 6 additions & 0 deletions crates/remote/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn parse_platform(output: &str) -> Result<RemotePlatform> {
let os = match os {
"Darwin" => RemoteOs::MacOs,
"Linux" => RemoteOs::Linux,
"FreeBSD" => RemoteOs::FreeBSD,
_ => anyhow::bail!(
"Prebuilt remote servers are not yet available for {os:?}. See https://zed.dev/docs/remote-development"
),
Expand Down Expand Up @@ -302,6 +303,7 @@ async fn build_remote_server_from_source(
"unknown-linux-gnu"
},
RemoteOs::MacOs => "apple-darwin",
RemoteOs::FreeBSD => "unknown-freebsd",
RemoteOs::Windows if cfg!(windows) => "pc-windows-msvc",
RemoteOs::Windows => "pc-windows-gnu",
}
Expand Down Expand Up @@ -502,6 +504,10 @@ mod tests {

assert!(parse_platform("Windows x86_64\n").is_err());
assert!(parse_platform("Linux armv7l\n").is_err());

let result = parse_platform("FreeBSD x86_64\n").unwrap();
assert_eq!(result.os, RemoteOs::FreeBSD);
assert_eq!(result.arch, RemoteArch::X86_64);
}

#[test]
Expand Down
6 changes: 4 additions & 2 deletions crates/remote_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ thiserror.workspace = true
rayon.workspace = true
uuid = { workspace = true, features = ["v4"] }

[target.'cfg(not(windows))'.dependencies]
[target.'cfg(not(any(target_os = "windows", target_os = "freebsd")))'.dependencies]
crash-handler.workspace = true
minidumper.workspace = true

[target.'cfg(not(windows))'.dependencies]
fork.workspace = true
libc.workspace = true
minidumper.workspace = true

[target.'cfg(windows)'.dependencies]
windows.workspace = true
Expand Down