userspace/memory/stack/arguments/
entry.rs1ample::r#struct!(
2 #[repr(C)]
3 pub struct Entry {
4 pub prev: *mut Entry,
5 pub next: *mut Entry,
6 pub pointer: crate::target::arch::Pointer, }
8);
9
10impl Entry {
11 pub fn from_pointer(pointer: crate::target::arch::Pointer) -> Entry {
12 Entry {
13 prev: core::ptr::null_mut(),
14 next: core::ptr::null_mut(),
15 pointer: pointer,
16 }
17 }
18}
19
20impl core::fmt::Debug for Entry {
21 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
22 unsafe {
23 let _cstr = self.pointer.0;
24
25 let _ = write!(f, "Entry: {{ ");
26
27 let cstr_ptr = self.pointer.0 as *mut i8;
28 if !cstr_ptr.is_null() {
29 let cstr = core::ffi::CStr::from_ptr(cstr_ptr);
30 if let Ok(str_slice) = cstr.to_str() {
31 let _ = write!(f, "\"{}\", ", str_slice);
32 } else {
33 let _ = write!(f, "<invalid utf8>, ");
34 }
35 }
36 let _ = write!(f, " }}");
37 return Ok(());
38 }
39 }
40}