{"id":17219351,"url":"https://github.com/andreafioraldi/sanitizer_stacktrace_rs","last_synced_at":"2025-04-13T23:38:49.783Z","repository":{"id":86885235,"uuid":"445203041","full_name":"andreafioraldi/sanitizer_stacktrace_rs","owner":"andreafioraldi","description":"A Rust crate to generate backtraces using the LLVM codebase","archived":false,"fork":false,"pushed_at":"2022-01-06T16:07:21.000Z","size":31,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T13:51:12.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/andreafioraldi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-06T14:42:51.000Z","updated_at":"2025-02-22T05:43:33.000Z","dependencies_parsed_at":"2023-04-20T21:03:26.169Z","dependency_job_id":null,"html_url":"https://github.com/andreafioraldi/sanitizer_stacktrace_rs","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/andreafioraldi%2Fsanitizer_stacktrace_rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Fsanitizer_stacktrace_rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Fsanitizer_stacktrace_rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafioraldi%2Fsanitizer_stacktrace_rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreafioraldi","download_url":"https://codeload.github.com/andreafioraldi/sanitizer_stacktrace_rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799202,"owners_count":21163396,"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-15T03:49:41.058Z","updated_at":"2025-04-13T23:38:49.771Z","avatar_url":"https://github.com/andreafioraldi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sanitizer_stacktrace_rs\nA Rust crate to generate backtraces using the LLVM codebase\n\n## Example\n\nYou can get a trace of raw addresses from the current context using\n\n```rust\nuse sanitizer_stacktrace::*;\n\nlet mut st = Stacktrace::new();\nst.unwind(STACK_TRACE_MAX);\nfor addr in st.trace() {\n    println!(\"{:#x}\", previous_pc(*addr));\n}\n```\n\nTo get a symbolized trace, use `symbolize`\n\n```rust\nuse sanitizer_stacktrace::*;\n\nlet mut st = Stacktrace::new();\nst.unwind(STACK_TRACE_MAX);\nst.symbolize(|addr, sym| {\n    println!(\n        \"0x{:x}\\t{}\",\n        addr,\n        sym.name().map(|x| x.as_str().unwrap()).unwrap_or(\"\")\n    );\n});\n```\n\nYou can also generate a stacktrace startign from specific values of PC and BP, like in a signal handler\n\n```rust\npub unsafe fn signal_handler(_sig: c_int, _info: siginfo_t, ctx: *mut ucontext_t) {\n    let mut st = Stacktrace::new();\n    st.unwind_from(\n        STACK_TRACE_MAX,\n        a.uc_mcontext.gregs[REG_RIP as usize] as usize,\n        a.uc_mcontext.gregs[REG_RBP as usize] as usize,\n        con as *const c_void,\n    );\n    for addr in st.trace() {\n        println!(\"{:#x}\", previous_pc(*addr));\n    }\n\n    std::process::exit(1);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafioraldi%2Fsanitizer_stacktrace_rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreafioraldi%2Fsanitizer_stacktrace_rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafioraldi%2Fsanitizer_stacktrace_rs/lists"}