• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use super::prelude::*;
2 use crate::target::ext::tracepoints::BufferShape;
3 use crate::target::ext::tracepoints::TraceBufferConfig;
4 
5 #[derive(Debug)]
6 pub struct QTBuffer(pub TraceBufferConfig);
7 
8 impl ParseCommand<'_> for QTBuffer {
9     #[inline(always)]
from_packet(buf: PacketBuf<'_>) -> Option<Self>10     fn from_packet(buf: PacketBuf<'_>) -> Option<Self> {
11         match buf.into_body() {
12             [b':', body @ ..] => {
13                 let mut s = body.splitn_mut(2, |b| *b == b':');
14                 let opt = s.next()?;
15                 // Clippy incorrect thinks this as_ref isn't needed, but it is.
16                 #[allow(clippy::useless_asref)]
17                 match opt.as_ref() {
18                     b"circular" => {
19                         let shape = s.next()?;
20                         Some(QTBuffer(TraceBufferConfig::Shape(match shape {
21                             [b'1'] => Some(BufferShape::Circular),
22                             [b'0'] => Some(BufferShape::Linear),
23                             _ => None,
24                         }?)))
25                     }
26                     b"size" => {
27                         let size = s.next()?;
28                         Some(QTBuffer(TraceBufferConfig::Size(match size {
29                             [b'-', b'1'] => None,
30                             i => Some(decode_hex(i).ok()?),
31                         })))
32                     }
33                     _ => None,
34                 }
35             }
36             _ => None,
37         }
38     }
39 }
40