Skip to content

Commit

Permalink
Filter Graphviz output by function name instead of file name.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Sep 19, 2017
1 parent c5f13b1 commit 653e452
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cov/examples/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn run() -> Result<()> {

let matches = clap_app!(graphviz =>
(@arg analyze: -a --analyze "Produce graph after analysis")
(@arg filter: -f --filter +takes_value "Only produce graphs from this source file")
(@arg filter: -f --filter +takes_value "Only produce graphs from this function")
(@arg files: <FILE>... "*.gcno and *.gcda files to form the graph")
).get_matches();

Expand Down
6 changes: 3 additions & 3 deletions cov/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,11 @@ impl Graph {
///
/// This is mainly intended for debugging.
///
/// Only functions with filename matching the input `filename` symbol will be printed. If the `filename` is
/// Only functions with name matching the input `function_name` symbol will be printed. If the `function_name` is
/// [`UNKNOWN_SYMBOL`], however, all nodes will be printed.
///
/// [`UNKNOWN_SYMBOL`]: ../intern/const.UNKNOWN_SYMBOL.html
pub fn write_dot<W: io::Write>(&self, filename: Symbol, mut writer: W) -> io::Result<()> {
pub fn write_dot<W: io::Write>(&self, function_name: Symbol, mut writer: W) -> io::Result<()> {
fn count_to_color_label(count: Option<u64>) -> (&'static str, Cow<'static, str>) {
match count {
Some(0) => ("red", Cow::Borrowed("0")),
Expand All @@ -919,7 +919,7 @@ impl Graph {
let mut allowed_nodes = HashSet::new();
for (ni, block) in self.graph.node_references() {
let function = &self[block.index];
if filename != UNKNOWN_SYMBOL && filename != function.source.map(|a| a.filename).unwrap_or(UNKNOWN_SYMBOL) {
if function_name != UNKNOWN_SYMBOL && function_name != function.source.map(|a| a.name).unwrap_or(UNKNOWN_SYMBOL) {
continue;
}
allowed_nodes.insert(ni);
Expand Down

0 comments on commit 653e452

Please sign in to comment.