Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI bug fixes, improvements, and color #315

Merged
merged 13 commits into from
Jul 31, 2017
Prev Previous commit
Next Next commit
project: add region method to return a project's region
  • Loading branch information
m4b committed Jul 30, 2017
commit 08bc43690c776fc33752b6b2d5959fc6c222101b
3 changes: 1 addition & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use panopticon_amd64 as amd64;
use panopticon_analysis::pipeline;
use panopticon_avr as avr;
use panopticon_core::{Machine, Function, loader};
use panopticon_graph_algos::GraphTrait;
use std::path::Path;
use std::result;
use std::sync::Arc;
Expand Down Expand Up @@ -86,7 +85,7 @@ fn disassemble(args: Args) -> Result<()> {
let filter = Filter { name: args.function_filter, addr: args.address_filter.map(|addr| u64::from_str_radix(&addr, 16).unwrap()) };
let (mut proj, machine) = loader::load(Path::new(&binary))?;
let maybe_prog = proj.code.pop();
let reg = proj.data.dependencies.vertex_label(proj.data.root).unwrap().clone();
let reg = proj.region().clone();

if let Some(prog) = maybe_prog {
let prog = Arc::new(prog);
Expand Down
7 changes: 7 additions & 0 deletions core/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


use {CallGraphRef, Function, Program, Region, Result, World};
use panopticon_graph_algos::GraphTrait;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use flate2::Compression;
use flate2::read::ZlibDecoder;
Expand Down Expand Up @@ -63,6 +64,12 @@ impl Project {
}
}

/// Returns this project's root Region
pub fn region(&self) -> &Region {
// this cannot fail because World::new guarantees that data.root = r
self.data.dependencies.vertex_label(self.data.root).unwrap()
}

/// Reads a serialized project from disk.
pub fn open(p: &Path) -> Result<Project> {
let mut fd = match File::open(p) {
Expand Down
2 changes: 1 addition & 1 deletion qt/src/singleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Panopticon {
}
} else if let Ok((mut proj, machine)) = loader::load(&Path::new(&path)) {
let maybe_prog = proj.code.pop();
let reg = proj.data.dependencies.vertex_label(proj.data.root).unwrap().clone();
let reg = proj.region().clone();

if let Some(prog) = maybe_prog {
let prog = ::std::sync::Arc::new(prog);
Expand Down