userspace/memory/stack/arguments/
entry.rs

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