feature: verbose feature for libusr
This commit is contained in:
parent
afa7e4cecb
commit
b4b99915ef
6
Makefile
6
Makefile
@ -17,12 +17,12 @@ CARGO_COMMON_OPTS=
|
||||
ifeq ($(PROFILE),release)
|
||||
CARGO_COMMON_OPTS+=--release
|
||||
endif
|
||||
ifeq ($(VERBOSE),1)
|
||||
CARGO_COMMON_OPTS+=--features verbose
|
||||
endif
|
||||
|
||||
CARGO_BUILD_OPTS=$(CARGO_COMMON_OPTS) \
|
||||
--target=../etc/$(ARCH)-$(MACH).json
|
||||
ifeq ($(VERBOSE),1)
|
||||
CARGO_BUILD_OPTS+=--features verbose
|
||||
endif
|
||||
ifneq ($(MACH),)
|
||||
CARGO_BUILD_OPTS+=--features mach_$(MACH)
|
||||
endif
|
||||
|
@ -217,7 +217,6 @@ impl Process {
|
||||
|
||||
let space_phys = lock.space.as_mut().unwrap().address_phys();
|
||||
let ttbr0 = space_phys | ((lock.id.asid() as usize) << 48);
|
||||
debugln!("New user thread for {:?}, asid={:#x}", lock.id, lock.id.asid());
|
||||
|
||||
let thread = Thread::new_user(lock.id, entry, stack, arg, ttbr0)?;
|
||||
let tid = thread.id();
|
||||
@ -237,7 +236,6 @@ impl Process {
|
||||
let dst_space = src_inner.space.as_mut().unwrap().fork()?;
|
||||
let dst_space_phys = (dst_space as *mut _ as usize) - mem::KERNEL_OFFSET;
|
||||
let dst_ttbr0 = dst_space_phys | ((dst_id.asid() as usize) << 48);
|
||||
debugln!("New TTBR0 for {:?}, asid={:#x}", dst_id, dst_id.asid());
|
||||
|
||||
let mut threads = Vec::new();
|
||||
let tid = Thread::fork(Some(dst_id), frame, dst_ttbr0)?.id();
|
||||
@ -534,7 +532,6 @@ impl Process {
|
||||
let entry = loader(new_space)?;
|
||||
let arg = Self::store_arguments(new_space, argv)?;
|
||||
|
||||
debugln!("Will now enter at {:#x}", entry);
|
||||
// TODO drop old address space
|
||||
process_lock.space = Some(new_space);
|
||||
|
||||
|
@ -9,3 +9,6 @@ edition = "2021"
|
||||
libsys = { path = "../libsys", features = ["user"] }
|
||||
lazy_static = { version = "^1.4.0", features = ["spin_no_std"] }
|
||||
memoffset = "^0.6.4"
|
||||
|
||||
[features]
|
||||
verbose = []
|
||||
|
@ -82,6 +82,7 @@ impl Zone {
|
||||
MemoryAccess::READ | MemoryAccess::WRITE,
|
||||
MemoryMap::ANONYMOUS | MemoryMap::PRIVATE,
|
||||
)?;
|
||||
#[cfg(feature = "verbose")]
|
||||
trace_debug!("Zone::alloc({}) => {:#x}", size, pages);
|
||||
|
||||
let zone_ptr = pages as *mut Zone;
|
||||
@ -101,6 +102,7 @@ impl Zone {
|
||||
}
|
||||
|
||||
unsafe fn free(zone: *mut Self) {
|
||||
#[cfg(feature = "verbose")]
|
||||
trace_debug!("Zone::free({:p})", zone);
|
||||
sys_munmap(zone as usize, (*zone).size + size_of::<Zone>())
|
||||
.expect("Failed to unmap heap pages");
|
||||
@ -183,6 +185,7 @@ unsafe impl GlobalAlloc for Allocator {
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
assert!(layout.align() < 16);
|
||||
let size = (layout.size() + 15) & !15;
|
||||
#[cfg(feature = "verbose")]
|
||||
trace_debug!("alloc({:?})", layout);
|
||||
if size <= SMALL_ZONE_ELEM {
|
||||
alloc_from(SMALL_ZONE_LIST.assume_init_mut(), SMALL_ZONE_SIZE, size)
|
||||
@ -196,6 +199,7 @@ unsafe impl GlobalAlloc for Allocator {
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||
#[cfg(feature = "verbose")]
|
||||
trace_debug!("free({:p}, {:?})", ptr, layout);
|
||||
assert!(!ptr.is_null());
|
||||
let mut block = ptr.sub(size_of::<Block>()) as *mut Block;
|
||||
|
1
libusr/src/env/mod.rs
vendored
1
libusr/src/env/mod.rs
vendored
@ -25,5 +25,6 @@ pub(crate) unsafe fn setup_env(arg: &ProgramArgs) {
|
||||
PROGRAM_ARGS.push(string);
|
||||
}
|
||||
|
||||
#[cfg(feature = "verbose")]
|
||||
trace!(TraceLevel::Debug, "args = {:?}", PROGRAM_ARGS);
|
||||
}
|
||||
|
@ -37,3 +37,6 @@ path = "src/sbin/login.rs"
|
||||
libusr = { path = "../libusr" }
|
||||
libsys = { path = "../libsys" }
|
||||
lazy_static = { version = "*", features = ["spin_no_std"] }
|
||||
|
||||
[features]
|
||||
verbose = ["libusr/verbose"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user