Discussion:
[Bug tui/21482] New: gdb 8.0 tui doesn't build with native curses on Solaris
ro at gcc dot gnu.org
2017-05-11 14:15:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

Bug ID: 21482
Summary: gdb 8.0 tui doesn't build with native curses on
Solaris
Product: gdb
Version: 8.0
Status: NEW
Severity: normal
Priority: P2
Component: tui
Assignee: unassigned at sourceware dot org
Reporter: ro at gcc dot gnu.org
Target Milestone: ---
Target: *-*-solaris2.*

When trying to build the gdb 8.0 branch with native curses on Solaris 10
(Solaris 11 and 12 include ncurses as well, and it's found by default), I ran
into a couple of issues:

* Initially, compilation failed like this:

In file included from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:
0,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:2
6,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c
:31:
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c: In function ‘CORE_A
DDR tui_disassemble(gdbarch*, tui_asm_line*, CORE_ADDR, int)’:
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:71:19: error: ‘class
string_file’ has no member named ‘wclear’; did you mean ‘clear’?
gdb_dis_out.clear ();
^
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:78:19: error: ‘class
string_file’ has no member named ‘wclear’; did you mean ‘clear’?
gdb_dis_out.clear ();
^
make[2]: *** [Makefile:1927: tui-disasm.o] Error 1

It turned out this happens because <curses.h> has

#define clear() wclear(stdscr)

this can be avoided by defining NOMACROS, however, like

make CFLAGS+=-DNOMACROS CXXFLAGS+=-DNOMACROS

* While this gets around the wclear/clear issue above, I ran into another
issue:

/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c: In function
‘void tui_erase_source_content(tui_win_info*, int)’:
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:257:18: error:
invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
no_src_str);
^
In file included from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:0,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:26,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:33:
/vol/gcc-7/lib/gcc/sparc-sun-solaris2.10/7.1.0/include-fixed/curses.h:699:12:
note: initializing argument 4 of ‘int mvwaddstr(WINDOW*, int, int, char*)’
extern int mvwaddstr(WINDOW *, int, int, char *);
^~~~~~~~~
make[2]: *** [Makefile:1927: tui-winsource.o] Error 1

Unlike ncurses, <curses.h> declares

extern int mvwaddstr(WINDOW *, int, int, char *);

* In the end, I've just avoided the issue by configuring with --disable-tui.

Rainer
--
You are receiving this mail because:
You are on the CC list for the bug.
qiyao at gcc dot gnu.org
2017-05-16 14:22:46 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

Yao Qi <qiyao at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |qiyao at gcc dot gnu.org

--- Comment #1 from Yao Qi <qiyao at gcc dot gnu.org> ---
Close this issue as it is fixed by
https://sourceware.org/ml/gdb-patches/2017-05/msg00287.html ?
--
You are receiving this mail because:
You are on the CC list for the bug.
ro at CeBiTec dot Uni-Bielefeld.DE
2017-05-17 08:19:21 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #2 from Rainer Orth <ro at CeBiTec dot Uni-Bielefeld.DE> ---
Post by qiyao at gcc dot gnu.org
--- Comment #1 from Yao Qi <qiyao at gcc dot gnu.org> ---
Close this issue as it is fixed by
https://sourceware.org/ml/gdb-patches/2017-05/msg00287.html ?
They are completely unrelated, unfortunately: this one persists even
after the fix above went in.

The problem boils down to

$ cat cc.c
#include <string.h>

const char *str = "msg";

void
func (char *str)
{
(void) strlen (str);
}

void
call (void)
{
func (str);
}
$ g++ -c -O2 -Wall -c cc.c
cc.c: In function 'void call()':
cc.c:14:12: error: invalid conversion from 'const char*' to 'char*'
[-fpermissive]
func (str);
^
cc.c:6:1: note: initializing argument 1 of 'void func(char*)'
func (char *str)
^~~~

However (as I wasn't aware initially), you can simply cast the constness
away in all calls to mvwaddstr. I'll give that a whirl.

Rainer
--
You are receiving this mail because:
You are on the CC list for the bug.
ro at CeBiTec dot Uni-Bielefeld.DE
2017-05-17 08:39:38 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #3 from Rainer Orth <ro at CeBiTec dot Uni-Bielefeld.DE> ---
Post by ro at CeBiTec dot Uni-Bielefeld.DE
--- Comment #2 from Rainer Orth <ro at CeBiTec dot Uni-Bielefeld.DE> ---
[...]
Post by ro at CeBiTec dot Uni-Bielefeld.DE
However (as I wasn't aware initially), you can simply cast the constness
away in all calls to mvwaddstr. I'll give that a whirl.
The attached patch worked for me, allowing a sparc-sun-solaris2.10
compilation to succeed on the 8.0 branch. Comparing gdb/tui on the
branch and mainline, I noticed that the only difference between the two
is this fix:

2017-05-13 Eli Zaretskii <***@gnu.org>

* tui/tui.c (tui_enable): Cast "unknown" to 'char *' to avoid a
C++ compiler warning.

for exactly the same problem (well, same problem, different function).

Rainer
--
You are receiving this mail because:
You are on the CC list for the bug.
ro at gcc dot gnu.org
2017-05-17 08:40:58 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #4 from Rainer Orth <ro at gcc dot gnu.org> ---
Created attachment 10054
--> https://sourceware.org/bugzilla/attachment.cgi?id=10054&action=edit
proposed patch
--
You are receiving this mail because:
You are on the CC list for the bug.
qiyao at gcc dot gnu.org
2017-05-17 16:18:43 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #5 from Yao Qi <qiyao at gcc dot gnu.org> ---
(In reply to Rainer Orth from comment #4)
Created attachment 10054 [details]
proposed patch
Can you post the patch to gdb-patches@?
--
You are receiving this mail because:
You are on the CC list for the bug.
ro at gcc dot gnu.org
2017-05-18 08:57:26 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

Rainer Orth <ro at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
URL| |https://sourceware.org/ml/g
| |db-patches/2017-05/msg00410
| |.html

--- Comment #6 from Rainer Orth <ro at gcc dot gnu.org> ---
Sure, patch posted.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2017-05-19 12:04:38 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.0-branch branch has been updated by Rainer Orth <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a1cc26f6c36117f7abbd1e7d347030c37ebb30b6

commit a1cc26f6c36117f7abbd1e7d347030c37ebb30b6
Author: Rainer Orth <***@CeBiTec.Uni-Bielefeld.DE>
Date: Fri May 19 14:01:50 2017 +0200

Fix tui compilation with Solaris libcurses: non-const last arg to mvwaddstr
(PR tui/21482)
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2017-05-19 12:19:03 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7a6e7fcc77997bf7679cce4f1cfebcd57ba8af70

commit 7a6e7fcc77997bf7679cce4f1cfebcd57ba8af70
Author: Rainer Orth <***@CeBiTec.Uni-Bielefeld.DE>
Date: Fri May 19 14:16:55 2017 +0200

Fix tui compilation with Solaris libcurses: non-const last arg to mvwaddstr
(PR tui/21482)

On both mainline and the 8.0 branch, gdb compilation fails on Solaris 10
with the native libcurses in gdb/tui for several instances of the same
problem:

/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c: In function
`void tui_erase_source_content(tui_win_info*, int)':
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:257:18:
error: invalid conversion from `const char*' to `char*' [-fpermissive]
no_src_str);
^
In file included from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:0,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:26,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:33:

/vol/gcc-7/lib/gcc/sparc-sun-solaris2.10/7.1.0/include-fixed/curses.h:699:12:
note: initializing argument 4 of `int mvwaddstr(WINDOW*, int, int, char*)'
extern int mvwaddstr(WINDOW *, int, int, char *);
^~~~~~~~~
make[2]: *** [Makefile:1927: tui-winsource.o] Error 1

Unlike ncurses, <curses.h> declares

extern int mvwaddstr(WINDOW *, int, int, char *);

i.e. the last arg is char *, not const char *.

The patch fixes this by casting the last arg to mvwaddstr to char *,
as was recently done on mainline in a newterm() call (the only
difference between 8.0 and mainline gdb/tui).

* tui/tui-windata.c (tui_erase_data_content): Cast last mvwaddstr
arg to char *.
* tui/tui-wingeneral.c (box_win): Likewise.
* tui/tui-winsource.c (tui_erase_source_content): Likewise.
(tui_show_source_line): Likewise.
(tui_show_exec_info_content): Likewise.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2017-05-19 13:06:04 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.0-branch branch has been updated by Rainer Orth <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=814385bb257fec68e0e64d43f2ccc40e219342e7

commit 814385bb257fec68e0e64d43f2ccc40e219342e7
Author: Rainer Orth <***@CeBiTec.Uni-Bielefeld.DE>
Date: Fri May 19 15:03:52 2017 +0200

Fix tui compilation with Solaris libcurses: clear define (PR tui/21482)
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2017-05-19 13:10:39 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

--- Comment #10 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6e7e1744e96abbf1a4229d5f269caf2cc921ec58

commit 6e7e1744e96abbf1a4229d5f269caf2cc921ec58
Author: Rainer Orth <***@CeBiTec.Uni-Bielefeld.DE>
Date: Fri May 19 15:08:45 2017 +0200

Fix tui compilation with Solaris libcurses: clear define (PR tui/21482)

On both mainline and the 8.0 branch, gdb compilation fails on Solaris 10
with the native libcurses like this:

In file included from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:
0,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:2
6,
from
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c
:31:
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c: In function
`CORE_A
DDR tui_disassemble(gdbarch*, tui_asm_line*, CORE_ADDR, int)':
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:71:19: error:
`class
string_file' has no member named `wclear'; did you mean `clear'?
gdb_dis_out.clear ();
^
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:78:19: error:
`class
string_file' has no member named `wclear'; did you mean `clear'?
gdb_dis_out.clear ();
^
make[2]: *** [Makefile:1927: tui-disasm.o] Error 1

It turned out this happens because <curses.h> has

#define clear() wclear(stdscr)

This can be avoided by defining NOMACROS, which the patch below does.
ncurses potentially has a similar problem, which can be avoided by defining
NCURSES_NOMACROS.

PR tui/21482
* gdb_curses.h (NOMACROS): Define.
(NCURSES_NOMACROS): Define.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-20 18:37:49 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #11 from Tom Tromey <tromey at sourceware dot org> ---
Is this still an issue?
--
You are receiving this mail because:
You are on the CC list for the bug.
ro at gcc dot gnu.org
2018-04-23 13:03:47 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21482

Rainer Orth <ro at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Assignee|unassigned at sourceware dot org |ro at gcc dot gnu.org
Target Milestone|--- |8.0

--- Comment #12 from Rainer Orth <ro at gcc dot gnu.org> ---
No, I just forgot to close the PR.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...