]> git.proxmox.com Git - cargo.git/blobdiff - vendor/backtrace/src/symbolize/gimli.rs
New upstream version 0.33.0
[cargo.git] / vendor / backtrace / src / symbolize / gimli.rs
index 2da584116421fae01b2811969c0fc4e6e8135bc1..464bd99ecca8c5d04eac8e449bcac6caacf01718 100644 (file)
@@ -7,20 +7,22 @@ use std::cell::RefCell;
 use std::env;
 use std::fs::File;
 use std::mem;
-use std::os::raw::c_void;
-use std::path::{Path, PathBuf};
+use libc::c_void;
+use std::path::PathBuf;
 use std::u32;
+use std::prelude::v1::*;
 
 use SymbolName;
+use types::BytesOrWideString;
 
 const MAPPINGS_CACHE_SIZE: usize = 4;
 
-type Dwarf<'map> = addr2line::Context<gimli::EndianBuf<'map, gimli::RunTimeEndian>>;
+type Dwarf = addr2line::Context<gimli::EndianRcSlice<gimli::RunTimeEndian>>;
 type Symbols<'map> = object::SymbolMap<'map>;
 
 struct Mapping {
+    dwarf: Dwarf,
     // 'static lifetime is a lie to hack around lack of support for self-referential structs.
-    dwarf: Dwarf<'static>,
     symbols: Symbols<'static>,
     _map: Mmap,
 }
@@ -35,7 +37,7 @@ impl Mapping {
             let dwarf = addr2line::Context::new(&object).ok()?;
             let symbols = object.symbol_map();
             // Convert to 'static lifetimes.
-            unsafe { (mem::transmute(dwarf), mem::transmute(symbols)) }
+            (dwarf, unsafe { mem::transmute(symbols) })
         };
         Some(Mapping {
             dwarf,
@@ -182,14 +184,14 @@ pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) {
 
 pub struct Symbol {
     addr: usize,
-    file: Option<PathBuf>,
+    file: Option<String>,
     line: Option<u64>,
     name: Option<String>,
 }
 
 impl Symbol {
     fn new(addr: usize,
-           file: Option<PathBuf>,
+           file: Option<String>,
            line: Option<u64>,
            name: Option<String>)
            -> Symbol {
@@ -209,8 +211,8 @@ impl Symbol {
         Some(self.addr as *mut c_void)
     }
 
-    pub fn filename(&self) -> Option<&Path> {
-        self.file.as_ref().map(|f| f.as_ref())
+    pub fn filename_raw(&self) -> Option<BytesOrWideString> {
+        self.file.as_ref().map(|f| BytesOrWideString::Bytes(f.as_bytes()))
     }
 
     pub fn lineno(&self) -> Option<u32> {