From c49646367ad55ee790f382a861c27637c1fb8239 Mon Sep 17 00:00:00 2001 From: asahtik Date: Thu, 7 Dec 2023 13:45:16 +0100 Subject: [PATCH] Check for crash dump before getting --- src/device/DeviceBase.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/device/DeviceBase.cpp b/src/device/DeviceBase.cpp index 550742688..68d2245c5 100644 --- a/src/device/DeviceBase.cpp +++ b/src/device/DeviceBase.cpp @@ -607,12 +607,16 @@ void DeviceBase::closeImpl() { if(found && (rebootingDeviceInfo.state == X_LINK_UNBOOTED || rebootingDeviceInfo.state == X_LINK_BOOTLOADER)) { pimpl->logger.trace("Found rebooting device in {}ns", duration_cast(steady_clock::now() - t1).count()); DeviceBase rebootingDevice(config, rebootingDeviceInfo, firmwarePath, true); - auto dump = rebootingDevice.getCrashDump(); - auto path = saveCrashDump(dump, deviceInfo.getMxId()); - if(path.has_value()) { - pimpl->logger.warn("Device crashed. Crash dump saved to {}", path.value()); + if(rebootingDevice.hasCrashDump()) { + auto dump = rebootingDevice.getCrashDump(); + auto path = saveCrashDump(dump, deviceInfo.getMxId()); + if(path.has_value()) { + pimpl->logger.warn("Device crashed. Crash dump saved to {}", path.value()); + } else { + pimpl->logger.warn("Device crashed. Crash dump could not be saved"); + } } else { - pimpl->logger.warn("Device crashed. Crash dump could not be saved"); + pimpl->logger.warn("Device crashed, but no crash dump could be extracted."); } gotDump = true; break;