iptr_decoder/packet_handler/
log.rs1use core::{convert::Infallible, num::NonZero};
18
19use crate::{DecoderContext, HandlePacket, IpReconstructionPattern, PtwPayload};
20
21#[derive(Default)]
25pub struct PacketHandlerRawLogger {}
26
27impl HandlePacket for PacketHandlerRawLogger {
28 type Error = Infallible;
30
31 fn at_decode_begin(&mut self) -> Result<(), Self::Error> {
32 log::trace!("Decode begin!");
33 Ok(())
34 }
35
36 fn on_short_tnt_packet(
37 &mut self,
38 _context: &DecoderContext,
39 packet_byte: NonZero<u8>,
40 highest_bit: u32,
41 ) -> Result<(), Self::Error> {
42 log::trace!(
43 "[Short TNT packet]\tpacket byte: {packet_byte:#010b}\thighest bit: {highest_bit}"
44 );
45 Ok(())
46 }
47
48 fn on_long_tnt_packet(
49 &mut self,
50 _context: &DecoderContext,
51 packet_bytes: NonZero<u64>,
52 highest_bit: u32,
53 ) -> Result<(), Self::Error> {
54 log::trace!(
55 "[Long TNT packet]\tpacket bytes: {packet_bytes:#050b}\thighest bit: {highest_bit}"
56 );
57 Ok(())
58 }
59
60 fn on_tip_packet(
61 &mut self,
62 _context: &DecoderContext,
63 ip_reconstruction_pattern: IpReconstructionPattern,
64 ) -> Result<(), Self::Error> {
65 log::trace!("[TIP packet]\tip reconstruction: {ip_reconstruction_pattern}");
66 Ok(())
67 }
68
69 fn on_tip_pgd_packet(
70 &mut self,
71 _context: &DecoderContext,
72 ip_reconstruction_pattern: IpReconstructionPattern,
73 ) -> Result<(), Self::Error> {
74 log::trace!("[TIP.PGD packet]\tip reconstruction: {ip_reconstruction_pattern}");
75 Ok(())
76 }
77
78 fn on_tip_pge_packet(
79 &mut self,
80 _context: &DecoderContext,
81 ip_reconstruction_pattern: IpReconstructionPattern,
82 ) -> Result<(), Self::Error> {
83 log::trace!("[TIP.PGE packet]\tip reconstruction: {ip_reconstruction_pattern}");
84 Ok(())
85 }
86
87 fn on_fup_packet(
88 &mut self,
89 _context: &DecoderContext,
90 ip_reconstruction_pattern: IpReconstructionPattern,
91 ) -> Result<(), Self::Error> {
92 log::trace!("[FUP packet]\tip reconstruction: {ip_reconstruction_pattern}");
93 Ok(())
94 }
95
96 fn on_pad_packet(&mut self, _context: &DecoderContext) -> Result<(), Self::Error> {
97 log::trace!("[PAD packet]");
98 Ok(())
99 }
100
101 fn on_cyc_packet(
102 &mut self,
103 _context: &DecoderContext,
104 cyc_packet: &[u8],
105 ) -> Result<(), Self::Error> {
106 log::trace!(
107 "[CYC packet]\t{}",
108 cyc_packet
109 .iter()
110 .map(|byte| alloc::format!("{byte:#010b}"))
111 .collect::<alloc::vec::Vec<_>>()
112 .join(", ")
113 );
114 Ok(())
115 }
116
117 fn on_mode_packet(
118 &mut self,
119 _context: &DecoderContext,
120 leaf_id: u8,
121 mode: u8,
122 ) -> Result<(), Self::Error> {
123 log::trace!("[MODE packet]\tLeaf ID: {leaf_id:#05b}\tmode:{mode:#07b}");
124 Ok(())
125 }
126
127 fn on_mtc_packet(
128 &mut self,
129 _context: &DecoderContext,
130 ctc_payload: u8,
131 ) -> Result<(), Self::Error> {
132 log::trace!("[MTC packet]\tCTC: {ctc_payload:#010b}");
133 Ok(())
134 }
135
136 fn on_tsc_packet(
137 &mut self,
138 _context: &DecoderContext,
139 tsc_value: u64,
140 ) -> Result<(), Self::Error> {
141 log::trace!("[TSC packet]\tTSC: {tsc_value:#066b}");
142 Ok(())
143 }
144
145 fn on_cbr_packet(
146 &mut self,
147 _context: &DecoderContext,
148 core_bus_ratio: u8,
149 ) -> Result<(), Self::Error> {
150 log::trace!("[CBR packet]\tCore:Bus Ratio: {core_bus_ratio:#010b}");
151 Ok(())
152 }
153
154 fn on_tma_packet(
155 &mut self,
156 _context: &DecoderContext,
157 ctc: u16,
158 fast_counter: u8,
159 fc8: bool,
160 ) -> Result<(), Self::Error> {
161 log::trace!(
162 "[TMA packet]\tCTC: {ctc:#018b}\tFast Counter: {fast_counter:#010b}\tFC8: {fc8}"
163 );
164 Ok(())
165 }
166
167 fn on_vmcs_packet(
168 &mut self,
169 _context: &DecoderContext,
170 vmcs_pointer: u64,
171 ) -> Result<(), Self::Error> {
172 log::trace!("[VMCS packet]\tVMCS Pointer: {vmcs_pointer:#x}");
173 Ok(())
174 }
175
176 fn on_ovf_packet(&mut self, _context: &DecoderContext) -> Result<(), Self::Error> {
177 log::trace!("[OVF packet]");
178 Ok(())
179 }
180
181 fn on_psb_packet(&mut self, _context: &DecoderContext) -> Result<(), Self::Error> {
182 log::trace!("[PSB packet]");
183 Ok(())
184 }
185
186 fn on_psbend_packet(&mut self, _context: &DecoderContext) -> Result<(), Self::Error> {
187 log::trace!("[PSBEND packet]");
188 Ok(())
189 }
190
191 fn on_trace_stop_packet(&mut self, _context: &DecoderContext) -> Result<(), Self::Error> {
192 log::trace!("[TRACE STOP packet]");
193 Ok(())
194 }
195
196 fn on_pip_packet(
197 &mut self,
198 _context: &DecoderContext,
199 cr3: u64,
200 rsvd_nr: bool,
201 ) -> Result<(), Self::Error> {
202 log::trace!("[PIP packet]\tCR3: {cr3:#x}\tRSVD.NR: {rsvd_nr}");
203 Ok(())
204 }
205
206 fn on_mnt_packet(
207 &mut self,
208 _context: &DecoderContext,
209 payload: u64,
210 ) -> Result<(), Self::Error> {
211 log::trace!("[MNT packet]\tPayload: {payload:#x}");
212 Ok(())
213 }
214
215 fn on_ptw_packet(
216 &mut self,
217 _context: &DecoderContext,
218 ip_bit: bool,
219 payload: PtwPayload,
220 ) -> Result<(), Self::Error> {
221 log::trace!("[PTW packet]\tIP bit: {ip_bit}\tPayload: {payload}");
222 Ok(())
223 }
224
225 fn on_exstop_packet(
226 &mut self,
227 _context: &DecoderContext,
228 ip_bit: bool,
229 ) -> Result<(), Self::Error> {
230 log::trace!("[EXSTOP packet]\tIP bit: {ip_bit}");
231 Ok(())
232 }
233
234 fn on_mwait_packet(
235 &mut self,
236 _context: &DecoderContext,
237 mwait_hints: u8,
238 ext: u8,
239 ) -> Result<(), Self::Error> {
240 log::trace!("[MWAIT packet]\tMWAIT hints: {mwait_hints:#010b}\tEXT: {ext:#010b}");
241 Ok(())
242 }
243
244 fn on_pwre_packet(
245 &mut self,
246 _context: &DecoderContext,
247 hw: bool,
248 resolved_thread_c_state: u8,
249 resolved_thread_sub_c_state: u8,
250 ) -> Result<(), Self::Error> {
251 log::trace!(
252 "[PWRE packet]\tHW: {hw}\tResolved Thread C-State: {resolved_thread_c_state:#010b}\tResolved Thread Sub C-State: {resolved_thread_sub_c_state:#010b}"
253 );
254 Ok(())
255 }
256
257 fn on_pwrx_packet(
258 &mut self,
259 _context: &DecoderContext,
260 last_core_c_state: u8,
261 deepest_core_c_state: u8,
262 wake_reason: u8,
263 ) -> Result<(), Self::Error> {
264 log::trace!(
265 "[PWRX packet]\tLast Core C-State: {last_core_c_state:#010b}\tDeepest Core C-State: {deepest_core_c_state:#010b}\tWake Reason: {wake_reason:#010b}"
266 );
267 Ok(())
268 }
269
270 fn on_evd_packet(
271 &mut self,
272 _context: &DecoderContext,
273 r#type: u8,
274 payload: u64,
275 ) -> Result<(), Self::Error> {
276 log::trace!("[EVD packet]\tType: {type:#010b}\tPayload: {payload:#x}");
277 Ok(())
278 }
279
280 fn on_cfe_packet(
281 &mut self,
282 _context: &DecoderContext,
283 ip_bit: bool,
284 r#type: u8,
285 vector: u8,
286 ) -> Result<(), Self::Error> {
287 log::trace!("[CFE packet]\tIP bit: {ip_bit}\tType: {type:#010b}\tVector: {vector:#010b}");
288 Ok(())
289 }
290}