Skip to content

Commit

Permalink
introduce python bindings, lots of refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
zolutal committed Jan 12, 2024
1 parent 8ee4181 commit d6eddd2
Show file tree
Hide file tree
Showing 14 changed files with 1,137 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
*.egg-info
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ readme = "README.md"
keywords = [ "elf", "debug", "dwarf"]
categories = ["Debugging"]

[lib]
name = "dwat"
crate-type = ["rlib", "cdylib"]

[dependencies]
gimli = { version = "0.27.0", default-features = false, features = ["read"] }
memmap2 = { version = "0.5.5" }
Expand All @@ -20,11 +24,14 @@ clap = { version = "4.2", features = ["derive"] }
thiserror = "1.0.50"
anyhow = "1.0.75"
tempfile = "3.8.1"
libc = { version = "0.2.152", optional = true }
pyo3 = { version = "0.20.2", features = ["extension-module"], optional = true }

[features]
default = ["std-object", "fallible-iterator", "smallvec"]
std = ["gimli/std"]
std-object = ["std", "object", "object/std", "object/compression", "gimli/endian-reader"]
python = ["pyo3", "libc"]

[profile.release]
codegen-units = 1
Expand Down
2 changes: 2 additions & 0 deletions Manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include pyproject.toml Cargo.toml
recursive-include src *
2 changes: 2 additions & 0 deletions examples/dump_verbose.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use memmap2::Mmap;
use std::fs::File;

use dwat::prelude::*;
use dwat::Dwarf;

fn main() -> anyhow::Result<()> {
Expand Down
6 changes: 4 additions & 2 deletions examples/lookup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use dwat::Dwarf;
use std::fs::File;
use memmap2::Mmap;

use dwat::prelude::*;
use dwat::Dwarf;

fn main() -> anyhow::Result<()> {
let mut args = std::env::args().skip(1);
let struct_name = args.next().unwrap_or_else(|| {
Expand All @@ -20,7 +22,7 @@ fn main() -> anyhow::Result<()> {

let file = File::open(path).unwrap();
let mmap = unsafe { Mmap::map(&file) }.unwrap();
let mut dwarf = Dwarf::load(&*mmap)?;
let dwarf = Dwarf::load(&*mmap)?;

// some good test cases:
// compat_rusage
Expand Down
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
features = ["pyo3/extension-module", "python"]

[project]
name = "dwat"
version = "0.5.0"
description = "Library for accessing DWARF debug information"
readme = "README.md"
url = "https://github.com/zolutal/dwat"
requires-python = ">=3.8"
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Rust",
"Operating System :: POSIX"
]
license = {file = "LICENSE"}
authors = [
{name = "Justin Miller"}
]

[project.urls]
homepage = "github.com/zolutal/dwat"
repository = "github.com/zolutal/dwat"

Loading

0 comments on commit d6eddd2

Please sign in to comment.