@@ -136,7 +136,10 @@ bool CorelliumAdapter::LoadRegisterInfo()
136136 }
137137
138138 if (architecture.empty ())
139- throw std::runtime_error (" failed to find architecture" );
139+ {
140+ LogWarn (" failed to find architecture" );
141+ return false ;
142+ }
140143
141144 // Store the original architecture for endianness detection before stripping the prefix
142145 std::string fullArchitecture = architecture;
@@ -336,8 +339,10 @@ std::vector<DebugThread> CorelliumAdapter::GetThreadList()
336339
337340 auto reply = this ->m_rspConnector ->TransmitAndReceive (RspData (" qfThreadInfo" ));
338341 while (reply.m_data [0 ] != ' l' ) {
339- if (reply.m_data [0 ] != ' m' )
340- throw std::runtime_error (" thread list failed?" );
342+ if (reply.m_data [0 ] != ' m' ) {
343+ LogWarn (" thread list failed" );
344+ return threads;
345+ }
341346
342347 const auto shortened_string =
343348 reply.AsString ().substr (1 );
@@ -376,13 +381,22 @@ bool CorelliumAdapter::SetActiveThreadId(std::uint32_t tid)
376381 return false ;
377382
378383 if ( this ->m_rspConnector ->TransmitAndReceive (RspData (string (" T{:x}" ), tid)).AsString () != " OK" )
379- throw std::runtime_error (" thread does not exist!" );
384+ {
385+ LogWarn (" thread does not exist" );
386+ return false ;
387+ }
380388
381389 if ( this ->m_rspConnector ->TransmitAndReceive (RspData (string (" Hc{:x}" ), tid)).AsString () != " OK" )
382- throw std::runtime_error (" failed to set thread" );
390+ {
391+ LogWarn (" failed to set thread" );
392+ return false ;
393+ }
383394
384395 if ( this ->m_rspConnector ->TransmitAndReceive (RspData (string (" Hg{:x}" ), tid)).AsString () != " OK" )
385- throw std::runtime_error (" failed to set thread" );
396+ {
397+ LogWarn (" failed to set thread" );
398+ return false ;
399+ }
386400
387401 this ->m_lastActiveThreadId = tid;
388402
@@ -430,7 +444,10 @@ bool CorelliumAdapter::RemoveBreakpoint(const DebugBreakpoint& breakpoint)
430444 kind = 4 ;
431445
432446 if (this ->m_rspConnector ->TransmitAndReceive (RspData (" z0,{:x},{}" , breakpoint.m_address , kind)).AsString () != " OK" )
433- throw std::runtime_error (" rsp reply failure on remove breakpoint" );
447+ {
448+ LogWarn (" rsp reply failure on remove breakpoint" );
449+ return false ;
450+ }
434451
435452 if (auto location = std::find (this ->m_debugBreakpoints .begin (), this ->m_debugBreakpoints .end (), breakpoint);
436453 location != this ->m_debugBreakpoints .end ())
@@ -512,7 +529,10 @@ std::unordered_map<std::string, DebugRegister> CorelliumAdapter::ReadAllRegister
512529 return m_regCache.value ();
513530
514531 if ( this ->m_registerInfo .empty () )
515- throw std::runtime_error (" register info empty" );
532+ {
533+ LogWarn (" register info empty" );
534+ return {};
535+ }
516536
517537 // Sort the registers according to their index, as the g reply packet will provide values in the same order
518538 std::vector<register_pair> register_info_vec{};
@@ -528,7 +548,10 @@ std::unordered_map<std::string, DebugRegister> CorelliumAdapter::ReadAllRegister
528548 const auto register_info_reply = this ->m_rspConnector ->TransmitAndReceive (RspData (&request, sizeof (request)));
529549 auto register_info_reply_string = register_info_reply.AsString ();
530550 if ( register_info_reply_string.empty () )
531- throw std::runtime_error (" register request reply empty" );
551+ {
552+ LogWarn (" register request reply empty" );
553+ return {};
554+ }
532555
533556 std::unordered_map<std::string, DebugRegister> all_regs{};
534557 for ( const auto & [register_name, register_info] : register_info_vec ) {
@@ -552,7 +575,10 @@ DebugRegister CorelliumAdapter::ReadRegister(const std::string& reg)
552575 return DebugRegister{};
553576
554577 if ( this ->m_registerInfo .find (reg) == this ->m_registerInfo .end () )
555- throw std::runtime_error (fmt::format (" register {} does not exist in target" , reg));
578+ {
579+ LogWarn (" register %s does not exist in target" , reg.c_str ());
580+ return DebugRegister{};
581+ }
556582
557583 return this ->ReadAllRegisters ()[reg];
558584}
@@ -651,7 +677,7 @@ DataBuffer CorelliumAdapter::ReadMemory(std::uintptr_t address, std::size_t size
651677 return input - ' A' + 10 ;
652678 if (input >= ' a' && input <= ' f' )
653679 return input - ' a' + 10 ;
654- throw std::invalid_argument ( " Invalid input string " ) ;
680+ return 0 ;
655681 };
656682
657683 while (*src && src[1 ]) {
@@ -697,7 +723,10 @@ std::string CorelliumAdapter::GetRemoteFile(const std::string& path)
697723 int32_t error;
698724 int32_t ret = this ->m_rspConnector ->HostFileIO (RspData (" vFile:setfs:0" ), output, error);
699725 if (ret < 0 )
700- throw runtime_error (" Could not set remote filesystem" );
726+ {
727+ LogWarn (" Could not set remote filesystem" );
728+ return " " ;
729+ }
701730
702731 std::string path_hex_string{};
703732 for ( const auto & ch : path )
@@ -706,7 +735,10 @@ std::string CorelliumAdapter::GetRemoteFile(const std::string& path)
706735 ret = this ->m_rspConnector ->HostFileIO (
707736 RspData (" vFile:open:{},{:X},{:X}" , path_hex_string.c_str (), 0 , 0 ), output, error);
708737 if (ret < 0 )
709- throw runtime_error (" Unable to open file with host I/O" );
738+ {
739+ LogWarn (" Unable to open file with host I/O" );
740+ return " " ;
741+ }
710742
711743 int32_t fd = ret;
712744
@@ -719,21 +751,27 @@ std::string CorelliumAdapter::GetRemoteFile(const std::string& path)
719751 ret = this ->m_rspConnector ->HostFileIO (
720752 RspData (" vFile:pread:{:X},{:X},{:X}" , fd, blockSize, offset), output, error);
721753 if (ret < 0 )
722- throw runtime_error (fmt::format (" host i/o pread() failed, result=%d, errno=%d" , ret, error));
754+ {
755+ LogWarn (" host i/o pread() failed, result=%d, errno=%d" , ret, error);
756+ return data;
757+ }
723758 if (ret == 0 )
724759 // EOF
725760 break ;
726761 if (ret != (int32_t )output.AsString ().length ())
727- throw runtime_error (fmt::format (" host i/o pread() returned {:X} but decoded binary attachment is size {:X}" ,
728- ret, output.AsString ().length ()));
762+ {
763+ LogWarn (" host i/o pread() returned %X but decoded binary attachment is size %zX" ,
764+ ret, output.AsString ().length ());
765+ return data;
766+ }
729767
730768 data += output.AsString ();
731769 offset += output.AsString ().length ();
732770 }
733771
734772 ret = this ->m_rspConnector ->HostFileIO (RspData (fmt::format (" vFile:close:{:X}" , fd)), output, error);
735773 if (ret)
736- throw runtime_error ( fmt::format ( " host i/o close() failed, result={} , errno={} " , ret, error) );
774+ LogWarn ( " host i/o close() failed, result=%d , errno=%d " , ret, error);
737775
738776 return data;
739777}
@@ -852,7 +890,7 @@ DebugStopReason CorelliumAdapter::ResponseHandler()
852890 return input - ' A' + 10 ;
853891 if (input >= ' a' && input <= ' f' )
854892 return input - ' a' + 10 ;
855- throw std::invalid_argument ( " Invalid input string " ) ;
893+ return 0 ;
856894 };
857895
858896 while (*src && src[1 ]) {
@@ -1240,7 +1278,7 @@ void CorelliumAdapter::HandleAsyncPacket(const RspData& data)
12401278 return input - ' A' + 10 ;
12411279 if (input >= ' a' && input <= ' f' )
12421280 return input - ' a' + 10 ;
1243- throw std::invalid_argument ( " Invalid input string " ) ;
1281+ return 0 ;
12441282 };
12451283
12461284 while (*src && src[1 ]) {
0 commit comments