Skip to content

Commit

Permalink
Add dbg! macro calls
Browse files Browse the repository at this point in the history
  • Loading branch information
gememma committed Jun 3, 2024
1 parent b2b8224 commit 1433be1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions mirrord/layer/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ impl CheckedInto<String> for *const c_char {

#[cfg(target_os = "macos")]
pub fn strip_mirrord_path(path_str: &Path) -> Option<&Path> {
path_str
.strip_prefix(MIRRORD_TEMP_BIN_DIR_PATH_BUF.to_owned())
dbg!(path_str.strip_prefix(dbg!(MIRRORD_TEMP_BIN_DIR_PATH_BUF.to_owned())))
.ok()
.or_else(|| {
path_str
.strip_prefix(MIRRORD_TEMP_BIN_DIR_CANONIC_PATHBUF.to_owned())
.ok()
dbg!(path_str.strip_prefix(dbg!(MIRRORD_TEMP_BIN_DIR_CANONIC_PATHBUF.to_owned()))).ok()
})
}

Expand All @@ -105,6 +102,7 @@ impl CheckedInto<PathBuf> for *const c_char {
let str_det = str_det.and_then(|path_str| {
let optional_stripped_path =
strip_mirrord_path(Path::new(path_str)).map(|x| Path::new("/").join(x));
dbg!(&optional_stripped_path);
if let Some(stripped_path) = optional_stripped_path {
// actually stripped, so bypass and provide a pointer to after the temp dir.
// `stripped_path` is a reference to a later character in the same string as
Expand Down
4 changes: 2 additions & 2 deletions mirrord/layer/src/exec_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub(crate) unsafe extern "C" fn _nsget_executable_path_detour(
) -> c_int {
let res = FN__NSGET_EXECUTABLE_PATH(path, buflen);
if res == 0 {
let path_buf_detour = CheckedInto::<PathBuf>::checked_into(path as *const c_char);
let path_buf_detour = dbg!(CheckedInto::<PathBuf>::checked_into(path as *const c_char));
if let Bypass(FileOperationInMirrordBinTempDir(later_ptr)) = path_buf_detour {
// SAFETY: If we're here, the original function was passed this pointer and was
// successful, so this pointer must be valid.
Expand Down Expand Up @@ -324,7 +324,7 @@ pub(crate) unsafe extern "C" fn dlopen_detour(
) -> *const c_void {
// we hold the guard manually for tracing/internal code
let guard = crate::detour::DetourGuard::new();
let detour: Detour<PathBuf> = raw_path.checked_into();
let detour: Detour<PathBuf> = dbg!(raw_path.checked_into());
let raw_path = if let Bypass(FileOperationInMirrordBinTempDir(ptr)) = detour {
trace!("dlopen called with a path inside our patch dir, switching with fixed pointer.");
ptr
Expand Down
2 changes: 1 addition & 1 deletion mirrord/layer/src/file/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn update_ptr_from_bypass(ptr: *const c_char, bypass: Bypass) -> *const c_char {
/// We ignore mode in case we don't bypass the call.
#[mirrord_layer_macro::instrument(level = "trace", ret)]
unsafe fn open_logic(raw_path: *const c_char, open_flags: c_int, _mode: c_int) -> Detour<RawFd> {
let path = raw_path.checked_into();
let path = dbg!(raw_path.checked_into());
let open_options = OpenOptionsInternalExt::from_flags(open_flags);

trace!("path {:#?} | open_options {:#?}", path, open_options);
Expand Down

0 comments on commit 1433be1

Please sign in to comment.