-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support console stderr redirection #169
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That behaviour should be properly documented.
Allows you send stderr output to
GDB
or 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.