* [PATCH 1/1] gdb/tui: Fix build for older ncurses
@ 2025-09-11 18:30 Ciaran Woodward
2025-09-12 15:04 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Ciaran Woodward @ 2025-09-11 18:30 UTC (permalink / raw)
To: gdb-patches; +Cc: Ciaran Woodward
Older versions of ncurses (including the version that ships inside
macos, and Centos 7) do not include the A_ITALIC macro. This patch
simply hides any use of A_ITALIC behind a preprocessor guard.
The result of this is that italics won't be rendered in the tui
if ncurses isn't supported. We do have other options if we think
it's important - for instance we could show italics as bold if
italics aren't supported. From my understanding, that might be
overthinking it - so I took the simplest approach here, just to
fix the build.
Those versions also define tgetnum as:
int tgetnum(char *id);
so attempting to compile for c++ results in the error:
ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
This is just a dated API issue, so a const cast resolves the issue.
---
gdb/tui/tui-io.c | 4 ++++
gdb/ui-style.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index c97e8fd1717..84cad9366d5 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -319,7 +319,9 @@ tui_apply_style (WINDOW *w, ui_file_style style)
wattron (w, A_NORMAL);
wattroff (w, A_BOLD);
wattroff (w, A_DIM);
+#ifdef A_ITALIC
wattroff (w, A_ITALIC);
+#endif
wattroff (w, A_UNDERLINE);
wattroff (w, A_REVERSE);
if (last_color_pair != -1)
@@ -368,8 +370,10 @@ tui_apply_style (WINDOW *w, ui_file_style style)
gdb_assert_not_reached ("invalid intensity");
}
+#ifdef A_ITALIC
if (style.is_italic ())
wattron (w, A_ITALIC);
+#endif
if (style.is_underline ())
wattron (w, A_UNDERLINE);
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 9a58e4dd2ae..ccc9094ca59 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -594,7 +594,7 @@ colorsupport ()
{
std::vector<color_space> result = {color_space::MONOCHROME};
- int colors = tgetnum ("Co");
+ int colors = tgetnum (const_cast<char*> ("Co"));
if (colors >= 8)
result.push_back (color_space::ANSI_8COLOR);
if (colors >= 16)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] gdb/tui: Fix build for older ncurses
2025-09-11 18:30 [PATCH 1/1] gdb/tui: Fix build for older ncurses Ciaran Woodward
@ 2025-09-12 15:04 ` Tom Tromey
2025-09-12 17:17 ` Ciaran Woodward
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2025-09-12 15:04 UTC (permalink / raw)
To: Ciaran Woodward; +Cc: gdb-patches
>>>>> "Ciaran" == Ciaran Woodward <ciaranwoodward@xmos.com> writes:
Ciaran> Older versions of ncurses (including the version that ships inside
Ciaran> macos, and Centos 7) do not include the A_ITALIC macro. This patch
Ciaran> simply hides any use of A_ITALIC behind a preprocessor guard.
Thanks for doing this.
Ciaran> The result of this is that italics won't be rendered in the tui
Ciaran> if ncurses isn't supported. We do have other options if we think
Ciaran> it's important - for instance we could show italics as bold if
Ciaran> italics aren't supported. From my understanding, that might be
Ciaran> overthinking it - so I took the simplest approach here, just to
Ciaran> fix the build.
Seems reasonable enough.
Ciaran> Those versions also define tgetnum as:
Ciaran> int tgetnum(char *id);
Ciaran> so attempting to compile for c++ results in the error:
Ciaran> ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
Ciaran> diff --git a/gdb/ui-style.c b/gdb/ui-style.c
Ciaran> index 9a58e4dd2ae..ccc9094ca59 100644
Ciaran> --- a/gdb/ui-style.c
Ciaran> +++ b/gdb/ui-style.c
Ciaran> @@ -594,7 +594,7 @@ colorsupport ()
Ciaran> {
Ciaran> std::vector<color_space> result = {color_space::MONOCHROME};
Ciaran> - int colors = tgetnum ("Co");
Ciaran> + int colors = tgetnum (const_cast<char*> ("Co"));
Would you mind adding a comment here explaining the need for the cast
and also for which version of curses it was found to be needed?
I think that may help future developers.
Anyway ok with this change.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH 1/1] gdb/tui: Fix build for older ncurses
2025-09-12 15:04 ` Tom Tromey
@ 2025-09-12 17:17 ` Ciaran Woodward
2026-07-27 16:15 ` Daniel Fellows
0 siblings, 1 reply; 6+ messages in thread
From: Ciaran Woodward @ 2025-09-12 17:17 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> Would you mind adding a comment here explaining the need for the cast
> and also for which version of curses it was found to be needed?
> I think that may help future developers.
>
> Anyway ok with this change.
> Approved-By: Tom Tromey <tom@tromey.com>
Thanks - added the comment & pushed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] gdb/tui: Fix build for older ncurses
2025-09-12 17:17 ` Ciaran Woodward
@ 2026-07-27 16:15 ` Daniel Fellows
2026-07-28 13:29 ` Ciaran Woodward
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Fellows @ 2026-07-27 16:15 UTC (permalink / raw)
To: ciaranwoodward; +Cc: gdb-patches, tom, nd
Hi Ciaran,
Would you be willing to backport this fix to gdb-17-branch?
We encountered the A_ITALIC build failure after moving our macOS builds
to GDB 17. I tested the fix successfully on both Intel and Arm macOS
hosts.
There is a small conflict with commit 07e542a3bd05, which added MinGW
handling in the same section of ui-style.c. The resolution is to retain
that MinGW block alongside your tgetnum change.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 1/1] gdb/tui: Fix build for older ncurses
2026-07-27 16:15 ` Daniel Fellows
@ 2026-07-28 13:29 ` Ciaran Woodward
2026-07-28 13:38 ` Daniel Fellows
0 siblings, 1 reply; 6+ messages in thread
From: Ciaran Woodward @ 2026-07-28 13:29 UTC (permalink / raw)
To: Daniel Fellows; +Cc: gdb-patches, tom, nd
> -----Original Message-----
> From: Daniel Fellows <daniel.fellows@arm.com>
> Sent: 27 July 2026 17:16
>
> Would you be willing to backport this fix to gdb-17-branch?
>
> We encountered the A_ITALIC build failure after moving our macOS builds
> to GDB 17. I tested the fix successfully on both Intel and Arm macOS
> hosts.
>
> There is a small conflict with commit 07e542a3bd05, which added MinGW
> handling in the same section of ui-style.c. The resolution is to retain
> that MinGW block alongside your tgetnum change.
Hi Daniel,
I'm happy for this fix to be backported, and I'm happy to push the commit
if you aren't able - from my perspective it seems extremely low risk.
I'm not quite sure on the backport process - I assume it needs approval by
a maintainer, at least.
Can any maintainer fill us in?
Cheers,
Ciaran
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-28 13:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-11 18:30 [PATCH 1/1] gdb/tui: Fix build for older ncurses Ciaran Woodward
2025-09-12 15:04 ` Tom Tromey
2025-09-12 17:17 ` Ciaran Woodward
2026-07-27 16:15 ` Daniel Fellows
2026-07-28 13:29 ` Ciaran Woodward
2026-07-28 13:38 ` Daniel Fellows
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox