{"id":18016889,"url":"https://github.com/fitzgen/dwprod","last_synced_at":"2025-03-26T18:32:32.646Z","repository":{"id":25688138,"uuid":"104944744","full_name":"fitzgen/dwprod","owner":"fitzgen","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-19T21:22:34.000Z","size":16,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T11:59:40.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-26T22:36:20.000Z","updated_at":"2024-07-30T08:43:48.000Z","dependencies_parsed_at":"2022-07-27T05:32:03.213Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/dwprod","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fdwprod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fdwprod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fdwprod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fdwprod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/dwprod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245713147,"owners_count":20660353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T04:19:37.107Z","updated_at":"2025-03-26T18:32:32.349Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dwprod\n\nFind the `DW_AT_producer` for all compilation units within a shared library or\nexecutable.\n\n[![](https://docs.rs/dwprod/badge.svg)](https://docs.rs/dwprod/) [![](http://meritbadge.herokuapp.com/dwprod)](https://crates.io/crates/dwprod) [![](https://img.shields.io/crates/d/dwprod.png)](https://crates.io/crates/dwprod) [![Unix Build Status](https://travis-ci.org/fitzgen/dwprod.png?branch=master)](https://travis-ci.org/fitzgen/dwprod)\n\n#### What is `DW_AT_producer`?\n\nThe `DW_AT_producer` is an attribute within DWARF debug info that says what\ncompiler was used to create each compilation unit that ended up within a given\nshared library or executable.\n\n#### Usage\n\n##### As a Library\n\nFirst, add this to your `Cargo.toml`:\n\n```toml\n[dependencies.dwprod]\nversion = \"0.1.0\"\n# Do not build the command line `dwprod` executable.\ndefault-features = false\n```\n\nThen, import the `dwprod` crate and use it to iterate over `DW_AT_producer`\nvalues:\n\n```rust\nextern crate dwprod;\n\nfn try_main() -\u003e dwprod::Result\u003c()\u003e {\n    let opts = dwprod::Options::new(\"path/to/some/executable\");\n\n    opts.producers(|producers| {\n        while let Some(producer) = producers.next()? {\n            println!(\"Found DW_AT_producer = {}\", producer);\n        }\n\n        Ok(())\n    })?\n}\n\nfn main() {\n    if let Err(e) = try_main() {\n        eprintln!(\"Uh oh! {}\", e);\n        ::std::process::exit(1);\n    }\n}\n```\n\nThe [`fallible-iterator`](https://crates.io/crates/fallible-iterator) crate can\nalso be used to leverage iterator combinators like `map` and `filter`:\n\n```rust\nextern crate dwprod;\nextern crate fallible_iterator;\n\nuse fallible_iterator::FallibleIterator;\nuse std::path::Path;\n\nfn each_rustc_producer\u003cF\u003e(\n    shared_lib_or_exe: \u0026Path,\n    mut callback: F\n) -\u003e dwprod::Result\u003c()\u003e\nwhere\n    F: FnMut(String)\n{\n    let opts = dwprod::Options::new(shared_lib_or_exe);\n    opts.producers(|producers| {\n        producers\n            // Filter down to only the producers with \"rustc\" in their name.\n            .filter(|p| p.contains(\"rustc\"))\n            // Then map the given callback over each producer.\n            .map(\u0026mut callback)\n            // Finally, use `count` to force iteration.\n            .count()?;\n\n        Ok(())\n    })?\n}\n```\n\n##### As a Command Line Tool\n\nFirst, install via `cargo`:\n\n```commands\n$ cargo install dwprod\n```\n\nThen, run `dwprod path/to/shared/library/or/executable` to get a dump of all of\nthe `DW_AT_producer` values for each compilation unit within the given shared\nlibrary or executable.\n\nHere is the result of running `dwprod` on itself:\n\n```commands\n$ dwprod $(which dwprod)\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nclang LLVM (rustc version 1.22.0-nightly (088216fb9 2017-09-04))\nGNU C 4.8.5 -m64 -mtune=generic -march=x86-64 -g3 -O3 -O2 -O2 -std=gnu11 -fvisibility=hidden -funroll-loops -ffunction-sections -fdata-sections -fPIC\nGNU C 4.8.5 -m64 -mtune=generic -march=x86-64 -g3 -O3 -O2 -O2 -std=gnu11 -fvisibility=hidden -funroll-loops -ffunction-sections -fdata-sections -fPIC\nGNU C 4.8.5 -m64 -mtune=generic -march=x86-64 -g3 -O3 -O2 -O2 -std=gnu11 -fvisibility=hidden -funroll-loops -ffunction-sections -fdata-sections -fPIC\nGNU C 4.8.5 -m64 -mtune=generic -march=x86-64 -g3 -O3 -O2 -O2 -std=gnu11 -fvisibility=hidden -funroll-loops -ffunction-sections -fdata-sections -fPIC\n\u003ctruncated\u003e\n```\n\nFor more details about the `dwprod` command line tool, run `dwprod --help`.\n\nLicense: Apache-2.0/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fdwprod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Fdwprod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fdwprod/lists"}