about summary refs log tree commit diff
path: root/src/libstd/sys/windows/backtrace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys/windows/backtrace.rs')
-rw-r--r--src/libstd/sys/windows/backtrace.rs52
1 files changed, 4 insertions, 48 deletions
diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs
index e6182cda58a..94aaf439f3d 100644
--- a/src/libstd/sys/windows/backtrace.rs
+++ b/src/libstd/sys/windows/backtrace.rs
@@ -30,13 +30,9 @@ use io;
 use libc::c_void;
 use mem;
 use ptr;
-use path::PathBuf;
-use fs::{OpenOptions, File};
-use sys::ext::fs::OpenOptionsExt;
 use sys::c;
 use sys::dynamic_lib::DynamicLibrary;
 use sys::mutex::Mutex;
-use sys::handle::Handle;
 
 macro_rules! sym {
     ($lib:expr, $e:expr, $t:ident) => (
@@ -55,6 +51,10 @@ mod printing;
 #[path = "printing/gnu.rs"]
 mod printing;
 
+#[cfg(target_env = "gnu")]
+#[path = "backtrace_gnu.rs"]
+pub mod gnu;
+
 type SymInitializeFn =
     unsafe extern "system" fn(c::HANDLE, *mut c_void,
                               c::BOOL) -> c::BOOL;
@@ -161,47 +161,3 @@ unsafe fn _write(w: &mut Write) -> io::Result<()> {
 
     Ok(())
 }
-
-fn query_full_process_image_name() -> io::Result<PathBuf> {
-    unsafe {
-        let process_handle = Handle::new(c::OpenProcess(c::PROCESS_QUERY_INFORMATION,
-                                                        c::FALSE,
-                                                        c::GetCurrentProcessId()));
-        super::fill_utf16_buf(|buf, mut sz| {
-            if c::QueryFullProcessImageNameW(process_handle.raw(), 0, buf, &mut sz) == 0 {
-                0
-            } else {
-                sz
-            }
-        }, super::os2path)
-    }
-}
-
-fn lock_and_get_executable_filename() -> io::Result<(PathBuf, File)> {
-    // We query the current image name, open the file without FILE_SHARE_DELETE so it
-    // can't be moved and then get the current image name again. If the names are the
-    // same than we have successfully locked the file
-    let image_name1 = query_full_process_image_name()?;
-    let file = OpenOptions::new()
-                .read(true)
-                .share_mode(c::FILE_SHARE_READ | c::FILE_SHARE_WRITE)
-                .open(&image_name1)?;
-    let image_name2 = query_full_process_image_name()?;
-
-    if image_name1 != image_name2 {
-        return Err(io::Error::new(io::ErrorKind::Other,
-                                  "executable moved while trying to lock it"));
-    }
-
-    Ok((image_name1, file))
-}
-
-// Get the executable filename for libbacktrace
-// This returns the path in the ANSI code page and a File which should remain open
-// for as long as the path should remain valid
-pub fn get_executable_filename() -> io::Result<(Vec<i8>, File)> {
-    let (executable, file) = lock_and_get_executable_filename()?;
-    let u16_executable = super::to_u16s(executable.into_os_string())?;
-    Ok((super::wide_char_to_multi_byte(c::CP_ACP, c::WC_NO_BEST_FIT_CHARS,
-                                       &u16_executable, true)?, file))
-}