crates/dwarves-tune-graph/src/srcgraph/mod.rs
//! The source-level graph (RED: not yet).
use std::path::Path;
use serde::{Deserialize, Serialize};
use crate::{Error, Graph};
/// Which libc the program links (the syscall table differs).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum Libc {
#[default]
Glibc,
Musl,
}
/// How to walk the source graph.
#[derive(Clone, Debug, Default)]
pub struct SrcOptions {
pub libc: Libc,
/// Only the given entries (no default `main`).
pub only_entries: bool,
}
/// One call edge, the warehouse `call_edges` row shape (`CallEdgeRow`).
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Edge {
pub crate_name: String,
pub caller_path: String,
pub callee_ident: String,
pub call_kind: String,
pub file: String,
pub line: u32,
}
/// Scan a workspace's Rust sources into call edges.
pub fn scan(_workspace: &Path) -> Result<Vec<Edge>, Error> {
Ok(Vec::new())
}
/// The possible syscalls from call edges.
pub fn analyze_edges(_edges: &[Edge], _entries: &[String], _opts: &SrcOptions) -> Result<Graph, Error> {
Err(Error::NoEntry("RED: not yet".into()))
}
/// The possible syscalls of a workspace's Rust programs.
pub fn analyze(workspace: &Path, entries: &[String], opts: &SrcOptions) -> Result<Graph, Error> {
analyze_edges(&scan(workspace)?, entries, opts)
}