Commit 7819497b authored by Luca Barbato's avatar Luca Barbato Committed by Thomas Daede
Browse files

Use the backtrace crate to report who is calling symbol

parent 65be320a
...@@ -14,6 +14,7 @@ rand = "0.4" ...@@ -14,6 +14,7 @@ rand = "0.4"
rustyline = "1" rustyline = "1"
y4m = "0.1" y4m = "0.1"
enum-iterator-derive = "0.1.1" enum-iterator-derive = "0.1.1"
backtrace = "0.3"
[build-dependencies] [build-dependencies]
cc = "1" cc = "1"
......
...@@ -274,6 +274,24 @@ impl Writer { ...@@ -274,6 +274,24 @@ impl Writer {
cdf[nsymbs] += (cdf[nsymbs] < 32) as u16; cdf[nsymbs] += (cdf[nsymbs] < 32) as u16;
} }
pub fn symbol(&mut self, s: u32, cdf: &mut [u16], nsymbs: usize) { pub fn symbol(&mut self, s: u32, cdf: &mut [u16], nsymbs: usize) {
use backtrace;
let mut depth = 3;
backtrace::trace(|frame| {
let ip = frame.ip();
depth -= 1;
if depth == 0 {
backtrace::resolve(ip, |symbol| {
if let Some(name) = symbol.name() {
eprintln!("Writing symbol {} from {}", s, name);
}
});
false
} else {
true
}
});
self.cdf(s, &cdf[..nsymbs]); self.cdf(s, &cdf[..nsymbs]);
Writer::update_cdf(cdf, s, nsymbs); Writer::update_cdf(cdf, s, nsymbs);
} }
......
#![allow(safe_extern_statics)] #![allow(safe_extern_statics)]
extern crate bitstream_io; extern crate bitstream_io;
extern crate backtrace;
extern crate byteorder; extern crate byteorder;
extern crate clap; extern crate clap;
extern crate libc; extern crate libc;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment