@@ -172,7 +172,7 @@ pub unsafe fn panic_print<PW: PanicWriter, C: Chip, PP: ProcessPrinter>(
172172 flush ( & mut writer) ;
173173 panic_banner ( & mut writer, panic_info) ;
174174
175- panic_resources . map ( |pr| {
175+ if let Some ( pr ) = panic_resources {
176176 let chip = pr. chip . take ( ) ;
177177 panic_cpu_state ( chip, & mut writer) ;
178178
@@ -184,10 +184,14 @@ pub unsafe fn panic_print<PW: PanicWriter, C: Chip, PP: ProcessPrinter>(
184184 use crate :: platform:: mpu:: MPU ;
185185 c. mpu ( ) . disable_app_mpu ( )
186186 } ) ;
187- pr. processes . take ( ) . map ( |p| {
187+ if let Some ( p ) = pr. processes . take ( ) {
188188 panic_process_info ( p, pr. printer . take ( ) , & mut writer) ;
189- } ) ;
190- } ) ;
189+ } else {
190+ let _ = writer. write_str ( "Processes List is not available\r \n " ) ;
191+ }
192+ } else {
193+ let _ = writer. write_str ( "Panic Resources are not available\r \n " ) ;
194+ }
191195 }
192196}
193197
@@ -240,7 +244,7 @@ pub unsafe fn panic_print_old<W: Write + IoWrite, C: Chip, PP: ProcessPrinter>(
240244 flush ( writer) ;
241245 panic_banner ( writer, panic_info) ;
242246
243- panic_resources . map ( |pr| {
247+ if let Some ( pr ) = panic_resources {
244248 let chip = pr. chip . take ( ) ;
245249 panic_cpu_state ( chip, writer) ;
246250
@@ -252,10 +256,14 @@ pub unsafe fn panic_print_old<W: Write + IoWrite, C: Chip, PP: ProcessPrinter>(
252256 use crate :: platform:: mpu:: MPU ;
253257 c. mpu ( ) . disable_app_mpu ( )
254258 } ) ;
255- pr. processes . take ( ) . map ( |p| {
259+ if let Some ( p ) = pr. processes . take ( ) {
256260 panic_process_info ( p, pr. printer . take ( ) , writer) ;
257- } ) ;
258- } ) ;
261+ } else {
262+ let _ = writer. write_str ( "Processes List is not available\r \n " ) ;
263+ }
264+ } else {
265+ let _ = writer. write_str ( "Panic Resources are not available\r \n " ) ;
266+ }
259267 }
260268}
261269
@@ -340,8 +348,12 @@ pub unsafe fn panic_banner<W: Write>(writer: &mut W, panic_info: &PanicInfo) {
340348///
341349/// **NOTE:** The supplied `writer` must be synchronous.
342350pub unsafe fn panic_cpu_state < W : Write , C : Chip > ( chip : Option < & ' static C > , writer : & mut W ) {
343- unsafe {
344- C :: print_state ( chip, writer) ;
351+ if chip. is_none ( ) {
352+ let _ = writer. write_str ( "\r \n Chip Information is not available\r \n " ) ;
353+ } else {
354+ unsafe {
355+ C :: print_state ( chip, writer) ;
356+ }
345357 }
346358}
347359
@@ -353,21 +365,27 @@ pub unsafe fn panic_process_info<PP: ProcessPrinter, W: Write>(
353365 process_printer : Option < & ' static PP > ,
354366 writer : & mut W ,
355367) {
356- process_printer. map ( |printer| {
357- // print data about each process
358- let _ = writer. write_fmt ( format_args ! ( "\r \n ---| App Status |---\r \n " ) ) ;
359- for slot in processes {
360- slot. proc . get ( ) . map ( |process| {
361- // Print the memory map and basic process info.
362- //
363- // Because we are using a synchronous printer we do not need to
364- // worry about looping on the print function.
365- printer. print_overview ( process, & mut BinaryToWriteWrapper :: new ( writer) , None ) ;
366- // Print all of the process details.
367- process. print_full_process ( writer) ;
368- } ) ;
368+ if processes. iter ( ) . filter ( |p| p. get ( ) . is_some ( ) ) . count ( ) > 0 {
369+ if let Some ( printer) = process_printer {
370+ // print data about each process
371+ let _ = writer. write_fmt ( format_args ! ( "\r \n ---| App Status |---\r \n " ) ) ;
372+ for slot in processes {
373+ slot. proc . get ( ) . map ( |process| {
374+ // Print the memory map and basic process info.
375+ //
376+ // Because we are using a synchronous printer we do not need to
377+ // worry about looping on the print function.
378+ printer. print_overview ( process, & mut BinaryToWriteWrapper :: new ( writer) , None ) ;
379+ // Print all of the process details.
380+ process. print_full_process ( writer) ;
381+ } ) ;
382+ }
383+ } else {
384+ let _ = writer. write_str ( "\r \n Process Printer is not available\r \n " ) ;
369385 }
370- } ) ;
386+ } else {
387+ let _ = writer. write_str ( "\r \n No loaded processes\r \n " ) ;
388+ }
371389}
372390
373391/// Blinks a recognizable pattern forever.
0 commit comments