Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-raillard-arm committed Dec 22, 2023
1 parent 7f2c49a commit 0083c3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
30 changes: 2 additions & 28 deletions tools/analysis/traceevent/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,6 @@ impl<'i, 'h, 'edm, InitDescF, T> EventVisitor<'i, 'h, 'edm, InitDescF, T>
where
InitDescF: 'h + FnMut(&'h Header, &'h EventDesc) -> T,
{
// pub fn visit_fields<State, F>(&mut self, init: State, mut f: F) -> Result<State, BufferError>
// where
// F: FnMut(State, (&FieldFmt, Value<'_>)) -> Result<State, BufferError>,
// {
// let data = &self.data;

// let event_id = self.event_id()?;
// let event_desc = self
// .desc_map
// .lookup(event_id)
// .ok_or_else(|| BufferError::EventDescriptorNotFound(event_id))?;

// let struct_fmt = event_desc.struct_fmt()?;

// let mut state = init;
// for desc in &struct_fmt.fields {
// let decl = &desc.declaration;
// let offset = desc.offset;
// let size = desc.size;
// let field_data = &data[offset..(offset + size)];
// // eprintln!(" FIELD {:?} SIZE={size} OFFSET={offset} DATA={field_data:?}", &decl.identifier);

// let val = decl.typ.make_decoder(self.header)?(field_data, self.scratch)?;
// state = f(state, (desc, val))?;
// }
// Ok(state)
// }

pub fn fields<'a>(
&'a self,
) -> Result<
Expand Down Expand Up @@ -274,6 +246,8 @@ where
Ok(&desc.name)
}

// FIXME: is it sound to derive that &mut EventDescMap from an &self ? Could this lead to
// creating multiple &mut ref alive at the same time ?
fn desc_map(&'edm self) -> &'edm mut EventDescMap<'h, T, InitDescF> {
// SAFETY: This comes from an &'edm mut reference in the first place, and since
// EventVisitor::new() requires an &'edm mut EventDescMap, we cannot accidentally
Expand Down
10 changes: 4 additions & 6 deletions tools/analysis/traceevent/src/cparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,12 @@ impl Expr {
pub(crate) fn is_record_field(&self, field: &str) -> bool {
// This must match the record_field() definition
if let Expr::MemberAccess(expr, _field) = self {
if _field == &field {
if _field == field {
if let Expr::Deref(expr) = (*expr).deref() {
if let Expr::Addr(expr) = (*expr).deref() {
if let Expr::Variable(typ, name) = (*expr).deref() {
if let Type::Variable(name2) = typ {
if name == "REC" && name2 == "REC" {
return true;
}
if let Expr::Variable(Type::Variable(name), name2) = (*expr).deref() {
if name == "REC" && name2 == "REC" {
return true;
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions tools/analysis/traceevent/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,6 @@ pub enum HeaderError {
#[error("Could not load section as it is too large: {0} bytes")]
SectionTooLarge(u64),

#[error("Could not load page size as it is too large: {0} bytes")]
PageSizeTooLarge(u32),

#[error("Could not load header page size as it is too large: {0} bytes")]
PageHeaderSizeTooLarge(FileSize),

Expand Down Expand Up @@ -1692,9 +1689,7 @@ where

let _long_size: u8 = input.read_int(endianness)?;
let page_size: u32 = input.read_int(endianness)?;
let page_size: FileSize = page_size
.try_into()
.map_err(|_| HeaderError::PageSizeTooLarge(page_size))?;
let page_size: FileSize = page_size.into();

Ok((abi, page_size))
}
Expand Down

0 comments on commit 0083c3f

Please sign in to comment.