Support console stderr redirection#169
Conversation
Allows you read stderr output from `GDB` or other debuggers
| /// Destination for stderr redirection with [`redirect_stderr`]. | ||
| #[doc(alias = "debugDevice")] | ||
| #[repr(u32)] | ||
| pub enum Destination { |
There was a problem hiding this comment.
I'm not sure if we should call this Destination or Redirect or what. I'm open to suggestions about that.
There was a problem hiding this comment.
Destination or RedirectTarget maybe?
Also I doubt more would ever be added but maybe #[non_exhaustive] would be good, in case we wanted to make e.g. a Socket target that would use redirect_to_3dslink under the hood or something like that
| #[doc(alias = "consoleDebugInit")] | ||
| pub fn redirect_stderr(dest: Destination) { | ||
| unsafe { consoleDebugInit(dest as _) } | ||
| } |
There was a problem hiding this comment.
This looks fine to me offhand, I wonder how it behaves if you also use redirect_to_3dslink with stderr = true ? I think they use the same mechanism under the hood, so maybe whichever you call first gets overridden by the second one?
There was a problem hiding this comment.
I took a look inside libctru and the mechanisms are dfferent. consoleDebugInit changes the underlying devoptab for stderr and 3dslinkConnectToHost replaces stderr's file descriptor via dup2. So unless I'm mistaken, 3dslink redirection will always take priority over console redirection.
There was a problem hiding this comment.
That behaviour should be properly documented.
Allows you send stderr output to
GDBor other debuggers. It's a nice alternative to 3dslink redirection if you're at the point where you have to jump into an interactive debugging session.