Skip to content

Commit

Permalink
Merge pull request #162 from benfred/libunwind
Browse files Browse the repository at this point in the history
Default to using libunwind-ptrace for native unwinding
  • Loading branch information
benfred authored Sep 9, 2019
2 parents 6d05c68 + 3586197 commit 8326c6d
Show file tree
Hide file tree
Showing 26 changed files with 383 additions and 2,216 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ fn main() {
// copied from remoteprocess/build.rs because I couldn't find a way to share this
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_ref() {
"windows" => println!("cargo:rustc-cfg=unwind"),
"macos" => {
// OSX native profiling doesn't work all that well right now, and
// its broken enough that I don't want to support it at the moment.
// only enable if a specific env variable is set
if std::env::var("PYSPY_ALLOW_NATIVE_PROFILING").is_ok() {
println!("cargo:rustc-cfg=unwind");
}
},
"linux" => {
// We only support native unwinding on x86_64 linux
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64"{
Expand Down
160 changes: 0 additions & 160 deletions remoteprocess/Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion remoteprocess/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license = "GPL-3.0"
build="build.rs"

[dependencies]
gimli = "0.19.0"
libc = "0.2"
log = "0.4"
proc-maps = "0.1.6"
Expand Down
10 changes: 2 additions & 8 deletions remoteprocess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,5 @@ processors, or from FreeBSD.
## Credits

This crate heavily relies on the [gimli](https://github.com/gimli-rs/gimli) project. Gimli is an
amazing tool for parsing DWARF debugging information, and we are using it here for getting
stack traces and looking up filename and line numbers given an instruction pointeer.

This crate includes code that was originally written as part of
[backtrace-rs](https://github.com/alexcrichton/backtrace-rs). In particular, we are using the OSX
symbolication code from backtrace-rs, which was modified here to support working with remote processes. This also requires a utility module ([dylib.rs](https://github.com/alexcrichton/backtrace-rs/blob/master/src/dylib.rs)) from
backtrace-rs to dynamically load the core symbolication framework on OSX, and which is also being
used on linux to load libunwind-ptrace if it is installed for a fallback stack unwinder. backtrace-rs is licensed under the [MIT license](https://opensource.org/licenses/MIT), a copy of which is included in the relevant files here.
amazing tool for parsing DWARF debugging information, and we are using it here for looking up filename
and line numbers given an instruction pointeer.
8 changes: 0 additions & 8 deletions remoteprocess/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ use std::env;
fn main() {
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_ref() {
"windows" => println!("cargo:rustc-cfg=unwind"),
"macos" => {
// OSX native profiling doesn't work all that well right now, and
// its broken enough that I don't want to support it at the moment.
// only enable if a specific env variable is set
if std::env::var("PYSPY_ALLOW_NATIVE_PROFILING").is_ok() {
println!("cargo:rustc-cfg=unwind");
}
},
"linux" => {
// We only support native unwinding on x86_64 linux
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64"{
Expand Down
3 changes: 2 additions & 1 deletion remoteprocess/examples/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn get_backtrace(pid: remoteprocess::Pid) -> Result<(), remoteprocess::Error> {
let process = remoteprocess::Process::new(pid)?;
// Create a stack unwind object, and use it to get the stack for each thread
let unwinder = process.unwinder()?;
let symbolicator = process.symbolicator()?;
for thread in process.threads()?.iter() {
println!("Thread {} - {}", thread.id()?, if thread.active()? { "running" } else { "idle" });

Expand All @@ -24,7 +25,7 @@ fn get_backtrace(pid: remoteprocess::Pid) -> Result<(), remoteprocess::Error> {

// Lookup the current stack frame containing a filename/function/linenumber etc
// for the current address
unwinder.symbolicate(ip, true, &mut |sf| {
symbolicator.symbolicate(ip, true, &mut |sf| {
println!("\t{}", sf);
})?;
}
Expand Down
82 changes: 0 additions & 82 deletions remoteprocess/examples/validate_libunwind.rs

This file was deleted.

Loading

0 comments on commit 8326c6d

Please sign in to comment.