Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions litebox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ringbuf = { version = "0.4.8", default-features = false, features = ["alloc"] }
buddy_system_allocator = { version = "0.11.0", default-features = false, features = ["use_spin"] }
# Depend on (currently unreleased) slabmalloc `main`, which contains some fixes on top of `0.11.0`
slabmalloc = { git = "https://github.com/gz/rust-slabmalloc.git", rev = "19480b2e82704210abafe575fb9699184c1be110" }
tracing = { version = "0.1.43", default-features = false }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.60.2", features = [
Expand Down
6 changes: 5 additions & 1 deletion litebox/src/litebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ impl<Platform: RawSyncPrimitivesProvider> LiteBox<Platform> {
#[cfg(feature = "lock_tracing")]
crate::sync::lock_tracing::LockTracker::init(platform);

let descriptors = RwLock::new(Descriptors::new_from_litebox_creation());

tracing::debug!("LiteBox instance initialized");

Self {
x: Arc::new(LiteBoxX {
platform,
descriptors: RwLock::new(Descriptors::new_from_litebox_creation()),
descriptors,
}),
}
}
Expand Down
2 changes: 2 additions & 0 deletions litebox_runner_linux_userland/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ litebox_platform_multiplex = { version = "0.1.0", path = "../litebox_platform_mu
litebox_shim_linux = { version = "0.1.0", path = "../litebox_shim_linux" }
litebox_syscall_rewriter = { version = "0.1.0", path = "../litebox_syscall_rewriter" }
memmap2 = "0.9.8"
tracing = "0.1.43"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }

[dev-dependencies]
sha2 = "0.10"
Expand Down
19 changes: 19 additions & 0 deletions litebox_runner_linux_userland/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ use std::time::Duration;
extern crate alloc;

/// Run Linux programs with LiteBox on unmodified Linux
///
/// # Tracing
///
/// LiteBox supports detailed tracing output controlled by the `LITEBOX_LOG` environment variable.
///
/// Examples:
/// - `LITEBOX_LOG=debug` - Show debug and higher level logs
/// - `LITEBOX_LOG=litebox=debug,litebox::fs=trace` - Multiple filters at different levels
#[derive(Parser, Debug)]
pub struct CliArgs {
/// The program and arguments passed to it (e.g., `python3 --version`)
Expand Down Expand Up @@ -82,6 +90,17 @@ static REQUIRE_RTLD_AUDIT: core::sync::atomic::AtomicBool =
/// panic. If it does actually panic, then ping the authors of LiteBox, and likely a better error
/// message could be thrown instead.
pub fn run(cli_args: CliArgs) -> Result<()> {
// Initialize tracing subscriber with LITEBOX_LOG environment variable
tracing_subscriber::fmt()
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_level(true)
.with_env_filter(
tracing_subscriber::EnvFilter::builder()
.with_env_var("LITEBOX_LOG")
.from_env_lossy(),
)
.init();

if !cli_args.insert_files.is_empty() {
unimplemented!(
"this should (hopefully soon) have a nicer interface to support loading in files"
Expand Down