[−][src]Enum gdbstub::target::TargetError
The error type for various methods on Target
and it's assorted associated
extension traits.
Error Handling over the GDB Remote Serial Protocol
The GDB Remote Serial Protocol has less-than-stellar support for error
handling, typically taking the form of a single-byte
errno
-style error codes.
Moreover, often times the GDB client will simply ignore the specific error
code returned by the stub, and print a generic failure message instead.
As such, while it's certainly better to use appropriate error codes when
possible (e.g: returning a EFAULT
(14) when reading from invalid memory),
it's often fine to simply return the more general TargetError::NonFatal
instead, and avoid the headache of picking a "descriptive" error code. Under
the good, TargetError::NonFatal
is sent to the GDB client as a generic
EREMOTEIO
(121) error.
From
and Into
implementations
From<()>
->TargetError::NonFatal
From<io::Error>
->TargetError::Io(io::Error)
(requiresstd
feature)
When using a custom target-specific fatal error type, users are encouraged
to write the following impl to simplify error handling in Target
methods:
type MyTargetFatalError = ...; // Target-specific Fatal Error impl From<MyTargetFatalError> for TargetError<MyTargetFatalError> { fn from(e: MyTargetFatalError) -> Self { TargetError::Fatal(e) } }
Unfortunately, a blanket impl such as impl<T: Target> From<T::Error> for TargetError<T::Error>
isn't possible, as it could result in impl conflicts.
For example, if a Target decided to use ()
as it's fatal error type, then
there would be conflict with the existing From<()>
impl.
Variants (Non-exhaustive)
A non-specific, non-fatal error has occurred.
Io(Error)
I/O Error.
At the moment, this is just shorthand for
TargetError::NonFatal(e.raw_os_err().unwrap_or(121))
. Error code 121
corresponds to EREMOTEIO
.
In the future, gdbstub
may add support for the "QEnableErrorStrings"
LLDB protocol extension, which would allow sending additional error
context (in the form of an ASCII string) when an I/O error occurs. If
this is something you're interested in, consider opening a PR!
Only available when the std
feature is enabled.
Errno(u8)
An operation-specific non-fatal error code.
A target-specific fatal error.
WARNING: Returning this error will immediately halt the target's
execution and return a GdbStubError::TargetError
from GdbStub::run
!
Note that the debugging session will will not be terminated, and can
be resumed by calling GdbStub::run
after resolving the error and/or
setting up a post-mortem debugging environment.
Trait Implementations
impl<E> From<()> for TargetError<E>
[src]
Converts a ()
into a TargetError::NonFatal
.
fn from(_: ()) -> TargetError<E>
[src]
impl<E> From<Error> for TargetError<E>
[src]
Converts a std::io::Error
into a TargetError::Io
.
fn from(e: Error) -> TargetError<E>
[src]
Auto Trait Implementations
impl<E> !RefUnwindSafe for TargetError<E>
impl<E> Send for TargetError<E> where
E: Send,
E: Send,
impl<E> Sync for TargetError<E> where
E: Sync,
E: Sync,
impl<E> Unpin for TargetError<E> where
E: Unpin,
E: Unpin,
impl<E> !UnwindSafe for TargetError<E>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,