Re: [hatari-devel] Hatari debug mode |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Christian Zietz <czietz@xxxxxxx>, Hatari Development <hatari-devel@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [hatari-devel] Hatari debug mode
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Mon, 18 Aug 2025 00:23:11 +0300
- Dkim-filter: OpenDKIM Filter v2.11.0 smtp.dnamail.fi 51BC54098E8F
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=helsinkinet.fi; s=2025-03; t=1755465791; bh=geLxn2tmoFmUbOUVlZoErkRbwJ9LmOjkX5ly7X/IZns=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Nq/WsOwyvs4DRzi0H3cHZk08QHPpm+Auwyyr9N4RTovfHXoWrmb8QfnS35axxRN7X 73OgJwJWPctCOx6OIqs3I88zavv54UV2GqtQA18KpKunAjMTAfgjXTDq2/ZVlRsWNS CBk3kaUTRBA4hD47/M6IBAxg/FTEDk1nAOplcq5tHPa7qYIErMUk9+vzIJ/C6f9JmH avmmlic61HQiPENYPm0gbU4PcKceSDnYHJrYRXMdcMaVyK9+uYNI/Ahg5/yHw3nnsd dL7j8ktljsUTYOCGKsv6LajXWW4r1GfrZ4CeLeQUgQl3RmQPbvU1iL4kZQ7/VKzwtc o1oLGtvOZYw0w==
Hi,
On 17.8.2025 23.19, Christian Zietz wrote:
Shouldn't Hatari skip "freopen()" calls if allocConsole() fails (=
returns zero)?
It probably wouldn't hurt implementing it in that way.
Just to make sure everything works as expected before pushing, could you
try the updated (attached) patch too?
- Eero
From c05ac5a0961b807af935246f1f0a9f6fe6406f88 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Mon, 28 Jul 2025 02:30:58 +0300
Subject: [PATCH] Open Windows console automatically for Debugger
---
doc/release-notes.txt | 1 +
src/debug/debugui.c | 4 ++++
src/gui-win/opencon.c | 13 +++++++++----
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/doc/release-notes.txt b/doc/release-notes.txt
index 75aa341d..974140ed 100644
--- a/doc/release-notes.txt
+++ b/doc/release-notes.txt
@@ -24,6 +24,7 @@ Emulation improvements:
Emulator improvements:
- Debugger:
+ - Open Windows console automatically for debugger
- Debugger input file commands can be split to multiple lines
by adding '\' to end of line to continue it
- Increase max lenght of accepted debugger file commands to 4k
diff --git a/src/debug/debugui.c b/src/debug/debugui.c
index a2702e6b..d8b43ec2 100644
--- a/src/debug/debugui.c
+++ b/src/debug/debugui.c
@@ -1231,6 +1231,10 @@ void DebugUI(debug_reason_t reason)
if (welcome)
{
+#ifdef WIN32
+ /* in case user forgot -W option */
+ Win_ForceCon();
+#endif
fputs(welcome, stderr);
welcome = NULL;
}
diff --git a/src/gui-win/opencon.c b/src/gui-win/opencon.c
index 60147444..60683436 100644
--- a/src/gui-win/opencon.c
+++ b/src/gui-win/opencon.c
@@ -24,10 +24,15 @@ static void Win_OpenInternal(void)
return;
opened = true;
- AllocConsole();
- freopen("CON", "w", stdout);
- freopen("CON", "r", stdin);
- freopen("CON", "w", stderr);
+ /* Fails if process already has a console, returns true on success:
+ * https://learn.microsoft.com/en-us/windows/console/allocconsole
+ */
+ if (AllocConsole())
+ {
+ freopen("CON", "w", stdout);
+ freopen("CON", "r", stdin);
+ freopen("CON", "w", stderr);
+ }
}
void Win_OpenCon(void)
--
2.39.5