debugger: CLI panics because of flashing progress
@@ -1144,6 +1144,8 @@ impl Debugger {
download_options.keep_unwritten_bytes =
self.debugger_options.restore_unwritten_bytes;
download_options.do_chip_erase = self.debugger_options.full_chip_erase;
+ let flash_result = match debug_adapter.adapter_type() {
+ DebugAdapterType::DapClient => {
let rc_debug_adapter = Rc::new(RefCell::new(debug_adapter));
let rc_debug_adapter_clone = rc_debug_adapter.clone();
let flash_result = {
@@ -1165,7 +1167,8 @@ impl Debugger {
fill_size_done: 0,
}));
- let flash_progress = if let Some(id) = progress_id {
+ let flash_progress =
+ if let Some(id) = progress_id {
FlashProgress::new(move |event| {
let mut flash_progress = flash_progress.borrow_mut();
let mut debug_adapter = rc_debug_adapter_clone.borrow_mut();
@@ -1291,15 +1294,27 @@ impl Debugger {
download_options,
)
};
- debug_adapter = if let Ok(v) = Rc::try_unwrap(rc_debug_adapter) {
- v.into_inner()
- } else {
- panic!("This is a bug. Please report it.")
+ debug_adapter = match Rc::try_unwrap(rc_debug_adapter) {
+ Ok(debug_adapter) => debug_adapter.into_inner(),
+ Err(too_many_strong_references) => {
+ let other_error = DebuggerError::Other(anyhow!("Unexpected error while dereferencing the `debug_adapter` (It has {} strong references). Please report this as a bug.", Rc::strong_count(&too_many_strong_references)));
+ return Err(other_error);
+ }
};
if let Some(id) = progress_id {
let _ = debug_adapter.end_progress(id);
}
+ flash_result
+ }
+ DebugAdapterType::CommandLine => download_file_with_options(
+ // TODO: Implement fancy CLI flash progress from probe-rs-cli-util
+ &mut session_data.session,
+ &path_to_elf,
+ Format::Elf,
+ download_options,
+ ),
+ };
match flash_result {
Ok(_) => {
