Pārlūkot izejas kodu

Allow dwarf expr support to be turned off

Gary Guo 3 gadi atpakaļ
vecāks
revīzija
a942d60e1a
3 mainītis faili ar 13 papildinājumiem un 2 dzēšanām
  1. 2 1
      Cargo.toml
  2. 1 1
      cdylib/Cargo.toml
  3. 10 0
      src/frame.rs

+ 2 - 1
Cargo.toml

@@ -16,8 +16,9 @@ spin = { version = "0.9", default-features = false, features = ["mutex", "spin_m
 alloc = []
 fde-phdr = ["libc"]
 fde-registry = ["alloc"]
+dwarf-expr = []
 system-alloc = []
-default = ["fde-phdr"]
+default = ["dwarf-expr", "fde-phdr", "fde-registry"]
 
 [profile.dev]
 # Must be turned on due to Rust bug https://github.com/rust-lang/rust/issues/50007

+ 1 - 1
cdylib/Cargo.toml

@@ -8,5 +8,5 @@ edition = "2018"
 crate-type = ["cdylib"]
 
 [dependencies]
-unwind = { path = "../", features = ["fde-registry"] }
+unwind = { path = "../", features = ["system-alloc"] }
 libc = "0.2"

+ 10 - 0
src/frame.rs

@@ -44,6 +44,7 @@ impl Frame {
         Ok(Some(Self { fde_result, row }))
     }
 
+    #[cfg(feature = "dwarf-expr")]
     fn evaluate_expression(
         &self,
         ctx: &Context,
@@ -83,6 +84,15 @@ impl Frame {
         )
     }
 
+    #[cfg(not(feature = "dwarf-expr"))]
+    fn evaluate_expression(
+        &self,
+        ctx: &Context,
+        expr: Expression<StaticSlice>,
+    ) -> Result<usize, gimli::Error> {
+        Err(gimli::Error::UnsupportedEvaluation)
+    }
+
     pub fn unwind(&self, ctx: &Context) -> Result<Context, gimli::Error> {
         let row = &self.row;
         let mut new_ctx = ctx.clone();