Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_std addr2line #100

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ exclude = ["/benches/*", "/fixtures/*"]
travis-ci = { repository = "gimli-rs/addr2line" }

[dependencies]
gimli = "0.16"
fallible-iterator = "0.1"
object = "0.9"
intervaltree = "0.2"
smallvec = "0.6"
gimli = { version = "0.16", default-features = false }
fallible-iterator = { version = "=0.1.4", default-features = false }
object = { version = "0.9", default-features = false }
intervaltree = { version = "0.2", default-features = false }
smallvec = { version = "0.6", default-features = false }
lazycell = "1.0"
rustc-demangle = { version = "0.1", optional = true }
cpp_demangle = { version = "0.2", optional = true }
cpp_demangle = { version = "0.2", default-features = false, optional = true }

[dev-dependencies]
memmap = "0.6"
Expand All @@ -37,7 +37,9 @@ debug = true
debug = true

[features]
default = ["rustc-demangle", "cpp_demangle"]
default = ["std", "rustc-demangle", "cpp_demangle"]
std = ["gimli/std", "object/std", "cpp_demangle/std"]
nightly = ["gimli/alloc", "fallible-iterator/alloc"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call this alloc.


[[test]]
name = "output_equivalence"
Expand Down
24 changes: 22 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
//! wrapper also uses symbol table information provided by the `object` crate.
#![deny(missing_docs)]

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "nightly", feature(alloc))]

#[cfg(all(not(feature = "std"), not(feature = "nightly")))]
compile_error!("You must enable either the std or nightly feature");

#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
use core as std;

#[cfg(feature = "std")]
mod alloc {
use std::*;
use std::prelude::v1::*;
}

#[cfg(feature = "cpp_demangle")]
extern crate cpp_demangle;
extern crate fallible_iterator;
Expand All @@ -35,9 +52,11 @@ extern crate rustc_demangle;
extern crate smallvec;

use std::cmp::Ordering;
use std::borrow::Cow;
use alloc::borrow::Cow;
use std::u64;
use std::rc::Rc;
use alloc::rc::Rc;
use alloc::vec::Vec;
use alloc::string::{ToString, String};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group the alloc imports together.


use fallible_iterator::FallibleIterator;
use intervaltree::{Element, IntervalTree};
Expand Down Expand Up @@ -382,6 +401,7 @@ impl<R: gimli::Reader> FunctionName<R> {
/// Demangle a symbol name using the demangling scheme for the given language.
///
/// Returns `None` if demangling failed or is not required.
#[allow(unused_variables)]
pub fn demangle(name: &str, language: gimli::DwLang) -> Option<String> {
match language {
#[cfg(feature = "rustc-demangle")]
Expand Down